Skip to content

fix(analysis): normalize error variant discriminators - #1668

Merged
EffortlessSteven merged 2 commits into
mainfrom
codex/1601-pr2-error-variant
Jul 14, 2026
Merged

EffortlessSteven merged 2 commits into
mainfrom
codex/1601-pr2-error-variant

Conversation

@EffortlessSteven

@EffortlessSteven EffortlessSteven commented Jul 14, 2026 •

Copy link
Copy Markdown
Member

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

Check Result
analysis::classify::text 11 passed
analysis::seam_cache 33 passed
analysis::test_grip_evidence::tests 230 passed
cargo fmt, cargo check -p ripr --lib, cargo clippy -p ripr --lib -- -D warnings clean

Review map

  • crates/ripr/src/analysis/classify/text/error_variant.rs: preserves the outer error constructor identity and rejects ambiguous token sets.
  • crates/ripr/src/analysis/test_grip_evidence.rs: keeps exact identity and exact payload discrimination separate, with opaque no-evidence inputs fail-closed.
  • crates/ripr/src/analysis/seam_cache.rs: invalidates both full and compact classified-seam caches when discriminator meaning changes.
  • crates/ripr/src/analysis/test_grip_evidence/tests.rs: covers nested constructors and opaque no-evidence regression behavior.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Review Change Stack

Walkthrough

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

Changes

Error variant discrimination

Layer / File(s) Summary
Extract exact error variant identities
crates/ripr/src/analysis/seam_inventory.rs
Error variant discriminators use parsed exact identities when available and preserve raw expressions otherwise; unit tests cover both behaviors.
Enforce exact oracle variant matching
crates/ripr/src/analysis/test_grip_evidence.rs, crates/ripr/src/analysis/test_grip_evidence/tests.rs
Oracle matching rejects ambiguous or unparseable discriminator values and tests verify the expected AuthError::RevokedToken discriminator.

Estimated code review effort: 2 (Simple) | ~10 minutes

Poem

I’m a rabbit with a careful ear,
Exact variants now ring clear.
Raw text waits when parsing fails,
Ambiguous matches leave the trails.
Hop, hop—strictness wins the day!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description does not follow the required template and omits most mandatory sections like scope, proof, rollback, and traceability. Rewrite the PR description using the template and fill in the missing required sections, especially Summary, Scope, Proof, Rollback, and Spec-Test-Code Traceability.
✅ Passed checks (4 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title is concise and accurately summarizes the main change to error variant discriminators.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/1601-pr2-error-variant

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

codecov Bot commented Jul 14, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 97.22222% with 1 line in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/ripr/src/analysis/test_grip_evidence.rs 83.33% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@chatgpt-codex-connector chatgpt-codex-connector 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.

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

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

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 lift

Doc claims full fail-closed behavior, but the retained legacy fallback still allows loose payload matching.

The new doc states: "Fail-closed: returns false whenever either side cannot be parsed or they do not share a common variant value." But when exact_error_variant(variant) fails and the trimmed candidate isn't a single exact token match, the code still falls through to error_constructor_payload_oracle_matches_seam(...) || error_string_payload_oracle_matches_seam(...) (Lines 1560-1562, unchanged) instead of returning false. Tracing the exact "unparseable" case added in seam_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_details summary, which states this rework was "removing the prior behavior that continued discrimination using payload-based matching paths when exact_error_variant failed" — the payload-matching path is still present and reachable for ambiguous/unparseable variant values. 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

📥 Commits

Reviewing files that changed from the base of the PR and between d19966f and 18db1c3.

📒 Files selected for processing (3)
  • crates/ripr/src/analysis/seam_inventory.rs
  • crates/ripr/src/analysis/test_grip_evidence.rs
  • crates/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)

@EffortlessSteven
EffortlessSteven enabled auto-merge (squash) July 14, 2026 12:33
@EffortlessSteven

Copy link
Copy Markdown
Member Author

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.

@EffortlessSteven
EffortlessSteven merged commit 369cdae into main Jul 14, 2026
26 checks passed
@EffortlessSteven
EffortlessSteven deleted the codex/1601-pr2-error-variant branch July 14, 2026 13:04
This was referenced Jul 14, 2026
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.

1 participant