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.

fix(cli): guard signer enrollment and preserve replay [B26,H16]

Corey Olson5a700e37d351
diff --git a/src/cli.js b/src/cli.js
index 053ef881..4a3f5102 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1645,6 +1645,7 @@ function specCommand(io, { first, second, rest, values }) {
return errors ? 1 : 0;
}
if (first === 'signers' && second === 'add') {
+ requirePersonChannel(io.personChannel);
const signer = addSigner(ctx.info.root, { by: values.by, key: values.key });
io.result?.(signer);
io.say(signer.added
diff --git a/test/engine.test.js b/test/engine.test.js
index 6986136c..09a8a235 100644
--- a/test/engine.test.js
+++ b/test/engine.test.js
@@ -14,13 +14,14 @@ const HOUR = 3_600_000;
const CLAIM_AT = '2026-10-07T18:00:00.000Z';
/** Open two independent SQLite copies of the same registered board and one available item. */
-function engineCopies(t) {
+function engineCopies(t, initialize = () => {}) {
const directory = mkdtempSync(join(tmpdir(), 'pullboard-engine-'));
const source = store.openBoard(join(directory, 'source.sqlite'));
store.register(source, { lane: 'coordinator', path: '/source' });
store.register(source, { lane: 'web', path: '/source/web-1' });
store.register(source, { lane: 'web', path: '/source/web-2' });
const item = store.addItem(source, { by: 'coordinator', lane: 'web', title: 'Engine fixture' });
+ initialize(source);
const document = exportBoard(source);
const copies = ['one', 'two'].map((name, index) => {
const clock = { now: () => new Date(`2026-10-07T${index + 16}:00:00.000Z`) };
@@ -58,6 +59,41 @@ function boardRows(board, itemId) {
};
}
+test('person answer channel replays identically on agent and plain replicas [B26,H16]', t => {
+ const questions = [];
+ const { copies } = engineCopies(t, source => {
+ questions.push(...['view', 'terminal', 'legacy'].map(channel => store.shout(source, {
+ from: 'coordinator', to: 'person', text: 'Private engine fixture ' + channel,
+ decision: true, lanes: ['web'],
+ })));
+ });
+ const [one, two] = copies;
+ const markers = ['CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT', 'AI_AGENT', 'CODEX_THREAD_ID', 'CODEX_SESSION_ID', 'CODEX_CI', 'CODEX_SHELL'];
+ const original = markers.map(name => [name, process.env[name]]);
+ try {
+ questions.forEach((id, index) => {
+ const channel = ['view', 'terminal', undefined][index];
+ const move = prepareEngineMove(one, 'answerDecision', [id, {
+ agentId: 'coordinator', text: 'Approved private fixture', lanes: ['web'], asPerson: true,
+ ...(channel ? { channel } : {}),
+ }]);
+ for (const name of markers) process.env[name] = 'fixture-agent';
+ const agentReceipt = applyEngineMove(one, move, { sequence: index + 1, at: CLAIM_AT });
+ for (const name of markers) delete process.env[name];
+ const plainReceipt = applyEngineMove(two, move, { sequence: index + 1, at: CLAIM_AT });
+ assert.equal(Boolean(agentReceipt.error), false);
+ assert.deepEqual(agentReceipt, plainReceipt, 'replica execution ignores sender-shell markers');
+ assert.equal(JSON.parse(agentReceipt.events[0].event_detail).channel, channel ?? 'terminal');
+ });
+ assert.deepEqual(exportBoard(one).tables, exportBoard(two).tables);
+ } finally {
+ for (const [name, value] of original) {
+ if (value === undefined) delete process.env[name];
+ else process.env[name] = value;
+ }
+ }
+});
+
test('the same sealed claim replays to identical rows and sequence retries are idempotent [H3,H16]', (t) => {
const { copies, item } = engineCopies(t);
const [one, two] = copies;
diff --git a/test/person.test.js b/test/person.test.js
index 60c938ec..7f61b233 100644
--- a/test/person.test.js
+++ b/test/person.test.js
@@ -1,7 +1,7 @@
/** Person terminal identity and immutable channel receipts on real repositories [B26]. */
import assert from 'node:assert/strict';
import { execFileSync, spawn, spawnSync } from 'node:child_process';
-import { chmodSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { chmodSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join, resolve } from 'node:path';
import { DatabaseSync } from 'node:sqlite';
@@ -257,3 +257,30 @@ test('[B26,S5] an agent shell cannot append a person sign-off but a plain shell
assert.equal(readFileSync(file, 'utf8'), original, name + ' preserves every existing sign-off byte');
}
});
+
+test('[B26,S18] signer enrollment refuses agent shells without creating or changing trust files', (t) => {
+ const box = project();
+ t.after(() => rmSync(box.dir, { recursive: true, force: true }));
+ const key = join(box.dir, 'fixture-signing-key');
+ const generated = spawnSync('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-f', key], { env: box.env, stdio: 'ignore' });
+ assert.equal(generated.status, 0, 'the fixture creates a disposable signing identity');
+ const files = ['signers', 'signers.initial', 'first-commit', 'signoffs.jsonl'].map(name => join(box.repo, '.pullboard', name));
+ /** Read only private fixture trust bytes; assertions never print key contents. */
+ const trustBytes = () => files.map(file => existsSync(file) ? readFileSync(file).toString('base64') : null);
+ const absent = trustBytes();
+ for (const [name, value] of Object.entries(MARKERS)) {
+ const refused = box.run(box.repo, ['spec', 'signers', 'add', '--key', key + '.pub', '--by', 'fixture-person', '--json'], { [name]: value });
+ assert.equal(refused.status, 1, name);
+ assert.equal(JSON.parse(refused.stdout).error.code, 'B26_PERSON_CHANNEL', name);
+ assert.equal(JSON.stringify(trustBytes()) === JSON.stringify(absent), true, 'refused enrollment creates no trust files');
+ }
+ const plain = box.run(box.repo, ['spec', 'signers', 'add', '--key', key + '.pub', '--by', 'fixture-person', '--json']);
+ assert.equal(plain.status, 0);
+ assert.equal(JSON.parse(plain.stdout).added, true);
+ const enrolled = trustBytes();
+ for (const [name, value] of Object.entries(MARKERS)) {
+ const refused = box.run(box.repo, ['spec', 'signers', 'add', '--key', key + '.pub', '--by', 'another-person', '--json'], { [name]: value });
+ assert.equal(refused.status, 1, name);
+ assert.equal(JSON.stringify(trustBytes()) === JSON.stringify(enrolled), true, 'refused enrollment preserves every trust byte');
+ }
+});