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
fix(gate): a new pool's setup waits out files opening it together [C7]
Corey Olson36130fa0c854
diff --git a/src/test-file-pool.js b/src/test-file-pool.jsindex 206ae7ed..2d1d90c3 100644--- a/src/test-file-pool.js+++ b/src/test-file-pool.js@@ -26,6 +26,8 @@ export const TEST_FILE_CORES_ENV = 'PULLBOARD_TEST_FILE_CORES';// free, or once a second to prune rows of processes that have gone.const POLL_MS = 25;const PRUNE_MS = 1_000;+// Budget: a new pool's one-time setup waits out other files setting it up this long before it fails.+const SETUP_LOCK_MS = 10_000;/*** Read the pool a test-file process belongs to, or null outside a run-tests run.@@ -79,17 +81,28 @@ async function openPool(home) {mkdirSync(home, { recursive: true });const DatabaseSync = await databaseSync();const db = new DatabaseSync(join(home, 'test-file-pool.sqlite'));- db.exec(`PRAGMA busy_timeout = 10000;- PRAGMA journal_mode = WAL;+ db.exec('PRAGMA busy_timeout = 10000');+ // Switching a new pool to WAL takes an exclusive lock that SQLite may refuse at once, without the busy wait,+ // when many files open the same new pool together; wait the lock out like any other.+ for (let deadline = Date.now() + SETUP_LOCK_MS; ; await new Promise(next => setTimeout(next, POLL_MS))) {+ try { db.exec('PRAGMA journal_mode = WAL'); break; }+ catch (error) { if (!/locked|busy/iu.test(error.message) || Date.now() > deadline) throw error; }+ }+ db.exec(`PRAGMA synchronous = NORMAL;CREATE TABLE IF NOT EXISTS file_holder(pid INTEGER PRIMARY KEY, since INTEGER NOT NULL, lender INTEGER);CREATE TABLE IF NOT EXISTS file_waiter(ticket INTEGER PRIMARY KEY AUTOINCREMENT, pid INTEGER NOT NULL UNIQUE);CREATE TABLE IF NOT EXISTS file_call(call TEXT PRIMARY KEY, lender INTEGER NOT NULL, closing INTEGER NOT NULL DEFAULT 0);`);// A pool made by an earlier build of this module gains the columns it lacks; a missing value reads as none.- const columns = table => db.prepare(`PRAGMA table_info(${table})`).all().map(column => column.name);- if (!columns('file_holder').includes('lender')) db.exec('ALTER TABLE file_holder ADD COLUMN lender INTEGER');- if (!columns('file_holder').includes('call')) db.exec('ALTER TABLE file_holder ADD COLUMN call TEXT');- if (!columns('file_call').includes('closing')) db.exec('ALTER TABLE file_call ADD COLUMN closing INTEGER NOT NULL DEFAULT 0');+ // Another file may add the same column first; its addition is as good as ours.+ const addColumn = (table, column, type) => {+ if (db.prepare(`PRAGMA table_info(${table})`).all().some(entry => entry.name === column)) return;+ try { db.exec(`ALTER TABLE ${table} ADD COLUMN ${column} ${type}`); }+ catch (error) { if (!/duplicate column/iu.test(error.message)) throw error; }+ };+ addColumn('file_holder', 'lender', 'INTEGER');+ addColumn('file_holder', 'call', 'TEXT');+ addColumn('file_call', 'closing', 'INTEGER NOT NULL DEFAULT 0');return db;}diff --git a/test/gate-admission.test.js b/test/gate-admission.test.jsindex cfca8750..808f6ee0 100644--- a/test/gate-admission.test.js+++ b/test/gate-admission.test.js@@ -58,7 +58,7 @@ test('four runs never hold more test files than cores, and the longest-recordedfor (const file of files) writeFileSync(join(root, file), timedFile(file, 300));const runs = await Promise.all([1, 2, 3, 4].map(run => runFixtureChildAsync(process.execPath, [runner, ...files],{ cwd: root, env: { ...env, FIXTURE_RUN: String(run) } })));- for (const result of runs) assert.equal(result.status, 0, result.failure ?? result.stdout);+ for (const result of runs) assert.equal(result.status, 0, `${result.failure ?? ""}\n${result.stdout.slice(-3000)}`);const events = log();assert.equal(events.filter(event => event.at === 'start').length, 24, 'every file of every run ran');assert.ok(peak(events) <= 4, `at most 4 files at once on 4 cores, saw ${peak(events)}`);