Repository navigation
test(compaction): stub the in-handler pre-route prime so Windows teardown can remove CODEX_HOME - #7091
Conversation
…pool block (Windows EBUSY)
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
✅ Deterministic PR hygiene checks passed. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
* fix(test-teardown): settle un-awaited background work before removing a tree The pre-route pool quota prime runs without being awaited and holds the native-main claim database open across ACL hardening and a WHAM read. Teardown retried removal with Bun.sleepSync, which blocks the event loop the prime needs to reach its finally, so on Windows every retry failed EBUSY until the 15 s budget ran out (#7088 and #7091 stubbed the prime per test). Track fire-and-forget work in src/lib/background-work, register the pool prime and its lazy-import callers, settle it in a global afterEach, and add removeTreeAfterBackgroundWork (settle, reap icacls, then retry with waits that yield). The compaction fixture uses it, and the per-test prime stubs from #7088 and #7091 are reverted so the real prime runs again. * fix(responses): serialize snapshot follow-up scheduling with shutdown * fix(config): track the config-dir ACL harden as background work icacls holds the config directory open while it runs; a config write or removal that lands on it before the child exits fails with a sharing violation on Windows. Registering the flight lets the per-case drain settle it, and the V2 refusal test now prints the CLI errors when the handler refuses before the native toggle. * fix(cli): reject occupied auxiliary ports before private startup work * fix(tray): retain timed-out probes until asynchronous reaping Remove WaitForExit from startup-health timeout ticks and retain process ownership until exit and both readers settle. Run lifecycle fixtures with the production Bun engine instead of a nested PowerShell cold start, which failed readiness before maintenance in Windows run 38503986851. * fix(config): preserve Windows ACL memo across repeated reads * test: bound child exit and pipe waits in slow-spawn cases * fix(ci): share one transpiler cache per shard; widen the DPAPI PowerShell bound Run 2 and 3 of the Windows proof failed on first-spawn timeouts (writeJournal child 40s, launcher attest 15s) and a 10s DPAPI PowerShell call. Each CI batch is its own bun test process, and with BUN_RUNTIME_TRANSPILER_CACHE_PATH unset the preload gives every batch an empty private cache, so the first child each batch spawns re-transpiles its whole module graph. The batch runner now creates one private cache per shard and exports it. The DPAPI helper's PowerShell bound moves from 10s to 20s: it is async and off the request path, and a cold PowerShell loading System.Security exceeded 10s on a loaded runner. * test(desktop-egress): give each proxy variable one spelling on Windows Windows environment names are case-insensitive, so the child env that set ALL_PROXY to the fixture proxy and all_proxy to "" defined one variable twice. Env-block ordering decided the winner; adding the shard transpiler cache variable flipped it, and the -all cases reached the real chatgpt.com (403). Clear every spelling and set only the intended route. * fix(test-teardown): never remove or exit under live tracked work; address review findings - removeTreeAfterBackgroundWork keeps the tree and names pending work instead of deleting under a live writer. - Final sandbox cleanup bounds background-work settlement (15 s) and leaves the root for stale recovery with the labels when work never settles. - spawnTestChild rejects when the child never started (ENOENT) instead of resolving an empty result. - Auxiliary preflight rejects loopback and hub management configured on one port. - Tray shutdown keeps a probe tracked until it has actually exited and waits for its pipe readers before disposal. - The free-socket preflight test binds inside try so a lost race still stops the first server. --------- Co-authored-by: jun <jun@juns-Mac-Studio.local>
Summary
Windows CI on
dev(run 38507644375, windows 4/9) still failedtests/responses/responses-compaction-routing.test.tsafter #7088, withEBUSY: resource busy or locked, rm ...ocx-compact-connect-probe-*. The failing case spent its entire 15 s removal retry budget.The cause is the pre-route quota prime that
resolveCodexAuthContextstarts and does not await insidehandleResponsesCompact. #7088 stubbed only the second, explicitresolveCodexAuthContextcall. The prime reachesprimeMain→withNativeMainSharedClaim→openClaimDatabase, which opens.opencodex-native-main.claim.sqliteunder the case'sCODEX_HOMEand then awaitshardenStableLockFile. On win32 that call is async ACL hardening. Teardown removes the directory withremoveTestTempTree, whose retries sleep withBun.sleepSync. Because that blocks the event loop, the hardening can never finish and close the file, so every retry hits the Windows sharing violation (EBUSY). The prime is single-flight across cases, so the failure moves to whichever case is tearing down while the prime runs.The fix is test-only. The
native Codex pool compactionblock now stubsprimeCodexPoolQuotasonsrc/codex/auth-api, the module the lazyimport("./auth-api")resolves through, in abeforeEach/afterEachpair. None of the three cases asserts on priming. This is not a product leak, because in a running proxy the prime finishes andreleaseClaimcloses the file. It only becomes a problem when a synchronous teardown starves it.Verification
hardenStableLockFileby 500 ms and checkinglsofat teardown (instrumentation reverted): before the fix,.opencodex-native-main.claim.sqlitewas still open after the spend lease dropped. After the fix, nothing under the case directory is open, and the spy records the interceptedpre-routeprimes (3 in the Spark case, 1 in each Reset-derived 429 in an OpenAI combo blocks same-account fallback models #590 case).bun test tests/responses/responses-compaction-routing.test.ts: 124 pass / 0 fail, three consecutive runs.bun run typecheck: clean.bun test tests/ci-workflows/file-size-ratchet.test.ts: 9 pass (file at 2667 lines, cap 2776).bun run privacy:scan: passed.bun run test. The change is confined to one test file's setup, so the focused file plus the ratchet covers it. Windows itself is left to the next cross-platformworkflow_dispatch, because PRs run only the Ubuntu subset.Checklist
Summary by CodeRabbit