Skip to content

Commit 663ccbe

Browse files
feat(doctor): X6 (part) — shared-services ledger probe (spec 13) (#48)
Complete the X6 probe set: doctor now reports the shared-service ledger summary (instance count + total ref rows), reusing the already-open state DB. Joins the trust + dns probes for the full self-verification matrix. The safe `--fix` (reconcile-only) is the remaining X6 piece. Test: doctor --json lists the "shared services" probe. Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 498d90d commit 663ccbe

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

internal/cli/doctor.go

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,19 @@ func runDoctor(cmd *cobra.Command) []docker.Check {
134134
})
135135
} else {
136136
v, _ := db.SchemaVersion()
137-
db.Close()
138137
checks = append(checks, docker.Check{Name: "state ledger", Status: docker.StatusOK, Detail: fmt.Sprintf("schema v%d @ %s", v, ctxName)})
138+
// Shared-service ledger summary (informational): instances + total refs.
139+
shared, _ := db.ListSharedServices()
140+
totalRefs := 0
141+
for _, s := range shared {
142+
n, _ := db.RefCount(s.Name)
143+
totalRefs += n
144+
}
145+
db.Close()
146+
checks = append(checks, docker.Check{
147+
Name: "shared services", Status: docker.StatusOK,
148+
Detail: fmt.Sprintf("%d instance(s), %d ref(s)", len(shared), totalRefs),
149+
})
139150
}
140151

141152
// DNS entries for *.localhost (spec 05) — best-effort, only when the current

internal/cli/gc_test.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,15 @@ func TestDoctorIncludesTrustProbe(t *testing.T) {
5959
t.Errorf("doctor --json missing the trust probe:\n%s", out.String())
6060
}
6161
}
62+
63+
func TestDoctorIncludesSharedProbe(t *testing.T) {
64+
var out strings.Builder
65+
root := NewRootCmd(Options{})
66+
root.SetArgs([]string{"doctor", "--json"})
67+
root.SetOut(&out)
68+
root.SetErr(&out)
69+
_ = root.Execute()
70+
if !strings.Contains(out.String(), `"shared services"`) {
71+
t.Errorf("doctor --json missing the shared-services probe:\n%s", out.String())
72+
}
73+
}

0 commit comments

Comments
 (0)