Skip to content

feat(middleware): implement ErrorClassifier (#22)#23

Merged
alexey-pelykh merged 1 commit intomainfrom
feat/error-classifier
Feb 25, 2026
Merged

feat(middleware): implement ErrorClassifier (#22)#23
alexey-pelykh merged 1 commit intomainfrom
feat/error-classifier

Conversation

@alexey-pelykh
Copy link
Copy Markdown

Summary

  • Implement regex-based error classifier that maps CLI subprocess stderr output to actionable error categories
  • Export ErrorCategory type (retryable | fatal | context_overflow | timeout | aborted) and classifyError() pure function
  • First-match-wins semantics: retryable → context_overflow → fatal_auth → default fatal
  • 50 tests covering all pattern categories, case insensitivity, default behavior, first-match-wins ordering, and type completeness

Closes #22

Test plan

  • All retryable patterns classified correctly (rate limit variants, 429, 503, overloaded, network errors)
  • All context overflow patterns classified correctly (context length/window/overflow, token limits)
  • All fatal auth patterns classified correctly (401, 403, unauthorized, forbidden, invalid key, authentication)
  • Unknown/empty strings default to fatal
  • Case-insensitive matching verified
  • First-match-wins ordering verified
  • timeout and aborted in type but never returned by classifier
  • pnpm check passes (format + typecheck + lint)
  • Full test suite passes (13043 tests)

🤖 Generated with Claude Code

…tegorization (#22)

Pure function module that maps CLI subprocess stderr output to actionable
error categories (retryable, context_overflow, fatal) using first-match-wins
semantics across ordered regex pattern arrays.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
@alexey-pelykh alexey-pelykh merged commit 783525d into main Feb 25, 2026
2 checks passed
@alexey-pelykh alexey-pelykh deleted the feat/error-classifier branch February 25, 2026 22:30
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.

Implement ErrorClassifier

1 participant