Repository navigation
#490 Split the doc-accuracy net: fast deterministic gate per PR, LLM review moves nightly - #599
Merged
Merged
Conversation
…op re-reviewing on every push [no-doc] [no-ut]
Doc accuracy has two failure classes with wildly different detection costs, and until now both were the Layer-2 LLM reviewer's job:
mechanical - a cited src/ path was moved, a foo.md#anchor lands nowhere. No judgement needed; the file exists or it does not.
semantic - prose that still parses and still links, but no longer matches what the code does.
So a ~7-minute billed turn was answering questions os.path.exists answers in milliseconds.
1. scripts/check-doc-links.py - the mechanical half, as a LINT not a report. Checks that backticked src/test/tools/scripts paths resolve (stripping :line and :line-line), that relative .md links resolve, and that #anchors match a real heading. Runs in 0.47 s over 329 files, 110 source paths and 1872 links. Wired into build-docs.yml BEFORE the .NET/DocFX setup, so a moved file fails in a second rather than after minutes of building an API reference. Modelled on typhon-claude's check-doc-drift.py, which made the same split for the knowledge base after a report-with-no-gate let 60 occurrences of a deleted type survive two months.
Baseline is clean: 0 findings. That is what makes it safe to be blocking.
Escape hatch: `<!-- doc-links: ignore -->` on or above a line. Used once, in in-depth-overview/README.md, where the prose DESCRIBES the link convention (`[NN-name](NN-name.md)`) rather than linking anywhere - a true positive by the rule, a false positive in intent.
Worth recording, because it nearly shipped: the first implementation collapsed whitespace runs when slugging headings, so every em-dash heading ("5. Spatial - querying by geometry") reported as a missing anchor. GitHub replaces each space individually, giving `5-spatial--querying-by-geometry`. Caught by running the script before wiring it up; two of the three initial "findings" were the script's bug, not the corpus's. All three detectors and both ignore forms are now verified against synthetic fixtures.
2. doc-accuracy-review.yml runs ONCE PER PR, not once per push. `synchronize` was the expensive trigger: every push re-ran the review, so fixing the reviewer's own findings re-invoked the reviewer on the fix - the loop [no-doc] exists to break. Now opened / ready_for_review / reopened. Open a draft, push freely, get one review when it is ready; close+reopen re-reviews a PR that changed a lot since (no workflow_dispatch, which would have to plumb a PR number and head SHA through the fork check, the [no-doc] lookup and the affected-map step).
Deliberately given up: drift introduced by a LATER push to an already-reviewed PR is not re-reviewed. Layer 3's weekly audit is the floor for that, exactly as it already is for fork PRs, which this workflow has always skipped for the same reason. No recall is lost that Layer 3 does not already own - only latency.
NOT changed, because it already existed: the LLM step is already gated on the affected-map resolving a non-empty page set, so a change with no mapped docs already skips it.
Also considered and rejected: moving the whole Layer-2 review to a nightly run with a morning reconciliation pass. Layer 3 already occupies that niche weekly; a nightly Layer 2 would be a third overlapping LLM sweep that loses the diff association which is the only thing making Layer 2 better than a corpus audit. And per typhon-claude's own CLAUDE.md, a report whose value depends on someone running it daily is how a corpus rots.
Verified: both workflows parse as YAML; lint PASSes on the real corpus; --warn exits 0; a bad --repo-root exits 2 rather than scanning nothing and reporting green.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
…ped, files issues [no-doc] [no-ut] Loïc's argument, which I initially pushed back on and was wrong to: 1. Nothing required the check and nothing blocked on it, so a PR could merge while the review was still running. The findings then landed on a closed PR nobody revisits - the per-PR TIMING bought nothing anyone could act on. 2. Reconciling docs is a different job from writing the feature, and the author is the worst reviewer of prose they wrote ten minutes ago and believe. My earlier objection - "post-merge it degrades into a corpus audit, which Layer 3 already does" - was only true of a WHOLE-CORPUS post-merge run. Scoped to yesterday's merges it keeps the diff-to-page association that is the only thing making Layer 2 worth more than an audit. That is the mistake; this commit fixes it. What changed: - doc-accuracy-review.yml is now nightly (05:00 UTC, an hour before the Monday Layer-3 audit so the weekly sweep dedups against whatever the nightly just filed). It lists the PRs merged in the last 25 h, resolves each one's affected doc pages, reviews them, and FILES [doc-drift] ISSUES rather than commenting on a merged PR. Every issue must carry "Introduced by: #N" - that attribution is precisely what a whole-corpus sweep cannot produce. - Fork PRs are no longer a special case. The old per-PR job had to skip them (no secrets, injection surface); a scheduled job cannot receive one, so fork-introduced drift is now covered like everything else instead of being deferred to Layer 3. - CONTRIB.md: [no-doc] is retired. It existed to break the fix -> re-review -> fix loop, which was a workaround for a cadence that was wrong to begin with. Harmless if anyone still writes it. Two things testing found before this could ship, both real: - Unioning the PRs' file lists resolved to 227 affected pages against a 329-file corpus - a whole-corpus sweep wearing a scoped costume, i.e. exactly what I had just argued against. Now resolved PER PR (measured on the same night: #598 -> 86 pages, #586 -> 226, #570 -> 0), which also keeps the "Introduced by" attribution honest since each page list has one PR behind it. - One big PR can alone resolve to ~230 pages, so a ten-PR night would exhaust the turn budget and produce a shallow skim of everything instead of a real review of something. Capped at the 5 most recent, with a ::warning:: and a line in the prompt naming the overflow - a silently truncated sweep reads exactly like a clean one, which is the failure mode this layer exists to avoid. The remainder falls to Layer 3. Also rejected, and recorded in the workflow header so it is not re-proposed: an opt-in [doc-review] token, and reviewing only when a draft PR is marked ready. Both fail UNSAFE when someone forgets - no review at all, or only commit 1 reviewed. Loïc made this argument against [doc-review] and it applies equally to the draft-based design I had already written. This one has nothing to remember. The scope step was extracted from the YAML and executed against the live repo end to end (PR listing, per-PR diff, docs-affected resolution, output gating) - heredoc-inside-block-scalar is where this class of workflow usually breaks. Layer 1 (scripts/check-doc-links.py, blocking, ~0.5 s) still runs on every push. Layer 3 (weekly whole-corpus) is unchanged. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
…out to match The cap of 5 was picked by feel. Measured against this repo's actual history it is exactly the observed maximum, which is the one place a runaway guard must not sit: 109 PRs across 74 active days — mean 1.5/day, median 1, busiest day ever 5, days that would have hit a cap of 5: zero. So it has never fired, and the first busier-than-usual day it starts silently dropping PRs. 20 is ~4x the observed max: not expected to fire on any real day, still bounded for a merge-train anomaly or a `workflow_dispatch` with a wide since_hours (which can pull a month of PRs in one run). --max-turns 100 -> 200 and timeout 30 -> 60 min, because the guard now permits 20 PRs and 100 turns spread over 20 PRs would be the shallow skim the cap exists to prevent. On a normal 1-2 PR night neither limit is approached. (For the record, since the two got conflated: issue-triage's 40 is --max-turns, a tool-call budget. This 20 is a count of PRs. Different axes — but raising one does require raising the other, which is the half I had missed.) Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Splits the doc-accuracy net by detection cost, and takes the expensive half off the PR critical path.
The problem
Doc accuracy has two failure classes, and until now both were the Layer-2 LLM reviewer's job:
src/…path was moved;foo.md#anchorlands nowhereos.path.exists— milliseconds, no judgementSo a ~7-minute billed turn was answering questions a filesystem call answers instantly — on every push, on every PR.
What changes
scripts/check-doc-links.py— cited paths resolve, links resolve,#anchorsmatch a real heading[doc-drift]issues[doc-audit]issuesNightly runs an hour before the weekly so Monday's sweep dedups against whatever the nightly just filed.
Layer 1 — the deterministic lint
Wired into
build-docs.ymlbefore the .NET/DocFX setup, so a moved file fails in a second rather than after minutes of building an API reference. Sits alongside the existing deterministic gates (telemetry reference, docs-affected map integrity). Modelled ontyphon-claude'scheck-doc-drift.py, which made the same split for the knowledge base.Clean baseline is what makes it safe to block.
Escape hatch
<!-- doc-links: ignore -->is used exactly once — inin-depth-overview/README.md, where the prose describes the link convention ([NN-name](NN-name.md)) rather than linking anywhere. A true positive by the rule, a false positive in intent.Layer 2 — why it moved off the PR path
Four arguments, all Loïc's, and I pushed back on the first version of them before conceding:
[no-doc]existed to break that loop — a workaround for a cadence that was wrong to begin with.My earlier objection — "post-merge it degrades into a corpus audit, which Layer 3 already does" — was only true of a whole-corpus post-merge run. Scoped to yesterday's merges it keeps the diff-to-page association that is the only thing making Layer 2 worth more than an audit. Every filed issue must carry
Introduced by: #N; that attribution is precisely what a corpus sweep cannot produce.Issues, not PR comments is the piece that makes it work: findings survive the merge, are attributable, and land in a queue somebody owns.
Rejected, and recorded in the workflow header so they aren't re-proposed
Both fail unsafe when someone forgets:
[doc-review]token → forget it and there is no review at all;GitHub cannot enforce "always start as a draft", so the second is not fixable by policy. The shipped design has nothing to remember.
Fork PRs stop being a special case
The old per-PR job had to skip them (no secrets, and an LLM over untrusted code+prompt is an injection surface). A scheduled job cannot receive a fork PR at all, so fork-introduced drift is now covered like everything else instead of being deferred to Layer 3.
issues:write-only token, and read-only--allowedToolscap the blast radius at one stray issue.Two things testing caught before this could ship
Unioning the PRs' file lists resolved to 227 affected pages against a 329-file corpus — a whole-corpus sweep wearing a scoped costume, i.e. exactly what I had just argued against. Now resolved per PR (measured on the same night: #598 → 86 pages, #586 → 226, #570 → 0), which also keeps
Introduced byhonest since each page list has one PR behind it.The first PR cap was 5 — exactly the observed historical maximum. Measured:
A runaway guard sitting on top of the observed range has never fired and starts silently dropping work the first busier-than-usual day. Raised to 20 (~4× the max), with
--max-turns100 → 200 and timeout 30 → 60 min to match — 100 turns spread over 20 PRs would be the shallow skim the cap exists to prevent. When it fires it emits a::warning::naming the overflow: a silently truncated sweep reads exactly like a clean one.Also in here
[no-doc]is retired (CONTRIB.mdupdated) — there is no longer a per-PR review for it to skip. Harmless if anyone still writes it.Verification
check-doc-links.pyPASSes on the real corpus;--warnexits 0; a bad--repo-rootexits 2 rather than scanning nothing and reporting greenscopestep was extracted from the YAML and executed against the live repo end to end — PR listing, per-PR diff, docs-affected resolution, output gating. Heredoc-inside-a-block-scalar is where this class of workflow usually breaksCONTRIB.md, one doc line🤖 Generated with Claude Code
https://claude.ai/code/session_01Gcg4vW8vJ4QjNyj6NQabHs