Repository navigation
feat(analysis): admit InlineUnit targets in a unique governed test module - #4839
Conversation
…dule (#4784) When no existing related test owns a value-seam repair, the producer may propose one insertion into an already-governed inline #[cfg(test)] module from RustIndex and parser-backed cfg facts. Existing exact tests stay preferred; missing, ambiguous, out-of-line, inaccessible, generated, and harness cases stay Missing with a typed reason. Region identity travels with the proposal so production edits in the same file stay rejected. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedNext included review available in 24 minutes. View limit detailsLimit details: You’ve used the included review currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Advanced Run ID: 📒 Files selected for processing (29)
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 |
…cage consumer The prefix/suffix containment check is proven by tests now. Production admission still carries the region identity; #4783 owns wiring it into the packet edit cage, so the validator stays an expected unused item in non-test builds rather than a whole-file allowlist. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
… errors check-no-panic-family treats test-module expect as an unallowed panic-family call. The parser-level controls now return Err with the intended failure mode instead. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
…sis tests check-architecture forbids analysis from importing crate::output. The Ready Proposed → NewInlineTestModule projection now lives next to recommended_test_for. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
Admission refuses tests/** owners through the existing rust_index authority rather than a second path heuristic. The source-role gate now lists that consumer, and the blocker copy no longer re-derives cfg-test role from a raw attribute string. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
check-network-policy matches the substring `curl` inside `l_curly_token`/`r_curly_token`. Those AST accessors bound inline cfg-test module bodies; they are not a network surface. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
EffortlessSteven
left a comment
There was a problem hiding this comment.
Candidate review (review-pr) — REVIEW_INCOMPLETE
reviewed_head_sha: 7455af288eb7fba89b660c0dedca54885013d8f3
integration_basis: origin/main at branch creation (13c7ec58a); behind-only movement does not invalidate this pass
claim_boundary: Admit one producer-owned InlineUnit new-test target for a unique governed inline cfg-test module; Existing stays preferred; ambiguous/unsupported stay Missing; region identity is carried, not a whole-file allowlist. No Integration producer, no #4783 cage rewrite, no test generation.
changed_surfaces_and_semantic_owners_inspected:
- analysis/new_test_target.rs (admission owner)
- analysis/new_test_target/region.rs (region identity + staged validator)
- analysis/syntax/ra.rs::governed_cfg_test_modules (cfg_predicates authority)
- analysis/repair_route.rs::value_target_selection (Existing > InlineUnit > Missing)
- analysis/test_grip_evidence.rs (full evidence admits; compact stays None)
- output/agent_seam_packets.rs::recommended_test_for (Proposed → NewInlineTestModule)
blocking_findings: none from source/oracle inspection of this head
non_blocking_suggestions:
- Live packet-cage enforcement of the region remains #4783 (validator is test-called, expected unused in non-test builds).
- RepairAttempt focused execution / nonzero selected counts remain out of this slice.
refuted_or_stale_findings: none
proof_and_ci_observed:
- cargo test -p ripr --lib analysis::new_test_target (24 passed)
- cargo test -p ripr --lib analysis::repair_route (ranking tests passed)
- producer_owned_inline_unit_proposal_projects_as_new_inline_module passed
- cargo xtask precommit exited 0 on this head
proof_or_review_missing: hosted exact-head required checks and artifacts (PR is draft)
affected_currentness_dimensions: production implementation, test stimulus, test oracle, public claim (additive TestGripEvidence field)
residual_assumptions_and_non_claims: Proposed is a safe target; an empty related-test set still lacks a missing-discriminator fact so repair_packet_ready can stay false. Compact/badge paths omit proposals. Integration is not selected here.
disposition: REVIEW_INCOMPLETE
Author self-review COMMENT: GitHub cannot request changes from the author. This is not approval. Re-enter review-pr on the exact published head after hosted CI is current before finish-pr merge convergence.
EffortlessSteven
left a comment
There was a problem hiding this comment.
Published-head review (review-pr) — REVIEW_READY
reviewed_head_sha: 48dbda1f08fad407d6e4a7564a451b0212ecd7f2
integration_basis: origin/main merged at f4dcc5784 in this head; later main (0836002b3, +8) is behind-only with a clean merge-tree and was not restacked
claim_boundary: Admit one producer-owned InlineUnit new-test target for a unique governed inline cfg-test module; Existing stays preferred; ambiguous/unsupported stay Missing; region identity is carried, not a whole-file allowlist. No Integration producer, no #4783 cage rewrite, no test generation.
changed_surfaces_and_semantic_owners_inspected:
- analysis/new_test_target.rs (admission owner)
- analysis/new_test_target/region.rs (region identity + staged validator)
- analysis/syntax/ra.rs::governed_cfg_test_modules (cfg_predicates authority)
- analysis/repair_route.rs::value_target_selection (Existing > InlineUnit > Missing)
- analysis/test_grip_evidence.rs (full evidence admits; compact stays None)
- output/agent_seam_packets.rs::recommended_test_for (Proposed → NewInlineTestModule)
- xtask is_test_file inventory: language/rust/mod.rs (#4785) + new_test_target.rs (#4784)
blocking_findings: none
non_blocking_suggestions:
- Live packet-cage enforcement of the region remains #4783 (validator is test-called; expected unused in non-test builds).
- RepairAttempt focused execution / nonzero selected counts remain out of this slice.
refuted_or_stale_findings: none
proof_and_ci_observed:
- cargo test -p ripr --lib analysis::new_test_target: 24 passed on this head
- cargo test -p ripr --lib analysis::repair_route: ranking tests passed
- producer_owned_inline_unit_proposal_projects_as_new_inline_module passed
- cargo xtask precommit exited 0 on 48dbda1f0
- Ripr Rust Small Result SUCCESS (run 36533734307, job 109300984854)
- Ripr Rust Small on GitHub Hosted / Rust gates SUCCESS (26m20s)
- Rust-only feature lane SUCCESS
- cargo-deny, dependency-review, pr-plan SUCCESS
- skipped-by-policy: msrv, vscode, perl, coverage, windows, docs gate, extra runners
proof_or_review_missing:
- ub-review CANCELLED (advisory review-mode; concurrency cancel-in-progress; not Ripr Rust Small Result)
- CodeRabbit skipped (OSS stars threshold)
- gemini-code-assist quota skipped
- those missing providers are not a clean review; this COMMENT is the author published-head record
affected_currentness_dimensions: conflict resolution (xtask inventory), candidate head identity, exact-head CI receipts; production/oracle inspection from the prior pass still holds
residual_assumptions_and_non_claims: Proposed is a safe target; an empty related-test set still lacks a missing-discriminator fact so repair_packet_ready can stay false. Compact/badge paths omit proposals. Integration is not selected here. Live cage remains #4783.
disposition: REVIEW_READY
Author self-review COMMENT: GitHub cannot request changes from the author. This is not approval. Required hosted check Ripr Rust Small Result is current on this SHA. No unresolved review threads.
| let owner_fn = rust_index::find_owner_function(index, seam.file(), seam.display_line()) | ||
| .ok_or(NewTestProposalBlocker::OwnerUnresolved)?; | ||
| if owner_fn.source_role != FunctionSourceRole::Production { | ||
| return Err(NewTestProposalBlocker::OwnerUnresolved); |
There was a problem hiding this comment.
🔴 Test-only owners receive production repair proposals
For a top-level #[cfg(test)] helper, owner_fn.source_role remains Production and admits an InlineUnit proposal. The helper exists only in test builds, so its seam receives an actionable production repair packet.
Learn more
The parser classifies a function as a test role only when it has a test attribute or belongs to a test-gated module; a standalone #[cfg(test)] function receives Production in summarize_file_with_parser. The new admission treats that role as proof that the function exists in production. With another inline test module in the file, it issues a target for this test-only helper. This incorrectly turns a test-only seam into an actionable production repair packet.
Example: #[cfg(test)] fn helper(x: i32) -> bool { x > 0 } beside #[cfg(test)] mod tests {} produces a proposed target for helper despite its absence from non-test builds.
Recommended fix: Require a parser-backed check of the owner's own cfg attributes and enclosing module gates before admitting a proposal; return a typed limitation for owners excluded from production builds.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let modules = | ||
| governed_cfg_test_modules(&facts.source).ok_or(NewTestProposalBlocker::LexicalFallback)?; | ||
| let region = unique_inline_region(seam.file(), &facts.source, owner_fn, &modules)?; |
There was a problem hiding this comment.
🔴 Repeated parsing stalls seam analysis
For each value seam, unique_inline_region reparses the complete owner file after governed_cfg_test_modules already parsed it. Files with many seams incur two full parses per seam, multiplying full-inventory analysis time.
Learn more
evidence_for calls admission for every value seam. Admission calls governed_cfg_test_modules, which parses the full file, and then production_owner_module_path parses the same file again. Those facts and their source already belong to the indexed file, so the repeated parsing is independent of whether a target exists.
Example: A 1,000-seam source file causes 2,000 whole-file parses during one cold full inventory rather than one parse for that file.
Recommended fix: Compute governed modules and owner module paths once per indexed file in the evidence pass or in the file-fact producer. Reuse the parsed facts across seams; preserve source-digest currentness when caching them.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let module = inline[0]; | ||
| if module.parent_modules != owner_modules { | ||
| return Err(NewTestProposalBlocker::OwnerInaccessible); |
There was a problem hiding this comment.
🟡 Accessible nested owners lose inline targets
When a public function lives in a child module, unique_inline_region rejects a crate-root test module despite valid Rust access. The only safe insertion target becomes Missing.
Learn more
The producer permits only identical parent module paths. Rust permits a crate-root tests module to call a public function in a child module, so unequal paths do not imply inaccessibility. This is a false negative in the new target-selection contract, not a request to weaken access for private functions.
Example: pub mod pricing { pub fn discount(x: i32) -> bool { x > 0 } } and a single crate-root #[cfg(test)] mod tests { use super::*; } have a valid insertion target, but admission returns OwnerInaccessible.
Recommended fix: Check real visibility along the path between the candidate test module and the owner, preserving rejection for private descendants or unresolved visibility.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /// Positive: a same-file private owner plus one exact inline cfg(test) module | ||
| /// earns InlineUnit from the production inventory path. | ||
| #[test] | ||
| fn same_file_private_owner_with_one_inline_module_earns_inline_unit() -> Result<(), String> { |
There was a problem hiding this comment.
🔍 Production proposal lacks rendered-path proof
Inventory tests assert selection, while the packet test supplies a synthetic proposal without a region. Add a fixture that follows real inventory through packet rendering, including a rejected module control.
Was this helpful? React with 👍 or 👎 to provide feedback.
| let admission = evidence.new_test_target.as_ref(); | ||
| let target_selection = value_target_selection(selected_test_target.as_ref(), admission); | ||
| let has_safe_target = !matches!(target_selection, RepairTargetSelection::Missing); |
There was a problem hiding this comment.
🔍 New target selection lacks contract trace
The diff changes actionable packet selection without updating specs, traceability, output documentation, or goldens. Check whether existing contracts already describe proposed InlineUnit targets and their new output.
Was this helpful? React with 👍 or 👎 to provide feedback.
| /// Validate an external edit against a previously admitted inline region. | ||
| /// Production text outside the module body must be unchanged. | ||
| /// | ||
| /// Tests own the current callers. The #4783 cage consumer is the production | ||
| /// path that will fail-close packet edits against this same function. | ||
| #[cfg_attr( | ||
| not(test), | ||
| expect( | ||
| dead_code, | ||
| reason = "producer-owned region validator is called from tests now; #4783 is the cage consumer" | ||
| ) | ||
| )] | ||
| pub(crate) fn validate_inline_region_edit( |
There was a problem hiding this comment.
🔍 Region authority is not yet enforced
validate_inline_region_edit has only test callers. The repair driver still refuses production-file targets; keep InlineUnit packet guidance distinct from permission to edit the file until the cage consumes this region.
Was this helpful? React with 👍 or 👎 to provide feedback.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 48dbda1f08
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if inline.len() != 1 || !out_of_line.is_empty() { | ||
| return Err(NewTestProposalBlocker::AmbiguousModule); |
There was a problem hiding this comment.
Scope module uniqueness to the owner's module
When a source file contains an applicable test module and another #[cfg(test)] module under an unrelated production module, both enter these file-wide vectors, so inline.len() != 1 reports AmbiguousModule even though only one candidate has parent_modules == owner_modules. This suppresses a valid InlineUnit proposal in a common multi-module file layout; filter modules by the resolved owner path before applying the uniqueness and out-of-line checks.
AGENTS.md reference: AGENTS.md:L233-L236
Useful? React with 👍 / 👎.
| let line = function | ||
| .fn_token() | ||
| .map(|token| line_index.line(token.text_range().start())) | ||
| .unwrap_or_else(|| line_index.line(function.syntax().text_range().start())); | ||
| if line != start_line { |
There was a problem hiding this comment.
Bind the module path to the resolved function identity
If multiple functions in different modules begin on the same physical line, this line-only search returns the first AST function rather than the supplied owner_fn. For example, with an unrelated function and test module in mod first followed on the same line by the changed owner in mod second, admission can associate the second owner's seam with first and mark that unrelated test region safe. Resolve by the function's symbol/range identity, not only start_line, so a repair packet cannot target another owner.
AGENTS.md reference: AGENTS.md:L233-L236
Useful? React with 👍 / 👎.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
…n-test-target-e401 Reconcile landed InlineUnit (#4839) with this Integration leaf: keep both producers, prefer a Proposed Integration, then Proposed InlineUnit, and retain Integration's PrivateOwner or layout blocker when both stay Missing so visibility negatives still name the reason. Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>
Summary
Admit one producer-owned
InlineUnitnew-test target when a value-seam owner has no existing related test and the owner file already contains one exact governed inline cfg-test module. The proposal names the file, owner, and insertion region; it does not generate a test body, invent an expected value, or allow production edits in the same file.Closes #4784.
Swarm / Source Boundary
This PR targets
EffortlessMetrics/ripr-swarm, the normal development trunk fortrusted same-repo
riprwork. Confirm the change belongs here:dependency, or repo-ops development for
ripr-swarmSource-of-truth Links
Proposal: issue #4784 (Slice I2)
Spec: none added; consumes reserved
NewTestTargetProposal/RepairTargetSelection::Proposedfrom #4576ADR: n/a
Plan item: parent capability #3162
Governing issue or accepted claim: #4784
Acceptance delta: a production
RustIndexpath can earn one exact InlineUnit proposal for a unique governed inline test module, with Existing preferred and ambiguous/unsupported cases Missing.Candidate Relationships
Candidate branch:
cursor/inline-unit-target-4784-7c10Stack parent: none. #4783 (region cage) is still unlanded; this producer carries region identity and a staged prefix/suffix validator rather than rewriting path-level
EditCagePolicy.Open sibling #4625 implements Integration admission for #4576 and is not absorbed here.
Scope
Producer admission plus current consumer projection for InlineUnit only.
Scope Classification
Production delta:
Proposed(InlineUnit)from indexed source-role andcfg_predicatesmodule facts when one unique inline test module is accessible to the owner.new_test_target: None.Evidence/support delta:
analysis/new_test_target/tests.rsrecommended_test_forSingle acceptance criterion: a production Rust path earns one exact InlineUnit proposal for an existing unique governed inline test module, without creating a module, generating a body, or authorizing production edits.
Non-goals: missing-module creation, Integration producer, #4783 cage rewrite, test generation, RepairAttempt execution, support-tier/release action.
Support-tier Impact
Policy Impact
policy/network_allowlist.txtdocuments thel_curly_tokensubstring false-positive)Proof
Local
precommitexited 0 on7455af288eb7fba89b660c0dedca54885013d8f3. Hosted PR CI is the merge-gate matrix.Claim Boundary
RIPR may propose one exact existing inline unit-test region when no safe existing test owns the repair. It does not prove the proposed test body is correct, authorize production edits, create a missing module, admit Integration targets, or run focused execution as verified RepairAttempt evidence. Live packet-cage enforcement of the region remains #4783.
Rollback
Revert this branch. Types remain the reserved four-field proposal shape.
Spec-Test-Code Traceability
crates/ripr/src/analysis/new_test_target/tests.rs,repair_route.rsranking tests,agent_seam_packets.rsprojection testnew_test_target.rs,region.rs,syntax/ra.rs,repair_route.rs,test_grip_evidence.rsStatic Language Check
killed,survived,untested,proven, andadequate.CI Economics
n/a
Engineering Check