Files
Michał Pierzchała d6d2e09529 test(kernel): cover all six errors.ts exports, kernel-errors mutation 55.19% → 86.26% (#1475)
* test(kernel): cover all six errors.ts exports with table-driven cases (#1456)

Extends errors.test.ts beyond normalizeError/toAppErrorCode:
- AppError construction and NormalizedError/AppError instanceof contract
- asAppError identity/wrap/duck-typing behavior (cross-realm errors,
  non-Error throws, fallback code precedence)
- isAgentDeviceError real-instance-only contract
- retriableForErrorCode and defaultHintForCode, table-driven over
  KNOWN_APP_ERROR_CODES (the module's own source of truth) rather than a
  hand-copied code subset
- normalizeAgentDeviceError delegation to normalizeError
- a cross-cutting composition test asserting the retriable/hint contract
  request-router.ts's enrichDaemonError and the CLI's printHumanError
  actually rely on

No production changes; mutation re-run and PR to follow.

* test(kernel): pin maybeEnrichCommandFailedMessage gating and regex boundaries (#1456)

Adds targeted cases for branches the table-driven/contract tests didn't
reach: the COMMAND_FAILED/processExitError/string-stderr gating in
maybeEnrichCommandFailedMessage, GENERIC_EXIT_MESSAGE's `-?\d+$` boundary
(negative code, trailing text, non-numeric code, whitespace in the tool
token), and STDERR_NOISE_PREFIX's zero-or-more-whitespace semantics for
both the adb/xcrun/simctl and "error:" groups.

* test(kernel): close remaining mutation gaps in firstStderrLine/detail helpers (#1456)

Each addition here was verified against a hand-applied mutation (matching
Stryker's actual survivor diffs) before landing, confirming it fails on
the mutant and passes on the original:

- firstStderrLine: line-trim-before-prefix-match (a real skip-pattern
  line ahead of the leading-whitespace one is required, since
  redactDiagnosticData already .trim()s the whole stderr string once
  before firstStderrLine ever sees it), and the >200-char truncation
  branch (both sides of the boundary: 200 exact vs 201+).
- stringDetail/booleanDetail: reject a wrong-typed diagnosticId/logPath/
  hint/retriable instead of surfacing it.
- stripDiagnosticMeta: details drops to undefined once stripping the
  known meta keys leaves nothing behind.

* style(kernel): apply oxfmt to errors.test.ts

Fixes the Lint & Format CI failure on PR #1456 — format:check flagged
this file, oxfmt --write resolves it with no behavior change.

* test(kernel): split errors.test.ts into focused sibling suites (#1456)

Per review feedback: the growing errors.test.ts hit 601 lines, past
AGENTS.md's extract-before-500 threshold (tests are not exempt). Splits
along the reviewer's requested seams, moving tests verbatim with no
assertion changes:

- errors-message.test.ts (234 lines) — stderr/message normalization:
  maybeEnrichCommandFailedMessage, firstStderrLine, the
  GENERIC_EXIT_MESSAGE/STDERR_NOISE_PREFIX regex boundaries.
- errors-metadata.test.ts (157 lines) — hint/diagnosticId/logPath/
  retriable/supportedOn lifting and stripping, divergence passthrough,
  the stringDetail/booleanDetail/stripDiagnosticMeta type-guard
  contracts, and the normalizeError/retriableForErrorCode/
  defaultHintForCode cross-cutting contract.
- errors-code-policy.test.ts (228 lines) — AppError construction,
  asAppError/isAgentDeviceError duck-typing contract, toAppErrorCode,
  the retriableForErrorCode/defaultHintForCode table-driven policy
  tests, and normalizeAgentDeviceError.

Also repoints scripts/mutation/ownership.test.ts's two references to
the deleted errors.test.ts path at errors-code-policy.test.ts — the
mutation ownership deriver reads the file from disk to follow its
import graph, so a stale path silently resolves to "owns nothing"
instead of failing loudly.

---------

Co-authored-by: Claude <noreply@anthropic.com>
2026-07-28 20:06:03 +02:00
..