# doctor: simplify mirror check after review

`ed38787`→[main](/content/gh/entireio/cli/commits/main/index.html)·

computermode·1mo ago·5 files·+70 added/-56 removed

- Split MirrorNoMetadata out of MirrorPrimaryMissing so the diagnosis is self-describing; the bundle no longer labels a fresh v1.1 repo V1 MISSING.
- Derive doctor headlines from MirrorStatus.String() — one source for status labels across doctor and bundle output.
- Render the primary ref from diag.Refs.Primary instead of hardcoding entire/checkpoints/v1, so guidance survives a future topology flip.
- Extract confirmDoctorFix, shared with checkDisconnectedMetadata.
- Document why the bundle's for-each-ref globs are broader than the resolved topology refs.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

## Sessions

dbe157735b54View transcript

## Changes

5

- cmd/entire/cli

- Mdoctor.go+50/-48

- Mdoctor_bundle.go+4

- Mdoctor_test.go+1/-1

- strategy

- Mv1_custom_ref_mirror.go+12/-4

- Mv1_custom_ref_mirror_test.go+3/-3

```plaintext
368 unmodified lines

... (stack traces and output summaries)
```

### confirmDoctorFix

confirmDoctorFix asks a yes/no fix confirmation shared by doctor checks. Returns false with no error when the user declines (prints "-> Skipped") or aborts the prompt.

```go
func confirmDoctorFix(w io.Writer, title string) (bool, error) {
    var confirmed bool
    form := NewAccessibleForm(
        huh.NewGroup(
            huh.NewConfirm().
                Title(title).
                Value(&confirmed),
        ),
    )
    if err := form.Run(); err != nil {
        if errors.Is(err, huh.ErrUserAborted) {
            return false, nil
        }
        return false, fmt.Errorf("prompt failed: %w", err)
    }
    if !confirmed {
        fmt.Fprintln(w, "  -> Skipped")
    }
    return confirmed, nil
}
```

// shortMirrorHash abbreviates a hash for mirror-check output; "none" when zero.
func shortMirrorHash(h plumbing.Hash) string {
    if h.IsZero() {
        return "none"
    }
    return h.String()[:8]
}

### Status Constants

const (
    MirrorNotConfigured  MirrorStatus = iota // topology has no mirror (v1 mode)
    MirrorOK                                 // mirror == primary tip
    MirrorNoMetadata                         // neither primary nor mirror exists yet (fresh repo)
    MirrorMissing                            // primary exists, mirror ref absent
    MirrorBehind                             // mirror is an ancestor of the primary tip
    MirrorDiverged                           // mirror is not an ancestor of the primary tip
    MirrorPrimaryMissing                     // primary metadata ref absent
)

```go
// String returns the status name used in doctor and bundle output.
func (s MirrorStatus) String() string {
    switch s {
    case MirrorNotConfigured:
        return "NOT CONFIGURED"
    case MirrorOK:
        return "OK"
    case MirrorNoMetadata:
        return "NO METADATA"
    case MirrorMissing:
        return "MISSING"
    case MirrorBehind:
        return "BEHIND"
    case MirrorDiverged:
        return "DIVERGED"
    case MirrorPrimaryMissing:
        return "V1 MISSING"
    default:
        return fmt.Sprintf("UNKNOWN(%d)", int(s))
    }
}
```
