Commit Graph

1 Commits

Author SHA1 Message Date
kshitijk4poor
171038d4bc feat(code-health): HX014 ratchet against private API-error predicates
The aux, compressor and turn paths each grew "is this a <kind> error?"
helpers that read an exception's status_code or grep its text; every
copy drifted from classify_api_error until the previous commit moved
the aux decisions onto the shared classifier. HX014 keeps new copies
out.

What it flags: a def or lambda with an exception parameter (exc/err/
error/e/ex/exception, *_err/*_error/*_exc, or an *Exception/*Error
annotation; a ClassifiedError parameter is not one) whose own body reads
<param>.status_code (also via getattr or .response) or probes the
exception's text (`in str(exc)`, a local bound to that text,
startswith/endswith, re.search/match/fullmatch, _contains_any). Scope:
agent/auxiliary*.py, agent/context_compressor*.py, agent/turn_*.py,
tests excluded.

Like the other HX rules it ratchets base vs head, so existing hits are
grandfathered. Waiver: `# health: allow HX014 -- <why>`.

Tests: tests/scripts/test_code_health_error_predicate_rule.py covers
flagged and passing shapes, scope and the base-vs-head verdict.

Part of the Code Health plan.
2026-11-08 13:18:54 +05:30