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(board): name write admission contention [C7,P4,B2]
Corey Olson3e83b30198ed
diff --git a/src/board-busy.js b/src/board-busy.jsindex 1bddaf21..5374e880 100644--- a/src/board-busy.js+++ b/src/board-busy.js@@ -1,6 +1,12 @@/** Translate SQLite lock contention without coupling error reporting to the full board store [C7]. */import { Refused } from './refused.js';+/** Recognize SQLite's busy code, including extended busy result codes. */+function isBusy(error) {+ const sqliteCode = Number.isInteger(error.errcode) ? error.errcode & 0xff : null;+ return sqliteCode === 5 || error.code === 'SQLITE_BUSY' || /database is locked/iu.test(error.message ?? '');+}+/*** Replace SQLite's bare lock error with the board path and elapsed wait when the wait expires.*@@ -10,8 +16,14 @@ import { Refused } from './refused.js';* @returns {Error}*/export function boardBusyError(file, startedAt, error) {- const sqliteCode = Number.isInteger(error.errcode) ? error.errcode & 0xff : null;- if (sqliteCode !== 5 && error.code !== 'SQLITE_BUSY' && !/database is locked/iu.test(error.message ?? '')) return error;+ if (!isBusy(error)) return error;return new Refused('BOARD_BUSY', `board file ${file} remained held by another process after ${Date.now() - startedAt}ms; wait for it to finish and retry`);}+/** Name a failed write admission; resolve its board path only after real contention occurs. */+export function boardWriteBusyError(db, startedAt, error) {+ if (!isBusy(error)) return error;+ const file = db.prepare('PRAGMA database_list').all().find(row => row.name === 'main')?.file || ':memory:';+ return boardBusyError(file, startedAt, error);+}+diff --git a/src/board.js b/src/board.jsindex 10ef0917..67589bb8 100644--- a/src/board.js+++ b/src/board.js@@ -81,6 +81,7 @@ import { DatabaseSync } from 'node:sqlite';import { boardNotWritable } from './board-access.js';import { ensureHotIndexes } from './board-hot.js';import { boardBusyError } from './board-access.js';+import { boardWriteBusyError } from './board-busy.js';export { boardBusyError } from './board-access.js';import {boardStanding,@@ -401,7 +402,9 @@ const TRANSACTION_DEPTH = new WeakMap();export function atomic(board, work) {const depth = TRANSACTION_DEPTH.get(board) ?? 0;const savepoint = `pullboard_atomic_${depth}`;- board.db.exec(depth ? `SAVEPOINT ${savepoint}` : 'BEGIN IMMEDIATE');+ const startedAt = Date.now();+ try { board.db.exec(depth ? `SAVEPOINT ${savepoint}` : 'BEGIN IMMEDIATE'); }+ catch (error) { throw boardWriteBusyError(board.db, startedAt, error); }TRANSACTION_DEPTH.set(board, depth + 1);const lastEvent = board.lastEvent;const emitted = board.emittedEvents?.length ?? 0;