Skip to content

ci: doc-refs audit, baseline-gated check for stale references in hand-written docs - #7623

Merged
squid-protocol merged 5 commits into
mainfrom
ci/doc-refs-checker
Nov 4, 2026
Merged

squid-protocol merged 5 commits into
mainfrom
ci/doc-refs-checker

Conversation

@squid-protocol

@squid-protocol squid-protocol commented Nov 3, 2026 •

Copy link
Copy Markdown
Owner

Summary

Part of #7624 (step 1).

This adds tests/doc_refs_audit.py, a baseline-gated audit that fails a PR when hand-written markdown names something the repo no longer has. This is step 1 of the docs-drift plan that followed the #7617 sweep.

That sweep fixed 113 files, and about 80% of what it found could be checked mechanically. The only wiki page that hadn't drifted was the CLI reference, and that's because test_cli_contract.py pins it. This audit pins the rest of the docs the same way.

Check Fires on
path A backticked repo path (tests/tools/x.py, gitgalaxy/core/) that isn't tracked, isn't gitignored and isn't published to the generated branch, where its folder exists here
link A relative link, or a github.com/squid-protocol/gitgalaxy/blob/main/... URL, whose target is missing
flag python <script>.py --flag or python -m gitgalaxy.x --flag, where neither the script nor any .py beside it spells the flag. A longer flag that starts with the same text doesn't count.
name A bare backticked name.py with no file of that name
skill "the x skill" for a skill that's neither in .claude/skills/ nor in the docs/ecosystem.md table
module A gitgalaxy/**/README.md that never names a public .py module beside it

Out of scope:

  • Generated pages (fix the generator instead) and third-party or fixture markdown.
  • Write-ups about other projects' code, such as museum teardowns and research, for the name check.
  • Any paragraph that names a sibling repo, for the path, name and flag checks.
  • Placeholders such as <lang>, * and {x}.
  • Text in code spans and frontmatter, for the link check.

Baseline keys are check | doc | target, with no line number, so editing elsewhere in a doc doesn't change the key. --ci fails only on new findings and lists baselined keys that no longer occur. Wrong findings go in ALLOWED with a reason, and there are 5 of them.

Baseline: 160 findings on main. Run against #7617's tree, 98 of them are fixed and none are new, so either PR can merge first. After #7617 merges, python tests/doc_refs_audit.py --write-baseline shrinks the baseline to 47.

Wiring and CI cost (ci-workflows.md §5)

  • CI: it's one if: always() step in the existing Small audits job, so it adds no runner request. It runs on the runner's python3, stdlib only, with no install and no history, in about 2 s. It runs on every PR, including docs-only ones, which the plan skips for the other small audits. That's intentional: both a doc edit and a code rename can break a reference. test_audit_skip_plan.py now allows that one step through, and asserts it has always() and no install.
  • Local: audit_check.py runs it as [doc-refs].
  • Gate registry: gate_controls.py lists it, with a negative control in test_doc_refs_audit.py.
  • Classifier: change_classifier.PATTERN_HOLDERS includes doc_refs_audit. Its globs name every doc, so counting it as a reader would turn every doc into test-read-doc and widen every plan. docs_read_by_tests.txt is unchanged.
  • Docs: CLAUDE.md, in the commands block and the baseline-audits section, and docs/agents/baseline-audits.md.

File-cap exception: this is a new gate plus its registration in the four places every gate is registered (workflow, gate registry, audit_check.py, skip-plan test). The new files are the script, its test and the generated baseline.

Follow-ups (filed separately)

Step 2: workers fix the doc-refs findings they cause in the same PR, with markdown outside the 5-file cap. That needs the promoter-bot precheck. Step 3: computed counts instead of copied ones. Step 4: a nightly drift job that files issues. Step 5: a periodic judgment sweep.

Test plan

  • tests/test_doc_refs_audit.py: 14 tests, including plain pytest from an unrelated directory.
  • test_audit_skip_plan, test_gate_controls, test_ci_replay_6278, test_engine_reach_workflows, test_change_classifier, test_cli_contract and test_dead_key_audit: 194 passed.
  • ruff_audit.py --ci is clean, ruff format --check is clean, and change_classifier.py --check is fresh.
  • doc_refs_audit.py --ci passes on this branch, and shows 0 new findings against docs: repo-wide refresh of READMEs, wiki, skills and agent docs #7617's tree.
  • Not run: the local mypy_audit crashes on this box's numpy stubs, which is an environment problem unrelated to this PR. CI's mypy job covers it.

🤖 Generated with Claude Code

squid-protocol and others added 2 commits November 3, 2026 17:15
…nd-written docs

tests/doc_refs_audit.py checks every hand-written markdown file for a backticked
repo path, relative link or this repo's GitHub URL whose target is gone, a
`script.py --flag` the script no longer spells, a bare `name.py` with no file,
a missing skill, and a gitgalaxy/**/README.md that never names a public module
beside it. Content-keyed baseline (177 findings on main), --ci fails only on new
ones. Runs as an always() step in the Small audits job (stdlib, ~2 s, no extra
runner) and in audit_check.py.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
A wrapped sentence puts keyword-rosetta's name and its docs/GATING.md on
different lines. Rebaselined: 160 on main; 47 left and none new on #7617.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

🐦‍⬛ Muninn Security Scan

✅ No security issues found.

🐦‍⬛ Powered by Muninn · Skald Lab

squid-protocol and others added 3 commits November 3, 2026 19:50
…d gate

test_source_reads.py bans errors="ignore"; the audit stays stdlib-only, so
it can't use gitgalaxy.core.source_text.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@squid-protocol
squid-protocol merged commit ef231c4 into main Nov 4, 2026
49 checks passed
@squid-protocol
squid-protocol deleted the ci/doc-refs-checker branch November 4, 2026 02:22
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.

1 participant