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: distinguish recorded adds from blocked relay attempts
Corey Olson0ff5cf7da365
diff --git a/test/relay-outbox.test.js b/test/relay-outbox.test.jsindex d4497359..58c0d72a 100644--- a/test/relay-outbox.test.js+++ b/test/relay-outbox.test.js@@ -1,3 +1,4 @@+import { recordedRelayRefusal } from './relay-recorded-refusal-fixture.js';import assert from 'node:assert/strict';import { readFileSync, writeFileSync } from 'node:fs';import { dirname } from 'node:path';@@ -259,3 +260,5 @@ test('a milestone edit naming an offline item follows that item when another mac'the milestone holds the item this machine added, not the other machine\'s');}});++test('a relay refusal after a recorded move says it was recorded [C6,N26,H16]', recordedRelayRefusal);diff --git a/test/relay-recorded-refusal-fixture.js b/test/relay-recorded-refusal-fixture.jsnew file mode 100644index 00000000..725bc368--- /dev/null+++ b/test/relay-recorded-refusal-fixture.js@@ -0,0 +1,71 @@+/** A real recorded add and an unrecorded add need different relay-lock guidance [C6,N26,H16]. */+import assert from 'node:assert/strict';+import { relayClientFixture } from './relay-client-fixture.js';++/** Hold only this private project's send lock at the exact post-record boundary, then prove both outcomes. */+export async function recordedRelayRefusal(t) {+ const box = await relayClientFixture(t);+ box.legacySnapshotApi('bad-route');+ box.rejectSnapshots({ status: 400, code: 'BAD_UPLOAD', message: 'fixture pauses initial checkpoint' });+ const linked = await box.link();+ assert.equal(linked.code, 0, linked.failure);+ const result = await box.script(`+ const { main } = await import(${JSON.stringify(box.mainURL)});+ const { spawn } = await import('node:child_process');+ const { mkdirSync, writeFileSync, rmSync, readFileSync } = await import('node:fs');+ const { DatabaseSync } = await import('node:sqlite');+ const holder = spawn(process.execPath, ['-e', 'setInterval(() => {}, 1000)'], { stdio: 'ignore' });+ const lock = ${JSON.stringify(box.linkFile + '.lock')};+ const database = ${JSON.stringify(box.root + '/.git/pullboard/board.sqlite')};+ const title = 'Recorded before private send lock';+ const missing = 'Unrecorded behind private send lock';+ let owns = false;+ /** A live owned child models another sender; no operational project is touched. */+ function hold() {+ mkdirSync(lock, { mode: 0o700 });+ writeFileSync(lock + '/pid', String(holder.pid));+ owns = true;+ }+ /** Release only the lock this fixture made, never a successor's directory. */+ function release() {+ if (owns && readFileSync(lock + '/pid', 'utf8') === String(holder.pid)) rmSync(lock, { recursive: true });+ owns = false;+ }+ const outcomes = [];+ try {+ for (const [text, recorded] of [[title, true], [missing, false]]) {+ if (!recorded) hold();+ let stdout = '', stderr = '';+ const code = await main(['add', ${JSON.stringify(box.lane)}, text], {+ cwd: process.cwd(), relayLockWaitMs: 150, relayLockProgressMs: 1000,+ stdout: { write(value) { stdout += value; if (recorded && /^#[0-9]+\\n$/u.test(value)) hold(); } },+ stderr: { write(value) { stderr += value; } }+ });+ const db = new DatabaseSync(database, { readOnly: true });+ try {+ const rows = db.prepare('SELECT item_id FROM item WHERE item_title=?').all(text);+ const link = JSON.parse(readFileSync(${JSON.stringify(box.linkFile)}, 'utf8'));+ const pending = db.prepare('SELECT COUNT(*) AS count FROM event WHERE event_id>?').get(link.cursor ?? 0).count;+ outcomes.push({ code, stdout, stderr, rows: rows.length, pending, held: owns });+ } finally { db.close(); }+ release();+ }+ } finally {+ release();+ holder.kill('SIGTERM');+ await new Promise(resolve => holder.once('close', resolve));+ }+ console.log(JSON.stringify({ outcomes }));+ `);+ assert.equal(result.code, 0, result.failure);+ const [recorded, missing] = result.document.outcomes;+ assert.equal(recorded.held, true, 'the private lock was acquired only after the real CLI reported its recorded add');+ assert.equal(recorded.rows, 1, 'exactly one item is durable; no retry is needed');+ assert.ok(recorded.pending > 0, 'the paused initial checkpoint leaves real local events waiting for sync');+ assert.match(recorded.stderr, /recorded[\s\S]*queued/iu);+ assert.doesNotMatch(recorded.stderr, /run (?:the |this )?command again|retry (?:the |this )?(?:command|move)/iu);+ assert.equal(missing.held, true);+ assert.equal(missing.rows, 0, 'the blocked operation has not added an item');+ assert.notEqual(missing.code, 0);+ assert.match(missing.stderr, /not (?:been )?recorded/iu);+}