Repository navigation
test(storage): wait for native-main startup before comparing the storage scan - #8819
Conversation
…age scan GET /api/storage compares the endpoint's scan with a filesystem inventory taken right after it. Native-main startup takes its CODEX_HOME owner lock and runs its first exclusive claim in the background after startServer() returns; on Windows the lock's ACL hardening is a subprocess. In dev batch run 43818098370 the owner journal (512 bytes) and the empty claim database landed between the scan (666 bytes, 4 files) and the inventory (1178 bytes, 6 files). The test now awaits waitForNativeMainStartupGate(), which resolves only after owner acquisition and the first claim, before scanning, and asserts the tree did not change while the endpoint scanned it. Exact equality and the allowed coordination-file list are unchanged. Refs dev batch run 43818098370.
Codex Review Summary: ✅ CompletedThis 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. Walkthrough
Merge Risk:
|
|
Maintainer integration of #8819 at 927004d. This repairs the windows 5/14 failure in dev batch run 43818098370 (f329892):
The other red shard in that run, windows 13/14 ( Next step: one batched |
Summary
tests/storage/api-storage.test.ts> "returns the scan report with buckets and totals, no error field" failed onwindows 5/14in dev batch run 43818098370 at f329892. The endpoint's scan reported{bytes: 666, fileCount: 4}and the inventory taken right after it{bytes: 1178, fileCount: 6}.Cause.
startServer()starts the native-main lifecycle, which acquires the CODEX_HOME owner lock and runs its first exclusive claim in the background afterstartServer()returns:prepareOwnerDatabasecreates the empty.opencodex-native-main.owner.sqlite, then awaitshardenStableLockFile. On Windows that hardening is an ACL subprocess (hardenSecretPathAsync).BEGIN IMMEDIATE, which leaves.opencodex-native-main.owner.sqlite-journalat 512 bytes.convergeOwnedStartuprunswithNativeMainExclusiveClaim, which creates the empty.opencodex-native-main.claim.sqlite.The scan saw the fixtures,
config.toml(46 bytes) and the empty owner database. The inventory also saw the owner journal and the claim database, which is exactly +2 files and +512 bytes. Both files are in the test's allowed list. The product behaves as intended: this server syncs Codex, so it owns the native-main lock. Only the test raced that startup.Fix. Before scanning, the test now awaits
waitForNativeMainStartupGate(), the settle point other server tests already use. It resolves only after owner acquisition, recovery and the first claim. After it, the next CODEX_HOME writer is the 60-second stage sweep, and on a fresh home that sweep creates nothing. The test also asserts that the inventory taken after settling equals the one taken after the scan. Exact equality withbody.totaland the allowed coordination-file list are unchanged.Not caused by this batch. In
git log e792c9dce4..f329892401 -- src/codex src/server/index.ts src/storagethe only commit is b378a43 (#8766). Of the owner, claim and lock-file code it changes onlynative-main-owner.ts, adding apublish()hook that ends retention on ownership loss. It creates no file and changes no timing. The awaited hardening that opens this window has existed since 6b9f734 (2026-08-06). The same test passed in the seven earlier failing dev batch runs I checked (43790630995 back to 43451726885), so this is the first observation. Inferred, not proven: the trigger is Windows runner timing.Refs dev batch run 43818098370.
Verification
nativeMainStartup.owner.hardenPathseam and paused 600 ms between the scan and the inventory, matching the CI timing.666/4vs1178/6).oven/bun:1.4.4container):bun test tests/storage/api-storage.test.tspassed 20/20. A probe in the same container confirmed the gate settlesreadywith the owner database, owner journal and claim database present, so the owned path ran./usr/bin/lockf -k /tmp/ocx-test.lock).bun run typecheck: no type errors.bun test tests/test-layout.test.ts tests/test-layout-tooling.test.tspassed, as didtests/ci-workflows/file-size-ratchet.test.tsandbun run structure:check.bun run test), because the local host is under heavy load. That coverage, and the Windows shard, is left to CI:ci:fullon this PR runs the four Ubuntu shards, and Windows needs the nextlane=allbatch ondev.Checklist
Summary by CodeRabbit