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.

Merge main into core/878-claude

Corey Olsondf82620e7331
diff --cc src/cli.js
index 2d1a10ef,8b9da011..49799ca1
--- a/src/cli.js
+++ b/src/cli.js
@@@ -4120,8 -4103,12 +4120,12 @@@ async function specCommand(io, { first
findings.forEach((finding) => messages.push(`${name}:${finding.line} ${finding.id ?? ''} ${finding.level}: ${finding.message}`.replace(' ', ' ')));
const history = parsed === practice ? doctrineHistory(ctx.info.root, name) : committedIds(ctx.info.root, name);
const cited = name === ctx.config.spec ? citations(ctx, history) : new Map();
- const lost = permanenceProblems(parsed === practice ? practice.repo : parsed, { committed: history.ids, cited });
+ const lost = permanenceProblems(parsed === practice ? practice.repo : name === ctx.config.spec ? withRowDrafts(parsed, hookRead(ctx, (board) => store.rowDrafts(board))) : parsed, { committed: history.ids, cited });
if (name === ctx.config.spec) {
+ const mainRows = new Set((previousSources.get(name) ?? []).map(row => row.id));
+ for (const problem of lost) {
+ if (mainRows.has(problem.id)) problem.message = 'is present on main but missing from this worktree; run git merge main, then pullboard spec check';
+ }
const answered = handAnsweredQuestions(previousSources.get(name) ?? [], parsed.rows, () => hookRead(ctx, (board) => store.rowDecisions(board)) ?? []);
lost.push(...answered.map((id) => ({ id, message: io.guidance(`pending question answered by hand; ask the person to run pullboard spec answer ${id} "<choice or text>" and restore the pending row`) })));
}
diff --cc test/hooks.test.js
index f7dab2fc,5769cdbf..3be63fe9
--- a/test/hooks.test.js
+++ b/test/hooks.test.js
@@@ -259,64 -260,80 +260,142 @@@ test('a spec-less feature commit is tol
}
});
+test('a lane agent drafts a row and cites it without leaving its lane [S1,B26]', () => {
+ const box = e2e.project('pullboard spec check');
+ assert.equal(box.run(box.repo, 'add', 'web', 'Show the list', '--criterion', 'web/list.html exists').code, 0);
+ const claimed = box.run(box.web, 'claim', '1');
+ assert.equal(claimed.code, 0, claimed.out + claimed.err);
+ const drafted = box.run(box.web, 'spec', 'draft', 'A person sees their list');
+ assert.equal(drafted.code, 0, drafted.out + drafted.err);
+ const id = drafted.out.trim().split('\n').at(-1);
+ assert.match(id, /^G\d+$/u, `spec draft prints the new id: ${drafted.out}`);
+ assert.equal(box.tryGit(box.web, 'status', '--porcelain').stdout, '', 'drafting from the lane leaves its worktree clean');
+ mkdirSync(join(box.web, 'web'), { recursive: true });
+ writeFileSync(join(box.web, 'web', 'list.html'), '<ul></ul>\n');
+ box.git(box.web, 'add', 'web/list.html');
+ const commit = box.tryGit(box.web, 'commit', '-q', '-m', `feat(web): show the list [${id}]`);
+ assert.equal(commit.status, 0, `the lane cites its drafted row in a feature commit: ${commit.stderr}`);
+ const submitted = box.run(box.web, 'submit', '1');
+ assert.equal(submitted.code, 0, `the lane submits with the gate pullboard spec check: ${submitted.out}${submitted.err}`);
+
+ // The coordinator's spec apply writes the board draft into SPEC.md as a draft row, and the person approves it there.
+ const row = () => readFileSync(join(box.repo, 'SPEC.md'), 'utf8').split('\n').find((line) => line.startsWith(`- ${id} `));
+ assert.equal(row(), undefined, 'until apply, SPEC.md does not hold the lane draft');
+ const applied = box.run(box.repo, 'spec', 'apply');
+ assert.equal(applied.code, 0, applied.out + applied.err);
+ assert.match(applied.out, new RegExp(`${id} drafted from a lane, for the person to approve`, 'u'));
+ assert.equal(row(), `- ${id} [draft, must] A person sees their list | gate: review`, 'spec apply writes the draft at its own id');
+ assert.equal(box.run(box.repo, 'spec', 'approve', id).code, 0, 'the person approves the drafted row as before');
+ assert.equal(box.run(box.repo, 'spec', 'apply').code, 0);
+ assert.match(row(), /\[approved, must\]/u, 'the approved row is applied');
+});
+
+test('a lane draft and a coordinator draft never share an id, in either order [S1,B26]', () => {
+ const box = e2e.project('pullboard spec check');
+ const draft = (cwd, text) => {
+ const result = box.run(cwd, 'spec', 'draft', text);
+ assert.equal(result.code, 0, result.out + result.err);
+ return result.out.trim().split('\n').at(-1);
+ };
+ // Lane first: the coordinator's next id skips the lane's board draft.
+ const laneFirst = draft(box.web, 'A lane row drafted first');
+ const coordinatorAfter = draft(box.repo, 'A coordinator row drafted after');
+ // Coordinator first, committed through the installed hooks: the lane's older files lack it, and its next id still skips it.
+ const coordinatorFirst = draft(box.repo, 'A coordinator row drafted first');
+ box.git(box.repo, 'add', 'SPEC.md');
+ const committed = box.tryGit(box.repo, 'commit', '-q', '-m', `docs(spec): draft two rows [${coordinatorAfter},${coordinatorFirst}]`);
+ assert.equal(committed.status, 0, committed.stderr);
+ const laneAfter = draft(box.web, 'A lane row drafted after');
+ const ids = [laneFirst, coordinatorAfter, coordinatorFirst, laneAfter];
+ assert.equal(new Set(ids).size, 4, `every proposal keeps its own id: ${ids.join(', ')}`);
+ assert.equal(box.tryGit(box.web, 'status', '--porcelain').stdout, '', 'the lane edits no file outside its lane');
+
+ const applied = box.run(box.repo, 'spec', 'apply');
+ assert.equal(applied.code, 0, applied.out + applied.err);
+ assert.doesNotMatch(applied.out, /holds other text/u);
+ const spec = readFileSync(join(box.repo, 'SPEC.md'), 'utf8');
+ for (const [id, text] of [[laneFirst, 'A lane row drafted first'], [coordinatorAfter, 'A coordinator row drafted after'],
+ [coordinatorFirst, 'A coordinator row drafted first'], [laneAfter, 'A lane row drafted after']]) {
+ assert.ok(spec.includes(`- ${id} [draft, must] ${text} | gate: review`), `${id} keeps its own text as a draft after apply`);
+ }
+ const approve = box.run(box.web, 'spec', 'approve', laneAfter);
+ assert.notEqual(approve.code, 0, 'a lane cannot approve its own draft; the person does');
+});
++
+ test('a hook names a Pullboard version mismatch instead of running old rules [C1,I2]', (t) => {
+ const box = stagedRepo(t);
+ const hooks = join(box.root, '.githooks'), bin = join(box.root, '.fakebin'), local = join(box.root, 'node_modules', '.bin');
+ mkdirSync(hooks); mkdirSync(bin);
+ box.git('config', 'core.hooksPath', '.githooks');
+ box.git('config', 'user.name', 'Fixture');
+ box.git('config', 'user.email', '[email protected]');
+ writeFileSync(join(hooks, 'commit-msg'), hookScript('commit-msg', '0.9.0'));
+ chmodSync(join(hooks, 'commit-msg'), 0o755);
+ /** A pullboard that reports one version and says so if its rules ever run. */
+ const fake = (dir, version) => {
+ mkdirSync(dir, { recursive: true });
+ writeFileSync(join(dir, 'pullboard'), `#!/bin/sh\nif [ "$1" = --version ]; then echo ${version}; exit 0; fi\necho "rules of ${version} ran" >&2\nexit 0\n`);
+ chmodSync(join(dir, 'pullboard'), 0o755);
+ };
+ const env = { ...process.env, PATH: `${bin}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' };
+ const commit = () => spawnSync('git', ['commit', '--allow-empty', '-q', '-m', 'chore: try a commit'], { cwd: box.root, env, encoding: 'utf8' });
+
+ fake(bin, '0.8.4');
+ let result = commit();
+ assert.equal(result.status, 1, 'an older global pullboard is stopped');
+ assert.match(result.stderr, /stopped before running any rule; these hooks were installed by Pullboard 0\.9\.0, but pullboard is Pullboard 0\.8\.4\. Run: npm i -g pullboard@0\.9\.0/u);
+ assert.doesNotMatch(result.stderr, /rules of 0\.8\.4 ran/u, 'the old rules never run');
+
+ fake(local, '0.8.4');
+ result = commit();
+ assert.equal(result.status, 1, 'an older project install is stopped');
+ assert.match(result.stderr, /Pullboard 0\.8\.4\. Run: npm i -D pullboard@0\.9\.0/u, 'a project install is fixed in the project');
+ rmSync(join(box.root, 'node_modules'), { recursive: true, force: true });
+
+ fake(bin, '0.9.9');
+ result = commit();
+ assert.equal(result.status, 1, 'a newer pullboard under older hooks is stopped too');
+ assert.match(result.stderr, /Pullboard 0\.9\.9\. Run: pullboard init/u, 'newer rules rewrite the hooks with init');
+
+ fake(bin, '0.9.0');
+ result = commit();
+ assert.equal(result.status, 0, `the matching version runs: ${result.stderr}`);
+ assert.match(result.stderr, /rules of 0\.9\.0 ran/u, 'the hook runs the version that installed it');
+ });
+
+ test('pre-push keeps its ref records when the version query reads stdin [C3,L3,I2]', () => {
+ const box = e2e.project('test ! -f RED');
+ writeFileSync(join(box.repo, 'RED'), 'this older commit is red\n');
+ box.git(box.repo, 'add', 'RED');
+ box.git(box.repo, 'commit', '-q', '-m', 'chore: create the red commit');
+ const red = box.git(box.repo, 'rev-parse', 'HEAD').trim();
+ box.git(box.repo, 'rm', '-q', 'RED');
+ box.git(box.repo, 'commit', '-q', '-m', 'chore: check out a green commit');
+ const green = box.git(box.repo, 'rev-parse', 'HEAD').trim();
+ assert.notEqual(red, green);
+ const remote = join(box.dir, 'private-remote.git');
+ box.git(box.dir, 'init', '--bare', '-q', remote);
+ box.git(box.repo, 'remote', 'add', 'private', remote);
+ const wrapper = join(box.dir, 'version-wrapper');
+ mkdirSync(wrapper);
+ /** Quote the controlled Node executable and the real fixture CLI. */
+ const quote = value => `'${value.replaceAll("'", "'\\''")}'`;
+ writeFileSync(join(wrapper, 'pullboard'), '#!/bin/sh\nif [ "$1" = --version ]; then cat > "$HOOK_VERSION_STDIN"; fi\nexec '
+ + quote(process.execPath) + ' ' + quote(e2e.BIN) + ' "$@"\n');
+ chmodSync(join(wrapper, 'pullboard'), 0o755);
+ box.env.PATH = `${wrapper}:${box.env.PATH}`;
+ box.env.HOOK_VERSION_STDIN = join(box.dir, 'version-input');
+
+ const pushed = box.tryGit(box.repo, 'push', 'private', `${red}:refs/heads/main`);
+ assert.notEqual(pushed.status, 0, `the gate on ${green} must not admit ${red}: ${pushed.stdout}${pushed.stderr}`);
+ assert.match(pushed.stderr, /is not checked out/u, pushed.stderr);
+ assert.notEqual(box.tryGit(remote, 'rev-parse', '--verify', 'refs/heads/main').status, 0,
+ 'the rejected push leaves the private remote unchanged');
+ assert.equal(readFileSync(box.env.HOOK_VERSION_STDIN, 'utf8'), '', 'the version query receives EOF');
+
+ const matching = box.tryGit(box.repo, 'push', 'private', `${green}:refs/heads/main`);
+ assert.equal(matching.status, 0, matching.failure || matching.stderr || matching.stdout);
+ assert.equal(box.git(remote, 'rev-parse', 'refs/heads/main').trim(), green,
+ 'the real hook still admits the checked and gated commit');
+ assert.equal(readFileSync(box.env.HOOK_VERSION_STDIN, 'utf8'), '', 'the successful push also preserves its refs');
+ });