Skip to content

fix(rust): bound derived tuple projection evidence at direct returns - #4068

Merged
EffortlessSteven merged 11 commits into
mainfrom
fix/rust-derived-projection-return-boundary-20260925
Sep 27, 2026
Merged

EffortlessSteven merged 11 commits into
mainfrom
fix/rust-derived-projection-return-boundary-20260925

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

The derived tuple-arm admission helper scans top-level assertions after the owner call but skips return; as a non-macro expression. Source inspection shows that assertions after the containing test has returned can still supply cardinality, receipt identity, and relation evidence.

Bound top_level_projection_observes at the first direct top-level ReturnExpr. Reject an owner call beyond that boundary and stop collecting assertions at it. Preserve the existing whole-body owner-uniqueness and shadowing checks. Complete observation before a later return still qualifies. Both derived admission and derived discrimination consume this one helper.

Related: #3769, #3807. This is a focused correctness follow-up, not closure of either parent or a Rust support-tier promotion.

Regression coverage added

  • Three unit tests exercise all six assertion orders across every return position, preserve complete/no-return positives, distinguish returns in nested functions/closures and literal/comment text, and retain owner-uniqueness rejection. Malformed fixture syntax fails the test rather than counting as successful rejection.
  • Two public-API tests reuse the existing isolated Cargo fixture, source-derived diff, and unique candidate-current arm selector. A return before any required assertion must leave the finding WeaklyExposed with observation_unverified; a return after complete observation must preserve Exposed.
  • Existing tests and fixture helpers are unchanged.

Validation and acceptance

Candidate: fa2ef59aba70eafcfb49e0eee0f3be49d30c5841
Base: e839ba25179e5770bdb263fc4f95692637160852

Source-only checks completed: exact source blob identity verification; git diff --check; reverse-patch applicability; existing test-block preservation; full published diff inspection. No local Rust compilation, rustfmt, or tests ran: the authoring environment has no Rust toolchain. Source checks are not runtime proof.

Hosted Rust run 36123546493 on the previous candidate stopped at formatting, reporting only brace placement in the two new integration-test signatures; compilation and tests were skipped. Commit fa2ef59 applies those exact rustfmt corrections. Current-head Rust run 36123909698 is in progress; its native checks are not yet established.

Required before acceptance:

  • Run cargo test -p ripr --lib projection_return_boundary --locked.
  • Run cargo test -p ripr --test match_arm_tuple_derived_local --locked and the applicable exact-head repository checks, including formatting.
  • Retain a red control with only the new production boundary removed and the new tests still enabled, then a green candidate run. The unpatched failure is currently a source-derived expectation, not an executed result.
  • Add the runtime-confirmed false-promotion case to the RIPR-SPEC-0108 honesty corpus and run its gate.
  • Complete substantive exact-head review and inspect hosted CI. Review-provider quota or a no-findings summary does not replace the missing proof.

Disposition: REVIEW_INCOMPLETE. No merge or auto-merge requested.

Scope and rollback

This handles direct top-level return statements only. It does not establish general control-flow reachability, conditional/nested-exit handling, macro expansion, or diverging-call analysis. Static exposure remains distinct from runtime mutation killing. No dependency, schema, workflow, release, tag, or publication change. Before merge, close this draft unmerged to abandon the candidate; after merge, revert this focused change without rewriting history.

@coderabbitai

coderabbitai Bot commented Sep 25, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 59 seconds.

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: 38f4dee3-95ed-4634-a28f-d6547daa5028

📥 Commits

Reviewing files that changed from the base of the PR and between 47e00b4 and 40c36be.

📒 Files selected for processing (15)
  • .ripr/traceability.toml
  • crates/ripr/src/analysis/classifier/evidence/tuple_match/derived_admission.rs
  • crates/ripr/src/analysis/classifier/evidence/tuple_match/derived_admission/return_boundary_tests.rs
  • crates/ripr/src/analysis/classifier/evidence/tuple_match_derived.rs
  • crates/ripr/tests/match_arm_tuple_derived_local.rs
  • fixtures/evidence-promotion-honesty-corpus/corpus.json
  • fixtures/match_arm_tuple_derived_return_before_assertion/SPEC.md
  • fixtures/match_arm_tuple_derived_return_before_assertion/diff.patch
  • fixtures/match_arm_tuple_derived_return_before_assertion/expected/CHANGELOG.md
  • fixtures/match_arm_tuple_derived_return_before_assertion/expected/check.json
  • fixtures/match_arm_tuple_derived_return_before_assertion/expected/human-full.txt
  • fixtures/match_arm_tuple_derived_return_before_assertion/expected/human.txt
  • fixtures/match_arm_tuple_derived_return_before_assertion/input/Cargo.toml
  • fixtures/match_arm_tuple_derived_return_before_assertion/input/src/lib.rs
  • fixtures/match_arm_tuple_derived_return_before_assertion/input/tests/projection.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.

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

Code Review

This pull request updates the top_level_projection_observes function to enforce that projections are observed before a function returns. It introduces a boundary check using return statements to ensure that observations occurring after a return are ignored, preventing incorrect certification of code arms. Additionally, comprehensive unit tests were added to verify this return boundary behavior and ensure that unreachable assertions do not incorrectly certify arms, while valid observations preceding a return are correctly handled. I have no feedback to provide as there were no review comments.

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

Author source review — REVIEW_INCOMPLETE

Reviewed head: fa2ef59aba70eafcfb49e0eee0f3be49d30c5841
Integration basis: e839ba25179e5770bdb263fc4f95692637160852; GitHub currently reports test-merge f7cc19544652a9dc3686fb22145c0e9b0f26d988.

Claim and inspected surfaces. Read the complete three-file patch, the projection admission helper, tuple dispatch/direct-oracle restrictions, its shared consumer in tuple_match_derived.rs, and the existing public fixture/changed-arm selector. The change bounds assertion collection at the first direct top-level return without truncating the full-body uniqueness or shadowing authorities.

Wrong-behavior challenges retained. The new matrix places return before the input, owner, or each observation in every assertion order. Separate controls cover complete observation before return, nested uncalled scopes, literal/comment mentions, and duplicate owner calls after return. Public tests require exactly the changed current arm, an explicit WeaklyExposed/observation_unverified result for missing observations, and an Exposed positive. Parse failure cannot satisfy the unit negatives. These are inspected test intentions, not executed results.

Evidence observed. Candidate blob identities match; git diff --check and reverse-patch applicability pass; existing test blocks are unchanged. The first hosted run stopped before compilation on two signature-formatting differences. This head applies exactly that reported delta. Current-head run 36123909698 was still in progress when checked. CodeRabbit reported quota exhaustion; Gemini supplied a no-findings summary. Neither establishes the outstanding native proof. No inline review threads were present when checked.

Acceptance blockers. Current-head Rust compilation and test results; an executed boundary-removal red control with tests retained; the corresponding RIPR-SPEC-0108 corpus case and gate; completed proof-backed review. No additional source defect was established within this bounded delta.

Residual scope. Conditional/nested exits, diverging calls, and macro expansion remain outside this claim. This is static evidence admission, not runtime mutation-kill proof. No merge or auto-merge readiness is asserted.

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

Evidence refresh on published head a8daf45-equivalent review (draft; no merge attempted):

Inspected changed surfaces:

  • crates/ripr/src/analysis/classifier/evidence/tuple_match/derived_admission.rs (+26/-1): computes observation_end at first direct ReturnExpr statement; owner at/after boundary returns Some(false); observation scan takes observation_end.
  • crates/ripr/src/analysis/classifier/evidence/tuple_match/derived_admission/return_boundary_tests.rs (new, unit tests).
  • crates/ripr/tests/match_arm_tuple_derived_local.rs (new integration-style tests, +37).

Risks considered:

  • Return-boundary narrowing could under-credit a tuple projection observed legitimately after an early return in a different branch. Mitigated: boundary only truncates the observation scan, binding/owner scans unchanged, and owner-position guard returns explicit false rather than unknown.
  • ExprStmt/ReturnExpr shape check is AST-version-sensitive; acceptable within pinned ra_ap_syntax.

Repo invariants checked:

  • Conservative-language posture preserved: change demotes over-credit toward explicit false, consistent with identity-not-tokens bias.
  • No output-contract, schema, or public-API surface touched (classifier internals + tests only).

Validation signals (published head):

  • Required gates green: Rust-gates, fixtures-gates, required-checks green; 0 unresolved threads.

Residual assumptions:

  • Did not run the two new test files locally in this pass; green required CI is the oracle.
  • Whether truncation at the first direct return matches intended semantics for multi-branch test bodies is a product-semantics question for the author.

Disposition: REVIEW_READY on evidence, merge held solely because the PR is draft. Flip to ready when the author confirms the semantics.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Correction to the review record above: the published head reviewed is fa2ef59, not a8daf45 (that SHA belongs to #4117). All findings in the record apply to fa2ef59. Disposition stands: REVIEW_READY on evidence, merge held for draft status.

…260925

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ui933un54X4MJRygfjwdjW
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Ui933un54X4MJRygfjwdjW

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

Exact-head review (review-pr), author-side COMMENT

reviewed_head_sha: 1a53483b0e0e539e0dee2c6d34e2c4937b082fad
integration_basis: origin/main merged in at 5c9f81dc2 (clean; the branch was 75 commits behind)
claim_boundary: the derived tuple-arm projection admission (`top_level_projection_observes`) stops collecting assertions at the containing test's first direct top-level `return` statement, and rejects an owner call placed after it. Related to #3769 and #3807. This is not a support-tier promotion and not general control-flow reachability.

Blocking findings: none.

Surfaces inspected

  • tuple_match/derived_admission.rs: observation_end is the index of the first top-level ExprStmt(ReturnExpr). The owner-uniqueness and shadowing scans still read the whole body, which is conservative. An owner at or after the boundary gives Some(false), and the assertion loop is bounded by take(observation_end). Both consumers, derived admission and derived discrimination, call this one helper, so there is no forked validator.
  • Nested scopes (|| { return; }, a local fn), comment text and string literals do not move the boundary, because only direct statements are inspected and the scan is syntax-based, not textual.
  • A tail-expression return (no semicolon) is not in statements() but is by definition last, so it cannot hide later assertions.
  • Actionability direction: the change can only turn Some(true) into Some(false). A finding can move from Exposed to WeaklyExposed/observation_unverified, never the reverse, so it fails closed.

Simplification in this push: the boundary predicate is folded into one matches! with a guard. No behavior change; tuple_match lib tests 21/21.

Oracle and mutation challenge (run locally, toolchain 1.95.0)

  • Revert (boundary disabled: observation_end forced to statements.len()):
    • projection_return_boundary_requires_every_observation_before_return FAILS (return position 0 ... left: Some(true), right: Some(false));
    • the public-API test projection_return_boundary_unreachable_assertions_cannot_certify_the_arm FAILS (the arm is certified Exposed past a return;).
  • Head: cargo test -p ripr --lib projection_return_boundary 3/3; cargo test -p ripr --test match_arm_tuple_derived_local 16/16. The positive control projection_return_boundary_after_complete_observation_preserves_exposure keeps Exposed. cargo xtask precommit passes, including clippy -D warnings.

Non-blocking suggestions and open author items

  • The PR body's own checklist asks for a RIPR-SPEC-0108 honesty-corpus member for this false-promotion case. It is not added here. The unit and public-API regressions carry the proof for this head, and a corpus member would add an independent-invariant guard against a future re-bless. I recommend it as a follow-up.
  • Conditional or nested exits, macro expansion and diverging calls are out of scope, as the PR states.

Exact-head CI: fresh run on this SHA: Rust gates success (run 36306557924), plus Ripr Rust Small Result, cargo-deny, dependency-review, pr-plan, ub-review and GitGuardian success. Lanes skipped by label routing are not engaged.

Missing review: Gemini (quota), CodeRabbit (rate limited) and Devin (credits) review is missing, not clean.

Disposition: REVIEW_READY (a COMMENT record; the author cannot approve).


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review September 27, 2026 08:56
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 27, 2026 •

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-27T08:59:47.174898Z 1a53483 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.

@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 2 potential issues.

Devin Review

@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: 1a53483b0e

ℹ️ 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".

@github-actions github-actions 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.

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm nested closure/local-fn returns and comment/string literals must not advance the boundary.
  • Confirm negative-case corpus pinning to RIPR-SPEC-0108 honesty gate not yet done; Devin flagged it on match_arm_tuple_derived_local.rs:699.
  • Confirm unit tests have no spec-test-code mapping; Devin flagged absence of explicit mapping to a spec requirement or explained omission.
  • Confirm author PR body explicitly marks disposition REVIEW_INCOMPLETE pending cargo test red-control, runtime-confirmed false-promotion corpus addition (RIPR-SPEC-0108), and substantive exact-head review. No native proof yet. Reviewer concurrence must not substitute.
  • Confirm pR is still in draft with disposition REVIEW_INCOMPLETE and authoring environment lacks a Rust toolchain, so local runtime proof is impossible; rely on hosted CI receipt referenced in PR body.

Parked follow-ups

  • Boundary detection is AST-version sensitive: only direct top-level ReturnExpr statements bind observation_end. Nested returns (closures, fns), comment text, and string literals are correctly excluded by the ExprStmt/ReturnExpr shape check.

Evidence gaps

  • Devin flagged missing spec-test mapping; author replied only on corpus pinning.
  • Model proof intent was rejected by deterministic validation.
  • Red control (new tests pass with the production boundary removed) is unexecuted; the PR body explicitly states the unpatched failure is source-derived only.
  • Hosted Rust run on 1a53483 still in progress; cargo test execution has not produced a receipt that overrides the author's source-only validation.

…o RIPR-SPEC-0093

The return-boundary unit tests and public-API witnesses decide whether a
MatchArm probe keeps the RIPR-SPEC-0093 observation_unverified downgrade
or earns the derived tuple-arm exception, so register them and the
derived_admission owner under that behavior (Devin review thread).

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyH6Ya3zZA8atiNCVFyUub
…ectory

`same_current_file` joined the probe location onto the canonical
authority root. Probe locations are already `--root` as given joined with
the changed path, so a relative root with a directory prefix (the fixture
runner's `--root fixtures/<name>/input`, or `ripr check --root sub/dir`)
resolved to `<root>/<root>/src/...`, failed, and silently skipped the
derived tuple-arm admission. Absolute and `.` roots were unaffected.

- canonicalize the probe location directly
- public-API witnesses under a nested relative root: the positive control
  earns `exposed` (fails without the fix) and the return boundary holds
- graduate the #4068 return-before-assertion false promotion into the
  RIPR-SPEC-0108 honesty corpus via fixture
  match_arm_tuple_derived_return_before_assertion (weakly_exposed); the
  fixture golden drifts to `exposed` with the derived_admission return
  boundary reverted, and a re-bless is rejected by the honesty gate
- traceability under RIPR-SPEC-0093; `goldens check` and `fixtures` show
  no other golden moved

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01UyH6Ya3zZA8atiNCVFyUub

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

Exact-head review of 40c36be (review-pr), disposition: REVIEW_READY once CI is green on this head.

Inspected:

  • The original change: derived_admission.rs bounds derived tuple-projection evidence at a direct return, so assertions after return; no longer promote the arm to exposed.
  • The new fix in tuple_match_derived.rs::same_current_file: probe locations are built as --root as typed joined with the changed path (probes/diff.rs), so they already resolve from the working directory. The old code joined them onto the canonical root a second time. That worked only for an absolute root or ., and a root with a directory prefix (--root ctl) silently lost the tuple-arm admission. The owner path join on the line above is correct, because owner files are root-relative.
  • Oracles:
    • relative_prefixed_root_keeps_the_derived_arm_admission fails on the old line. It needs a nested workspace, because at equal depth the old bug resolves by coincidence.
    • relative_prefixed_root_keeps_the_return_boundary keeps the #4068 boundary under a relative root.
    • The new corpus case rust_tuple_derived_return_before_assertion_no_promotion drifts to exposed in cargo xtask fixtures with derived_admission.rs reverted, and the honesty gate rejects a re-bless of that drift.
  • Golden impact: goldens check and the full fixtures run show 0 drift across 588 comparisons. The only new golden is the added fixture.
  • The corrected thread replies strike the earlier wrong cause.

Residual: probe_file.canonicalize() depends on the process working directory, which is the same assumption the probe path's construction already makes.

Outside review: Gemini out of quota, Devin out of credits, droid-review queued; that review is missing, not clean.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven merged commit 54e867a into main Sep 27, 2026
29 checks passed
@EffortlessSteven
EffortlessSteven deleted the fix/rust-derived-projection-return-boundary-20260925 branch September 27, 2026 20:31
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.

2 participants