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.

feat(cli): separate person and agent channels [B26,S5]

Corey Olsonb8b327f100c0
diff --git a/bin/run-tests.js b/bin/run-tests.js
index fabe51e7..44a0387d 100644
--- a/bin/run-tests.js
+++ b/bin/run-tests.js
@@ -7,6 +7,7 @@ import { delimiter, join, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import { spawnSync } from 'node:child_process';
import { tmpdir } from 'node:os';
+import { AGENT_SHELL_MARKERS } from '../src/person.js';
const runner = fileURLToPath(import.meta.url);
@@ -29,6 +30,8 @@ function testEnvironment(sandbox) {
for (const key of Object.keys(env)) {
if (key.startsWith('GIT_')) delete env[key];
}
+ // Model a plain user terminal; person-boundary tests inject agent markers explicitly.
+ for (const key of AGENT_SHELL_MARKERS) delete env[key];
env.HOME = home;
env.USERPROFILE = home;
env.PULLBOARD_HOME = home;
diff --git a/docs/formats.md b/docs/formats.md
index a1e90eb3..29ec4bcf 100644
--- a/docs/formats.md
+++ b/docs/formats.md
@@ -243,9 +243,11 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap
| `guards` | board | `missing`, `changed`, `stale` |
| `shout` | sender | `shout`, `to`, `decision`, `request`, `answers` |
| `pass` | coordinator | `shout`, `to`, `decision`, `request`, `answers` |
-| `answer` | answerer | `shout`, `to`, `decision`, `request`, `answers`, `outcome` |
+| `answer` | answerer | `shout`, `to`, `decision`, `request`, `answers`, `outcome`, `channel` |
<!-- events:end -->
+Person answer events additionally record their `channel`, either `terminal` or `view`, including the forwarded answer to the original asker. Agent answers omit that field.
+
Migration preserves event rows and adds only schema objects that are missing.
The schema, trigger and parser tables in this guide are checked against live `openBoard(':memory:')` and `parseSpec` results by `docs/formats.test.js`.
diff --git a/src/api.js b/src/api.js
index 4eadb884..81541aef 100644
--- a/src/api.js
+++ b/src/api.js
@@ -141,6 +141,7 @@ async function executeMove(root, body, runCommand) {
const events = [];
const status = await runCommand(argv, {
cwd,
+ personChannel: 'view',
stdout: { isTTY: false, write: (text) => { output += text; } },
stderr: { write: (text) => { diagnostics += text; } },
onEvent: (row) => { events.push(row); },
diff --git a/src/board.js b/src/board.js
index 0389731e..9f8351a5 100644
--- a/src/board.js
+++ b/src/board.js
@@ -1218,10 +1218,10 @@ export function verdictsFor(board, id) {
* Insert a shout within the caller's transaction.
*
* @param {any} board
- * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean }} message
+ * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean, channel?: 'terminal' | 'view' }} message
* @returns {number}
*/
-function insertShout(board, { from, to, text, lanes, decision = false, answers = null, evidence = null, request = false }) {
+function insertShout(board, { from, to, text, lanes, decision = false, answers = null, evidence = null, request = false, channel = 'terminal' }) {
if (!text.trim()) throw new Refused('EMPTY_SHOUT', 'a shout needs text');
if (request && (from !== 'person' || to !== COORDINATOR || decision || answers !== null)) {
throw new Refused('BAD_REQUEST', 'a request goes from the person to the coordinator; use the board requests endpoint with its text');
@@ -1250,6 +1250,10 @@ function insertShout(board, { from, to, text, lanes, decision = false, answers =
throw new Refused('NOT_A_DECISION', `shout #${answers} asked for no decision; reply with pullboard shout`);
}
if (evidence) checkEvidence(board, evidence);
+ const personAnswer = from === PERSON && answers !== null && !decision;
+ if (personAnswer && !['terminal', 'view'].includes(channel)) {
+ throw new Refused('B26_PERSON_CHANNEL', 'record the person answer through the terminal or the view; run pullboard view');
+ }
const result = board.db
.prepare(
`INSERT INTO shout (shout_from, shout_to, shout_text, shout_at, shout_decision, shout_answers,
@@ -1259,7 +1263,7 @@ function insertShout(board, { from, to, text, lanes, decision = false, answers =
)
.run(from, to, text.trim(), now(board), decision ? 1 : 0, answers, evidence?.kind ?? null, evidence ? evidence.outcome.trim() : null, evidence?.item ?? null, evidence?.commit ?? null, request ? 1 : 0, outcome);
const id = Number(result.lastInsertRowid);
- logEvent(board, from, answers === null ? 'shout' : decision ? 'pass' : 'answer', null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}) });
+ logEvent(board, from, answers === null ? 'shout' : decision ? 'pass' : 'answer', null, { shout: id, to, decision: Boolean(decision), request: Boolean(request), answers, ...(outcome ? { outcome } : {}), ...(personAnswer ? { channel } : {}) });
return id;
}
@@ -1267,7 +1271,7 @@ function insertShout(board, { from, to, text, lanes, decision = false, answers =
* Shout to a lane, an agent, `all`, or the person (B7, B25, B26). The caller passes declared lanes.
*
* @param {any} board
- * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean }} message
+ * @param {{ from: string, to: string, text: string, lanes: string[], decision?: boolean, answers?: number | null, evidence?: any, request?: boolean, channel?: 'terminal' | 'view' }} message
* @returns {number}
*/
export function shout(board, message) {
@@ -1299,10 +1303,10 @@ export function passDecision(board, id, { agentId, note, lanes }) {
*
* @param {any} board
* @param {number} id
- * @param {{ agentId: string, text: string, lanes: string[], asPerson?: boolean }} options
+ * @param {{ agentId: string, text: string, lanes: string[], asPerson?: boolean, channel?: 'terminal' | 'view' }} options
* @returns {number}
*/
-export function answerDecision(board, id, { agentId, text, lanes, asPerson = false }) {
+export function answerDecision(board, id, { agentId, text, lanes, asPerson = false, channel = 'terminal' }) {
return atomic(board, () => {
const ask = getShout(board, id);
if (ask.shout_request) {
@@ -1322,10 +1326,10 @@ export function answerDecision(board, id, { agentId, text, lanes, asPerson = fal
throw new Refused('NOT_YOUR_DECISION', `shout #${id} is addressed to ${ask.shout_to}, not ${lane} (agent ${agentId})`);
}
const from = personAnswer ? PERSON : agentId;
- const answerId = insertShout(board, { from, to: ask.shout_from, text, lanes, answers: id });
+ const answerId = insertShout(board, { from, to: ask.shout_from, text, lanes, answers: id, channel });
if (personAnswer && ask.shout_answers !== null) {
const original = getShout(board, ask.shout_answers);
- insertShout(board, { from: PERSON, to: original.shout_from, text: `Person answered #${id}: ${String(text).trim()}`, lanes, answers: original.shout_id });
+ insertShout(board, { from: PERSON, to: original.shout_from, text: `Person answered #${id}: ${String(text).trim()}`, lanes, answers: original.shout_id, channel });
}
return answerId;
});
diff --git a/src/cli.js b/src/cli.js
index ffb6ccae..b0108924 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -10,6 +10,7 @@ import { parseArgs } from 'node:util';
import * as store from './board.js';
import { CONFIG_FILE, COORDINATOR, loadConfig } from './config.js';
import { loadDoctrine } from './doctrine.js';
+import { requirePersonChannel } from './person.js';
import { digestOf, gateReport, runGate, runShell } from './gate.js';
import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, isClean, repoInfo, resolveCommit, tryGit, untracked } from './git.js';
import {
@@ -308,6 +309,7 @@ function personMode(ctx, me, values) {
if (!ctx.info.isMain || me.id !== COORDINATOR) {
throw new Refused('B26_PERSON_ANSWER', 'only the main checkout can act as the person; ask your coordinator to answer or pass this decision');
}
+ requirePersonChannel(ctx.io.personChannel);
return true;
}
@@ -1471,7 +1473,7 @@ function workCommands(io, args) {
}),
answer: () => act((ctx, board, me) => {
const asPerson = personMode(ctx, me, values);
- const id = store.answerDecision(board, idArg(first), { agentId: me.id, text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config), asPerson });
+ const id = store.answerDecision(board, idArg(first), { agentId: me.id, text: [second, ...rest].filter(Boolean).join(' '), lanes: laneNames(ctx.config), asPerson, channel: ctx.io.personChannel ?? 'terminal' });
const ask = store.getShout(board, idArg(first));
io.result?.({ id, answers: ask.shout_id });
if (asPerson) {
@@ -1663,6 +1665,7 @@ function specCommand(io, { first, second, rest, values }) {
return 0;
}
if (first === 'signoff') {
+ requirePersonChannel(io.personChannel);
const ids = [second, ...rest].filter(Boolean).flatMap((text) => idList(text));
if (!ids.length) throw new Refused('USAGE', 'pullboard spec signoff <ids> [--by <principal>] [--note "what was checked"]');
const invalid = ids.filter((id) => spec.rows.find((row) => row.id === id)?.status !== 'approved');
diff --git a/src/person.js b/src/person.js
new file mode 100644
index 00000000..fe0972a2
--- /dev/null
+++ b/src/person.js
@@ -0,0 +1,19 @@
+/** Person actions use the view when the terminal belongs to an agent [B26]. */
+import { Refused } from './refused.js';
+
+/** Markers carried by Claude Code and Codex agent subprocesses, rather than user configuration. */
+export const AGENT_SHELL_MARKERS = Object.freeze([
+ 'CLAUDECODE', 'CLAUDE_CODE_ENTRYPOINT', 'AI_AGENT',
+ 'CODEX_THREAD_ID', 'CODEX_SESSION_ID', 'CODEX_CI', 'CODEX_SHELL',
+]);
+
+/** Refuse terminal person actions in an agent shell; only the authenticated view adapter supplies view. */
+export function requirePersonChannel(channel = 'terminal', environment = process.env) {
+ if (!['terminal', 'view'].includes(channel)) {
+ throw new Refused('B26_PERSON_CHANNEL', 'person actions use the terminal or the view; run pullboard view, the person’s channel');
+ }
+ if (channel === 'terminal' && AGENT_SHELL_MARKERS.some((name) => Boolean(environment[name]))) {
+ throw new Refused('B26_PERSON_CHANNEL', 'this terminal belongs to an agent; run pullboard view, the person’s channel, and let the person act there');
+ }
+ return channel;
+}
diff --git a/test/person.test.js b/test/person.test.js
new file mode 100644
index 00000000..7ff8c489
--- /dev/null
+++ b/test/person.test.js
@@ -0,0 +1,257 @@
+/** 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 { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { DatabaseSync } from 'node:sqlite';
+import { once } from 'node:events';
+import { test } from 'node:test';
+
+const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
+const MARKERS = {
+ CLAUDECODE: '1',
+ CLAUDE_CODE_ENTRYPOINT: 'cli',
+ AI_AGENT: '1',
+ CODEX_THREAD_ID: 'thread-fixture',
+ CODEX_SESSION_ID: 'session-fixture',
+ CODEX_CI: '1',
+ CODEX_SHELL: '1',
+};
+const SPEC = `# Person answer fixture
+
+## G · Goals
+- G1 [approved, must] The fixture keeps its board. | gate: true
+`;
+const TEMP_DIRS = [];
+
+/** Remove every recognized agent marker from an environment copy. */
+function cleanEnvironment(source) {
+ const env = { ...source };
+ for (const key of Object.keys(MARKERS)) delete env[key];
+ return env;
+}
+
+/** Quote a literal executable path for the fixture hook's POSIX shim. */
+function shellWord(value) {
+ return `'${value.replaceAll("'", "'\\''")}'`;
+}
+
+/** Create an isolated Git environment and an actual CLI subprocess runner. */
+function sandbox() {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-person-channel-')));
+ TEMP_DIRS.push(dir);
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec ${shellWord(process.execPath)} ${shellWord(BIN)} "$@"\n`);
+ chmodSync(join(bin, 'pullboard'), 0o755);
+ const env = cleanEnvironment({
+ ...process.env,
+ PATH: `${bin}:${process.env.PATH}`,
+ GIT_CONFIG_GLOBAL: '/dev/null',
+ GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Person channel test',
+ GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Person channel test',
+ GIT_COMMITTER_EMAIL: '[email protected]',
+ PULLBOARD_HOME: join(dir, 'pullboard-home'),
+ });
+ /** Run real Git commands under isolated author and configuration settings. */
+ const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();
+ /** Run the real Pullboard CLI in its own process with optional environment markers. */
+ const run = (cwd, args, extraEnv = {}) => spawnSync(process.execPath, [BIN, ...args], {
+ cwd, env: { ...env, ...extraEnv }, encoding: 'utf8', timeout: 10_000,
+ });
+ return { dir, env, git, run };
+}
+
+/** Initialize a real repository, configure its lane, and join a real worktree. */
+function project() {
+ const box = sandbox();
+ const repo = join(box.dir, 'repo');
+ mkdirSync(repo);
+ box.git(repo, 'init', '-q', '-b', 'main');
+ const initialized = box.run(repo, ['init']);
+ assert.equal(initialized.status, 0, initialized.stderr);
+ const configPath = join(repo, 'pullboard.json');
+ const config = JSON.parse(readFileSync(configPath, 'utf8'));
+ writeFileSync(configPath, `${JSON.stringify({
+ ...config,
+ gate: 'true',
+ spec: 'SPEC.md',
+ lanes: { web: { owns: ['web/'], specs: ['G1'] } },
+ shared: [],
+ }, null, 2)}\n`);
+ writeFileSync(join(repo, 'SPEC.md'), SPEC);
+ box.git(repo, 'add', '-A');
+ box.git(repo, 'commit', '-q', '-m', 'chore: set up person channel fixture');
+ const web = join(box.dir, 'web-1');
+ box.git(repo, 'worktree', 'add', '-q', web, '-b', 'web/one');
+ const joined = box.run(web, ['join', 'web']);
+ assert.equal(joined.status, 0, joined.stderr);
+ return { ...box, repo, web };
+}
+
+/** Read persisted shout and event counts without opening or migrating the board. */
+function boardCounts(file) {
+ const db = new DatabaseSync(file, { readOnly: true });
+ try {
+ return {
+ shouts: db.prepare('SELECT COUNT(*) AS count FROM shout').get().count,
+ events: db.prepare('SELECT COUNT(*) AS count FROM event').get().count,
+ };
+ } finally {
+ db.close();
+ }
+}
+
+/** Return the private database event detail for the most recent answer. */
+function lastAnswerDetail(file) {
+ const db = new DatabaseSync(file, { readOnly: true });
+ try {
+ const row = db.prepare("SELECT event_detail FROM event WHERE event_kind = 'answer' ORDER BY event_id DESC LIMIT 1").get();
+ assert.ok(row, 'the successful person answer must append an answer event');
+ return JSON.parse(row.event_detail);
+ } finally {
+ db.close();
+ }
+}
+
+test('[B26] person answers refuse agent environments without writes and record terminal channel', (t) => {
+ t.after(() => {
+ for (const dir of TEMP_DIRS) rmSync(dir, { recursive: true, force: true });
+ });
+ const box = project();
+ const asked = box.run(box.web, ['shout', 'coordinator', 'Ship the patch?', '--decision']);
+ assert.equal(asked.status, 0, asked.stderr);
+ const askedId = /as #(\d+)/u.exec(asked.stdout)?.[1];
+ assert.ok(askedId, asked.stdout);
+ const passed = box.run(box.repo, ['pass', askedId, 'The person should decide.']);
+ assert.equal(passed.status, 0, passed.stderr);
+ const personId = /as #(\d+)/u.exec(passed.stdout)?.[1];
+ assert.ok(personId, passed.stdout);
+
+ const database = join(box.repo, '.git', 'pullboard', 'board.sqlite');
+ const beforeRefusals = boardCounts(database);
+ for (const [marker, value] of Object.entries(MARKERS)) {
+ const refused = box.run(box.repo, ['answer', personId, 'Ship it.', '--as', 'person', '--json'], { [marker]: value });
+ assert.equal(refused.status, 1, `${marker}: ${refused.stdout}${refused.stderr}`);
+ assert.equal(refused.stderr, '', `${marker} refusal should be a single JSON document`);
+ const document = JSON.parse(refused.stdout);
+ assert.equal(document.error.code, 'B26_PERSON_CHANNEL', marker);
+ assert.match(document.error.message, /view/iu, marker);
+ assert.match(document.error.next, /pullboard view/iu, marker);
+ assert.deepEqual(boardCounts(database), beforeRefusals, `${marker} must not append an answer or event`);
+ }
+
+ const terminal = box.run(box.repo, ['answer', personId, 'Ship it.', '--as', 'person', '--json'], cleanEnvironment(box.env));
+ assert.equal(terminal.status, 0, terminal.stderr);
+ const answer = JSON.parse(terminal.stdout);
+ assert.equal(answer.version, 1);
+ assert.equal(lastAnswerDetail(database).channel, 'terminal');
+});
+
+
+/** Start the actual view in an agent environment and retain only its private request credentials. */
+async function startView(t, box) {
+ const child = spawn(process.execPath, [BIN, 'view', '--no-open', '--port', '0', '--json'], {
+ cwd: box.repo, env: { ...box.env, ...MARKERS }, stdio: ['ignore', 'pipe', 'pipe'],
+ });
+ let output = '';
+ let diagnostics = '';
+ child.stdout.setEncoding('utf8');
+ child.stderr.setEncoding('utf8').on('data', (part) => { diagnostics += part; });
+ const closed = once(child, 'close');
+ t.after(async () => {
+ if (child.exitCode !== null) return;
+ child.kill('SIGTERM');
+ let timer;
+ await Promise.race([closed, new Promise((done) => {
+ timer = setTimeout(() => { child.kill('SIGKILL'); done(); }, 5000);
+ })]);
+ clearTimeout(timer);
+ });
+ const document = await new Promise((ready, fail) => {
+ const timer = setTimeout(() => fail(new Error('the private view did not start: ' + diagnostics)), 10_000);
+ child.stdout.on('data', (part) => {
+ output += part;
+ try {
+ const value = JSON.parse(output);
+ clearTimeout(timer);
+ ready(value);
+ } catch { /* The JSON envelope may arrive in several chunks. */ }
+ });
+ child.once('error', (error) => { clearTimeout(timer); fail(error); });
+ child.once('close', () => { clearTimeout(timer); fail(new Error('the private view exited: ' + diagnostics)); });
+ });
+ const address = new URL(document.url);
+ const secret = address.searchParams.get('k');
+ assert.ok(secret, 'the actual view starts with its private session credentials');
+ /** Send bounded authenticated requests through the same adapter the view uses. */
+ const request = (path, options = {}) => fetch(new URL(path, address.origin), {
+ ...options, headers: { 'x-pullboard-key': secret, ...options.headers }, signal: AbortSignal.timeout(10_000),
+ });
+ return request;
+}
+
+test('[B26,B27] a view launched by an agent records view on both person answer receipts', async (t) => {
+ const box = project();
+ t.after(() => rmSync(box.dir, { recursive: true, force: true }));
+ const asked = box.run(box.web, ['shout', 'coordinator', 'Ship from the view?', '--decision', '--json']);
+ assert.equal(asked.status, 0, asked.stderr);
+ const original = JSON.parse(asked.stdout).id;
+ const passed = box.run(box.repo, ['pass', String(original), 'The person should decide.', '--json']);
+ assert.equal(passed.status, 0, passed.stderr);
+ const person = JSON.parse(passed.stdout).id;
+ const request = await startView(t, box);
+ const boards = await (await request('/api/v1/boards')).json();
+ const board = boards.boards.find((candidate) => candidate.root === box.repo);
+ assert.ok(board, 'the real initialized project is listed in the view');
+ const path = `/api/v1/boards/${board.id}/moves`;
+ const database = join(box.repo, '.git', 'pullboard', 'board.sqlite');
+ const before = boardCounts(database);
+ const forged = await request(path, {
+ method: 'POST', headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ verb: 'answer', item: person, agent: 'coordinator', args: { text: 'Yes.', as: 'person', channel: 'view' } }),
+ });
+ assert.equal(forged.status, 400, 'channel is adapter evidence, never a caller-supplied argument');
+ assert.equal((await forged.json()).error.code, 'BAD_REQUEST');
+ assert.deepEqual(boardCounts(database), before);
+ const response = await request(path, {
+ method: 'POST', headers: { 'content-type': 'application/json' },
+ body: JSON.stringify({ verb: 'answer', item: person, agent: 'coordinator', args: { text: 'Yes.', as: 'person' } }),
+ });
+ assert.equal(response.status, 200, await response.clone().text());
+ const answer = await response.json();
+ assert.equal(answer.event.event_by, 'person');
+ assert.equal(JSON.parse(answer.event.event_detail).channel, 'view');
+ const db = new DatabaseSync(database, { readOnly: true });
+ try {
+ const receipts = db.prepare("SELECT event_detail FROM event WHERE event_kind = 'answer' AND event_by = 'person' ORDER BY event_id").all();
+ assert.equal(receipts.length, 2, 'the decision answer and its forwarded reply both remain recorded');
+ assert.deepEqual(receipts.map((row) => JSON.parse(row.event_detail).channel), ['view', 'view']);
+ } finally { db.close(); }
+});
+
+
+test('[B26,S5] an agent shell cannot append a person sign-off but a plain shell can', (t) => {
+ const box = project();
+ t.after(() => rmSync(box.dir, { recursive: true, force: true }));
+ mkdirSync(join(box.repo, 'test'));
+ writeFileSync(join(box.repo, 'test/proof.test.js'), '/** Local board preservation evidence [G1]. */\n');
+ box.git(box.repo, 'add', 'test/proof.test.js');
+ box.git(box.repo, 'commit', '-q', '-m', 'test: cite board preservation [G1]');
+ const file = join(box.repo, '.pullboard/signoffs.jsonl');
+ const plain = box.run(box.repo, ['spec', 'signoff', 'G1', '--by', 'CO', '--json']);
+ assert.equal(plain.status, 0, plain.stdout + plain.stderr);
+ assert.equal(JSON.parse(plain.stdout).count, 1);
+ const original = readFileSync(file, 'utf8');
+ for (const [name, value] of Object.entries(MARKERS)) {
+ const refused = box.run(box.repo, ['spec', 'signoff', 'G1', '--by', 'CO', '--json'], { [name]: value });
+ assert.equal(refused.status, 1, name + ': ' + refused.stdout + refused.stderr);
+ const error = JSON.parse(refused.stdout).error;
+ assert.equal(error.code, 'B26_PERSON_CHANNEL', name);
+ assert.match(error.next, /pullboard view/iu, name);
+ assert.equal(readFileSync(file, 'utf8'), original, name + ' preserves every existing sign-off byte');
+ }
+});