Repository navigation
fix(analysis): normalize error variant discriminators - #1668
Conversation
WalkthroughError variant discriminators now extract exact parsed identities, fall back to raw expressions when parsing fails, and require unambiguous exact identities during oracle matching. Tests cover parsed, unparseable, and integration cases. ChangesError variant discrimination
Estimated code review effort: 2 (Simple) | ~10 minutes Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Code Review
This pull request refactors how ErrorVariant seam discriminators are stored and matched. Instead of storing the full surrounding return expression, it now extracts and stores the exact error variant identity (e.g., "AuthError::RevokedToken" instead of "return Err(AuthError::RevokedToken);"). The matching logic in test_grip_evidence.rs has been updated to handle both the new exact variant format and older or unparseable expressions gracefully, and corresponding unit tests have been added. There are no review comments, so I have no feedback to provide.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 18db1c3b0f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
There was a problem hiding this comment.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/ripr/src/analysis/test_grip_evidence.rs (1)
1537-1566: 🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy liftDoc claims full fail-closed behavior, but the retained legacy fallback still allows loose payload matching.
The new doc states: "Fail-closed: returns
falsewhenever either side cannot be parsed or they do not share a common variant value." But whenexact_error_variant(variant)fails and the trimmed candidate isn't a single exact token match, the code still falls through toerror_constructor_payload_oracle_matches_seam(...) || error_string_payload_oracle_matches_seam(...)(Lines 1560-1562, unchanged) instead of returningfalse. Tracing the exact "unparseable" case added inseam_inventory.rs(return Err(format!("failed: {reason}"));) confirms it reaches this legacy payload-matching fallback rather than failing closed.This also contradicts the accompanying
line_range_change_detailssummary, which states this rework was "removing the prior behavior that continued discrimination using payload-based matching paths whenexact_error_variantfailed" — the payload-matching path is still present and reachable for ambiguous/unparseablevariantvalues. Either the doc comment/summary should be corrected to describe the legacy-fallback path accurately, or the fallback should be removed if the intent really is strict fail-closed exact-identity matching per the PR's stated goal ("accepts only unambiguous exact identities").📝 Minimal fix: correct the doc to reflect the retained legacy fallback
-/// Fail-closed: returns `false` whenever either side cannot be parsed or they -/// do not share a common variant value. +/// Fail-closed only for the exact-identity path: when the seam variant is a +/// bare identity or parses via `exact_error_variant`, this returns `false` on +/// any mismatch. For legacy/unparseable `variant` text this still falls back +/// to payload-based matching (`error_constructor_payload_oracle_matches_seam` +/// / `error_string_payload_oracle_matches_seam`) rather than failing closed.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@crates/ripr/src/analysis/test_grip_evidence.rs` around lines 1537 - 1566, Update the documentation for error_variant_oracle_matches_seam_variant to accurately describe the retained legacy payload-matching fallback when exact variant parsing fails, including that this path is not strictly fail-closed. Keep the existing fallback behavior unchanged and align the related line_range_change_details summary with the actual implementation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/ripr/src/analysis/seam_inventory.rs`:
- Around line 1117-1123: Update exact_error_variant in the error-variant
classifier to preserve the outer constructor identity when Err(...) contains
nested constructors, rather than selecting the first sorted inner token. Add a
test covering a nested form such as Err(SomeError::Wrap(Inner::Value)) and
verify it returns the outer variant; retain fail-closed behavior for unparseable
expressions.
---
Outside diff comments:
In `@crates/ripr/src/analysis/test_grip_evidence.rs`:
- Around line 1537-1566: Update the documentation for
error_variant_oracle_matches_seam_variant to accurately describe the retained
legacy payload-matching fallback when exact variant parsing fails, including
that this path is not strictly fail-closed. Keep the existing fallback behavior
unchanged and align the related line_range_change_details summary with the
actual implementation.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro Plus
Run ID: 1f5b7f67-d64e-491b-a798-2d2b2e046c30
📒 Files selected for processing (3)
crates/ripr/src/analysis/seam_inventory.rscrates/ripr/src/analysis/test_grip_evidence.rscrates/ripr/src/analysis/test_grip_evidence/tests.rs
🔗 Linked repositories identified
CodeRabbit considers these linked repositories for cross-repo context during reviews:
EffortlessMetrics/ripr(auto-detected)EffortlessMetrics/unsafe-review(auto-detected)EffortlessMetrics/ub-review(auto-detected)EffortlessMetrics/perl-lsp(auto-detected)
|
Addressed in commit 319500b. The review documentation now distinguishes exact variant identity from the dedicated exact constructor/string-payload path. Exact identity mismatches remain fail-closed, and opaque expressions without recognized payload evidence cannot promote discrimination. The parser, cache, and affected grip tests pass. |
What this does
Error-variant seam analysis could select an inner nested constructor or reuse a stale cache entry after changing discriminator meaning. It also needs to preserve exact constructor and string-payload evidence without promoting opaque expressions.
Fix: exact_error_variant selects only the outer qualified constructor, and cache schemas 0.5 and 0.2 invalidate full and compact classified seams. Exact identity matching remains strict. Constructor and string-payload expressions use dedicated exact payload matching, while opaque expressions without payload evidence remain non-discriminating.
Verification
Review map