Skip to content

feat: rule severity levels and granular exit codes#2

Merged
SpollaL merged 1 commit into
masterfrom
feat/severity-and-exit-codes
Apr 23, 2026
Merged

feat: rule severity levels and granular exit codes#2
SpollaL merged 1 commit into
masterfrom
feat/severity-and-exit-codes

Conversation

@SpollaL
Copy link
Copy Markdown
Owner

@SpollaL SpollaL commented Apr 23, 2026

Summary

  • severity: warning | error field on rules (defaults to error). Warning rules display results but do not cause pipeline failure.
  • Granular exit codes replace the old binary 0/1:
Code Meaning
0 All rules passed
1 One or more error-severity rules failed
2 Only warning-severity rules triggered (no errors)
3 Invalid rules file or schema mismatch
4 Data file not found or unreadable
  • Agents can branch on exit code without parsing stdout.
  • Table output gains a SEVERITY column.

Example

rules:
  - name: id_not_null
    column: id
    check: not_null
    severity: error      # blocks pipeline

  - name: phone_format
    column: phone
    check: regex
    pattern: '^\+?[\d\s\-]{7,15}$'
    severity: warning    # alerts but doesn't block

Test plan

  • Severity defaults to error when omitted from YAML
  • severity: warning and severity: error parse correctly
  • Warning rule with violations → Fail status + Warning severity in result
  • Error rule with violations → Fail status + Error severity
  • Mixed error+warning failures → exit code 1
  • Warning-only failures → exit code 2
  • All pass → exit code 0
  • Empty result set → exit code 0

🤖 Generated with Claude Code

- Adds `severity: warning | error` field to rules YAML (defaults to error)
- Warning rules print results but do not fail the pipeline
- Granular exit codes: 0=all pass, 1=error rule failed, 2=warning-only triggered, 3=invalid rules/schema, 4=file not found
- ExitCodeError wrapper propagates specific exit codes through anyhow error chain
- compute_exit_code() public function for testability
- Output table now includes SEVERITY column
- 37 tests total (4 in rules.rs, 3 in runner.rs, 7 in main.rs)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@SpollaL SpollaL merged commit 3d5a709 into master Apr 23, 2026
1 check failed
@SpollaL SpollaL deleted the feat/severity-and-exit-codes branch April 23, 2026 20: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