Skip to content

rust: parenthesized unwrap_err receivers bypass the Ok-preserving adapter gate #7872

Closed

Description

@EffortlessSteven

Verified current defect on PR #7627 head e325248cf94338cd5462f909f100e1597e3d0ea0 (2026-10-14 04:02 UTC), governing claim #6640.

crates/ripr/src/analysis/extract/oracles/scan.rs::receiver_keeps_call_error finds the first ( and treats its closing group as the first call. When the receiver is parenthesized, that group contains the entire adapter chain, leaving an empty suffix. The function returns true without checking .and, .or, or .ok_or inside it. The shared uncompared_unwrap_err predicate is consumed by the line scanner and syntax/ra.rs::uncompared_unwrap_err_statement.

Production reproduction using the existing error_path_sibling_variant.rs::sibling_exclusion_reading fixture (changed Err(PayError::Insufficient)):

withdraw(10, 20).and(Err::<u64, _>(PayError::Insufficient)).unwrap_err();
// ReachableUnrevealed, ["unknown/none"] — correct refusal

(withdraw(10, 20).and(Err::<u64, _>(PayError::Insufficient))).unwrap_err();
// WeaklyExposed, ["broad_error/weak"] — incorrect credit

((withdraw(10, 20).and(Err::<u64, _>(PayError::Insufficient)))).unwrap_err();
// Same incorrect credit

The parenthesized .or(Err(..)) form also receives credit despite being outside the documented whitelist. Exact-source predicate controls additionally admit (find(3).ok_or(E::Missing)).unwrap_err();, while refusing its unparenthesized twin. The Option control was executed against the exact predicate, not asserted as a full-pipeline owner finding.

Independent runtime discriminator: Rust 1.95.0 executes the parenthesized .and(Err(..)).unwrap_err() successfully both for baseline Err(Insufficient) and wrong Ok(0); bare Ok(0).unwrap_err() fails. Thus the newly credited assertion cannot distinguish the owner's error side. This is a false weak observation, not an exposed escalation.

Executed evidence: isolated review-owned tree; submitted production bytes unchanged; task-local pinned Rust 1.95.0 (59807616e). Command:

cargo +1.95.0 test --locked -p ripr --test error_path_sibling_variant --jobs 2 -- --nocapture

13 existing integration tests plus an initial 5-control probe pass (14 test functions total; exit 0). That initial probe used sibling Limit, which the separate sibling gate suppressed; it does not refute this defect. A discriminating probe using Insufficient then ran seven shapes: bare unwrap, plain map_err, parenthesized map_err remain correct positives; unparenthesized .and remains a correct negative; one/two parentheses around .and and parentheses around .or produce three incorrect credits. Its focused invocation exited 101 with 1 failed test / 13 filtered out. No setup or compilation failure.

Concrete same-writer handoff: preserve the writer of claude/project-thread-vv94ve; repair receiver parsing in this candidate so grouping cannot skip adapter validation (normalize or recursively inspect parentheses without broadening unknown calls). Extend the existing scanner/parser parity test with parenthesized and nested .and(Err(..)) and .ok_or(..) refusal controls, retaining grouped bare-call and grouped map_err positives. Add the full-pipeline negative above, with a nonempty related test and exact changed finding. Re-run those focused controls and the existing sibling-exclusion tests; route required corpus/golden checks through the normal proof path. No gate relaxation or golden blessing of this result.

Current integration observation: main 405deb02681372f9b6f684d4d22c53e82b260ad6; merge base 4711c122a0248d75807ba2e0401169a2f46743aa; git merge-tree --write-tree succeeds, resulting tree b03d18c2d32b58f60350d721a1e6dadb392fee04. Execution above binds the PR head, not a merged-tree build. All-state searches for unwrap_err/parentheses and receiver_keeps_call_error found no duplicate issue.

Retained review artifacts: /workspace/review-7627-evidence/{control.patch,parenthesized-controls.log,integration.log,exact-predicate.rs,exact-predicate.log,runtime-controls.rs,runtime-controls.log,admission.txt}. Production-path control executable SHA256: d28b0691afd47cb4781c2262c3c95b054cda30bd2d24b6652b83a9cb70e0860f. These paths are local to the delegated environment; the reproduction and results above are the durable handoff.

Activity

  1. EffortlessSteven commented on Oct 14, 2026

    @EffortlessSteven
    MemberAuthor

    Repaired on #7627 at head 6b59ee182. The first group before unwrap_err() must now be a call on a plain path. Both the scanner and parser adapters, and an end-to-end check_workspace test, refuse the grouped .and, nested grouped .and, grouped .or and grouped ok_or shapes. A mutation check confirms both tests fail without the gate. This issue closes when #7627 merges.


    Generated by Claude Code

  2. EffortlessSteven commented on Oct 14, 2026

    @EffortlessSteven
    MemberAuthor

    Bounded independent metamorphic recheck (Codex reviewer, 2026-10-14 UTC) at #7627 current head 6b59ee182f1abfe1f47f84f3d253363c2c3b5a37, PR base 4711c122a0248d75807ba2e0401169a2f46743aa. The dangerous grouped .and(Err(..)) witness now correctly reads reachable_unrevealed / unknown-none through the real CLI. The repair also loses equivalent positive spellings; keep this with the existing writer claude/project-thread-vv94ve, not a duplicate issue.

    Source fixture:

    #[derive(Debug, PartialEq)]
    pub enum PayError { Insufficient, Limit }
    pub fn withdraw(balance: u64, amount: u64) -> Result<u64, PayError> {
        if amount > balance {
            return Err(PayError::Insufficient); // changed from Limit
        }
        Ok(balance - amount)
    }

    Each test body is one of:

    withdraw(10,20).unwrap_err();                           // weakly_exposed, broad_error/weak
    withdraw /* token */ (10,20).unwrap_err();               // same, preserved
    (withdraw(10,20)).unwrap_err();                         // reachable_unrevealed, unknown/none
    (withdraw(10,20).map_err(|e| e)).unwrap_err();            // reachable_unrevealed, unknown/none
    r#withdraw(10,20).unwrap_err();                         // reachable_unrevealed, unknown/none
    (withdraw(10,20).and(Err::<u64,_>(PayError::Insufficient))).unwrap_err(); // correct refusal

    All six CLI invocations exited 0, with nonempty error_path findings at src/lib.rs:5 and one related test each. For every admitted/equivalent positive, native Rust 1.95.0 compiled and ran the test successfully on current Err and failed it (exit 101 after successful compile) when the changed return was replaced with Ok(0). The .and negative compiled/passed both. Thus the grouped call and grouped identity map observe the same Result side as the bare positive; raw-name spelling denotes the same function. This is lost weak semantic credit, not false exposed.

    Likely repair surface: analysis/extract/oracles/scan.rs::{is_call_path,receiver_keeps_call_error}, shared by the parser's uncompared unwrap_err reader. The leading-call-path gate rejects all grouping and #; preserve balanced grouping without hiding the adapter chain, and normalize a valid Rust raw identifier through existing syntax authority. The original issue's historical experiment already recorded grouped map_err as a positive; it is historical evidence, not relabeled as a new previous-head run. Add scanner/parser parity plus real-consumer grouped positive twins while retaining the now-correct .and refusal. No shared-walker refactor requested.

    Disposition: PROOF_NEEDS_REPAIR for equivalent-spelling preservation under this task; original false-weak-credit route is repaired in the six-row scope. The published repair/spec currently narrows to a plain call path, so this note explicitly identifies the semantic coverage lost rather than asserting an unchanged broader documented guarantee. Parent owns full acceptance, required hosted qualification, Ready and protected merge.

    Observed explicit locked build, official task-local Rust 1.95.0 (59807616e), Linux x86_64, debug=0/incremental=false. First offline build stopped before compile for missing home; locked online build succeeded and captured the selected compiler-artifact executable. Retained VM evidence /workspace/scratch/metamorphic-review/{matrix.py,evidence/{matrix.json,results7627.json,native-results.json,build7627-online.jsonl,build7627-online.log,bin7627.sha256},cases/7627/*/}. No candidate source edit, full-suite duplication, hosted rerun, or integration qualification.

    Evidence closeout note: native compiler/runtime controls are retained outside the analyzer fixture roots at native-controls/7627/; final CLI replay uses only the intended source/test fixture and one related test. Runtime logs retain their original invocation paths; relocation does not relabel an old execution. The tested classes above were reproduced after this fixture-isolation check.

  3. EffortlessSteven commented on Oct 14, 2026

    @EffortlessSteven
    MemberAuthor

    Closed by #7935, squash-merged as 778a6d3.

    Grouped receivers are now read through rather than refused, so the shapes this issue's recheck found as underclaims credit again: (withdraw(..)).unwrap_err(), (withdraw(..).map_err(f)).unwrap_err() and r#withdraw(..).unwrap_err() all read broad_error / weak.

    The original false credit stays closed. (withdraw(..).and(Err(..))).unwrap_err() reads nothing, and so do its nested, .or and outer-map_err variants. Each case is pinned in the parity test on both adapters and end to end.

    On main at 778a6d3, cargo check -p ripr --tests passes and the xtask oracle and population pin tests pass.


    Generated by Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions