Skip to content

doc-health accepts a --previous-report from a different repo identity, turning a path slip into phantom regressions and uncited-resolution errors #342

Closed

Description

@brettheap

doc-health.py silently accepts a --previous-report produced under a
different repo identity. Nothing matches, so the comparison reports an operator
path slip as a corpus catastrophe — and the exit code stays 0.

Mechanism

Finding identity is the triple (family, repo, path) —
report.py:40, Finding.match_key(). The repo component is the run's repo
slug, which for --single-repo <path> is derived from the directory
basename
. Nothing ties a written report to the identity it was produced under,
and nothing checks it on the way back in.

Give the comparison a baseline built under a different basename and every key
misses. Two rules then fire at once:

  1. regressions() — no previous key matches, so every current CRITICAL/ERROR
    finding is "new".
  2. uncited_resolutions() (report.py:48-70) — every contested finding in
    the baseline looks like it vanished without a citation, and each one is
    injected into the current run as a fresh uncited-resolution ERROR.

The second is the nastier half: it does not merely misreport the diff, it
inflates the current findings count with errors that describe nothing real.

Reproduction (from the PR #333 post-land gates)

Baseline built in a worktree at .../scratchpad/base-wt, head run as
openxFactory. The baseline's own header records the wrong identity —
scope limited to single repo base-wt.

run baseline identity findings new regressions
bad base-wt 5 critical, 31 error, 82 warning, 3 info 36
good openxFactory 5 critical, 8 error, 82 warning, 3 info 0

31 − 8 = 23, and the bad report contains exactly 23 uncited-resolution
entries
; the good one contains 0. The 36 "regressions" are simply every
critical+error in the run. The phantom findings named files the change never
touched — docs/archive-record-discrepancies.md,
ideation/staging/..., other sessions' openspec/changes/....

Exit code was 0 throughout. That mismatch — 36 screaming regressions, clean
exit — was the only tell that it was an artifact.

Proof set narrowing it to identity alone:

  • Matching the basename snapped warnings/info into agreement (82/3 both sides),
    which the mismatched run had also skewed (73/4).
  • Base and head run in identical worktrees → 5/8/82/3 on both sides, 0
    regressions.
  • Relative (.) vs absolute ($PWD) path eliminated as a factor: both give
    8 errors.
  • The working tree was clean and tracked-identical to the squash throughout.

Why this is worth fixing

Same class as #338. A check reports a benign condition — an operator pointed
at the wrong directory — in the vocabulary of its most serious one: critical
regressions and uncited contested resolutions, the family that exists to catch
someone quietly dropping a contested finding. An operator who sees 36 regressions,
investigates, and finds it was a path slip learns to discount the message. That
erodes the gate in both directions: real regressions get waved through, and the
phantom errors could equally be "fixed" by writing dispositions for findings that
never resolved.

Fix shape

  1. Reports carry their identity. Record the repo (or repo-set) the run
    scanned in the report, machine-readably.
  2. Comparison refuses on a disjoint set. If the previous report's repo set
    does not intersect the current run's, fail loudly with an actionable message
    naming both — an operator error to surface, never a corpus regression to
    report. A partial overlap warrants a warning that names the difference.
  3. At minimum, uncited_resolutions() must not inject errors for repos absent
    from the current run's scope.

It generalizes a known hand-carried trap

The doc-health slug/basename discipline — "run from a directory whose basename
is openxFactory or the slug shifts"
— has been carried in handoff docs since
the doxBench arc, as a rule humans remember. This issue is that rule's
enforcement finally moving into the tool, where a machine can hold it.

Found during PR #333's post-land gates; out of scope there. Cross-reference #338.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions