test(client,perf): make companion tunnel and perf-capture assertions discriminating

Merged
TH
6d ago
+224-125

Summary

Ships Area 1 of #3461 (test-quality fixes from #3429/#3432 reviews). Tests only; no production changes.

  • Close-code test (client-companion-tunnel-worker.test.ts): asserts each expected wire close per stream and adds a fractional 3500.5 bridge code. Since normalizeOutgoingCloseCode passes any 3000–4999 value through, this is the seam that makes normalizeCloseCode's non-integer rejection observable: dropping that guard now fails with 3500 ≠ 3001.
  • Teardown chain (client-metro-companion.test.ts): the seven chained scenarios became test.each cases, each with its own projectRoot, state file, pid, and outcome tables (previously case 7 reused case 6's state and pid). Mutation-checked individually: dropping EPERM-on-SIGTERM tolerance, the unreadable-command guard, the isProcessAlive early return, ESRCH-on-SIGKILL tolerance, or turning EACCES into a swallowed code each fails exactly its own case.
  • EPERM comment: path corrected to src/daemon/daemon-stop.ts (file verified; docs-only, no mutation).
  • Perf-capture kind rejection (platform-runtime-perf-capture-host.test.ts): asserts code: 'INVALID_ARGS' alongside the message. Flipping the producer to COMMAND_FAILED now fails the test.

Validation

Head 7f9500d0a. pnpm check:affected --run: passes locally under the machine lock. pnpm check:coverage-crap --all on the touched sources: no function at or above CRAP 30 (85.99% stmts). Per-check mutation evidence in the Summary; production tree restored clean after each.

Part of #3461
Part of #3414