Files
Dragan Spiridonov 4952d4eebe fix: remediate qe-court findings on the release diff (3 fatal + 4 significant)
A qe-court adversarial review (cross-vendor Codex GPT + AQE devils-advocate +
security prosecutors, filing blind) BLOCKED the release by catching edge cases the
green unit suite missed. All confirmed charges fixed:

FATAL:
- F1 codex.ts / claude-code.ts: no 'error' listener on child.stdin — an early
  child exit (not-logged-in path) raised an uncaught EPIPE that crashed the host.
  Added a stdin error guard + try/catch (both providers — same template bug).
- F2 db-recovery.ts: non-atomic copyFileSync + no lock let concurrent hook
  processes tear the restored memory.db. Now: copy to a temp on the same fs →
  atomic rename, under a best-effort exclusive lock (skip if a peer is restoring).
- F3 db-recovery.ts: isDbHealthy opened readonly + integrity_check, which
  FALSE-NEGATIVES a HEALTHY WAL db when -shm is zeroed over virtiofs — the exact
  target failure mode — and would have parked the good DB + reverted to an older
  backup (silent data loss). Now the live-corruption signal is the SQLite HEADER:
  a -wal/-shm fault never corrupts the main file, so a header-valid DB is treated
  healthy and NEVER parked. Backups still get a full integrity_check before use.

SIGNIFICANT:
- spend-ledger.ts: a swallowed ALTER migration made every INSERT hit a missing
  column, throw, get caught, and silently drop ALL spend → budget-cap bypass.
  record() now tracks whether the column exists and INSERTs accordingly (spend is
  always recorded; attribution degrades gracefully).
- witness-verify.ts: verifyAqeReceipt was fail-OPEN under an empty allowlist (the
  default state) — a self-signed forgery returned valid:true. Now fail-closed
  ('no-trust-root') unless an explicit allowSelfSigned opt-in; harness path asserts
  alg==='ed25519'; unparseable allowlist JSON now logs loudly.
- gate-reexecute.ts accept/v1+sig: enforce a minimum paired-sample size (n>=8 —
  below it a "95% CI" is just the raw delta) and assert mean(samples)==sealed
  scalar (defends against a forged scalar/vector pairing).

Verified: qe-court acceptance eval 100%; 1498 shared/validation/llm/flywheel tests
pass (incl. new F2/F3 regressions, fail-closed, alg, min-n, consistency cases);
tsc clean; build green. Deferred (non-blocking rough edges, noted in the court
record): codex maxTokens/temperature passthrough, healthCheck-while-logged-out,
semaphore microtask race, stableStringify byte-parity (needs a real qe-harness sample).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-18 15:33:38 +00:00
..