fix(gates): stop citing out-of-repo session instruments and guard the rule - #311
Merged
Merged
Conversation
… rule Repo prose (src/** comments and ui/README.md) cited "the instrument that proves the other half" by file name -- jsdom probes, Python compile gates, edit sheets. Those instruments live outside the repository and never entered it (there is no JS runner in CI), so every such citation is a dead link for every reader. The repo had already written the convention down -- state_gate.rs's R165 block says "the instrument lives outside the repo, so no file name here (#606)" -- but nothing enforced it: 62 occurrences violate it, one of them in that same file, three lines after that very sentence. Keep the statement, drop the file name, at all 62 sites. Add src/citation_gate.rs so the rule has an enforcer: for every backticked file-shaped token in the repo's text files (Rust comments only for .rs, since the sites live in comments and this gate's own fixtures live in string literals), if the basename matches the session-instrument naming (^[rc][0-9]+[-_]) and no file of that name exists, the test fails. The scope is deliberately narrow: runtime artefacts (<data>/config.toml), negated statements, historical entries and output-file placeholders are not flagged -- they are either runtime facts or true precisely because the file does not exist. Evidence: 62 sites fixed (62 insertions / 62 deletions, one line each); cargo test 409 -> 413 (four new tests: the rule, a >=200-token positive control, the synthetic teeth set, and the naming predicate); cargo fmt --check rc=0; clippy --all-targets -D warnings rc=0. A/B on the live tree: injecting one citation into a .rs comment and one into ui/README.md makes the rule fail with both file:line locations, while the other three tests stay green.
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.
Summary
Repo prose (
src/**comments andui/README.md) cited "the instrument that proves the other half" by file name — jsdom probes, Python compile gates, edit sheets. Those instruments live outside the repository and never entered it (there is no JS runner in CI), so every such citation is a dead link for every reader.The repo had already written the convention down —
state_gate.rs's R165 block says "the instrument lives outside the repo, so no file name here (#606)" — but nothing enforced it. Recon measured 62 occurrences violating it, one of them in that same file, three lines after that very sentence.This PR keeps the statement and drops the file name at all 62 sites, and adds
src/citation_gate.rsso the rule has an enforcer.Related Issue
No issue was open; this came out of repository recon.
Changes
src/state_gate.rs42,ui/README.md17,src/i18n_pack.rs2,ui/js/app.js1. The surrounding sentence is preserved; exactly one line changes per site (62 insertions / 62 deletions).src/citation_gate.rs(test-only, registered as#[cfg(test)] mod citation_gate;). Corpus = the repo's text files, walked at runtime fromCARGO_MANIFEST_DIRso new files enter scope automatically; for.rsonly the comment text is scanned (the citation sites live in comments, while this gate's own synthetic fixtures live in string literals). Site = a backticked, file-shaped token; verdict = basename matches the session-instrument naming (^[rc][0-9]+[-_]) and no file of that name exists.ui/README.mdrecords the convention (new section) together with its exact scope.ui/js/app.jswas touched, so its cache-bust token was bumped:app.js?v=20260927-1→-2.Tests
cargo test— 413 passed / 0 failed (baseline 409; +4 new tests)cargo fmt --check— rc=0clippy --all-targets -- -D warnings— rc=0A/B on the live tree: injecting one citation into a
.rscomment and one intoui/README.mdmakes the rule fail, naming bothfile:linelocations, while the other three tests stay green.Scope (stated honestly)
The predicate is naming shape + presence, not "any out-of-repo reference". It deliberately does not flag runtime artefacts (
<data>/config.toml), negated statements ("the repo has noui/package.json"), historical changelog entries ("Removeddata/models.example.json") or output-file placeholders (aitokenpool-transactions-YYYYMMDD.csv) — those are either runtime facts or true precisely because the file does not exist.Checklist
fix/<描述>)