Skip to content

fix(stub): compile &mut dyn/slice/str params; name equal inputs for relational boundaries - #8371

Merged
EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-pcwi4e
Oct 17, 2026
Merged

EffortlessSteven merged 3 commits into
mainfrom
claude/project-thread-pcwi4e

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Requested by Steven · project thread

Before: ripr agent stub wrote an uncompilable test for a &mut dyn Trait, &mut [T] or &mut str parameter (let mut sink: dyn Sink = todo!(), E0277). For a relational boundary over operands it cannot fill (self.tokens > n), the fill-in said "choose n so that self.tokens > n", inputs that pass under >= too.

After: unsized &mut targets bind a std::boxed::Box<dyn Trait>, std::vec::Vec<T> or std::string::String stand-in passed as &mut; relational boundaries ask for equal operands (self.tokens == n), the only inputs that separate the operator from its neighbor.

How: owned_mut_binding and relational_boundary in analysis/test_stub.rs. std:: paths so a crate-local Vec (shadowed in the existing fixture) cannot capture them.

Found by running check + agent stub --write over 34 authored demo crates; full findings in #8361 (16 stubs offered, all but this one compiled; 3 false exposed value cases and silent no-route families are filed there, not fixed here).

Verification (local): cargo xtask precommit pass; cargo test -p ripr --lib test_stub 43 pass; cargo test -p ripr --test agent_stub_compiles written_stubs_compile pass with three new &mut shapes (dyn, slice, str). Not run: full workspace tests, hosted CI.


Generated by Claude Code

…elational boundaries (#8361)

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Qnwj3dw38czgKaHAJtoEi2
@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 self-assigned this Oct 17, 2026
Comment thread crates/ripr/src/analysis/test_stub.rs Resolved

Copy link
Copy Markdown
Member Author

Local verification on head 35309b2: cargo xtask precommit pass; cargo test -p ripr --lib test_stub 43 pass; cargo test -p ripr --test agent_stub_compiles written_stubs_compile pass (new dyn/slice/str shapes compile and stop at their todo!()).

Independent review (fresh Sonnet subagent on the exact head, since Gemini is out of quota) found two real gaps, both fixed in 35309b2 with unit assertions: &mut [[u8; 4]] was misread as an array, and &mut (dyn A + B) was not unsized-handled. It also found no stale golden/doc text for the changed fill-in wording. Graphite's inline comment on the ; filter is the same first gap, fixed.

Not verified: full workspace tests and hosted CI.


Generated by Claude Code

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

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 61 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: 3358ebf2-c292-4e09-b2ba-143d258bd81e
📥 Commits

Reviewing files that changed from the base of the PR and between 51acaab and 8dcc512.

📒 Files selected for processing: 20
  • changelog.d/8361-stub-unsized-mut-and-boundary-hint.md
  • crates/ripr/src/analysis/test_stub.rs
  • crates/ripr/src/analysis/test_stub/tests.rs
  • crates/ripr/tests/agent_stub_compiles.rs
  • fixtures/one_hop_field_projection/expected/CHANGELOG.md
  • fixtures/one_hop_field_projection/expected/human.txt
  • fixtures/one_hop_field_projection_discarded/expected/CHANGELOG.md
  • fixtures/one_hop_field_projection_discarded/expected/human.txt
  • fixtures/one_hop_field_projection_sibling/expected/CHANGELOG.md
  • fixtures/one_hop_field_projection_sibling/expected/human.txt
  • fixtures/one_hop_field_projection_wrong_sink/expected/CHANGELOG.md
  • fixtures/one_hop_field_projection_wrong_sink/expected/human.txt
  • fixtures/rust_map_insert_count_empty/expected/CHANGELOG.md
  • fixtures/rust_map_insert_count_empty/expected/human.txt
  • fixtures/rust_map_overwrite_count/expected/CHANGELOG.md
  • fixtures/rust_map_overwrite_count/expected/human.txt
  • fixtures/seeded_push_after_early_return/expected/CHANGELOG.md
  • fixtures/seeded_push_after_early_return/expected/human.txt
  • fixtures/typescript_mock_payload_iife_impl/expected/CHANGELOG.md
  • fixtures/typescript_mock_payload_iife_impl/expected/human.txt
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

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

Confirmed findings

  • PR body says written_stubs_compile passes but the function name in the diff is written_stubs_compile_and_stop_at_their_own_todo. Either rename the body claim or split the test; not blocking, but worth clarifying for the human reviewer.

Verification questions

  • Confirm crates/ripr/src/analysis/test_stub.rs:1086 — owned_mut_binding only recognizes object types parenthesized as (dyn T) / (dyn T + Bound). A reference-form object type that the parser emits without parentheses (e.g. dyn T already handled, anything wrapped in additional whitespace or a single-trait bound written as dyn T: Bound if such a shape ever appears) routes correctly today, but the lane did not enumerate every shape upstream of strip_mut_reference. Suggest a guarded unit case for any object type the upstream parser currently emits to confirm the parenthesized branch is the only required strip.
  • Confirm new &mut str row in written_stubs_compile covers compile, but the unit test only exercises a direct String binding; crate-local aliasing and field-of-struct (self.name: String) routes are not unit-tested. Container-shadowing is mitigated by std:: paths, yet a crate::utils::Box shadow would still capture the Box path on import.
  • Confirm relational_boundary only fires for </<=/>/>= and only on PredicateBoundary seams, leaving ==/!=/equality seams with their existing description text.
  • Confirm integration test added three expectations (n>12 dyn, n>13 slice, n>14 str) under written_stubs_compile_and_stop_at_their_own_todo; written_stubs_compile is a sibling function name referenced in PR body but the diff only adds expectations, no fresh compile assertion target.
  • Confirm relational-boundary probe gates on SeamKind::PredicateBoundary and a single comparison op in {<,<=,>,>=}, so non-relational boundaries (==, !=, ErrorVariant, MatchArmTaken, ReturnValue, DiscriminatorTaken) fall to the prior one_line(description) path. No new wording overrides unrelated seams.

Refuted

  • let mut sink: Box<dyn Sink> = todo!(); would leave &mut *sink pointing at uninitialized memory in the compiled stub, causing a lifetime-sanitizer trip even before the callee panics.; refuted because: The stub is hand-written text; todo!() is the only executed path on the callee side. The owned local is never read again after the &mut *sink argument, so the reborrow ends at the statement. Box<T>::from allocation failure is not a path here (no Box::from(slice) / Box::<[T]>::from(vec) is generated), and a panic from todo!() drops sink cleanly. The unit test asserts the exact Box<dyn Sink + Send> shape produced for (dyn Sink + Send).
  • When the relational operand compares a field to a parameter of the same type (e.g. self.tokens > n for u32), asking for self.tokens == n is the equal-input condition, but for n > n-style predicates the discriminating inputs collapse to n == n, a tautology. The new test only covers the field-vs-param case where there is genuine separation; single-binding predicates would emit n == n and a human must still pick a sentinel.
  • relational_boundary's single_comparison call may fail on seams whose expression text is not a single bare comparison (e.g., already parenthesized, has chained &&/||, or has been pre-normalized), silently reverting to the old wrong wording.; refuted because: SeamKind::PredicateBoundary is a precondition ripr controls upstream; the existing seam_at helper used in the new test sets the exact self.tokens > n shape. Without traversing the PredicateBoundary emitter, this lane cannot disprove a stale-shape seam in practice; rejected as out of bounded coverage, retained as residual risk.
  • &mut *sink reborrow through Box could alias the active Box inner and risk an unsized-active-view aliasing UB when sink.put is invoked past todo!(); refuted because: The reborrow is taken on a freshly todo!()-constructed Box; no prior borrow of *sink exists, so exclusive &mut is sound for the duration of the test scope, and the assertion that the stub stops at todo!() confirms no live alias.
  • Box::from(Vec) / Box::<[u8]>::from(Vec) on a freshly-constructed stub local could OOM and panic, and that panic crosses a worker-handoff boundary in any JS host using ripr as a library.; refuted because: Diff is a synchronous text generator; no Vec->Box coercion happens here, host runtime is out of lane scope, and the calibration rule treats allocation-failure in this shape as a refuted false-premise unless the PR raises it.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

…een here

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

Copy link
Copy Markdown
Member Author

Ripr Rust Small failed only on goldens: 8 fixture human.txt files still carry the pre-#8275 summary wording, which is red on main too and unrelated to this diff. Fix exists in #8351 (open); I ported its 16 fixture files into this branch (a6-commit after 35309b2) so the check is green here whether or not #8351 lands first. Local goldens check cannot run offline (fixture dependency prepare needs network), so CI is the proof.

Re the Actions review: the written_stubs_compile name in the PR body is shorthand for the filtered written_stubs_compile_and_stop_at_their_own_todo run, and crate::utils::Box shadowing is covered by the std::boxed::Box spelling. The README-style questions about relational_boundary gating are answered by its first two lines (PredicateBoundary only, </<=/>/>= only).


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.

Confirmed findings

  • human.txt:32 weakly_exposed -> weak relabel is mechanical across 8 fixtures and the typed complete_with_findings -> complete plus parenthetical propagation_unknown -> unknown drops are uniform. No test asserts the parser still understands Severity::Weak or State::Limited after the label change; the golden itself is the oracle. Acceptable; flag as low advisory.
  • crates/ripr/tests/agent_stub_compiles.rs:293 — n > 14 (&mut str) compares non-discriminatorily against n > 12/n > 13: each only asserts Expect::StopsAtRiprTodo (compile + own-todo). Strictly speaking a stub of if n > 14 { n } else { name.len() } is no harder to compile than one of if n > 13 { n } else { buf.len() }, so the trio is slightly cardinality-of-shapes rather than three orthogonal checks. Acceptable as shape coverage; flag only as low so reviewer can decide if discriminating oracle-row cases belong here.
  • The helper is_array_length_suffix only tracks [ ( < ] ) > depth and tracks an initial prev variable that is never read; it still produces the right answer, but an unstated invariant (that braces/brackets and lifetime 'a may appear in element types) deserves a one-line comment so future maintainers don't extend it incorrectly.

Verification questions

  • Confirm let mut sink: dyn Sink = todo!(); was the prior E0277 failure mode. The new written_stubs_compile_and_stop_at_their_own_todo row at n>12 asserts only that the stub text compiles AND stops at its own todo!(). Coverage is fine if &mut dyn Sink and &mut (dyn Sink + Send) produce identical text modulo Box<dyn Sink + Send>; suggest a unit assertion in unsized_mut_reference_parameters_bind_an_owned_stand_in for the parenthesized-with-bound variant executed through the seam-style path, not only the helper directly, and a separate compile row for a &mut (dyn Sink + Send) parameter so (dyn Sink + Send) -> Box<dyn Sink + Send> is proven end-to-end via the stub pipeline. (crates/ripr/tests/agent_stub_compiles.rs:105).
  • Confirm std-paths are necessary given fixture-local Vec shadowing (per PR body and comment), and the changelog note mentions this; boundaries like dyn T (&mut *binding) and str / [T] (&mut binding) follow the type's actual reborrow shape rather than blindly &muting the inner.
  • Confirm proof gap: only one field-boundary PredicateBoundary seam is unit-tested; relational_boundary() has branches by operator (<,<=,>,>=) and path through discriminator_hint that are not unit-asserted.
  • Confirm no test exercises a crate that shadows Box / Vec / String (e.g. mod std { pub struct Box; ... }); the PR claims the std:: paths defeat shadowing but only the inference path itself was given unit coverage, not a downstream write→compile witness.

Refuted

  • Fixed-size array &mut [u8; 4] falls through to (inner.to_string(), format!("&mut {binding}")), producing let mut buf: [u8; 4] = todo!(); — sized, sound. The only failing case would be a hypothetical Box<[u8; 4]> argument, which the upstream parser does not emit as &mut <inner> text.; refuted because: Arrays are sized; a bare let mut x: [u8; 4] = todo!(); is well-formed. The Box<[T;N]> shape is not in scope here and would be a separate parser-shape issue, not a memory-lifetime bug.
  • Box<dyn Sink> regression could sneak in unnoticed if owned_mut_binding falls back to the old let mut sink: dyn Sink (E0277) and the integration test's cargo check would fail loud; refuted because: Cargo check failure would indeed fail loud, BUT the integration test uses Expect::StopsAtRiprTodo which is satisfied by a stub that compiles for ANY reason — including refusing early (which the harness also routes to StopsAtRiprTodo in some rows) or by an unused-mut no-op. The lane cannot certify red/green without a positive substring assertion.
  • Diff could leak &mut *sink reborrow across a worker boundary (raw pointer to Box); refuted because: Box stays on the calling stack of the freshly-generated #[test] fn; &mut *x is a place expression that deref-coerces to &mut dyn Sink with lifetime bounded to the test. No Send/Sync, no thread spawn, no worker detach in generated code.
  • is_array_length_suffix depth counter increments on < but does not handle Rust generic arguments that legitimately contain ; (e.g. *const [T; N] type-level assertions). At type-print depth 0 a ; would still classify as array. Inputs reaching owned_mut_binding are already stripped of &mut and lifetimes, so such exotic shapes are not exercised.; refuted because: Helper is only called from the [..]-stripped branch; depth counter balances [/] correctly and (/) handle parenthesized generics. The unit test asserts [[u8; 4]] is Vec<[u8; 4]> (slice), [u8; 4] is itself (array), confirming the discriminator. False premise at the integration boundary.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven merged commit a198b72 into main Oct 17, 2026
26 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-pcwi4e branch October 17, 2026 06:49
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