Skip to content

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.

test: permanent ids, wont rows, briefs and routes

Corey Olson9b16e8b8307f
diff --git a/test/board.test.js b/test/board.test.js
index 1a631d79..2d4c1ca5 100644
--- a/test/board.test.js
+++ b/test/board.test.js
@@ -212,17 +212,20 @@ test('an item can wait on others: claiming it is refused until they are verified
assert.throws(() => store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Late', after: [dropped] }), /WITHDRAWN/);
});
-test('a board made before dependencies existed is migrated on open', () => {
+test('a board made by an older version is migrated on open', () => {
const dir = mkdtempSync(join(tmpdir(), 'pullboard-migrate-'));
try {
const file = join(dir, 'board.sqlite');
const old = store.openBoard(file, clock);
- old.db.exec('ALTER TABLE item DROP COLUMN item_after');
+ for (const column of ['item_after', 'item_brief', 'item_route']) old.db.exec(`ALTER TABLE item DROP COLUMN ${column}`);
+ old.db.exec('ALTER TABLE agent DROP COLUMN agent_route');
store.closeBoard(old);
const reopened = store.openBoard(file, clock);
- const columns = reopened.db.prepare('PRAGMA table_info(item)').all().map((column) => column.name);
+ const columns = (table) => reopened.db.prepare(`PRAGMA table_info(${table})`).all().map((column) => column.name);
+ const [items, agents] = [columns('item'), columns('agent')];
store.closeBoard(reopened);
- assert.ok(columns.includes('item_after'));
+ for (const column of ['item_after', 'item_brief', 'item_route']) assert.ok(items.includes(column), column);
+ assert.ok(agents.includes('agent_route'));
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -239,3 +242,42 @@ test('next finds the oldest free item in your lane, or says what everything wait
assert.equal(store.nextFor(board, { agentId: 'web-1', lane: 'web', verify: true }).item, null);
assert.equal(store.nextFor(board, { agentId: 'web-2', lane: 'web', verify: true }).item.item_id, contract);
});
+
+test('an item carries a brief; editing it changes how to build, never what [B10]', () => {
+ const id = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Help text', brief: ' Copy how add prints. ' });
+ assert.equal(store.getItem(board, id).item_brief, 'Copy how add prints.');
+ claimAs(id, 'web-1', 'web');
+ const digest = store.getItem(board, id).item_frozen_digest;
+ store.editItem(board, id, { agentId: 'coordinator', brief: 'Copy how add prints; test it like add.' });
+ assert.equal(store.getItem(board, id).item_brief, 'Copy how add prints; test it like add.');
+ assert.equal(store.getItem(board, id).item_frozen_digest, digest);
+ assert.throws(() => store.editItem(board, id, { agentId: 'api-1', brief: 'mine now' }), /NOT_YOURS.*coordinator/);
+ assert.throws(() => store.editItem(board, id, { agentId: 'coordinator' }), /USAGE/);
+ assert.throws(() => store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Huge', brief: 'x'.repeat(8001) }), /BRIEF_TOO_LONG/);
+ assert.deepEqual(JSON.parse(store.events(board, { itemId: id }).find((event) => event.event_kind === 'edit').event_detail), { brief: '38 characters' });
+ store.submit(board, id, { agentId: 'web-1', commit: SHA_A, tree: 't' });
+ store.verify(board, id, { agentId: 'web-2', decision: 'ACCEPT', head: SHA_A, digest, policy: 'any', note: 'removed the help case; its test failed' });
+ assert.throws(() => store.editItem(board, id, { agentId: 'coordinator', brief: 'late' }), /CLOSED/);
+});
+
+test('a light agent claims and verifies only light items, each with a brief; strong agents take strong work first [B11]', () => {
+ store.register(board, { lane: 'web', path: '/repo-web-3', route: 'light' });
+ assert.throws(() => store.register(board, { lane: 'web', path: '/repo-web-3' }), /ALREADY_JOINED.*routed light/);
+ assert.throws(() => store.register(board, { lane: 'web', path: '/repo-web-9', route: 'cheap' }), /BAD_ROUTE/);
+ assert.throws(() => store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Rename', route: 'light' }), /NO_BRIEF/);
+ const light = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Rename', route: 'light', brief: 'Rename x to y in web/a.js.' });
+ const strong = store.addItem(board, { by: 'coordinator', lane: 'web', title: 'Design the cache' });
+ assert.throws(() => claimAs(strong, 'web-3', 'web'), /ROUTE.*light route/);
+ assert.equal(store.nextFor(board, { agentId: 'web-3', lane: 'web' }).item.item_id, light);
+ assert.equal(store.nextFor(board, { agentId: 'web-1', lane: 'web' }).item.item_id, strong);
+ claimAs(strong, 'web-1', 'web');
+ assert.deepEqual(store.nextFor(board, { agentId: 'web-3', lane: 'web' }).item.item_id, light);
+ assert.throws(() => store.editItem(board, strong, { agentId: 'coordinator', route: 'light', brief: 'now light' }), /HELD.*only while it is open/);
+ assert.throws(() => store.editItem(board, light, { agentId: 'coordinator', brief: '' }), /NO_BRIEF/);
+ store.submit(board, strong, { agentId: 'web-1', commit: SHA_A, tree: 't' });
+ assert.equal(store.nextFor(board, { agentId: 'web-3', lane: 'web', verify: true }).item, null);
+ const verdict = { agentId: 'web-3', decision: 'ACCEPT', head: SHA_A, digest: 'digest:Design the cache', policy: 'any', note: 'tried it' };
+ assert.throws(() => store.verify(board, strong, verdict), /ROUTE.*strong verifier/);
+ store.verify(board, strong, { ...verdict, agentId: 'web-2' });
+ assert.equal(claimAs(light, 'web-3', 'web').renewed, false);
+});
diff --git a/test/e2e.test.js b/test/e2e.test.js
index c23e76f6..9f3d3a02 100644
--- a/test/e2e.test.js
+++ b/test/e2e.test.js
@@ -314,3 +314,53 @@ test('next claims the next free item; --verify names the next to check [N2]', ()
assert.match(box.run(box.repo, 'next', '--verify').out, /next to verify: #1 Page, built by web-1/);
assert.match(box.run(box.web, 'next', '--verify').err, /NOTHING_FREE/);
});
+
+test('a deleted spec row is refused at commit; spec check finds any id gone from history or cited [S8, S9]', () => {
+ const box = project();
+ const spec = join(box.repo, 'SPEC.md');
+ writeFileSync(spec, SPEC.replace(/- G2 .*\n/, ''));
+ box.git(box.repo, 'add', 'SPEC.md');
+ const refused = box.tryGit(box.repo, 'commit', '-q', '-m', 'docs(spec): drop the api row');
+ assert.notEqual(refused.status, 0);
+ assert.match(refused.stderr, /SPEC.md: G2 is gone; ids are permanent: keep the row and mark it wont/);
+ box.git(box.repo, 'commit', '-q', '--no-verify', '-m', 'docs(spec): drop the api row');
+ box.git(box.repo, 'commit', '-q', '--no-verify', '--allow-empty', '-m', 'feat(web): ghost [G7]');
+ writeFileSync(spec, `${SPEC.replace(/- G2 .*\n/, '')}- G3 [draft, must] Not committed yet.\n`);
+ assert.equal(box.run(box.repo, 'add', 'web', 'Uses G3', '--specs', 'G3').code, 0);
+ writeFileSync(spec, SPEC.replace(/- G2 .*\n/, ''));
+ const check = box.run(box.repo, 'spec', 'check');
+ assert.equal(check.code, 1);
+ assert.match(check.out, /SPEC.md: G2 error: was committed in [0-9a-f]{12} and is gone/);
+ assert.match(check.out, /SPEC.md: G7 error: commit [0-9a-f]{7,} cites it, but it was never committed/);
+ assert.match(check.out, /SPEC.md: G3 error: item #1 cites it, but it was never committed/);
+ writeFileSync(spec, `${SPEC.replace('- G2 [approved, must]', '- G2 [wont, must]')}- G3 [retired] Planned before the spec settled.\n- G7 [retired] Cited by mistake.\n`);
+ const fixed = box.run(box.repo, 'spec', 'check');
+ assert.equal(fixed.code, 0, fixed.out);
+ box.git(box.repo, 'add', 'SPEC.md');
+ assert.equal(box.tryGit(box.repo, 'commit', '-q', '-m', 'docs(spec): keep every id').status, 0);
+ const cited = commitFile(box, box.repo, 'docs/api.md', 'x', 'feat(api): call the api [G2]');
+ assert.notEqual(cited.status, 0);
+ assert.match(cited.stderr, /G2 is marked won't build/);
+});
+
+test('an item carries a brief to whoever claims it; a light agent sees only light work [B10, B11]', () => {
+ const box = project();
+ writeFileSync(join(box.dir, 'brief.md'), 'Edit web/page.js only.\nCopy the header from api/server.js.\n');
+ assert.equal(box.run(box.repo, 'add', 'web', 'Design', 'the', 'page', '--specs', 'G1').code, 0);
+ assert.match(box.run(box.repo, 'add', 'web', 'Rename', '--route', 'light').err, /NO_BRIEF/);
+ assert.match(box.run(box.repo, 'add', 'web', 'Rename', '--brief', 'x', '--brief-file', 'y').err, /USAGE.*give the brief once/);
+ const added = box.run(box.repo, 'add', 'web', 'Copy', 'the', 'header', '--route', 'light', '--brief-file', join(box.dir, 'brief.md'));
+ assert.equal(added.out.trim(), '#2', added.err);
+ assert.match(box.run(box.repo, 'list').out, /#2 {2}open {2}web {2}Copy the header {2}light/);
+ const made = box.run(box.repo, 'worktree', 'web', '--route', 'light');
+ assert.match(made.out, /joined as web-2 in the web lane, on the light route/);
+ const light = made.out.match(/^made (\S+) /)[1];
+ assert.match(box.run(light, 'whoami').out, /^web-2 \(web lane, light route\)/);
+ const next = box.run(light, 'next');
+ assert.match(next.out, /claimed #2: Copy the header\nbrief:\n {2}Edit web\/page.js only.\n {2}Copy the header from api\/server.js./);
+ assert.match(box.run(light, 'claim', '1').err, /ROUTE/);
+ assert.match(box.run(box.web, 'next').out, /claimed #1: Design the page/);
+ assert.equal(box.run(box.repo, 'edit', '1', '--brief', 'Start from the sketch in docs/page.md.').code, 0);
+ assert.match(box.run(box.web, 'show', '1').out, /brief:\n {2}Start from the sketch in docs\/page.md./);
+ assert.match(box.run(box.web, 'edit', '2', '--brief', 'mine').err, /NOT_YOURS/);
+});
diff --git a/test/spec.test.js b/test/spec.test.js
index 49e3c11f..2e43a966 100644
--- a/test/spec.test.js
+++ b/test/spec.test.js
@@ -8,10 +8,12 @@ import { join } from 'node:path';
import { test } from 'node:test';
import {
citedIds,
+ deletedIds,
frozenCriterion,
idProblems,
lintSpec,
parseSpec,
+ permanenceProblems,
readSignoffs,
signOff,
standings,
@@ -129,3 +131,27 @@ test('commit headers cite ids in a trailing bracket [C2]', () => {
assert.deepEqual(citedIds('feat(web): add the page'), []);
assert.deepEqual(citedIds('fix: handle [x] in the middle of text'), []);
});
+
+test('a row marked wont stays with its id, drops out of the counts, and cannot be cited [S9]', () => {
+ const spec = { ...parseSpec(`# Demo\n\n## G · Goals\n- G1 [approved, must] Kept. | gate: test\n- G2 [wont, must] Cut by the client on 6 Oct.\n`), name: 'SPEC.md' };
+ assert.deepEqual(lintSpec(spec), []);
+ assert.deepEqual(unmetRows(spec.rows, []).map((row) => row.id), ['G1']);
+ assert.deepEqual(idProblems(spec, ['G2']), ["G2 is marked won't build; the person reopens it first"]);
+ const item = { item_title: 'Build it', item_criterion: '', item_spec_ids: 'G2' };
+ assert.throws(() => frozenCriterion(spec, item), /UNKNOWN_SPEC.*won't build.*withdraws the item/);
+});
+
+test('an id once committed or cited never leaves the spec [S8]', () => {
+ const before = '# Demo\n\n## G · Goals\n- G1 [approved, must] One. | gate: t\n- G2 [draft, must] Two.\n```\n- G9 [draft] An example in a fence.\n```\n';
+ assert.deepEqual(deletedIds(before, '# Demo\n\n## G · Goals\n- G1 [approved, must] One. | gate: t\n'), ['G2']);
+ assert.deepEqual(deletedIds(before, before.replace('[draft, must] Two.', '[wont, must] Two.')), []);
+ const spec = parseSpec('# Demo\n\n## G · Goals\n- G1 [approved, must] One. | gate: t\n');
+ const problems = permanenceProblems(spec, {
+ committed: new Map([['G1', 'a'.repeat(40)], ['G2', 'b'.repeat(40)]]),
+ cited: new Map([['G1', 'commit 1234567'], ['G2', 'item #3'], ['X4', 'commit 89abcde']]),
+ });
+ assert.deepEqual(problems, [
+ { id: 'G2', message: 'was committed in bbbbbbbbbbbb and is gone; ids are permanent: restore the row and mark it wont or retired' },
+ { id: 'X4', message: 'commit 89abcde cites it, but it was never committed to the spec; add it as a retired row saying what it meant' },
+ ]);
+});