From a44bf11bbb432cdc3795523777b8a4edd38adbc0 Mon Sep 17 00:00:00 2001 From: Gustavo Bertoi Date: Mon, 29 Jun 2026 14:10:35 -0300 Subject: [PATCH] =?UTF-8?q?feat(doctor):=20X6=20(part)=20=E2=80=94=20share?= =?UTF-8?q?d-services=20ledger=20probe=20(spec=2013)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) --- internal/cli/doctor.go | 13 ++++++++++++- internal/cli/gc_test.go | 12 ++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/internal/cli/doctor.go b/internal/cli/doctor.go index 4206930..33134e5 100644 --- a/internal/cli/doctor.go +++ b/internal/cli/doctor.go @@ -134,8 +134,19 @@ func runDoctor(cmd *cobra.Command) []docker.Check { }) } else { v, _ := db.SchemaVersion() - db.Close() checks = append(checks, docker.Check{Name: "state ledger", Status: docker.StatusOK, Detail: fmt.Sprintf("schema v%d @ %s", v, ctxName)}) + // Shared-service ledger summary (informational): instances + total refs. + shared, _ := db.ListSharedServices() + totalRefs := 0 + for _, s := range shared { + n, _ := db.RefCount(s.Name) + totalRefs += n + } + db.Close() + checks = append(checks, docker.Check{ + Name: "shared services", Status: docker.StatusOK, + Detail: fmt.Sprintf("%d instance(s), %d ref(s)", len(shared), totalRefs), + }) } // DNS entries for *.localhost (spec 05) — best-effort, only when the current diff --git a/internal/cli/gc_test.go b/internal/cli/gc_test.go index ca7c4c4..bb728a8 100644 --- a/internal/cli/gc_test.go +++ b/internal/cli/gc_test.go @@ -59,3 +59,15 @@ func TestDoctorIncludesTrustProbe(t *testing.T) { t.Errorf("doctor --json missing the trust probe:\n%s", out.String()) } } + +func TestDoctorIncludesSharedProbe(t *testing.T) { + var out strings.Builder + root := NewRootCmd(Options{}) + root.SetArgs([]string{"doctor", "--json"}) + root.SetOut(&out) + root.SetErr(&out) + _ = root.Execute() + if !strings.Contains(out.String(), `"shared services"`) { + t.Errorf("doctor --json missing the shared-services probe:\n%s", out.String()) + } +}