Repository navigation
fix(analysis): a selector swap on a trailing-? line is not a changed error arm (#9866) - #9950
Conversation
…error arm (#9866) A one-line selector swap (min_by_key to max_by_key, first to last) beside an unchanged trailing ? read as error_path with 'execute the changed error arm' guidance. The ? only propagates the empty case. The lexical fallback now compares the changed line with the line it replaced and abstains as static_unknown when the edit is a selector-name swap and the line carries no explicit error marker. Added ?, changed error variants and every other edit keep error_path. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
|
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 34 minutes. View limit details
Comment |
There was a problem hiding this comment.
Code Review
This pull request addresses issue #9866 by introducing a mechanism to prevent one-line selector swaps (such as min_by_key to max_by_key, first to last, or next to next_back) on lines ending with the ? operator from being incorrectly classified as error_path gaps. The changes add classify_changed_line_against in crates/ripr/src/analysis/probes/lexical.rs to compare the new line against the removed counterpart, ensuring that if only a selector method name is swapped, the line abstains as static_unknown rather than indicating a changed error arm. Comprehensive unit tests and integration fixtures have been added to verify this behavior and ensure that real changed error variants still correctly retain their error_path classification. There are no review comments, and I have no feedback to provide.
…text (#9866) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
There was a problem hiding this comment.
Confirmed findings
- SELECTOR_NAMES allow-list in lexical.rs:213 covers 12 names; any new selector method pair (e.g. sort_by_key, kth) bypasses the #9866 abstention and a future line with a ? + such a swap will re-trigger the legacy error_path false positive. PR body acknowledges this as residual; consider documenting the maintainer-facing list in SPEC or a TODO comment near the const so the next similar issue has a precedent to extend.
- is_selector_swap accepts unrelated recognized methods, including empty-producing direction changes such as first()→next(), and withholds ErrorPath despite changing error behavior.
Verification questions
- Confirm the motivating fixture does not assert the selected element when multiple queue entries have distinguishable priorities or names.
- Confirm the error-arm positive control changes Error::Empty to Error::Closed, so it controls explicit-error classification but does not test a selector swap combined with an explicit error variant.
- Confirm the existing negative controls cover non-selector methods, extra tokens, and explicit errors, but not semantically incompatible selector pairs.
Refuted
- Malformed or adversarial input could cause unsafe behavior or resource exhaustion in the new lexical heuristic.; refuted because: The change operates on bounded Rust source text with standard string/comment masking and linear scans; it introduces no unsafe code, allocation of unbounded size, external I/O, secret handling, or privilege boundary.
- Whole-identifier matching is sufficient to prevent false swaps.; refuted because: Widening to whole identifiers rejects minimum/xmax substrings and requires method-call syntax, but it does not establish that two different recognized methods have equivalent error semantics; first→next is the concrete counterexample.
- The changed Rust code may contain an active-view/ArrayBuffer stale-length UB surface.; refuted because: No JavaScript runtime, native buffer, typed-array resize/detach/transfer, or backing-store length arithmetic appears in the changed route; the relevant values are owned Rust strings and enum families.
- The changed code introduces a worker-handoff, async capture, GC, detach, or ownership-transfer boundary that could create UB.; refuted because: The changed source operates on borrowed text slices and owned strings/chars during synchronous lexical classification; no JavaScript runtime or worker/async/transfer API is present in the changed Rust paths or fixtures.
- The error-arm positive control already proves a selector swap beside an explicit error marker remains error_path.; refuted because: That combined shape appears only in the lexical unit negative-control table; the integration fixture changes the error variant without changing the selector.
Evidence gaps
- Runtime/unit sensor completion is not established in the available lane.
- Model proof intent was rejected by deterministic validation.
|
Independent exact-head review of 00167d2: CLEAN. An earlier review of ed70a61 found Generated by Claude Code |
…9921 evidence-line wording (RIPR-SPEC-0122) Main's #9921 dropped the observation_unverified suffix from per-finding human evidence lines and re-blessed 57 human-full goldens; #9950 blessed selector_swap_try_error_arm_control in the same batch and kept the stale suffix, leaving main's own tip red on cargo xtask goldens check (reproduced on pure origin/main d91c149 and on this branch's merge ref: run 39955805404 failed only this goldens step after 20125/20125 nextest tests passed). Mechanical one-line re-bless to the current renderer with the bless ledger reason.
#9890) * feat(classify): credit an applied returned closure pin (#9490 slice 3) A pin that applies a returned closure (make_adder(2)(3)) now credits the closure body when every argument is a distinct nonzero numeric literal. RIPR-SPEC-0265 rule 5; shape-closure-returned-adder is credited/exposed. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * fix(classify): canonicalize applied-closure literal values and refresh the stale shape-limit control Review finding (graphite, PRRT_kwDOSiSx0c6va-Sr): the applied-input distinctness check compared normalized literal TEXT, so equal values behind different spellings (2 vs 02, 1.0 vs 1.00) passed as pairwise different and credited the coincident pair 2 + 2 == 2 * 2 the rule refuses. Canonicalize the value (strip leading integer zeros and trailing fraction zeros) before the seen-set check, and pin the refusals with unit controls. CI red (Ripr Rust Small Result, runs 39873631526/39873631512): the single failing test a_returned_closure_the_test_applies_reads_as_a_ shape_limit asserted the pre-#9490 withheld reading for the exact shape this PR credits; it came in unchanged from #9488 via the main merge. Rewrite it as the inverse control (the shape-limit rule must not withhold the credited shape) and update its registered traceability path. Proof: pinned_shape_limit 19/19 and returned_closure_pin 5/5 in default and lang-rust-only lanes; owner_pin lib filter 320/320; clippy -p ripr --all-targets -D warnings clean; fmt clean; policy cascade (no-panic-family, process, allow-attributes, static-language, executable-files, network, lint-policy, traceability) all exit 0. goldens check drift is limited to typescript_enum_wrong_export and reproduces on the pristine PR head (inherited: #9881 re-blessed it on main after this branch's merge of main; the merge ref resolves it), no Rust classify golden drifts. * test(goldens): re-bless selector_swap_try_error_arm_control for the #9921 evidence-line wording (RIPR-SPEC-0122) Main's #9921 dropped the observation_unverified suffix from per-finding human evidence lines and re-blessed 57 human-full goldens; #9950 blessed selector_swap_try_error_arm_control in the same batch and kept the stale suffix, leaving main's own tip red on cargo xtask goldens check (reproduced on pure origin/main d91c149 and on this branch's merge ref: run 39955805404 failed only this goldens step after 20125/20125 nextest tests passed). Mechanical one-line re-bless to the current renderer with the bless ledger reason. * ci: probe event delivery for PR 9890 qualification * fix(classify): bind returned-closure exposure to discriminating applied pins Bounded review-owned adoption proposal for #9890 / #9490 slice3. Join effective-body numeric discrimination, literal/type/binding refusals, and required owner-pin enforcement before lexical token confirmation. Retain supported positive controls and independent honesty coverage. Canonical source custody remains with the existing PR author. * fix(classify): complete closure attribution checks and proof controls Preserve exact float discrimination and reject alternate result/callee attribution; retain native paired controls and fixture contract. * chore: raise spec-example floor to 183 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * chore: re-bless returned closure masking fixture after main output changes (#9490) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * lower rust missed_credit_ceiling to the blessed 133 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * re-bless returned_closure_arithmetic_masking for main's ReturnValue next-step wording (RIPR-SPEC-0265) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * resolve missed_credit_ceiling merge: rust 142 (main 143 minus this PR's returned-adder row) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * rust floor 204, missed_credit_ceiling 142 after merging spawn/join rule 4 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * rustfmt the returned-closure owner-tail chain Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * Judge returned-closure input distinctness on typed values Distinct decimal spellings can round to one f32/f64 input, so the pairwise-different requirement now compares the parsed typed values. Adds a rounded-equal f32 negative control and completes the traceability list for the returned-closure controls. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * test(goldens): re-bless returned_closure_arithmetic_masking for main's legend and repair wording (RIPR-SPEC-0265) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV * fix(classify): resolve a bare constant in an associated fn against the enclosing item scope; list example 9 in the spec test mapping (RIPR-SPEC-0265) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01JJgwEL5EqfhxV47nHYYpMV --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: EffortlessSteven <steven@effortlessmetrics.com> Co-authored-by: Steven Zimmerman <steven@effortlesssteven.com>
Summary
Before: on
benchmarks/stub_quality/cases/C_scheduler, swappingmax_by_keyformin_by_keyonlet idx = ....map(|(i, _)| i)?;read aserror_path(weakly_exposed) with "Add a test input that executes the changed error arm and assert the exact variant or payload it produces". The?only propagatesNonefor an empty queue; what changed is which element is selected.After: the same line abstains as
static_unknownwith the inspect-first next step. A real changed?error arm is unchanged.How: the lexical fallback (
classify_changed_line) mintsErrorPathfrom any?.classify_changed_line_againstinanalysis/probes/lexical.rs(the probe-family owner, called fromprobes/diff.rs) now compares the changed line with the line it replaced. When the only difference is one selector method name replaced by another (min/max,min_by/max_by,min_by_key/max_by_key,first/last,next/next_back,find/rfind, compared as whole identifiers) and the line has no explicit error marker (Err(,Error::,map_err,bail!,anyhow!),ErrorPathis withheld and the line abstains asstatic_unknown. Everything else keeps the existing families (fail closed).Proof:
error_path, "executes the changed error arm").selector_swap_try_not_error_path(goldens:static_unknown) and positive controlselector_swap_try_error_arm_control(a changedQueueError::EmptytoQueueError::Closedon a?line stayserror_path,weakly_exposed), both in the promotion honesty corpus.?, non-selector call changed, selector plus another edit, selector swap besideError::variant, identical text) and whole-identifier matching.?: 0 elsewhere infixtures/,benchmarks/andmetrics/diffs (only C_scheduler); the four?selector lines inrelease_s3759.diffare new lines, not swaps.cargo fmt --check,cargo test -p ripr --lib lexical,cargo xtask goldens check,cargo xtask fixtures,cargo xtask verdict-corpus check-all,cargo xtask check-evidence-promotion-honesty,cargo xtask precommit(pass).Residual: a selector swap beside an explicit error marker (
.ok_or(Error::Empty)?) keepserror_path(unchanged behavior). Only the listed selector names are recognized; other selector swaps keep the old family.Swarm / Source Boundary
ripr-swarmSource-of-truth Links
Proposal:
Spec: RIPR-SPEC-0107
ADR:
Plan item:
Governing issue or accepted claim: #9866
Acceptance delta (one sentence): A one-line selector swap on a line ending in
?no longer reads as anerror_pathgap with changed-error-arm guidance and abstains asstatic_unknown, while a real changed?error arm stayserror_path.Candidate Relationships
Candidate branch (GitHub PR head is authoritative after publication): claude/fix-9866-selector-try
Stack parent or prerequisite PR (if any): none
Proposed replacement of PR (if any; not yet accepted): none
Acceptance retained from a replaced candidate (if any): none
Accepted winner and losing candidate disposition (when decided): n/a, no competing candidate
Scope
crates/ripr/src/analysis/probes/lexical.rs,crates/ripr/src/analysis/probes/diff.rs, two fixtures, two promotion-corpus entries, one changelog fragment.Closes #9866.
Generated by Claude Code