From 15d3c0dde211b14109ba97a1ffb0790c1054f6f7 Mon Sep 17 00:00:00 2001 From: JUN <243035832+lidge-jun@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:25:42 +0900 Subject: [PATCH 1/3] test(config): publish the overlap fixture after the recheck budget is spent The 500ms case raced a fixed sleep against the overlapping loader's rechecks and failed on a loaded macOS runner (dev batch 40824593871). --- tests/config/config-removed-opencode-free.test.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/config/config-removed-opencode-free.test.ts b/tests/config/config-removed-opencode-free.test.ts index 1e2dd2de2d4..dfb041650c2 100644 --- a/tests/config/config-removed-opencode-free.test.ts +++ b/tests/config/config-removed-opencode-free.test.ts @@ -440,6 +440,7 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms const home = createTempHome("ocx-recovery-overlap-"); const ready = home.path("publisher-ready"); const release = home.path("publisher-release"); + const exhausted = home.path("recheck-budget-spent"); const backup = `${getConfigPath()}.pre-opencode-free-removal.bak`; const module = pathToFileURL(repoPath("src/config.ts")).href; const bytes = Buffer.from(JSON.stringify({ ...getDefaultConfig(), providers: { "opencode-free": {} } })); @@ -455,7 +456,15 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms if (Date.now() >= until) throw new Error('publisher release timed out'); Bun.sleepSync(5); } - Bun.sleepSync(${delay}); + // The long case publishes only once the overlapping load has spent its whole recheck budget. + // A fixed sleep raced the rechecks on loaded runners (dev batch 40824593871, macOS). + if (${delay} === 500) { + const spent = Date.now() + 20000; + while (!real.existsSync(${JSON.stringify(exhausted)})) { + if (Date.now() >= spent) throw new Error("recheck budget never spent"); + Bun.sleepSync(5); + } + } else Bun.sleepSync(${delay}); } }})); const { loadConfig } = await import(${JSON.stringify(module)}); if (loadConfig().providers['opencode-free']) throw new Error('retired provider retained');`; @@ -472,6 +481,7 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms Bun.sleepSync = ms => { if (ms !== 10 || ++retries > 9) throw new Error('unbounded recovery recheck'); if (retries === 1) fs.writeFileSync(${JSON.stringify(release)}, 'release'); + if (retries === 9) fs.writeFileSync(${JSON.stringify(exhausted)}, 'spent'); sleep(ms); }; const { loadConfig } = await import(${JSON.stringify(module)}); if (loadConfig().providers['opencode-free']) throw new Error('retired provider retained'); From aa4e3c5d5e358be509373d737bc1f7459c7fb32e Mon Sep 17 00:00:00 2001 From: JUN <243035832+lidge-jun@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:35:26 +0900 Subject: [PATCH 2/3] test(config): release the overlap publisher only after every recheck Writing the marker before the ninth recheck could let the publisher finish during that sleep; it is now written after loadConfig returns and the retry count is asserted. --- tests/config/config-removed-opencode-free.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/config/config-removed-opencode-free.test.ts b/tests/config/config-removed-opencode-free.test.ts index dfb041650c2..2d36600f7a0 100644 --- a/tests/config/config-removed-opencode-free.test.ts +++ b/tests/config/config-removed-opencode-free.test.ts @@ -481,11 +481,12 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms Bun.sleepSync = ms => { if (ms !== 10 || ++retries > 9) throw new Error('unbounded recovery recheck'); if (retries === 1) fs.writeFileSync(${JSON.stringify(release)}, 'release'); - if (retries === 9) fs.writeFileSync(${JSON.stringify(exhausted)}, 'spent'); sleep(ms); }; const { loadConfig } = await import(${JSON.stringify(module)}); if (loadConfig().providers['opencode-free']) throw new Error('retired provider retained'); - if (retries === 0 || (${delay} === 500 && retries !== 9)) throw new Error('overlap schedule missed');`; + if (retries === 0 || (${delay} === 500 && retries !== 9)) throw new Error('overlap schedule missed'); + // Release the publisher only after every recheck observed the held original. + fs.writeFileSync(${JSON.stringify(exhausted)}, 'spent');`; second = Bun.spawn([process.execPath, "--eval", secondScript], { env: { ...process.env }, stdout: "ignore", stderr: "pipe" }); expect(await second.exited).toBe(0); writeFileSync(release, "release"); From e984d2fee1bd73610174ddfac3667beac188c5a9 Mon Sep 17 00:00:00 2001 From: JUN <243035832+lidge-jun@users.noreply.github.com> Date: Thu, 29 Oct 2026 15:46:47 +0900 Subject: [PATCH 3/3] test(config): fail the overlap case when a publisher wait expires Both waits ran inside the mocked linkSync, so a thrown timeout was caught by backupOriginal and the case could still pass. The publisher now exits nonzero instead. --- tests/config/config-removed-opencode-free.test.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/config/config-removed-opencode-free.test.ts b/tests/config/config-removed-opencode-free.test.ts index 2d36600f7a0..9d0ff78fc8b 100644 --- a/tests/config/config-removed-opencode-free.test.ts +++ b/tests/config/config-removed-opencode-free.test.ts @@ -453,7 +453,8 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms paused = true; real.writeFileSync(${JSON.stringify(ready)}, 'ready'); const until = Date.now() + 20000; while (!real.existsSync(${JSON.stringify(release)})) { - if (Date.now() >= until) throw new Error('publisher release timed out'); + // Exit, not throw: backupOriginal would catch a throw from linkSync and let the case pass. + if (Date.now() >= until) process.exit(2); Bun.sleepSync(5); } // The long case publishes only once the overlapping load has spent its whole recheck budget. @@ -461,7 +462,7 @@ test.each([5, 500])("overlapping loads preserve protected originals with a %i ms if (${delay} === 500) { const spent = Date.now() + 20000; while (!real.existsSync(${JSON.stringify(exhausted)})) { - if (Date.now() >= spent) throw new Error("recheck budget never spent"); + if (Date.now() >= spent) process.exit(3); Bun.sleepSync(5); } } else Bun.sleepSync(${delay});