Skip to content

fix(core): isolate rule failures so one crashing rule no longer kills the whole run - #464

Merged
oekazuma merged 2 commits into
mainfrom
fix/rule-failure-isolation
Aug 12, 2026
Merged

oekazuma merged 2 commits into
mainfrom
fix/rule-failure-isolation

Conversation

@oekazuma

@oekazuma oekazuma commented Aug 11, 2026 •

Copy link
Copy Markdown
Owner

Summary

Previously, a single rule throwing during check() crashed the entire analysis (exit 2, no results). Now each rule runs inside its own try/catch:

  • runRules returns failedRules: { id, message }[] alongside results/examined.
  • A crashed rule is removed from scoring via the existing 'off' drop mechanism (withFailedRulesOff in config-apply.ts), so it leaves the Health denominator instead of silently counting as a pass — measured cell: a crashing rule shifts Health 83 → 80 in the fixture project because its inventory weight is dropped, not zero-filled.
  • The CLI reports each failure on stderr (svelte-vitals: rule <id> failed and was skipped: <first line>), using the same channel as skipped-file warnings. The vite plugin surfaces failures through its existing warnings array.

Declared behavior change: a run containing a crashing rule previously died with exit 2 and no output; it now completes with real results for every other rule, plus a stderr warning naming the failed rule.

Verification

  • New isolation tests in packages/core/test/engine.test.ts (crash → other rules' results intact, failedRules populated, Health denominator excludes the crashed rule).
  • Mutation check: removing the try/catch makes 5 of the new tests fail.
  • pnpm -r test (core 1423 / cli 1151 / vite 214), pnpm lint, pnpm -r typecheck all pass.

Changeset: @svelte-vitals/core + svelte-vitals patch.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Bug Fixes
    • Rule failures no longer stop analysis or cause an unsuccessful exit.
    • Analysis continues with available results while reporting clear warnings in stderr.
    • Failed rules are excluded from Health score weighting to prevent misleading scores.
    • Warnings include the affected rule and a concise error message.
  • Improvements
    • Vite integrations now surface failed-rule warnings and provide additional details in debug mode.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@oekazuma, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 51 minutes

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 893cfd8b-ef0b-4541-8664-a4fbee5d94c1

📥 Commits

Reviewing files that changed from the base of the PR and between a1560b3 and f5a99ce.

📒 Files selected for processing (3)
  • .changeset/rule-failure-isolation.md
  • packages/core/test/engine.test.ts
  • packages/vite/src/analyze.ts
📝 Walkthrough

Walkthrough

Rule execution now isolates synchronous and asynchronous failures. Failed rules produce warnings, remain outside successful results, and can be disabled for Health-score weighting. The CLI and Vite integrations consume the new failure data, with core, scoring, and end-to-end tests covering the behavior.

Changes

Rule Failure Isolation

Layer / File(s) Summary
Capture rule failures
packages/core/src/engine.ts, packages/core/src/rules/correctness/orphan-effect.ts, packages/core/test/engine.test.ts
runRules records synchronous and asynchronous rule failures while preserving successful results and examined counts.
Disable failed-rule weighting
packages/core/src/config-apply.ts, packages/core/src/index.ts, packages/core/test/config-apply.test.ts, packages/core/test/score.test.ts
withFailedRulesOff disables failed rule IDs and preserves unrelated configuration. Tests verify rule selection and Health-score changes.
Handle failures in the CLI
packages/cli/src/index.ts, packages/cli/test/rule-failure-isolation.test.ts, .changeset/rule-failure-isolation.md
The CLI excludes failed rules from Health weighting, emits first-line stderr warnings, and completes successfully.
Report failures in Vite analysis
packages/vite/src/analyze.ts, packages/vite/src/hooks/handle.ts
Vite analysis adds failed-rule warnings and debug logging while retaining successful results.

Estimated code review effort: 4 (Complex) | ~45 minutes

Sequence Diagram(s)

sequenceDiagram
  participant analyzeProject
  participant runRules
  participant withFailedRulesOff
  participant HealthScore
  analyzeProject->>runRules: execute configured rules
  runRules-->>analyzeProject: return results and failedRules
  analyzeProject->>withFailedRulesOff: disable failed rule IDs
  withFailedRulesOff-->>HealthScore: provide scoring configuration
  HealthScore-->>analyzeProject: calculate Health score
  analyzeProject-->>analyzeProject: append failed-rule warnings
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: isolating rule failures so one crashing rule does not terminate the full analysis run.
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.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@oekazuma

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 11, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@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: 3

🤖 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 `@packages/core/test/engine.test.ts`:
- Around line 153-154: Remove the audit-history comment immediately preceding
the relevant test in engine.test.ts, including the 2608-CORE-06 reference and
CORE-07 note; leave the test title and implementation unchanged.

In `@packages/vite/src/analyze.ts`:
- Line 122: Update the documentation for AnalyzeResult.warnings to describe both
config-file issues and non-fatal rule-analysis failures added by the failedRules
loop. Remove or revise the claim that warnings is empty when no config file
exists, since rule failures can still populate it.
- Around line 118-122: Update the failedRules handling in the analyze flow to
derive a non-mutating scoreConfig withFailedRulesOff(config, failedRules.map((f)
=> f.id)) when failures exist. Use scoreConfig instead of config for
computeScore, formatConsoleReport, and formatJsonReport, while preserving config
for the remaining analysis behavior.
🪄 Autofix

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

Plan: Pro Plus

Run ID: 2e6c3733-fe09-4e8d-b390-2ef589656c67

📥 Commits

Reviewing files that changed from the base of the PR and between 824199f and a1560b3.

📒 Files selected for processing (12)
  • .changeset/rule-failure-isolation.md
  • packages/cli/src/index.ts
  • packages/cli/test/rule-failure-isolation.test.ts
  • packages/core/src/config-apply.ts
  • packages/core/src/engine.ts
  • packages/core/src/index.ts
  • packages/core/src/rules/correctness/orphan-effect.ts
  • packages/core/test/config-apply.test.ts
  • packages/core/test/engine.test.ts
  • packages/core/test/score.test.ts
  • packages/vite/src/analyze.ts
  • packages/vite/src/hooks/handle.ts

Comment thread packages/core/test/engine.test.ts Outdated
Comment thread packages/vite/src/analyze.ts
Comment thread packages/vite/src/analyze.ts
@oekazuma
oekazuma merged commit ddcf62d into main Aug 12, 2026
8 checks passed
@oekazuma
oekazuma deleted the fix/rule-failure-isolation branch August 12, 2026 00:19
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