Repository navigation
gate(xtask): parser-backed cfg-test region authority (#3631) - #3640
Conversation
Replace the hand-written depth-tracking scanner behind check-rust-source-role-authority with region detection from the real grammar (ra_ap_syntax, already an xtask dependency; no new deps). The new authority lives in xtask/src/rust_region_scan.rs: parse the file, exempt each top-level item whose attribute run carries the exact cfg(test) spelling (the same honored spelling table, re-hosted and pinned, since facts::cfg_predicates is pub(crate)), and return the complement with the same newline-seam guarantee. Producer exemptions, allowed-site inventory, RULES matching, and the is_test_file inventory are unchanged. A differential scanner-vs-parser run over every tracked .rs file in the repository (742 files, fixture corpora included) showed: - 0 gate-pattern differences (RULES + is_test_file membership identical on every file), so gate output on this corpus is byte-compatible and goldens stay untouched; - 289 whitespace-only region differences (seam bookkeeping); - 63 structural differences, all in the safe direction (the parser exempts at least as much as the scanner, never less), each attributed to: (a) the scanner's char-literal ender overshooting escaped literals such as a backslash escaped in a char literal, which silently leaked whole cfg-test modules into production scans - the retired scanner failed to exempt even its own test module in xtask/src/main.rs - and (b) the documented multi-line attribute/doc-comment trim gap (#3631 edge case 2). The three documented edge cases (else-if initializer chains, multi-line metadata trim, braced const-generic arguments) are eliminated by construction and pinned by new tests. Files that do not parse cleanly are now scanned verbatim (over-catch only) and the fallback is disclosed in a Parse Fallbacks section of source-role-authority.md; no file in the scan scope (crates/ripr/src) hits that path today. The retired scanner is not kept as the fallback: an unreachable 600-line lexer would be a false-confidence surface. Spec: RIPR-SPEC-0153 gains a rework note and the implementation mapping for the new authority module.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Team Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. Summary by CodeRabbit
WalkthroughThe change replaces the hand-written Rust source scanner with parser-backed region detection. It adds exact ChangesSource-role authority gate
Estimated code review effort: 4 (Complex) | ~45 minutes Merge Risk: ⚪ Minimal · up to No concrete correctness or operational issue remains, so the change is ready to merge after normal checks. Sequence Diagram(s)sequenceDiagram
participant AuthorityGate as check-rust-source-role-authority
participant RegionScanner as production_text_regions
participant PolicyReport as finish_policy_report_with_disclosures
AuthorityGate->>RegionScanner: Parse Rust source and compute production text
RegionScanner-->>AuthorityGate: Return production text and fallback flag
AuthorityGate->>PolicyReport: Pass violations and fallback disclosure
PolicyReport-->>AuthorityGate: Write policy report and status
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Description checkExplanation The description gives strong technical context, scope, differential evidence, residuals, and verification results. However, it does not follow most required template sections, including Swarm / Source Boundary, Source-of-truth Links, Scope Classification, Support-tier Impact, Policy Impact, Claim Boundary, Rollback, Spec-Test-Code Traceability, Static Language Check, CI Economics, Engineering Check, and Gates. Resolution Update the description to include every required template section. Complete the applicable checkboxes and fields, including source boundary, links, scope and acceptance criterion, support and policy impact, proof, claim boundary, rollback, traceability, static-language status, CI economics, engineering checks, and executed gates. Mark non-applicable sections as
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Code Review
This pull request replaces the hand-written depth-tracking scanner for the Rust source-role authority gate with a parser-backed scanner using ra_ap_syntax. This resolves several edge cases, such as escaped character literals leaking test modules, and introduces a safe verbatim fallback with disclosure reporting for files that fail to parse. The review feedback suggests optimizing the policy report generation in xtask/src/main.rs by avoiding format! allocations inside a loop.
There was a problem hiding this comment.
Decision
- Needs reviewer attention before upstream: findings remain.
Confirmed findings
- Unreachable 600-line retired scanner was deliberately deleted (per PR body) instead of retained as a verbatim fallback; this is intentional but means a future parse failure mode has no second lexical authority to cross-check against.
- xtask/src/main.rs:4524 — policy_report_body disclosure loop still uses format! per iteration inside the inner item loop; the outer heading/intro can use push_str but the inner
- {item}line allocates a fresh String per disclosure item. Minor perf nit, same family as gemini-code-assist note on line 4532.
Verification questions
- Confirm cargo-test scheduled-late: receipt lands before gate per profile. Tests cited by PR body (1794 xtask, 6933 workspace) are not yet witnessed in available receipts but are heavy-runnable and gated by the late phase; not blocking but trust-affecting until landed.
Parked follow-ups
- Gemini's
format!-in-loop nit is real but low-impact; disclosure rendering is bounded by fallbacks list (typically 0).
Evidence gaps
- Cargo test receipt scheduled late; current lane has no live cargo witness — artifact-verifier failure is unrelated to region authority.
- Model proof intent was rejected by deterministic validation.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Source review and verification receipt
reviewed_head_sha: 39d68f216a386bf57af02dd5e1629d8ddb6884f4
integration_basis: d5f7cf2bf5a8e2110a7f312297a078c535e409c5
claim_boundary: replacement of the source-role gate's production-region scanner, not all repository lexers or a generalized cfg evaluator. This receipt records the review performed during the PR's final CI run; the PR has since merged as 470b5acb1856ea65dd534b7f515531962f146c25.
Changed surfaces and semantic owners inspected
xtask/src/rust_region_scan.rs: clean-parse top-level item ownership, exact cfg(test) spelling recognition, retained-region stitching, and whole-input fallback on parse errors.xtask/src/main.rs: gate integration, unchanged pattern/authorized-consumer boundary, and shared report construction. Ordinary report callers supply no disclosure; fallback reporting is additive.docs/specs/RIPR-SPEC-0153-rust-source-role.md: implementation mapping and rework boundary.- New region and report tests, including retained production before/after exempt items, nested items, comments/attributes, braced const generics, escaped literals, newline seams, malformed-input equality, and accepted/rejected cfg spellings.
Findings and counter-read
No remaining blocking source finding in the inspected scope. Three existing review threads were checked against the current source and resolved: disclosure allocation, malformed-parse fallback, and syntax-node macro/item boundaries.
The important counter-read is that removing more text is not inherently safer. Exclusion is justified by ownership of an exactly test-gated top-level item. Tests retaining production tails and nested production-owned text constrain accidental over-exclusion; malformed input must remain byte-for-byte available to the existing matcher. Always returning the input, dropping malformed input, broadening cfg recognition, and omitting the separator are distinct wrong implementations opposed by the reviewed oracles. These are source-level oracle challenges, not a claim of an executed mutation experiment.
I corrected the PR description's broad lexer-removal claim and its earlier safe-direction wording. The remaining tiny spelling recognizer, compound cfg non-goals, and separate orphaned-file cleanup are explicit.
Proof and CI observed
Routed Rust Small run 33942846269, exact head above: required Rust gates and PR evidence both completed successfully; Rust gate job 101243508029 completed successfully. Formatting preflight also passed. I inspected the workflow recipe and the job/step statuses.
Local Rust commands were not run in this session. Detailed job-log retrieval was unavailable; the builder-reported corpus comparison, test totals, and zero-rebless counts were not independently reproduced and remain attributed as such. No artifact-content inspection is claimed.
Currentness, residuals, and disposition
Head/source/tests/report integration were reviewed together. This does not certify a later head, release/source promotion, compound cfg semantics, or a new product capability. The malformed undeclared io_util.rs residual is isolated in #3641, not treated as part of this gate change.
disposition: REVIEW_READY for the bounded source change at the reviewed head, supported by the observed successful hosted gates. This is a COMMENT review, not a second-identity approval or a claim that this session performed the merge.
Summary
Implements #3631's parser-based rework: the
check-rust-source-role-authoritygate's hand-written cfg-test region scanner (~654 lines, six review rounds of
lexer fixes) is replaced by a parser-backed region authority built on
ra_ap_syntax— already a direct xtask dependency, so zero new crates. Theproduct side was already parser-backed. This replaces the gate's region
scanner; the small exact-spelling recognizer remains, so this is not a claim
that every hand-written lexer in the repository has been removed.
Why
The scanner's long-tail was the finding generator: #3629's three rounds and
#3631's three documented edge cases (else-if initializer chains bailing to
end-of-file, multi-line attribute/doc-comment trim gaps, braced const-generic
args confusing item detection). The parser eliminates all three by
construction — item spans come from syntax nodes.
Differential evidence (fixture-first, run before the flip)
742 tracked
.rsfiles scanned with both implementations side by side:is_test_file(membershipidentical everywhere; gate output on this corpus is unchanged and
goldens checkstays exit 0 with zero re-bless.attributed to two families of previously leaked test-only text. Broader
exemption is not inherently safe; the relevant distinction is whether the
removed text belongs to a test-gated item:
char_literal_or_lifetime_endovershootsescaped char literals (
'\\'), swallowing following source so depth-0#[cfg(test)]items were never seen — the scanner failed to exempt evenits own test module in
xtask/src/main.rs;unit tests.
Changes
xtask/src/rust_region_scan.rs(new):production_text_regions— cleanparse → top-level item walk with the exact
cfg(test)spelling predicate(re-hosted minimal spelling table, pinned by accepted/rejected tests);
parse errors → verbatim scan with
used_verbatim_fallbackset, disclosedunder a "Parse Fallbacks" section in
source-role-authority.md(over-catchonly relative to the retained matcher: test interiors remain scanned;
no file in scope hits it today). The retired scanner was deliberately not
kept as the fallback: an unreachable 600-line lexer with no live callers
would be a false-confidence surface.
xtask/src/main.rs: gate consumes the authority; scanner + 12 helpers +raw_production_text_testsdeleted; shared policy-report core refactoredso the 27 existing
finish_policy_reportcall sites stay byte-identical.Named residuals
xtask/src/io_util.rsis truncated mid-enum on origin/main and is not adeclared module — dead tracked text, outside this gate's scope. Its
separate deletion-only candidate is chore(xtask): remove orphaned truncated I/O helper copy #3641 under refactor(xtask): decompose the 120,652-line xtask/src/main.rs monolith — 8x larger than the CLI monolith (#1915) and 12x the Python one (#1719) #2119.
cfg(test); theall/any/not/cfg_attrfamilies are deferred to the product authority (noted in module docs).
Reported local verification
cargo fmt --check;cargo test -p xtask(1794 passed);cargo test --workspace(6933 passed);cargo clippy --workspace --all-targets -- -D warnings;cargo xtask check-rust-source-role-authority(pass);cargo xtask goldens check(exit 0, zero re-bless);cargo xtask precommit;cargo xtask check-static-language;cargo xtask check-spec-format;cargo xtask check-traceability.Closes #3631.