Skip to content

fix(analysis): a selector swap on a trailing-? line is not a changed error arm (#9866) - #9950

Merged
EffortlessSteven merged 2 commits into
mainfrom
claude/fix-9866-selector-try
Oct 23, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
claude/fix-9866-selector-try

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Summary

Before: on benchmarks/stub_quality/cases/C_scheduler, swapping max_by_key for min_by_key on let idx = ....map(|(i, _)| i)?; read as error_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 propagates None for an empty queue; what changed is which element is selected.

After: the same line abstains as static_unknown with the inspect-first next step. A real changed ? error arm is unchanged.

How: the lexical fallback (classify_changed_line) mints ErrorPath from any ?. classify_changed_line_against in analysis/probes/lexical.rs (the probe-family owner, called from probes/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!), ErrorPath is withheld and the line abstains as static_unknown. Everything else keeps the existing families (fail closed).

Proof:

  • Reproduced red first with the pre-fix binary on the C_scheduler diff (error_path, "executes the changed error arm").
  • New fixture selector_swap_try_not_error_path (goldens: static_unknown) and positive control selector_swap_try_error_arm_control (a changed QueueError::Empty to QueueError::Closed on a ? line stays error_path, weakly_exposed), both in the promotion honesty corpus.
  • Unit tests for the swap, the alternate/negative controls (no old line, added ?, non-selector call changed, selector plus another edit, selector swap beside Error:: variant, identical text) and whole-identifier matching.
  • Other one-line selector swaps ending in ?: 0 elsewhere in fixtures/, benchmarks/ and metrics/ diffs (only C_scheduler); the four ? selector lines in release_s3759.diff are new lines, not swaps.
  • Ran: 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)?) keeps error_path (unchanged behavior). Only the listed selector names are recognized; other selector swaps keep the old family.

Swarm / Source Boundary

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

Source-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 an error_path gap with changed-error-arm guidance and abstains as static_unknown, while a real changed ? error arm stays error_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

…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
@coderabbitai

coderabbitai Bot commented Oct 23, 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 34 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 126 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Essentials
  • Run ID: ae9c125c-2dcd-4a4f-94d5-eb56ce50fc3d
📥 Commits

Reviewing files that changed from the base of the PR and between dff1e38 and 00167d2.

📒 Files selected for processing: 20
  • changelog.d/9866-selector-swap-try-not-error-path.md
  • crates/ripr/src/analysis/probes/diff.rs
  • crates/ripr/src/analysis/probes/lexical.rs
  • fixtures/evidence-promotion-honesty-corpus/corpus.json
  • fixtures/selector_swap_try_error_arm_control/SPEC.md
  • fixtures/selector_swap_try_error_arm_control/diff.patch
  • fixtures/selector_swap_try_error_arm_control/expected/CHANGELOG.md
  • fixtures/selector_swap_try_error_arm_control/expected/check.json
  • fixtures/selector_swap_try_error_arm_control/expected/human-full.txt
  • fixtures/selector_swap_try_error_arm_control/expected/human.txt
  • fixtures/selector_swap_try_error_arm_control/input/Cargo.toml
  • fixtures/selector_swap_try_error_arm_control/input/src/lib.rs
  • fixtures/selector_swap_try_not_error_path/SPEC.md
  • fixtures/selector_swap_try_not_error_path/diff.patch
  • fixtures/selector_swap_try_not_error_path/expected/CHANGELOG.md
  • fixtures/selector_swap_try_not_error_path/expected/check.json
  • fixtures/selector_swap_try_not_error_path/expected/human-full.txt
  • fixtures/selector_swap_try_not_error_path/expected/human.txt
  • fixtures/selector_swap_try_not_error_path/input/Cargo.toml
  • fixtures/selector_swap_try_not_error_path/input/src/lib.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@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

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

Copy link
Copy Markdown
Member Author

Independent exact-head review of 00167d2: CLEAN. An earlier review of ed70a61 found is_selector_swap too broad (non-method identifiers, strings and comments spelled like selectors); repaired by masking strings/comments and requiring method-call position, with the six repros pinned as negative controls. Verified: the C_scheduler swap now reads static_unknown; swaps beside Err(/Error::/map_err and turbofish forms keep error_path; fixtures, lexical tests and the honesty check pass. Residual fail-closed shapes (a selector swap plus an error-string change abstains; v[0..first(n)?] counts as method position) miss an advisory and promote nothing. Requesting the required check.


Generated by Claude Code

@EffortlessSteven
EffortlessSteven merged commit e2d33dd into main Oct 23, 2026
48 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/fix-9866-selector-try branch October 23, 2026 12:01
EffortlessSteven pushed a commit that referenced this pull request Oct 23, 2026
…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.
EffortlessSteven added a commit that referenced this pull request Oct 25, 2026
#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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

rust: a selector change (min_by_key -> max_by_key) on a line ending in ? reads as an error_path gap with "execute the changed error arm" guidance

2 participants