Skip to content

feat(doctor): split reference resolution by trailer severity, resolve through the all-refs index - #81

Merged
Ian-stetsenko merged 1 commit into
mainfrom
feat/doctor-ref-severity
Nov 9, 2026
Merged

Ian-stetsenko merged 1 commit into
mainfrom
feat/doctor-ref-severity

Conversation

@TommyC81

@TommyC81 TommyC81 commented Nov 7, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

lore doctor's reference check splits by trailer severity. Reference resolution (supersedes/depends-on) keeps warning status, is always present, and keeps the verbatim ok message; Reference resolution (related) is info-status and appears only with findings - a clean corpus omits it entirely, in JSON and in text. Reference ids now resolve through the shared all-refs Lore-id index, so references to atoms living on unscanned side branches no longer false-dangle (doctor and lore trace now agree). An index that cannot be built yields exactly one Reference resolution (skipped) warning and the run continues.

Resolves #80.

Implementation

One commit, whose message carries the full design story. It was built and gated as two slices before squashing, plus review fixes folded in. Index adoption: checkReferencesResolve resolves ids through the all-refs index; side-branch references resolve; findings, exit behavior, and JSON shape unchanged; a real-git integration suite covers the side-branch scenario (hermetic temp-dir repo). Severity split: the check returns two checks; the warning class keeps its contract byte-for-byte, the info class is finding-gated; the index-failure path keeps the skipped-policy contract (exactly one skipped warning, neither split check appears, check order unchanged); unit tests pin every class combination plus a three-severities guard (a rejecting config loader drives errors/warnings/info to 1/1/1 and exit 1 from the error alone). Review fixes folded: the index-failure test asserts order + count instead of pinning the companion rename PR's check literal, and the integration-test dependency bag carries a default SupersessionResolver (runtime-inert here, required once the companion change lands).

Design notes (pre-empting review questions)

  • Why omit the info check when empty rather than emit an ok line? The summary count is the gate signal: "0 warnings" should read as "no review-blocking findings" without a human mentally subtracting a structural ok. An always-present info-ok check would also reintroduce noise in every clean corpus's text output - the exact problem the split removes.
  • Why info, not warning, for Related? The trailer carries no decision semantics; a dead Related link inconveniences navigation, it does not break structure. Doctor's job is to make severity mean something; the commit-msg validator keeps its warning (attention vocabulary) and the companion commit-gate PR blocks both classes at creation time (prevention vocabulary).
  • Exit behavior unchanged. Info findings never set the exit code; only errors do (the three-severities guard pins this).
  • Detail-line format unchanged for both classes; JSON consumers key severity off the check name/status pair.
  • Merge-order robustness. The index-failure test asserts the first-three check names and the total count rather than the dependency check's literal name, so the companion rename PR (Orphaned dependencies -> Superseded dependencies) merges in either order without touching this suite. The real-git integration test constructs a full production-shaped dependency bag (including a default SupersessionResolver, pre-existing on main and runtime-inert here), so it keeps passing once the companion chain-resolution change adds its resolver requirement. The only cross-PR conflict is one test-harness hunk, resolved mechanically. No CHANGELOG coupling: no PR in this family touches CHANGELOG.md.
  • Test harness. The unit suite gains a runDoctorFormatted seam (text-formatter and rejecting-loader injection); all existing runDoctor call sites are unchanged.

Testing

35 files / 524 tests green on Windows (baseline 512 at main): +12 tests across both commits (index adoption integration suite + class-combination units + three-severities guard + skipped-policy pins).

Live before/after on a production corpus (~967 Lore-ids, this repository's own lore corpus):

  • Before: one check - WARNING Reference resolution: 16 broken reference(s) found (15 Related + 1 Supersedes lumped).
  • After: WARNING Reference resolution (supersedes/depends-on): 1 broken reference(s) found and INFO Reference resolution (related): 15 broken related reference(s) found - the summary reads 1 warnings, 2 info and the warning count finally means structural damage. The dependency check is byte-identical before and after (untouched here).

Changelog (maintainer surface)

This PR deliberately does not touch CHANGELOG.md; changelog entries are the maintainer's surface. Suggested line if wanted: lore doctor reference check severity split - dangling Supersedes/Depends-on references report under a dedicated warning-status check while dangling Related references report under an info-status check that appears only with findings; ids resolve through the shared all-refs Lore-id index, and an index that cannot be built yields one skipped warning check.

Two problems fixed in the doctor reference check. First, ids were resolved against the scanned atom set only, so a reference to an atom living on an unscanned side branch false-dangled even though lore trace resolves it; ids now resolve through the shared all-refs Lore-id index (built only when a scanned atom actually carries a reference id; all refs, HEAD-preferred - the same semantics as trace and validate). If the index cannot be built, exactly one 'Reference resolution (skipped)' warning is reported and the run continues. Second, the single lumped check conflated severity classes: dangling Supersedes/Depends-on (review-blocking) and dangling Related (informational) surfaced identically, so the summary count could not serve as a gate signal. The check splits into 'Reference resolution (supersedes/depends-on)' at warning status (always present, ok message verbatim) and 'Reference resolution (related)' at info status, emitted only with findings and omitted entirely - check and text line both - for a clean corpus. Detail-line format is unchanged; the exit contract stays errors-only (a three-severities guard pins 1/1/1 with exit 1 from the error alone). The real-git side-branch integration suite proves cross-branch acceptance end-to-end; its dependency bag carries a default SupersessionResolver, which is runtime-inert here and keeps the suite green once the companion dependency-check change adds its resolver requirement. CHANGELOG.md is untouched (maintainer surface).

Lore-id: 2ea23fa2
Constraint: Warning-class ok message stays verbatim 'All references resolve'; detail-line format unchanged
Constraint: Skipped-policy contract byte-stable: exactly one skipped warning, fixed message, neither split check appears, check order unchanged
Constraint: Info check omitted entirely (JSON and text) when empty; exit contract errors-only
Constraint: CHANGELOG.md stays out of the PR; the maintainer authors changelog entries
Tested: Unit tests per class combination, index-failure policy pins, three-severities exit guard, real-git side-branch integration suite; red-first on the split cycles
Tested: Full gate on Windows: 35 files / 524 tests (baseline 512 at main), +12 tests
Tested: Combined-tree verification with the companion commit-validation and chain-resolution changes: 578/578 across 37 files
Confidence: high
Scope-risk: narrow
@TommyC81
TommyC81 force-pushed the feat/doctor-ref-severity branch from b8ec995 to 3ba3a70 Compare November 7, 2026 13:52
@Ian-stetsenko
Ian-stetsenko merged commit 8aa912b into main Nov 9, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

lore doctor reports dangling Related and dangling Supersedes/Depends-on at the same severity, under one check

2 participants