Skip to content

fix(grip): bind snapshot discrimination to the owner result on return seams (#8121) - #8318

Merged
EffortlessSteven merged 12 commits into
mainfrom
claude/great-fermat-dayr32
Oct 17, 2026
Merged

EffortlessSteven merged 12 commits into
mainfrom
claude/great-fermat-dayr32

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Swarm / Source Boundary

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

Source-of-truth Links

Spec: docs/specs/RIPR-SPEC-0005-repo-seam-inventory.md
Governing issue or accepted claim: #8121 (residual comment 6227801705; follows the field-seam admission in #8251)
Acceptance delta (one sentence): a snapshot of an unrelated value cannot close a changed return seam.

Candidate Relationships

Candidate branch: claude/great-fermat-dayr32
Stack parent or prerequisite PR (if any): none (#8251 already merged)

Scope

  • One gate in oracle_discriminates_seam_in_test plus a small snapshot_owner_binding module (text/line-based, fail-closed). It is a static name-binding check and does not read snapshot bytes.

Scope Classification

  • One production behavior

Production delta: return-value + Snapshot oracle requires owner-result binding.
Evidence/support delta: crates/ripr/tests/snapshot_return_admission.rs (5 tests), spec paragraph, traceability, changelog fragment.
Single acceptance criterion: unrelated snapshot stays weakly_gripped; direct owner snapshot and independent exact assertions keep their grade.
Non-goals: full snapshot identity/settings/projection binding (rest of #8121), field seams, non-snapshot oracles, honesty-corpus golden addition.

Support-tier Impact

  • none

Policy Impact

  • doc artifacts

Proof

cargo test --locked -p ripr --test snapshot_return_admission --test snapshot_field_admission
cargo test --locked -p ripr --lib test_grip_evidence
cargo xtask precommit

Result: RED without the fix (2 of 5 new tests fail: unrelated snapshot, rebound name; the 3 positives pass). With the fix: 5/5 pass, 6/6 field-admission tests unchanged, 427 test_grip_evidence lib tests pass, precommit exit 0. Not run locally: full workspace tests, fixtures/goldens check/dogfood beyond what precommit selects, hosted CI.

Claim Boundary

May claim: an unrelated snapshot no longer over-credits a return seam in repo grading. Must not claim: snapshot bytes/settings/projection are verified; a snapshot of a value derived through a helper (not a direct owner call or binding) now under-credits by design.

Rollback

Revert this commit; no schema, workflow or dependency changes.

Spec-Test-Code Traceability

  • Spec: RIPR-SPEC-0005
  • Tests: crates/ripr/tests/snapshot_return_admission.rs
  • Code: crates/ripr/src/analysis/test_grip_evidence/snapshot_owner_binding.rs, test_grip_evidence.rs

Static Language Check

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

CI Economics

n/a

Engineering Check

  • No new panic, unwrap, expect, todo, or unimplemented in production code.
  • No new panic, unwrap, expect, todo, or unimplemented in tests.

Refs #8121 (issue stays open for its remaining acceptance).


Generated by Claude Code

… seams (#8121)

A snapshot admitted by kind for a return_value seam now discriminates only
when it names the owner call or a plain local last bound to it, so an
unrelated committed snapshot no longer grades a changed return strongly.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XsvDqL1Ui8moGnvSX29qJj
@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 Oct 17, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

  • Ask an admin to enable usage-based reviews

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 65 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: 55e82faa-ccd9-4963-a5b3-236301dbf1c0
📥 Commits

Reviewing files that changed from the base of the PR and between 0f209dc and a720d2f.

📒 Files selected for processing: 6
  • .ripr/traceability.toml
  • changelog.d/8121-return-snapshot-admission.md
  • crates/ripr/src/analysis/test_grip_evidence.rs
  • crates/ripr/src/analysis/test_grip_evidence/snapshot_owner_binding.rs
  • crates/ripr/tests/snapshot_return_admission.rs
  • docs/specs/RIPR-SPEC-0005-repo-seam-inventory.md
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

…8121)

Comparisons (==, !=, <=, >=, =>) and non-place left-hand sides such as
'if count == 0 {' no longer withdraw snapshot credit.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XsvDqL1Ui8moGnvSX29qJj

@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 source review of 6d28eddd2ca8f34aa9b556b69c8969b7432a1cfc: REPAIR_REQUIRED.

The final ownership search found this existing PR, so it retains the writer and candidate. No competing PR is being opened. The original counterexample remains under #3161 and the #8121 residual.

Three remaining source defects affect the stated preservation/refusal contract:

  1. At snapshot_owner_binding.rs:24-29, any textual owner call or any free identifier anywhere in the macro is accepted. Neither path establishes that the eager value operand is the owner's result. An owner call behind control transfer or an opaque macro is sufficient; a block that merely reads a captured owner binding and yields an unrelated value is also sufficient. The initializer check at lines 119-122 has the same containing-a-call problem. Parse and validate the actual value expression, and retain macro/call provenance authority before awarding discrimination.
  2. At lines 107-130, owner binding state changes only for a local binding or recognized assignment to that name. Passing or aliasing an interior-mutable result and later changing it through the alias leaves the original binding credited, even though a snapshot can then be independent of the changed return. Reuse the shared binding/use authority to withhold credit after unsupported escape, aliasing or opaque intervening use.
  3. At lines 85-87, the entire assertion line is discarded before binding analysis. A genuine completed let immediately before the snapshot on that same line loses its existing credit, with or without whitespace after the semicolon. Use statement/token offsets so a preceding completed binding is admitted and a later binding remains refused.

Please keep Draft through a joined repair and refresh the affected independent oracle/provenance/adjacency controls before qualification. This review is anchored to the published source above; it does not establish a build, CLI result or hosted qualification for this PR.

@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 reviewer attention before upstream: findings remain.

Confirmed findings

  • crates/ripr/tests/snapshot_return_admission.rs:131 — No negative test exercises a rebound through a wrapping macro/closure (e.g., a vec![make_count(2)] index read or a closure-captured re-bind). Add one control asserting assert_weak for a macro-internal owner call that escapes name binding, so a future refactor that broadens call_text_contains_named_call to skip macros stays honest.

Verification questions

  • Confirm boolean short-circuit RHS like let count = make_count(2) \|\| other; makes count carry an unrelated value but still passes the direct-owner test; name binding assumes let RHS == owner.
  • Confirm macro/closure rebinding routes are not covered: let _f = \|\| { let count = make_count(2); }; let count = 7; insta::assert_snapshot!(count); resets scope, but a later closure-invocation re-bind inside a different block would survive the linear top-level scan.

Refuted

  • Helper duplicates text-parsing vs. owner_result_binding and should be unified into a shared seam-binding helper.; refuted because: owner_result_binding targets a different shape (receiver-style field seams); the new helper is the first ReturnValue+Snapshot binding path and reuses both super-helpers (call_text_contains_named_call, strip_comments_and_strings). Unification is parked for a second consumer, not this PR.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

PR #8275 (RIPR-SPEC-0122) converted the bounded human render to plain language but missed these 8 fixtures. Each diff is wording-only: Summary/State/Static exposure/Hidden schema tokens become plain words with identical class counts; check.json and human-full.txt are byte-identical. Blessed via cargo xtask goldens bless with reason citing #8165/RIPR-SPEC-0122. Windows-only ts_repair_packet quoting drift intentionally not blessed.

Copy link
Copy Markdown
Member Author

Claiming this PR for review and merge convergence (newest-first backlog lane). Backlog-oldest-first thread: please skip #8318.


Generated by Claude Code

Block scope, pattern binders (if let/while let/for/match arm/closure) and a
non-call initializer no longer carry owner-result credit to a snapshot.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJQ3eTmHZCPmLwyb77Hexw

Copy link
Copy Markdown
Member Author

Independent Sonnet review of 6d28edd found three real false-positive gaps in snapshot_owner_binding.rs; fixed in f7a327d:

  1. Block scope: bindings now carry their brace depth and are dropped when the block closes, so an inner-block let count = make_count(..) can't credit a snapshot of an outer literal.
  2. Pattern binders (if let, while let, for, match arms, closure params) that name the local withdraw credit.
  3. The initializer must be the owner call itself (optionally ? / .unwrap()); make_count(2).to_string(), unrelated(make_count(2)), comparisons no longer count. Spec wording updated.

Added 3 negative integration tests (inner block, if let shadow, transformed call) plus unit tests; I confirmed the 3 integration negatives FAIL on the old code and pass now. cargo test -p ripr --test snapshot_return_admission 9/9, --lib snapshot_owner_binding pass, cargo xtask precommit exit 0 at f7a327d. A fresh re-review of the new head is running before merge.


Generated by Claude Code

…aw owner credit (#8121)

Also aligns the cli_smoke preview triage State oracle with the compact
bounded renderer from #8275 (red on main).

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XJQ3eTmHZCPmLwyb77Hexw

Copy link
Copy Markdown
Member Author

Second independent re-review of f7a327d found no panics but three more false-positive paths: } else if let shadow, binder in a later match arm, and several statements on one line. Fixed in 4ed885d (strip leading } before header checks; check every arm; evaluate each ;-separated piece) with three more negative integration tests, all confirmed failing on the previous head and passing now.

Local proof at 4ed885d: cargo test -p ripr --test snapshot_return_admission 12/12, --lib snapshot_owner_binding pass, cargo xtask precommit exit 0. The same reviewer confirmed spec RIPR-SPEC-0005 wording matches the code. Marking Ready + merge-ready.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 05:12
@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!

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 05:34
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 05:34
@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!

@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 reviewer attention before upstream: findings remain.

Confirmed findings

  • No test exercises a snapshot whose oracle text uses whitespace/newline between let binding and snapshot (e.g. let count\n =\n make_count(2);); initializer_is_owner_call tolerates whitespace via trim_start but a multi-line initializer may not be matched.

Verification questions

  • Confirm unit tests in snapshot_owner_binding.rs cover assignment_target, initializer_is_owner_call, and pattern binder classification but do NOT exercise name_is_direct_owner_result scope/brace tracking end-to-end.
  • Confirm macro/closure rebind paths (vec![make_count(2)], closure-captured re-bind) lack a negative integration test; the text-based binder detector relies on over-matching withdrawing credit but is not exercised on these shapes.
  • Confirm boolean short-circuit RHS like let count = make_count(2) \|\| other; is not covered by a negative test; initializer_is_owner_call will match the first owner_name occurrence but \|\| short-circuit means count carries other's value at runtime.
  • Confirm integration tests do not exercise several remaining owner-Result paths the spec calls out: helper-derivation under-credits (acknowledged non-goal), macro-internal owner rebinds (vec![make_count(2)]), short-circuit RHS like make_count(2) \|\| other, and closure-captured re-bind in a later block.

Refuted

  • A rebound by macro or closure that re-binds count to a fresh owner call later in the test would over-credit an unrelated snapshot.; refuted because: name_is_direct_owner_result walks top-level statements up to oracle_line; a macro/closure owner call invoked later than the assertion does not change the binding at the assertion site, so the gate still rejects an unrelated snapshot. Even if a future refactor broadens call detection, the fail-closed direction means the worst case is under-credit, never over-credit.

Parked follow-ups

  • Reused prior reviewer concern (graphite-app comment on snapshot_return_admission.rs:131): macro-internal owner call rebinds escape linear name binding and are not yet covered by a negative control test. Acceptable as a parked trace-bundle gap since direction is fail-closed.
  • Trace-bundle rebind via macro/closure that re-binds count to a fresh owner call across a function/macro boundary is not directly asserted; gate is fail-closed so impact is under-credit, not over-credit. Parked follow-up rather than a finding.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven

Copy link
Copy Markdown
Member Author

Diagnostic Status Update: PR #8318

Copy link
Copy Markdown
Member Author

Failing check: Ripr Rust Small Result, from the Golden output contracts step of run 39006774982 on head 9c8e37d. All other gates (fmt, precommit, honesty, clippy, nextest, doctests) passed.

Not this PR's: I reproduced cargo xtask goldens check locally. The drift is the same 8 fixtures' human.txt Summary line (probe(s), ... weakly_exposed vs probes (... weak ...)), from the plain-language verdict in #8165. This PR changes repo-mode return-seam grading and moves none of them. It is the blocker the owner already diagnosed, which #8351 fixes and which is not yet on main.

Action: I merged #8351's branch (fix/8165-missed-golden-blessings, 0e25ff5) into this branch as e9fb0af, a clean merge with no conflicts. Once #8351 reaches main this merge becomes a no-op in the squash diff. After the merge, local goldens check shows none of the 8 drifts. The one remaining local error is an offline fetch of anyhow 1.0.100 for owner_return_pin_fallible_literal, an environment gap that does not occur in CI. Hosted re-run on e9fb0af is the proof; I have not re-run it myself.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 06:50
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 06:50
@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!

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 07:10
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 07:11

Copy link
Copy Markdown
Member Author

Failing check: Ripr Rust Small Result on head 703099a, run 39011407852. Not a code failure: the gate summary shows formatting, precommit, honesty, agent_skills, dependencies, process/network policy, workspace and all-features checks and clippy all success; rust-tests is cancelled and goldens, fixtures, verdict_corpus and pr_evidence are skipped as a consequence. The Rust gates job ended cancelled at 07:12:41, right after the draft/ready toggle at 07:10:56 / 07:11:22, so the run was superseded.

A fresh run for the same head (39012701950) started at 07:12:49, and its route job already passed. No code change or empty commit is needed; I will read the new run's result. The earlier goldens failure (the #8165 wording drift) is fixed on main by #8351 and is included in this head.


Generated by Claude Code

@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 reviewer attention before upstream: findings remain.

Confirmed findings

  • Scope tracking in name_is_direct_owner_result walks test.body.lines() with brace counting but ignores Rust string/char literal scoping across lines; a multi-line string literal containing } will desync depth. No real-world test triggers this in the integration suite, but a maliciously crafted fixture could.
  • assignment_target does not exclude <<= / >>= properly. The current rule says <= / >= compare, <<= / >>= assign. But for at pointing at the second =, is_comparison_angle looks at bytes[at-1] which is =, not </>, so the second = of <<= falls into the not matches!(bytes[at+1], Some(b'=')\|Some(b'>')) branch and bytes.get(at-1) == Some(b'<') branch — let-checked. Actually fine. Real issue: assignment_target accepts any place whose = is preceded by +, -, etc. trimmed. let _ = count += 1; parses fine. But the assertion bytes[at] == b'=' followed by checking at-1 for =/! excludes ==/!= correctly. Leave alone. Use this slot for the wrapped-initializer gap instead. (crates/ripr/src/analysis/test_grip_evidence/snapshot_owner_binding.rs:230).

Verification questions

  • Confirm snapshot_observes_owner_result fast-path accepts any in-string owner_call text and any free identifier, then defers binding decisions to name_is_direct_owner_result; sibling free_identifiers excludes field paths, qualifiers, callees, macros so vec![make_count(2)].x and Self::make_count do not over-match.
  • Confirm multi-line initializer let count =\n make_count(2); is rejected: split_once('=') splits on first '=' but the statement accumulator concatenates lines with spaces, so the trailing space preserves the call. However no integration test exercises this shape.
  • Confirm macro escape let count = vec![make_count(2)][0]; or let count = (\|\| make_count(2))(); is treated as owner result because the call text appears and the initializer starts with a bracketed expression whose top-level call follows; current initializer_is_owner_call will accept vec![make_count(2)] only if first identifier is the owner, otherwise reject. Need explicit negative test.
  • Confirm free identifier extraction drops callee/macro forms but treats assert!(count) inside the oracle text as a free identifier count, which then triggers scope tracking. If the snapshot line is past the let, this works; but a snapshot that contains assert!(count) inline before the let binding still extracts count and may mis-bind when owner_name shadows.

Refuted

  • snapshot_owner_binding is wired in for SeamKind::FieldConstruction or for non-Snapshot oracles, regressing unrelated admission.; refuted because: test_grip_evidence.rs:2120-2126 gates with seam.kind()==ReturnValue and OracleKind::Snapshot; field seam admission path passes through unchanged because it is a separate call site.

Evidence gaps

  • Author and re-reviewer report three iterative false-positive repairs (block-scope depth, pattern binders, statement split) plus three more (else-if-let, later arm, same-line rebind) on this PR; integration coverage and precommit proof at 4ed885d / e9fb0af, but the lane cannot verify these locally (build/clippy/test heavy gates skipped, ripr sensor failed exit-2).
  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 17, 2026 11:03
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 17, 2026 11:03
@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!

Copy link
Copy Markdown
Member Author

Failing check: Ripr Rust Small on GitHub Hosted / Rust gates / Ripr Rust Small Result on head 703099a (run 39012701950, 07:35). Not this PR's. The gate summary shows rust-tests success; only goldens failed, with human.txt drift in about a dozen fixtures (for example propagate_swallowed_ok, rust_map_insert_count_empty, owner_return_pin_test_module_shadow) where the golden expects an empty line and the output now adds Write a test for it: or No test stub here: .... That is the all-families stub route line from #8412 on main, which this PR does not touch (the PR diff is the six snapshot-binding files).

Fix already exists and is included: main carries the re-bless as d91a25d (bless 35 human goldens for the all-families stub route line), and the current head a720d2f contains it. A fresh run is in progress on a720d2f; I will read its result. No code change or empty commit from me.


Generated by Claude Code

@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 reviewer attention before upstream: findings remain.

Confirmed findings

  • Static string/comment stripping in strip_oracle_text and strip_comments_and_strings is line-based; a multi-line string literal containing a } could desync brace counting in name_is_direct_owner_result. Over-match withdraws credit, so the worst case is under-credit, which matches the spec.

Parked follow-ups

  • Prior reviewer concerns about vec![make_count(2)] macro escape, closure-captured rebind, multi-line let initializer, and multi-line string desync were not directly covered by tests added in this head.

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