Skip to content

feat(analysis): admit InlineUnit targets in a unique governed test module - #4839

Merged
EffortlessSteven merged 7 commits into
mainfrom
cursor/inline-unit-target-4784-7c10
Sep 29, 2026
Merged

EffortlessSteven merged 7 commits into
mainfrom
cursor/inline-unit-target-4784-7c10

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 29, 2026 •

Copy link
Copy Markdown
Member

Summary

Admit one producer-owned InlineUnit new-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 for
trusted same-repo ripr work. Confirm the change belongs here:

  • ordinary feature, analyzer, editor, docs, spec, fixture, badge,
    dependency, or repo-ops development for ripr-swarm

Source-of-truth Links

Proposal: issue #4784 (Slice I2)
Spec: none added; consumes reserved NewTestTargetProposal / RepairTargetSelection::Proposed from #4576
ADR: n/a
Plan item: parent capability #3162
Governing issue or accepted claim: #4784
Acceptance delta: a production RustIndex path 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-7c10
Stack 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

  • One production behavior

Production delta:

  • Full evidence admits Proposed(InlineUnit) from indexed source-role and cfg_predicates module facts when one unique inline test module is accessible to the owner.
  • Ranking remains Existing then InlineUnit then Missing. Integration proposals stay Missing on this producer.
  • Compact/badge evidence keeps new_test_target: None.
  • Region authority is a prefix/suffix containment check against the unique reparsed module, not a whole-file allowlist.

Evidence/support delta:

  • Inventory-path and parser tests in analysis/new_test_target/tests.rs
  • Repair-route ranking tests
  • Packet projection test next to recommended_test_for

Single 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

  • none

Policy Impact

  • lint / Clippy (removed reserved dead_code rows)
  • process/network (policy/network_allowlist.txt documents the l_curly_token substring false-positive)

Proof

cargo test -p ripr --lib analysis::new_test_target --offline
cargo test -p ripr --lib analysis::repair_route --offline
cargo test -p ripr --lib producer_owned_inline_unit_proposal_projects_as_new_inline_module --offline
cargo xtask precommit

Local precommit exited 0 on 7455af288eb7fba89b660c0dedca54885013d8f3. 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

Static Language Check

  • Static output avoids killed, survived, untested, proven, and adequate.

CI Economics

n/a

Engineering Check

  • No new panic-family calls in production or tests (no-panic-family gate passed).
Open in Web Open in Cursor 

…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>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: e1049bec-ef8b-4ba5-8b62-6958cab514e3

📥 Commits

Reviewing files that changed from the base of the PR and between f4dcc57 and 48dbda1.

📒 Files selected for processing (29)
  • .ripr/allow-attributes.txt
  • crates/ripr/src/analysis/canonical_gap.rs
  • crates/ripr/src/analysis/mod.rs
  • crates/ripr/src/analysis/new_test_target.rs
  • crates/ripr/src/analysis/new_test_target/region.rs
  • crates/ripr/src/analysis/new_test_target/tests.rs
  • crates/ripr/src/analysis/repair_route.rs
  • crates/ripr/src/analysis/seam_cache.rs
  • crates/ripr/src/analysis/seam_classification.rs
  • crates/ripr/src/analysis/seam_inventory.rs
  • crates/ripr/src/analysis/syntax/mod.rs
  • crates/ripr/src/analysis/syntax/ra.rs
  • crates/ripr/src/analysis/test_grip_evidence.rs
  • crates/ripr/src/app/agent_brief.rs
  • crates/ripr/src/cli/rerun.rs
  • crates/ripr/src/lsp/diagnostics.rs
  • crates/ripr/src/lsp/hover.rs
  • crates/ripr/src/lsp/tests.rs
  • crates/ripr/src/output/agent_brief.rs
  • crates/ripr/src/output/agent_seam_packets.rs
  • crates/ripr/src/output/badge/tests.rs
  • crates/ripr/src/output/evidence_health.rs
  • crates/ripr/src/output/evidence_record.rs
  • crates/ripr/src/output/pilot/tests.rs
  • crates/ripr/src/output/repo_exposure.rs
  • crates/ripr/src/output/review_comments.rs
  • crates/ripr/src/output/sarif.rs
  • policy/network_allowlist.txt
  • xtask/src/main.rs

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

…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>
cursoragent and others added 4 commits September 29, 2026 06:16
… 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 EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Combined-tree conflict in the is_test_file consumer inventory after #4785
moved language/rust.rs to language/rust/mod.rs. Keep that path and the
#4784 new_test_target.rs consumer.

Co-authored-by: Steven Zimmerman, CPA <EffortlessSteven@users.noreply.github.com>

@EffortlessSteven EffortlessSteven left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 29, 2026 07:23
@EffortlessSteven
EffortlessSteven merged commit 56fc960 into main Sep 29, 2026
22 of 25 checks passed
@EffortlessSteven
EffortlessSteven deleted the cursor/inline-unit-target-4784-7c10 branch September 29, 2026 07:24

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 6 potential issues.

Devin Review

Comment on lines +174 to +177
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +193 to +195
let modules =
governed_cfg_test_modules(&facts.source).ok_or(NewTestProposalBlocker::LexicalFallback)?;
let region = unique_inline_region(seam.file(), &facts.source, owner_fn, &modules)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔴 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +234 to +236
let module = inline[0];
if module.parent_modules != owner_modules {
return Err(NewTestProposalBlocker::OwnerInaccessible);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +263 to +266
/// 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> {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +231 to +233
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

Comment on lines +23 to +35
/// 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(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 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.

Devin Review


Was this helpful? React with 👍 or 👎 to provide feedback.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment on lines +231 to +232
if inline.len() != 1 || !out_of_line.is_empty() {
return Err(NewTestProposalBlocker::AmbiguousModule);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

Comment on lines +727 to +731
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 {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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 👍 / 👎.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-29T07:27:50.920322Z 48dbda1 Draft marked ready
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

cursor Bot pushed a commit that referenced this pull request Sep 29, 2026
…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>
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.

analysis(rust): admit an InlineUnit target in an existing governed test module

2 participants