Repository navigation
fix(rust): classify cfg(test) helpers as evidence - #3273
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
Summary by CodeRabbit
WalkthroughInline ChangesRust test-surface classification
Estimated code review effort: 3 (Moderate) | ~25 minutes Merge Risk: ⚪ Minimal · up to This localized change classifies inline cfg(test) helpers as evidence without altering test registration or production controls, and the supplied checks pass. No actionable merge-blocking risk remains beyond normal review. Sequence Diagram(s)sequenceDiagram
participant RustSource
participant SyntaxAnalyzer
participant CompactGripContext
participant AnalysisOutput
RustSource->>SyntaxAnalyzer: inspect cfg(test) module ancestors
SyntaxAnalyzer->>CompactGripContext: provide test-scoped and production owner names
CompactGripContext->>AnalysisOutput: retain helper evidence and exclude production findings
Possibly related issues
Suggested labels: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ 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 updates the Rust syntax analysis to classify helper functions inside inline #[cfg(test)] modules as test infrastructure, even if they lack a #[test] attribute. This ensures consistent downstream classification. A review comment suggests optimizing the helper function is_cfg_test_module_member by pre-filtering attributes containing 'cfg' and 'test' to avoid unnecessary string allocations and character filtering.
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal fresh hosted evidence for this exact head. |
|
Replacement head |
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal required hosted evidence for exact head |
|
Replacement head |
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal required hosted evidence for exact head |
|
Replacement head |
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal required hosted evidence for exact head |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
|
Replacement head |
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal required hosted evidence for exact head |
|
Replacement head |
Exact-head review — REVIEW_INCOMPLETEReviewed PR #3273 at exact head
Disposition: REVIEW_INCOMPLETE pending terminal required hosted evidence for exact head |
Exact-head review — REVIEW_READYReviewed PR #3273 at exact head Semantic owner
Verified downstream rather than assumed: Helper attribution
Bounds
EvidenceLocal, in a clean worktree checked out at exact
That gap is superseded rather than outstanding. Hosted evidence on
Droid has been non-terminal for over eleven hours. Per repository law that is missing review-provider output, not clean output. It is an advisory lane and not branch-protection required, so it does not gate merge, but it is named here rather than counted as a pass. Review threadsThe one inline finding (gemini-code-assist, module-attribute allocation) is answered on its thread with source-backed reasoning and resolved. It is a micro-optimization on a parse-bound cold path that would not have removed the first allocation anyway; declining it is recorded, not silently dropped. CodeRabbit completed a full review at Claim correction appliedThe PR body previously read DispositionREVIEW_READY for merge convergence at Generated by Claude Code |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
There was a problem hiding this comment.
Confirmed findings
- No active-view or resizable-buffer UB surface is touched by this PR; lane reports zero in-scope findings. Resizable/stale-length/etc. checks trivially hold vacuously. Residual: cfg(test) helper classification is checked by parser+diff+test_grip fixtures already in the PR; allocation-per-attribute is bounded and out of scope for this lane.
- No exploit-primitive surface touched: no unsafe, no native interop, no secret material, no I/O. Hosted security lane green per seeded thread; Droid Auto Review pending is a review-provider gap, not a clean signal.
- This lane has nothing actionable to report. The PR touches no JS-backed or worker-boundary code; the only ownership of 'handoff' relevant here is the helper→owner call handoff in CompactGripContext, which is already gated by the same-file unit production-helper-allowed predicate (test_scoped AND production_owner collision) plus explicit super:: bypass, and exercised by the 232/232 test_grip_evidence suite.
Verification questions
- Confirm cargo-test receipt absent in this PR review packet. Local focused proofs were run (RA parser 1, test_grip 232, cfg(test) diff 1, assertion-shaped fixture 1) but full cargo-test terminal output not landed for head bae14d0. Lane cannot independently confirm full suite passes.
- Confirm sibling-path scan: rust_index::is_test_file path exclusion remains the only path-based producer rule; non-test files in src/ with inline cfg(test) get full AAT coverage but the change is bounded to exact #[cfg(test)] string match. Sibling patterns not examined: #[cfg(test)] on fn directly (cfg-test fn attribute rather than module), nested mods under cfg(test), multi-line cfg(any(test, ...)) — out of scope per PR Claim Boundary but worth a verification probe.
- Confirm same-file helper suppression now requires both test-scoped name AND production-owner name — but
test_scoped_function_names_by_fileno longer filters on!function.is_test, so physicaltests/**files and non-src/**/*.rstest files populate it; in a file where the same identifier names both a cfg(test) helper and the local package production owner, a same-name function defined OUTSIDE any cfg(test) module in that file will NOT be filtered and the conjunction still allows the production-helper attribution path to pass for non-test-scoped helpers, leaving the physical positive path unchanged. The conjunction does not protect non-test-scoped same-file shadow calls. - Confirm
is_cfg_test_module_membermatches#[cfg(test)]only by whitespace-collapsed string equality against"#[cfg(test)]", so legitimate variants like#[cfg(all(test, feature = "x"))],#[cfg(any(test, ...))], macro-generated#[cfg(test)]inside other macros, or proc-macro re-emitted attributes are silently ignored — making the is_test role depend on textual accident rather than semantic membership.
Test proof
- Focused HEAD proof failed (exit 101):
cargo test --locked --package ripr --test syntax_ra_tests ra_adapter_marks_inline_cfg_test_helpers_as_test_role -- --exact. This is a current failure, not a red/green witness.
Refuted
- Could a producer-owned is_test reclassification leak across an async/RPC/transfer boundary where a stale value is held by a worker and escape classification on detach?; refuted because: There is no such boundary in the diff: no JS host, no wasm-bindgen postMessage, no async runtime, no Send/Sync crossing in the changed lines. FunctionFact is a plain serializable struct consumed within the same synchronous analyze_diff call.
- Tests are tautological or smoke-only (would assert same condition they set up); refuted because: Each new regression exercises a distinct invariant: helper role classification (4-assertion), semantic vs path-only production (3-assertion), and helper attribution conjunction (existing matrix still passes). None of them reduces to setup==assertion.
Evidence gaps
- Hosted evidence is still pending for this SHA per seeded thread (Rust Small, coverage, JUnit, source-of-truth, UB) and precommit is NOT_ESTABLISHED; only local focused proofs are reported.
- Model proof intent was rejected by deterministic validation.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Post-merge exact-head review — follow-up changes required
Reviewed the merged candidate at PR head bae14d0e0d6681478e08d2c2a80cd77ff5d036c8 / merge commit 6cd70658c5fa86f4c65a1d1730729a95649edab7.
The narrow producer change is directionally correct, but two production-path defects remain after merge.
P1 — cached pre-fix facts and classifications remain authoritative
This PR changes the semantic meaning of FunctionFact.is_test, but it does not change any cache generation. At the merged head:
CACHE_SCHEMA_VERSION = 0.6
COMPACT_CLASSIFIED_SEAM_CACHE_SCHEMA_VERSION = 0.3
FILE_FACT_CACHE_SCHEMA_VERSION = 0.2
CARGO_PKG_VERSION = 0.10.0
RepoFileFactCacheKey is only schema version + package version + path + content hash. For an unchanged source file, a cache written by the pre-merge 0.10.0 binary therefore still matches the post-merge 0.10.0 binary and replays the old is_test = false fact. The full and compact classified-seam caches can likewise replay the old finding directly. A user with a warm cache may therefore observe none of #3273's behavior until source bytes, package version, or cache state changes.
Required follow-up: bump every cache generation that can retain FileFacts or a derived classified result, and add a regression that writes a pre-change semantic envelope and proves the post-change key cannot hit it. A cold-only fixture does not discriminate this failure.
P1 — the helper remains indexed, but no longer remains relation evidence
ra.rs now sets a plain function inside inline #[cfg(test)] to FunctionFact.is_test = true, while correctly withholding TestFact unless the function itself has a test attribute. However, helper_owner_calls_by_file_with_fanout still builds the helper graph only from index.functions.filter(|function| !function.is_test).
That leaves an inline helper in neither role used by the relation path:
not a TestFact
and
excluded from HelperOwnerCallsByFile
So a real #[test] that calls an inline helper, where the helper calls the production owner, can lose the established helper→owner relation and under-credit the production seam. The new tests prove raw functions retention and prove that the helper does not become a production finding; they do not prove the load-bearing test→helper→production relation or oracle survives.
Required follow-up: preserve evidence-role helpers in the bounded helper relation graph without re-admitting them as production seam subjects. Add a fixture whose changed subject is production code, whose only exact observer is #[test] → inline cfg(test) helper → production owner, and whose removal experiment fails when the helper is filtered out. Keep the same-name collision and explicit super:: controls.
Bounded residual
The parser-side role is also RA-only: lexical fallback still sets is_test from test attributes only. That broader parser/fallback source-role parity belongs in the next source-role slice, but it needs an explicit acceptance row rather than being assumed from #3273.
Disposition: the merged change may retain its narrow claim that exact inline #[cfg(test)] functions do not seed production findings on a cold RA-parse path. It cannot yet claim warm-cache correctness or preservation of helper-mediated production evidence.
…ter source-role classification (#3286) (#3304) * fix(rust): preserve inline cfg(test) helper-to-production evidence after source-role classification (#3286) #3273 widened FunctionFact::is_test to plain helpers inside inline #[cfg(test)] modules; the helper-relation graph and local-name resolver excluded every is_test function, silently dropping the #[test] -> cfg(test) helper -> owner evidence path (reproduced: the relation degraded to the weak SameTestFile fallback). Helper-graph admission now excludes only actual TestFact members; seam and production-owner filters keep the wider #3273 role. Regression fixture pins the retained HelperOwnerCall relation, the non-promotion to TestFact, and the unchanged evidence-role classification. * test(rust): key helper-graph test exclusion on exact function identity (#3286) Review hardening: the actual-test set keys on (file, name, start_line) so a same-file same-name plain helper is admitted exactly instead of conservatively excluded, and the regression fixture pins the mediated relation's oracle kind and strength, not just the relation reason. * refactor(rust): borrow the actual-test identity keys (#3286) Review cleanup: admission lookups use a borrowed key struct instead of cloning path and name per function. * test(rust): pin same-file test/helper name-collision identity (#3286) Review hardening: a #[test] fn and a plain helper sharing (file, name) stay distinguished by start_line identity — the helper keeps mediating evidence and the test stays out of helper admission.
… evidence (#3287) (#3305) * fix(cache): invalidate pre-source-role file facts and classified evidence (#3287) Bump the four fact/classification cache generations — file facts 0.2 to 0.3, full classified seams 0.6 to 0.7, sharded 0.2 to 0.3, compact 0.3 to 0.4, and the test-gated count cache 0.1 to 0.2 — with version-history reasons naming the #3273 source-role and #3286 helper-evidence semantic changes at package 0.10.0. Generation-transition tests prove a previous-generation envelope with identical package/path/content identity misses, a cold-then-warm run preserves the corrected semantics as a real hit, and RIPR_CACHE_DIR relocation plus sharded paths follow the same law. * test(cache): prove copied-envelope rejection and the file-fact generation (#3287) Review hardening: the transition test now copies a previous-generation envelope to the current key's entry path and proves the embedded key identity still rejects it; the directory-law test covers the file-fact cache; style nits applied (direct source slice, absolute constant path).
Summary
#[cfg(test)]module as producer-owned test/evidence role (FunctionFact.is_test) in the Rust syntax producer, so harness plumbing stops becoming a new-production-seam subject.TestFactregistration limited to functions that actually carry#[test], so related-test and oracle metadata are unchanged.tests/**helper→owner attribution and explicitsuper::-qualified calls.Swarm / Source Boundary
ripr-swarmNo crates.io, VS Marketplace, Open VSX, Release-asset, signing, release-environment, or release-secret surface is touched.
Source-of-truth Links
Proposal: n/a
Spec:
docs/specs/RIPR-SPEC-0133-assertion-shaped-owner-guidance.md(fixture contract for the regeneratedassertion_shaped_oracle_cfg_testgolden)ADR: n/a
Plan item: n/a
Active goal: n/a
Issue: #3213 (partial — see Claim Boundary)
Scope
crates/ripr/src/analysis/syntax/ra.rs— inline#[cfg(test)]module role classification at the producer boundary.crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rs— same-file helper-owner attribution guarded by the new producer role fact.fixtures/assertion_shaped_oracle_cfg_test/**— intentional golden regeneration plus SPEC/CHANGELOG reason.Scope Classification
Production delta:
#[cfg(test)]attribute is nowFunctionFact.is_test = true. Diff probes, seam inventory, and evidence relation consume that single producer-owned fact rather than re-inferring the role per consumer.Evidence/support delta:
#[test]function stays infacts.tests, the helper is not promoted intofacts.tests, and the production control stays production role.src/test_helper.rscontrol still do.assertion_shaped_oracle_cfg_testexpectations (1 weakly-exposed production finding → 0).Single acceptance criterion:
#[cfg(test)]helper is retained as evidence and excluded from production findings, without changing production controls orTestFactmembership.Non-goals:
tests/**path exclusion, which already exists onmain.Support-tier Impact
Claim/proof notes:
Policy Impact
Ledger or exception notes:
assertion_shaped_oracle_cfg_testgolden regeneration is intentional and recorded in the fixture'sSPEC.mdandexpected/CHANGELOG.mdwith the RIPR-SPEC-0133 / analysis(rust): stop treating test-harness plumbing as new production seams #3213 reason.cargo xtask goldens checkpasses with no other drift.Proof
Result, failures, or skipped proof:
goldens checkpassed; fmt/diff-check passed.cargo xtask precommitwas NOT_ESTABLISHED at publication (10-minute timeout under concurrent Cargo load). See the precommit follow-up comment on this PR for the re-run disposition on exact headbae14d0e.bae14d0e: Routed Rust Small, Coverage, Test Analytics (JUnit), Security, Source of Truth, ub-review, and PR Plan are allsuccess.CI,Future Clippy (advisory), andWindows Advisoryareskippedby label policy.Droid Auto Reviewhas remainedpendingsince 08:49Z and is therefore missing review-provider output, not clean output.Claim Boundary
After this PR it may be claimed that:
#[cfg(test)]helper in asrc/**file is producer-classified as test/evidence role, stays indexed as evidence, and does not become a production finding subject;src/test_helper.rsremain production subjects;TestFactmembership and therefore related-test/oracle metadata are unchanged.It must not yet be claimed that #3213 is satisfied. Delivered vs residual acceptance:
tests/foo.rsreturningResult<()>emits no production gapsnot_applicableto this PR — path exclusion viarust_index::is_test_filealready exists onmain(analysis/language/rust.rs). Bench targets and*_test.rs/test_*.rsconventions remain uncovered.assert!andif … return Err(…)forms give the same production-seam inventorynot_established— no discriminating proof in this PR.#[cfg(test)]helper remains relation/oracle evidence for its production ownerpasslimited— established for inline#[cfg(test)]insrc/**only.passnot_established— no output-surface disclosure is added here.perl-lsp-swarmsuppressions attributable only toripr#1428can be removednot_established— requires a published release carrying this change.#3213 therefore stays open with residual acceptance after this merges.
Rollback
Revert the PR. The change is additive at the producer boundary plus one fixture golden regeneration; reverting restores the prior
is_testderivation, the prior helper-attribution guard, and the prior expected outputs in one commit. No schema, config, or CI surface is involved.Spec-Test-Code Traceability
analysis::syntax::ra::tests::ra_adapter_marks_inline_cfg_test_helpers_as_test_role,analysis::language::rust::tests::diff_analysis_skips_inline_cfg_test_helpers_but_keeps_production_controls,analysis::test_grip_evidencesuitecrates/ripr/src/analysis/syntax/ra.rs,crates/ripr/src/analysis/test_grip_evidence/related_tests/context.rsfixtures/assertion_shaped_oracle_cfg_test/expected/{check.json,human.txt,CHANGELOG.md}Static Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a — no workflow, policy gate, branch-protection, artifact, or lane cost change.
Engineering Check
panic,unwrap,expect,todo, orunimplementedin production code.panic,unwrap,expect,todo, orunimplementedin tests.check.jsongolden content changes, the schema does not)Gates
Covered by
cargo xtask precommiton exact headbae14d0eplus the hosted lanes listed under Proof. The full fixed-candidate matrix in the template remains the release-qualification step, not this PR's gate.Advances #3213. Does not close it — residual acceptance is tabulated under Claim Boundary.