Repository navigation
fix(rust): field-write stub refusal and borrowed-receiver-only confirmation (#12061) - #12157
Conversation
…mation (#12061) Re-cut of the two pieces of #11642 that #11813 did not land: the field_written_in_method stub refusal with its hand-written step, and the rule that only a borrowed receiver's field write is confirmed by a read of the caller's binding (owner_borrows_receiver). Positive and discriminating negative pins added to field_write_seam. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
|
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 reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 21 minutes. View limit details
|
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
EffortlessSteven
left a comment
There was a problem hiding this comment.
REPAIR_REQUIRED — head 29894c5 (pre cache bump)
Scope: full diff read; I built the head and ran cargo test -p ripr --test field_write_seam (12 of 12 pass, including the three new pins) and ran ripr check on a by-value builder repo. I did not run the lib tests (OOM on this host) or turn the receiver guard off myself; the negative experiment is taken from the PR body.
What holds
owner_borrows_receiverfails closed: no readable signature, a typed non-referenceself(Box<Self>,Self), aPin<&mut Self>, aFn(..)generic that moves the first(, or&mut\nselfall read as "not borrowed", which only removes credit. The test table covers by-value, typed and lookalike (selfish) cases.- The guard sits inside
assigned_field_read_confirms, the one rule both the diff probe and the repository seam ask, so check and repair stay in agreement. The refusal is keyed on the assignment shape only: the same-impl struct-literal field still gets its stub (tested). - Observed on a
Copybuilder with one test reading the unmoved binding and one reading the chain's result: the check reports1 unclear, no repair start, and "No test stub here: the change sets a field ofselfinside a method instead of building a value the method returns, so the stub cannot tell which value to assert on". The wording is plain by the #12123 standard (stubis existing vocabulary; "unclear" is in the summary glossary). - Cost to know: a by-value receiver whose test reads the returned value (a real check) now also reads unclear, since ripr cannot yet confirm it through the chain. The spec says so ("stays unjudged"). That is a recall loss against the current behaviour, which I did not measure on main; it is the fail-closed side.
R1 (blocking, small): the guidance tells builder users to assert on the wrong value. SPEC-0228 now promises "(for a builder, on the value the chain returns)". The code does not say that anywhere:
triage.rs: "assert the exact value of the changed field on the value you called it on" (the by-value caveat follows, but only about ripr's confirmation).lsp/hover.rs: "assert the exact value of the changed field on the value it was called on."agent_seam_packets.rsmissing_oracle_shape: "exact assertion on the changed field of the value the method was called on".
For amut selfbuilder, "the value it was called on" is the moved or copied receiver; the PR's own copy-builder pin establishes that asserting there confirms nothing. A user (or agent) who follows all three writes a test that passes with the change reverted.is_field_write_seamdoes not look at the receiver kind. Fix: reuseowner_borrows_receiverto pick wording ("on the value it returns" for a by-value receiver, "on the value you called it on" for a borrow) in all three, or at least make the spec and the strings say the same thing. Add a test per surface for the by-value wording.
Non-blocking
- The new refusal reason, hover and packet strings are not gated per receiver kind in the stub itself: a
&mut selfsetter and amut selfbuilder both getfield_written_in_methodwith the same reason. That is fine for a refusal, but the reason could name which case it is. - Cache bump is pending as planned; classification changes here, so it needs the next free value at merge and a delta review.
Not established: Ripr Rust Small Result at this head.
Generated by Claude Code
Review R1 on #12157: for a by-value (mut self) builder the guidance said to assert on the value the method was called on, which is a moved copy and confirms nothing. The seam now records whether the owner borrows its receiver; the hover, the packet's missing_oracle_shape and the human step say 'the value the call returns' for a by-value receiver and 'the value it was called on' for a borrow, and the stub refusal splits into field_written_in_method and field_written_by_value. Also reads a multiline '&mut\n self' receiver, and adds an honesty-corpus case for the Copy builder. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
…eses (#12061) Graphite on #12157: owner_borrows_receiver took the first '(' after 'fn ' as the parameter list, so 'fn apply<F: Fn(u32) -> u32>(&mut self, ..)' read as not borrowed. That dropped credit and, now that the seam records the mode, worded the read as the call's result. The reader skips the generic list, and the recorded fact is tri-state: an unreadable signature or a typed receiver records nothing and words the read neutrally. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY — head 7093802
Delta review of the repair to my REPAIR_REQUIRED on 29894c5.
Receiver wording. Every surface (LSP hover seam_next_step_for, agent packet missing_oracle_shape_for, human hand_written_test_step) takes its wording from the single field_write_read(seam) mapping. By-value says "the value the call returns", borrowed says "the value it was called on", and an unrecorded fact names neither value. Each surface has a unit test for all three modes. A grep found no leftover old wording.
Stub refusal. field_written_in_method (receiver Ref/RefMut) and field_written_by_value (anything else) are chosen from the parsed signature.receiver, not the seam fact, and each has a test.
Multiline receiver parse. owner_borrows_receiver reads the first parameter of the first fn, accepts &, an optional lifetime, mut and whitespace (including newlines) before self, or self: &…, and otherwise returns false. The unit test covers &mut\n self, & mut self, &'a mut self, self: &mut Self, and negatives mut self, self, self: Box<Self>, &mutself, selfish and no signature. It could not be made to read a non-receiver as a borrow. A Fn(..) bound in generics before the parameter list shifts the first (, which yields false. That fails closed (no promotion), so I do not treat it as blocking.
Copy-builder honesty case. fixtures/rust_copy_builder_field_write uses a Copy type with retries(mut self, n) and a test that asserts the caller's unmoved binding. The golden is static_unknown, with no exposed and the by-value wording. The corpus entry asserts must_not_promote, maximum_class: weakly_exposed and one finding. The positive partner is pinned in field_write_seam.
Run on this head. Filtered lib tests (15 passed) and --test field_write_seam (13 passed). Whole-workspace lib tests do not fit in my sandbox, and I did not run the honesty gate or fixtures here.
Remaining before merge. The cache bump (three constants), the exact-head Ripr Rust Small Result, and the usual changelog and spec checks.
Generated by Claude Code
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
…d writes (#12061) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY — head d41ad4e
Delta review against my REVIEW_READY at 7093802. Three source changes (954acee, 9350fe7, d41ad4e) plus main merges. I limited the diff to this PR's own files against the merge base with main.
1. Generics-aware receiver reader (954acee). owner_receiver_borrow now returns Option<bool>: Some(true) for a reference receiver, Some(false) for plain self / mut self, None when unreadable, typed (Box<Self>), or no receiver. owner_borrows_receiver is == Some(true), so every promotion path is unchanged from the version I approved and still fails closed. It finds the first ( at generic depth 0, tracking </> and ignoring > when the previous character is -.
- Where clauses come after the parameter list and are never reached.
- Nested generics (
Into<Vec<(u32, u32)>>) are handled because parentheses at depth above 0 are skipped, and>>closes two levels. ->inside a bound (F: Fn(u32) -> u32) does not close the list.- An unterminated list returns
None. A comma inside a typed receiver (self: Arc<Mutex<(u32, u32)>>) truncates the first parameter to a non-reference form (None), andself: &Foo<(A, B)>truncates to a reference, which is the right answer for both. - The new tests pin those shapes, and the by-value-with-generic-bound case (
retries<F: Fn(u32)>(mut self, f: F)) readsSome(false), so guidance names the returned value for it. - I did not run these unit tests; the lib-test build is OOM-killed on this host, so the exact-head hosted result applies. I read the code and tests against the edge cases above.
- Residual, non-blocking: the reader still takes the first
fnin the body text, as before.
2. Dead re-export dropped (9350fe7). The unused owner_borrows_receiver re-export in analysis/classify/mod.rs is gone. The function is still used inside activation.rs.
3. Cache bump (d41ad4e). CACHE_SCHEMA_VERSION 1.131 to 1.132, and the sharded and compact classified-seam versions 0.135 to 0.136, one above main (main is 1.131 / 0.135). The unit pin test, the two CURRENT_CORPUS_CACHE_SCHEMA_VERSION constants (lsp gap-corpus currentness and rust_corpus_projection), the docs/OUTPUT_SCHEMA.md examples and the committed repo-exposure fixtures all moved together. I grepped the head for stray 1.131 / 0.135 values and found only history comments.
Collision to watch. Open #12211 also bumps CACHE_SCHEMA_VERSION to 1.132 (no classified-seam constants). Whichever of the two merges second must rebase to 1.133 / 0.137 and move the same pins.
Generated by Claude Code
…tion pinned hashes (#12061) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY — head 50296f4
Delta review against d41ad4e. The delta is only 4 files under fixtures/boundary_gap/expected/first-useful-action/unchanged-after-attempt/ (before.repo-exposure.json, after.repo-exposure.json, agent-receipt.json, agent-verify.json), 7 lines added and 7 removed.
Hash fields only. All 7 changed line pairs are identical after replacing hex digests with a placeholder; no non-hash text differs. The changed fields are content_sha256 and sha256 in the two repo-exposure snapshots, before_content_sha256 and after_content_sha256 in the receipt, and the matching sha256 entries in agent-verify.json. The refreshed snapshot hash is consistent across the files: sha256:00a5295e… appears as content_sha256 in both snapshots and as before_content_sha256 and after_content_sha256 in the receipt, so the chain agrees. This is the same refresh pattern as #12120 for 1.131 and follows from the 1.132 cache bump. I did not regenerate the fixture here.
Generated by Claude Code
…ld-write step (#12061) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3
EffortlessSteven
left a comment
There was a problem hiding this comment.
REVIEW_READY — head 37e929c
Delta review of record against 50296f4. The delta is one file, crates/ripr/src/output/human/triage.rs: the borrowed-receiver (FieldWrittenInMethod) human step loses its trailing by-value sentence ("If the method takes self by value (a builder), ripr cannot yet confirm that check…"), and the existing assertion gains !written.contains("by value"). The removal is correct: that step is reached only for a borrowed receiver, where the sentence was wrong, and the by-value case has its own arm directly above that sends the reader to the call's result.
Stale-wording sweep on this head (git grep over the whole tree):
- No golden, fixture, schema, or check-user-text input contains the removed text: zero hits for "cannot yet confirm that check", "will still report this change as unclear", and "takes
selfby value" outside code comments. - The remaining shared prefix "assert the exact value of the changed field on the value you called it on" appears only in
triage.rsand two assertions intests/field_write_seam.rs(lines 263 and 282). Both arecontainschecks on the shared prefix, so truncating the tail cannot break them: line 282 still matches, and line 263 (the by-value negative) is unaffected. - The one other "ripr cannot yet confirm" hit is prose in RIPR-SPEC-0228 describing the unjudged by-value write; it documents behaviour, not the step text, and stays accurate.
I could not build lib tests locally (OOM here), so this rests on the source read and the grep, not on a run. The new !contains("by value") assertion is satisfied by inspection of the single remaining string. The hosted Ripr Rust Small Result is not green on this head as of my read; merge needs it green on the exact head first.
Disposition: no blocking findings.
Generated by Claude Code
Governing issue or accepted claim: #12061
Acceptance delta (one sentence): A field write in a method refuses the test stub with
field_written_in_method(orfield_written_by_valuefor a by-value receiver) and a plain hand-written step, and a by-value receiver's field write is no longer credited by a read of the caller's unmoved binding.Re-cut of the two pieces of closed #11642 (head a7006d0) that #11813 did not land, onto current main.
Summary
analysis/test_stub.rs,output/human/triage.rs: newTestStubRefusal::FieldWrittenInMethod(field_written_in_method,&self/&mut selfreceivers) andFieldWrittenByValue(field_written_by_value, anything else) for aFieldConstructionseam that is a field assignment, each with a hand-written step naming the right value.analysis/classify/activation.rs:assigned_field_read_confirmsrequiresowner_borrows_receiver. A generics-aware, tri-stateowner_receiver_borrowreads the signature, so a by-value receiver (mut self, a builder) stays unjudged on the diff and repository sides and an unreadable signature fails closed.RepoSeam.owner_borrows_receiverrecords the receiver mode so LSP hover, agent packetmissing_oracle_shapeand the human step choose wording per mode (field_write_read).rust_copy_builder_field_write_unmoved_readplus fixturerust_copy_builder_field_write.1.132/0.136(sharded and compact) with pinned tests, docs and fixtures.changelog.d/12061-...mdupdated.Claim boundary
Proof
true,copy_builder_read_of_the_unmoved_binding_is_not_a_checkfails.cargo xtask precommitexit 0 on d41ad4e.🤖 Generated with Claude Code
https://claude.ai/code/session_01SvmPmquJYbS63HJWP8gjc3