Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion internal/cli/doctor.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ func newDoctorCmd(g *GlobalOpts) *cobra.Command {
}
renderChecks(cmd, checks)
if fix {
fmt.Fprintln(cmd.OutOrStdout(), "\n(--fix has no automatic remediations wired yet; planned with M6 doctor)")
doctorFix(cmd)
}
for _, c := range checks {
if c.Status == docker.StatusFail {
Expand All @@ -55,6 +55,28 @@ func newDoctorCmd(g *GlobalOpts) *cobra.Command {
return cmd
}

// doctorFix applies the STRICTLY non-destructive remediations (spec 13): the
// self-healing ledger reconcile (prune ref rows for projects no longer live). It
// never drops a volume/DB/container — those are explicit-confirmation jobs
// (`shared gc`, `workspace destroy`). Best-effort: a down daemon or no workspace
// is reported, not fatal.
func doctorFix(cmd *cobra.Command) {
w := cmd.OutOrStdout()
fmt.Fprintln(w, "\n--fix: applying safe remediations…")
mgr, closeFn, err := buildManager(cmd)
if err != nil {
fmt.Fprintf(w, " reconcile skipped: %v\n", err)
return
}
defer closeFn()
pruned, err := mgr.Reconcile(cmd.Context())
if err != nil {
fmt.Fprintf(w, " reconcile skipped: %v\n", err)
return
}
fmt.Fprintf(w, " reconciled the ledger: pruned %d stale ref row(s)\n", len(pruned))
}

// rebuildLedger reconstructs the shared_service + ref ledger from on-disk config
// intersected with live container labels (spec 09 §crash-recovery).
func rebuildLedger(cmd *cobra.Command, g *GlobalOpts) error {
Expand Down
Loading