Skip to content

Apply one zero-argument expect_err rule on both adapters - #7980

Merged
EffortlessSteven merged 2 commits into
mainfrom
claude/project-thread-vv94ve
Oct 14, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
claude/project-thread-vv94ve

Conversation

@EffortlessSteven

Copy link
Copy Markdown
Member

Before: after #7952, MockFoo::new().expect_err( );, a mockall expectation for a method named err with a space inside the parens, read as a medium mock_expectation on the line scanner. The parser path read the same line as a weak broad_error plus a medium mock_expectation. That happened because the two zero-argument checks disagreed: without_expect_err treats an argument group that trims to empty as zero arguments, while ends_with_expect_err matched only the literal .expect_err().

After: both adapters read a zero-argument expect_err() on a call receiver as a mock expectation only, with or without inner whitespace. Result::expect_err("msg") still reads broad_error / weak.

ends_with_expect_err now finds the outer .expect_err( whose group closes the expression and requires a non-empty argument. Masking blanks a message's quotes, so the argument is read back from the unmasked text.

How. This PR follows up an independent post-merge review of #7952 (correctness and tests/spec angles; neither found anything blocking). It adds parity cases for MockFoo::new().expect_err();, MockFoo::new().expect_err( ); and run(); // expect_called (the comment-masking change in #7952 had no discriminating case). It also registers spec_0227_uncompared_expect_err_reads_like_unwrap_err under RIPR-SPEC-0227 in .ripr/traceability.toml, and extends the #7604 changelog fragment.

Proof:

  • With the scan.rs change reverted, the spaced case fails on the parser path with [(BroadError, Weak), (MockExpectation, Medium)].
  • cargo xtask precommit passes.
  • verdict-corpus check-all passes; oracle accuracy is 41/41 with 0 overclaims.

Residuals filed elsewhere:

🤖 Generated with Claude Code

https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK


Generated by Claude Code

Post-merge review of #7952: without_expect_err treats an argument
group that trims to empty as a mock's zero-argument expect_err(), but
ends_with_expect_err matched only the literal `.expect_err()`. So
`MockFoo::new().expect_err( );` read a medium mock_expectation on the
line scanner and added a weak broad_error on the parser path.
ends_with_expect_err now finds the outer call whose group closes the
expression and requires a non-empty argument, read back from the
unmasked text because masking blanks a message's quotes.

Adds parity cases for a zero-argument expect_err() on a call receiver,
spaced and unspaced, and for `expect_` in a comment. Registers the
expect_err parity test under RIPR-SPEC-0227 in traceability.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK
@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 marked this pull request as ready for review October 14, 2026 19:43
@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 14, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

The included review limit has been reached and this organization has disabled usage-based review continuation. Wait for reviews to reset or ask a billing admin to change After included review limits.

Next included review available in 3 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 10 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: b3357150-32ac-43e8-9385-049a2aaeda53
📥 Commits

Reviewing files that changed from the base of the PR and between 7922ca9 and d615ac6.

📒 Files selected for processing: 5
  • .ripr/traceability.toml
  • changelog.d/7604-bare-expect-err.md
  • crates/ripr/src/analysis/extract/oracles/classify.rs
  • crates/ripr/src/analysis/extract/oracles/patterns.rs
  • crates/ripr/src/analysis/extract/oracles/scan.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 potential issue.

Devin Review

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

Decision

  • Needs reviewer attention before upstream: findings remain.

Confirmed findings

  • Siblings ends_with_unwrap_err, ends_with_expect, ends_with_panic, and without_expect_err are not touched by this diff; if the PR's stated invariant is 'both adapters agree on zero-argument expect_err', the parity claim is only true for ends_with_expect_err vs without_expect_err on the specific surface changed. Other adapters that may treat bare expect_err() similarly are out of scope for this hunk.
  • Smallest-complete-fix scope is appropriate: adds three parity cases, one spec registration, one changelog extension. No expansion into #7979 (comment args, spaced/UFCS) or #7955 (multi-line/multi-statement) territory. Boundary placement correct.

Verification questions

  • Confirm without sibling diff coverage: without_expect_err, ends_with_unwrap_err, ends_with_expect, ends_with_panic, balanced_group_end, mask_comments_and_strings are all defined outside this hunk; Devin's prior scan.rs:2646 finding (comment-only argument) re-opens under the new check and is not addressed in this PR.

Refuted

  • The new test run(); // expect_called is sufficient evidence that the comment-masking fix from #7952 is preserved under this change; refuted because: It covers a line-trailing comment outside the call group, which is the case the prior #7952 fix already addressed. It does not cover a comment inside the argument group of a real call (the case Devin flagged).
  • The new ends_with_expect_err duplicates without_expect_err's group-parsing logic and should call a shared helper; refuted because: patterns.rs's without_expect_err lives in a different module with a different scope (returns Option<&str> mask, not bool). Extracting a shared helper now would expand surface beyond the smallest fix; current approach reuses the already-shared mask_comments_and_strings + balanced_group_end primitives.

Parked follow-ups

  • Devin's prior review-comment (RIGHT side scan.rs:2646) flagged block comments inside expect_err(): masked.apply mask_comments_and_strings turns /* note */ into spaces of equal length, so the argument group reads as a single space block — not an empty group, not a real message string. This is a real gap and not addressed by the PR's new test cases; residuals belong with related follow-ups.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

Devin on #7980: `MockFoo::new().expect_err(/* setup */);` is mockall's
zero-argument expectation, but both zero-argument checks trimmed the raw
group text, so the comment counted as a message. The line scanner then
dropped the mock name and the parser path read a weak broad_error.
has_argument_tokens (patterns.rs) now decides for both: a group holds
an argument when its masked text is non-blank or it holds a string or
character literal. Adds the parity case.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01LF96T8WMLipviRmdgetFpK

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

Decision

  • Needs verification checks before upstream.

Verification questions

  • Confirm parity cases added are all positive: zero-arg on receiver (with/without spaces) and comment-only argument. There is no negative corpus regression ensuring Result::expect_err("msg") still reads broad_error/weak under the new shared has_argument_tokens rule.
  • Confirm rIPR-SPEC-0227 registration is added for the new test but no spec_0227_uncompared_expect_err_reads_like_unwrap_err body assertion is present in classify.rs - only the existing spec_0227_uncompared_unwrap_err_is_a_weak_broad_error_oracle mirrors the unwrap pattern. The traceability entry points to a test function that is not added in this diff.
  • Confirm ends_with_unwrap_err, ends_with_expect, ends_with_panic still gate on literal () rather than has_argument_tokens, so parity claim only holds for expect_err.

Refuted

  • mask_comments_and_strings in scan.rs:2631 blanks string quotes, so a message-bearing Result::expect_err("msg") would be misread as zero arguments.; refuted because: has_argument_tokens independently counts string_quotes via mask_with_string_delimiter_quotes and char literals via mask_with_char_literals, so a quoted message is recognized as an argument even when the masked trim is empty. The new test expect_err_expect_word_message (pre-existing) continues to assert the broad_error/weak read.
  • Cross-method parity invariant ('all zero-arg expect_* / unwrap / panic adapters agree') is broken because siblings still use the trim-based rule.; refuted because: PR body and the github-actions review explicitly scope this change to expect_err only; the invariant claim is local to that one adapter pair, and #7979/#7955 already track related out-of-scope cases.
  • has_argument_tokens returns true for expect_err("") (empty string literal), so the comment-arg fix silently broadens zero-arg to also exclude empty-string messages, which is the wrong direction; refuted because: Tested: an empty string is still a real Result::expect_err argument and should keep the message; counting it via string_quotes>0 is the correct behavior. The char-literal branch covers '' too. Comment-only groups still return false because masked.trim() is empty and both literal counters are zero. No regression.

Parked follow-ups

  • Sibling methods ends_with_unwrap_err, ends_with_expect, ends_with_panic still rely on the older is_empty/trim rule; the cross-method parity invariant is not established by this diff and would need a follow-up if required.
  • Siblings ends_with_unwrap_err / ends_with_expect / ends_with_panic still use the old ends_with(')') / literal '.expect_err()' shape and were not brought into parity.

Evidence gaps

  • Model proof intent was rejected by deterministic validation.

@EffortlessSteven
EffortlessSteven marked this pull request as draft October 14, 2026 20:46
@EffortlessSteven
EffortlessSteven marked this pull request as ready for review October 14, 2026 20:46
@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

Copy link
Copy Markdown
Member Author

Exact-Head Review Record

  • reviewed_head_sha: \d615ac6059ce0372252e2c026cd9ef27d75f129e\
  • integration_basis: \8e9d0d89c922a945d81d22aa168eaae067b049ca\
  • claim_boundary: Closes rust: a bare expect_err(..) reads as mock_expectation / medium instead of a result-side broad_error / weak #7604. Unifies zero-argument \�xpect_err\ handling between the AST classifier and the lexical line-scanner; both adapters now share \has_argument_tokens\ in \patterns.rs\ to distinguish zero-argument calls (including comment-only argument groups) from nonempty arguments without dropping mock expectation credit.
  • changed_surfaces_and_semantic_owners_inspected: \crates/ripr/src/analysis/extract/oracles/{classify,patterns,scan}.rs, .ripr/traceability.toml, \changelog.d/7604-bare-expect-err.md.
  • blocking_findings: None.
  • non_blocking_suggestions: None.
  • refuted_or_stale_findings:
    • Devin finding regarding commented mock calls losing expectation credit was addressed in commit \d615ac605\ by introducing token-aware \has_argument_tokens; parity tests verified; review thread resolved.
  • proof_and_ci_observed:
    • Hosted CI run \38634881934\ on exact head \d615ac605: \Ripr Rust Small on GitHub Hosted / Rust gates\ passed and \Ripr Rust Small Result\ succeeded.
    • Merge-tree with \origin/main\ is clean (\62a357e2b66facdd7b8635bb2829f1aa205cd76e, 0 conflicts).
  • proof_or_review_missing: None.
  • affected_currentness_dimensions: None; clean behind-only squash against current \origin/main.
  • residual_assumptions_and_non_claims: Single-line expect_err calls only; multi-line wrapped unwrap_err / expect_err fallback remains separate under Join rustfmt-wrapped unwrap_err / expect_err in the lexical fallback #7977.
  • disposition: REVIEW_READY

@EffortlessSteven
EffortlessSteven merged commit f746152 into main Oct 14, 2026
36 checks passed
@EffortlessSteven
EffortlessSteven deleted the claude/project-thread-vv94ve branch October 14, 2026 23:06
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