Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
test(resources): bound delayed marker waits [C7]
Corey Olson79820ec21d75
diff --git a/test/resources-verify-fixture.js b/test/resources-verify-fixture.jsindex 0936d107..9d45705a 100644--- a/test/resources-verify-fixture.js+++ b/test/resources-verify-fixture.js@@ -27,7 +27,11 @@ export function checkProject(box) {runFixtureGit(['add', '-A'], { cwd: repo, env: box.env });runFixtureGit(['-c', 'core.hooksPath=/dev/null', '-c', 'user.name=Resource fixture', '-c', '[email protected]', 'commit', '-q', '-m', 'fixture: initialize board'], { cwd: repo, env: box.env });const base = runFixtureGit(['rev-parse', 'HEAD'], { cwd: repo, env: box.env });- writeFileSync(join(repo, 'test/cpu-check.test.js'), `import { writeFileSync } from 'node:fs';\nimport { test } from 'node:test';\ntest('item check marker', () => writeFileSync('item-check-started', 'started'));\ntest('submit check marker', () => writeFileSync('submit-check-started', 'started'));\n`);+ const markerDelayText = process.env.PULLBOARD_TEST_RESOURCE_MARKER_DELAY_MS ?? '0';+ assert.ok(markerDelayText === '0' || markerDelayText === '15000',+ 'PULLBOARD_TEST_RESOURCE_MARKER_DELAY_MS must be 0 or 15000');+ const markerDelayMs = Number(markerDelayText);+ writeFileSync(join(repo, 'test/cpu-check.test.js'), `import { writeFileSync } from 'node:fs';\nimport { test } from 'node:test';\nconst delay = ${markerDelayMs};\nconst mark = async path => { if (delay) await new Promise(resolve => setTimeout(resolve, delay)); writeFileSync(path, 'started'); };\ntest('item check marker', () => mark('item-check-started'));\ntest('submit check marker', () => mark('submit-check-started'));\n`);runFixtureGit(['add', 'test/cpu-check.test.js'], { cwd: repo, env: box.env });runFixtureGit(['-c', 'core.hooksPath=/dev/null', '-c', 'user.name=Resource fixture', '-c', '[email protected]', 'commit', '-q', '-m', 'test: add CPU check'], { cwd: repo, env: box.env });return { repo, base };diff --git a/test/resources.test.js b/test/resources.test.jsindex 2bcf8574..9c83f26b 100644--- a/test/resources.test.js+++ b/test/resources.test.js@@ -102,22 +102,38 @@ function fixture() {}/** Wait for a fixture command to create a marker file, with a hang ceiling only for failure. */-function waitForMarker(path, timeoutMs = 10_000) {+function waitForMarker(path, timeoutMs = 60_000) {if (existsSync(path)) return Promise.resolve();- const watcher = watch(dirname(path), { persistent: false });+ const watcher = watch(realpathSync(dirname(path)), { persistent: false });return new Promise((resolveMarker, rejectMarker) => {- const timer = setTimeout(() => rejectMarker(new Error(`timed out waiting for ${path}`)), timeoutMs);- const check = () => {- if (!existsSync(path)) return;+ let settled = false;+ let timer;+ let poller;+ /** Release the deadline, fallback poller, and watcher together. */+ const cleanup = () => {clearTimeout(timer);+ clearInterval(poller);watcher.close();- resolveMarker();};- watcher.on('error', error => { clearTimeout(timer); rejectMarker(error); });+ /** Settle the marker promise once and always release its observers. */+ const finish = (error) => {+ if (settled) return;+ settled = true;+ cleanup();+ error ? rejectMarker(error) : resolveMarker();+ };+ /** Check for the marker after a watch event or bounded poll interval. */+ const check = () => {+ if (!existsSync(path)) return;+ finish();+ };+ timer = setTimeout(() => finish(existsSync(path) ? null : new Error(`timed out waiting for ${path}`)), timeoutMs);+ poller = setInterval(check, 100);+ watcher.on('error', finish);watcher.on('change', check);watcher.on('rename', check);check();- }).finally(() => watcher.close());+ });}/** Create the previous private queue schema so simultaneous openers exercise its migration. */@@ -354,7 +370,7 @@ async function requeuedRemoteRun(queue) {}/** Read the next worker event, failing promptly with its stderr if it exits unexpectedly. */-async function event(child, timeoutMs = 10_000) {+async function event(child, timeoutMs = 60_000) {if (child.pendingLines.length) return JSON.parse(child.pendingLines.shift());if (child.exitResult) throw new Error(child.failure ?? `worker exited ${child.exitResult.code}/${child.exitResult.signal}: ${child.errors}`);const line = await new Promise((resolveLine, reject) => {@@ -544,6 +560,7 @@ test('browser-free checks skip the slot only when the machine allows it [C7]', aconst browserHolder = poolWorker(box, { agent: `policy-browser-${String(value)}`, browser: true, item: '681', kind: 'gate' });await acquired(browserHolder);const started = waitForMarker(marker);+ const startedOutcome = started.then(() => null, error => error);const resultPromise = runFixtureChildAsync(process.execPath, [BIN, 'check', String(item), '--yes'], { cwd: repo, env: box.env });let result;try {@@ -561,6 +578,7 @@ test('browser-free checks skip the slot only when the machine allows it [C7]', aresult = await resultPromise;}assert.equal(result.status, 0, result.failure ?? result.stderr);+ assert.equal(await startedOutcome, null, 'the check marker observer settles and closes');assert.equal(readFileSync(marker, 'utf8'), 'started');}