test(client): cover the out-of-process CRAP functions through their public seams

Merged
TH
8d ago
+730-164

Summary

Closes #3415, part of the umbrella burn-down #3414.

Five out-of-process functions sat above the CRAP threshold. Each is now reached through its module's public entry point — no new production exports, no test-only injection:

FunctionCRAP beforeafter
readWorkerOptions11010
normalizeCloseCode46.911
parseDevicePort305
handleBridgeHttpRequest305
stopCompanionProcess44.211

Two findings are exempted rather than covered, because no test can move the number:

  • packages/platform-web/src/agent-browser-audio-probe.ts (7 fns) — the functions are serialized into a string evaluated inside the browser page, so Node coverage never records them.
  • packages/capture-kit/src/png-worker.ts (runJob) — Vitest v8 coverage does not merge node:worker_threads coverage; it measures 0% however much of the worker runs.

Instead of covering runJob, png-worker-client.test.ts now proves each job kind really runs off-thread: a pending job ref()s the worker, so process.getActiveResourcesInfo() reports a MessagePort, which the silent sync fallback cannot produce.

Exemptions use health.thresholdOverrides in fallow-crap.json, which is CRAP-scoped, so complexity findings stay with check:fallow.

Validation

  • check:coverage-crap --all → no function at or above 30; --base origin/main → clean
  • check:fallow --base origin/main → no issues in the changed files
  • check:affected --run on the pushed SHA → all runnable checks passed
  • tsc -b, oxlint, pnpm format clean