Skip to content

test(ep0f): registry hermetic classifier mock + logger timeout diagnostics (kata ep0f) - #675

Merged
danshapiro merged 11 commits into
mainfrom
the-usual/ep0f-deflake
Aug 22, 2026
Merged

test(ep0f): registry hermetic classifier mock + logger timeout diagnostics (kata ep0f)#675
danshapiro merged 11 commits into
mainfrom
the-usual/ep0f-deflake

Conversation

@danshapiro

Copy link
Copy Markdown
Owner

Summary

Root-cause fixes for two of the five test-hygiene load-flake families tracked as kata ep0f's timing-pin class (observed under host load 54–94 across four full-suite executions during the rust-sidecar-sdk-0-3 gate campaign). Test-files only; zero production changes.

logger.separation — exit-before-flush race

The three tsx -e probes ended setTimeout(() => process.exit(0), 25|50), which races rotating-file-stream's lazy open + async first write. Measured under induced load ~90: logger.ts import takes 368ms; its 'Resolved debug log path' record lands at 390ms — a ~15× overshoot of the 25ms exit window; historical passes survived on ~3ms of luck. On a miss the record can never land, and waitForFileContent treats empty as not-yet, burning its full 30s gate on an impossible condition.

  • Probes now self-poll their own resolveDebugLogPath() target and process.exit(0) only once their expected content is on disk (cap 10s; PROBE-FATAL via synchronous fs.writeFileSync(2, …) + exit(1) otherwise).
  • waitForFileContent timeout errors now include the logDir listing with per-file sizes and the probes' captured stdout/stderr.
  • All five tests assert probe exitCode === 0 and absence of PROBE-FATAL after content waits; the multi-probe waits run concurrently.

terminal-registry :3317 — real worker spawn + 12.5 GB DB inside a 1s window

vi.waitFor's default budget (interval 50ms / timeout 1000ms, Vitest 3.2.4) wrapped a REAL fire-and-forget classification: nested node:worker_threads spawn opening the host's 12.5 GB opencode.db. Measured 222ms idle / 638ms loaded (single-shot) against the 1000ms cap. CI containers lack the DB + fast path, so the flake was dev-host specific.

  • File-wide vi.mock('../../../server/coding-cli/providers/opencode-subagent-query.js') mirroring the two sibling test files; mockResolvedValue(false) in a describe-local beforeEach (the outer describe's vi.resetAllMocks() wipes factory-set implementations — the trap is documented in the test).
  • Stale 'no opencode.db here' comment corrected; the misleading "both directions" test renamed to its true child→root scope (real both-directions coverage stays in terminal-registry.rebind-metadata-resync.test.ts; real classifier coverage in opencode-subagent-query.test.ts).
  • Sibling header comment in bind-reclassify-guard.test.ts reworded to match.

Verification

  • RED: neither flake reproduced in 15 loaded iterations (load 74–91); fallback ladder used: kata-recorded failures + captured margin measurements + live zero-files reproduction of the mechanism.
  • GREEN under induced load (48 detached CPU burners, load 74–94): registry focused ×50, registry full-file ×5, logger full-file ×20, sibling files ×3 each, combined back-to-back pass.
  • Failure branches exercised as one-off manual receipts (PROBE-FATAL marker delivery + rc=1; diagnostics branch forced inside the real harness then reverted).
  • Coordinated full-suite gate: cloud backend, green at the test-file HEAD 42085e4b8; the three later commits are plan-doc-only.
  • Failure-mode discovery filed as kata zqz3 (uncreatable FRESHELL_LOG_DIR → infinite rfs mkdir retry starving the event loop) — found via strace while generating receipts, explicitly out of scope here.
  • Kata f884 filed: nothing lint/typechecks test/** today.

Review journey (the-usual-beta)

  • Plan loop: FAILED/non-converged at its 3-round cap; all 13 findings (Majors incl. a phantom-GREEN criterion and a silently-degrading vitest CLI form mistake) dispositioned with committed plan repairs.
  • Delta loop: PASSED at round 3 (r1/r2 Majors repaired; each repair episode passed the beta focused-recheck loop).
  • Recap with full receipts: .worktrees/.the-usual-logs/ep0f-deflake/recap.md.

Kata ep0f stays open for the three remaining families (remote-proxy, opencode-serve-manager, codex-session-flow).

…2 pid lifecycle, M3 honest test typecheck, M4 observable PROBE-FATAL GREEN, m1 backend truth, m2 waitFor wording)
…check claim, rename misleading test name, PROBE-FATAL via sync fd write + reachable observability)
…n focused loops, rename-surviving -t selector, per-test captured output, narrowed success criterion 5); plan loop ends at cap FAILED/non-converged
… kills real 12.5GB-DB worker spawn inside vi.waitFor 1s window (kata ep0f)
…utput on content-wait timeouts (kata ep0f; re-applied onto #674's durable-receipt version)
…l durable receipt); branch rebased onto it
@danshapiro
danshapiro force-pushed the the-usual/ep0f-deflake branch from 9df7dad to f914a01 Compare August 22, 2026 07:21
@danshapiro danshapiro changed the title test(ep0f): root-cause two load flakes — logger probe exit-before-flush + registry hermetic classifier mock test(ep0f): registry hermetic classifier mock + logger timeout diagnostics (kata ep0f) Aug 22, 2026
@danshapiro
danshapiro merged commit 530f5f3 into main Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant