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(core): record declared model family [O3]

Corey Olson5c9f43f21ba4
diff --git a/docs/api.md b/docs/api.md
index 5db94c47..dc29a523 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -60,6 +60,8 @@ A successful command returns the fields listed below. `version` is always the nu
| `hook pre-push` | `version:number`, `messages:array` |
<!-- api-command-shapes:end -->
+`join` and `worktree` accept an optional free-text `--family` declaration. Rejoining the same worktree preserves its agent id; a supplied family updates the declaration, while omitting `--family` preserves it. `resume` includes it as `me.family`; `show` includes `item_builder_family` and each verdict's `verdict_verifier_family`. These recorded fields are `null` when the agent did not declare a family, and later declarations do not rewrite prior submissions or verdicts.
+
## Refusals
A refusal keeps the command's existing exit status and prints exactly one versioned document to stdout. In JSON mode stderr stays empty. The command-specific `code` identifies the rule; `message` explains what happened; `next` gives the next step.
diff --git a/src/board.js b/src/board.js
index c758413d..d2939308 100644
--- a/src/board.js
+++ b/src/board.js
@@ -53,6 +53,7 @@ const SCHEMA = `
agent_path TEXT NOT NULL UNIQUE,
agent_last_shout_id INTEGER NOT NULL DEFAULT 0,
agent_route TEXT NOT NULL DEFAULT 'strong',
+ agent_family TEXT,
agent_created_at TEXT NOT NULL
);
CREATE TABLE IF NOT EXISTS item (
@@ -72,6 +73,7 @@ const SCHEMA = `
item_frozen TEXT,
item_frozen_digest TEXT,
item_built_by TEXT,
+ item_builder_family TEXT,
item_commit TEXT,
item_tree TEXT,
item_verdict TEXT,
@@ -87,6 +89,7 @@ const SCHEMA = `
verdict_id INTEGER PRIMARY KEY AUTOINCREMENT,
item_id INTEGER NOT NULL REFERENCES item (item_id),
verdict_by TEXT NOT NULL,
+ verdict_verifier_family TEXT,
verdict_decision TEXT NOT NULL,
verdict_reason TEXT NOT NULL,
verdict_note TEXT NOT NULL DEFAULT '',
@@ -209,6 +212,9 @@ function migrate(db) {
['item', 'item_route', "TEXT NOT NULL DEFAULT 'strong'"],
['item', 'item_check', "TEXT NOT NULL DEFAULT ''"],
['agent', 'agent_route', "TEXT NOT NULL DEFAULT 'strong'"],
+ ['agent', 'agent_family', 'TEXT'],
+ ['item', 'item_builder_family', 'TEXT'],
+ ['verdict', 'verdict_verifier_family', 'TEXT'],
['item', 'item_claim_head', 'TEXT'],
['item', 'item_files', "TEXT NOT NULL DEFAULT ''"],
['item', 'item_review_by', 'TEXT'],
@@ -346,13 +352,15 @@ export function agentAt(board, path) {
/**
* Register a worktree as an agent (B3): the main checkout as the one coordinator, any other
* worktree as the next agent in its lane (`web-1`, `web-2`, ...), on a route: the tier of model
- * behind it, which decides the items it may take (B13). Registering again is a no-op.
+ * behind it, which decides the items it may take (B13). The optional family is free text supplied
+ * by the agent; the board neither names nor infers it. Registering again preserves the agent id;
+ * an explicitly supplied family updates the declaration, while omission preserves it.
*
* @param {any} board
- * @param {{ lane: string, path: string, route?: string }} who
+ * @param {{ lane: string, path: string, route?: string, family?: string | null }} who
* @returns {string} The agent's id.
*/
-export function register(board, { lane, path, route = 'strong' }) {
+export function register(board, { lane, path, route = 'strong', family }) {
checkRoute(route);
if (lane === COORDINATOR && route !== 'strong') {
throw new Refused('BAD_ROUTE', 'the coordinator plans, merges and verifies; it is always strong');
@@ -366,6 +374,10 @@ export function register(board, { lane, path, route = 'strong' }) {
`this worktree is ${existing.agent_id} in the ${existing.agent_lane} lane, routed ${existing.agent_route}; use another worktree for ${lane} routed ${route}`,
);
}
+ if (family !== undefined && family !== existing.agent_family) {
+ board.db.prepare('UPDATE agent SET agent_family = ? WHERE agent_id = ?').run(family, existing.agent_id);
+ logEvent(board, existing.agent_id, 'family', null, { family });
+ }
return existing.agent_id;
}
const { total } = board.db
@@ -377,9 +389,9 @@ export function register(board, { lane, path, route = 'strong' }) {
const id = lane === COORDINATOR ? COORDINATOR : `${lane}-${total + 1}`;
board.db
.prepare(
- 'INSERT INTO agent (agent_id, agent_lane, agent_path, agent_route, agent_created_at) VALUES (?, ?, ?, ?, ?)',
+ 'INSERT INTO agent (agent_id, agent_lane, agent_path, agent_route, agent_family, agent_created_at) VALUES (?, ?, ?, ?, ?, ?)',
)
- .run(id, lane, path, route, now(board));
+ .run(id, lane, path, route, family ?? null, now(board));
logEvent(board, id, 'join', null, route === 'strong' ? { lane } : { lane, route });
return id;
});
@@ -828,6 +840,7 @@ export function submit(board, id, { agentId, commit, tree, files = [] }) {
},
set: (found) => ({
item_built_by: agentId,
+ item_builder_family: board.db.prepare('SELECT agent_family FROM agent WHERE agent_id = ?').get(agentId)?.agent_family ?? null,
item_commit: commit,
item_tree: tree,
item_lease_until: null,
@@ -973,13 +986,14 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,
noteGiven: () => (note.trim() ? null : new Refused('NOTE_REQUIRED', 'a reject says what failed: --note "..."')),
},
before: (found) => {
+ const family = board.db.prepare('SELECT agent_family FROM agent WHERE agent_id = ?').get(agentId)?.agent_family ?? null;
board.db
.prepare(
`INSERT INTO verdict (item_id, verdict_by, verdict_decision, verdict_reason, verdict_note,
- verdict_commit, verdict_digest, verdict_head, verdict_at)
- VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
+ verdict_commit, verdict_digest, verdict_head, verdict_verifier_family, verdict_at)
+ VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,
)
- .run(id, agentId, decision, code, note.trim(), found.item_commit, digest, head, now(board));
+ .run(id, agentId, decision, code, note.trim(), found.item_commit, digest, head, family, now(board));
},
set: (found) => ({ item_verdict: decision, item_verified_by: isAccept ? agentId : null, item_owner: isAccept ? found.item_owner : null }),
});
diff --git a/src/cli.js b/src/cli.js
index 7efc7b16..4135308a 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -56,9 +56,9 @@ Nothing ships until a second agent verifies it.
Set up
pullboard tour see it work: a reject and its rework, scripted, in thirty seconds
pullboard init config, SPEC.md, agent instructions, git hooks, board
- pullboard worktree <lane> [--route light] make a worktree for a new agent in a lane, joined, and say what to run next
- pullboard join <lane> [--route light] register the worktree you are in as an agent in a lane
- --route light: a lighter model that takes only items routed light
+ pullboard worktree <lane> [--route light] [--family <name>] make and join a worktree for a new agent
+ pullboard join <lane> [--route light] [--family <name>] register this worktree as an agent
+ --route sets which work the model can take; --family records its name
pullboard whoami | lanes | status who you are, the lanes, the board at a glance
pullboard view [--port N] [--no-open] every project on this machine in your browser: items, shouts, doctrine,
agents and activity, live; add items, shout and hold lanes from it
@@ -147,6 +147,7 @@ const OPTIONS = {
brief: { type: 'string' },
'brief-file': { type: 'string' },
route: { type: 'string' },
+ family: { type: 'string' },
as: { type: 'string' },
check: { type: 'string' },
agent: { type: 'string' },
@@ -356,15 +357,19 @@ function withBoard(ctx, work) {
*
* @param {any} ctx
* @param {any} board
- * @returns {{ id: string, lane: string }}
+ * @returns {{ id: string, lane: string, route?: string, family: string | null }}
*/
function whoAmI(ctx, board) {
- if (ctx.info.isMain) return { id: store.ensureCoordinator(board, ctx.info.root), lane: COORDINATOR };
+ if (ctx.info.isMain) {
+ const id = store.ensureCoordinator(board, ctx.info.root);
+ const agent = store.agentAt(board, ctx.info.root);
+ return { id, lane: COORDINATOR, family: agent?.agent_family ?? null };
+ }
const agent = store.agentAt(board, ctx.info.root);
if (!agent) {
throw new Refused('NOT_JOINED', 'this worktree has not joined a lane: pullboard join <lane> (see: pullboard lanes)');
}
- return { id: agent.agent_id, lane: agent.agent_lane, route: agent.agent_route };
+ return { id: agent.agent_id, lane: agent.agent_lane, route: agent.agent_route, family: agent.agent_family ?? null };
}
/**
@@ -577,7 +582,7 @@ function resumeHere(io) {
const { me } = card;
const say = (line) => io.say(line);
const plural = (n, word) => `${n} ${word}${n === 1 ? '' : 's'}`;
- say(`resume: ${me.id}, ${me.lane} lane${isMain ? ', the main checkout' : ''}, at ${root}`);
+ say(`resume: ${me.id}${me.family ? ` (${me.family})` : ''}, ${me.lane} lane${isMain ? ', the main checkout' : ''}, at ${root}`);
const dirty = dirtyFiles(root).length;
if (!isMain) {
const branch = tryGit(root, ['rev-parse', '--abbrev-ref', 'HEAD']).stdout || 'HEAD';
@@ -696,12 +701,12 @@ function setupCommands(io, { first, values }) {
throw new Refused('NO_LANE', `no lane "${first ?? ''}"; lanes: ${laneNames(ctx.config).slice(1).join(', ') || 'none yet, declare them in pullboard.json'}`);
}
const route = values.route ?? 'strong';
- const id = withBoard(ctx, (board) => store.register(board, { lane: first, path: ctx.info.root, route }));
+ const id = withBoard(ctx, (board) => store.register(board, { lane: first, path: ctx.info.root, route, family: values.family }));
io.result?.({ agent: id, lane: first, route, path: ctx.info.root });
io.say(`joined as ${id} in the ${first} lane${route === 'light' ? ', on the light route' : ''}`);
return 0;
},
- worktree: () => worktreeFor(io, first, values.route ?? 'strong'),
+ worktree: () => worktreeFor(io, first, values.route ?? 'strong', values.family ?? null),
};
}
@@ -712,9 +717,10 @@ function setupCommands(io, { first, values }) {
* @param {any} io
* @param {string | undefined} lane
* @param {string} route
+ * @param {string | null} family
* @returns {number}
*/
-function worktreeFor(io, lane, route) {
+function worktreeFor(io, lane, route, family = null) {
const ctx = context(io);
if (!lane || lane === COORDINATOR || !isLane(ctx.config, lane)) {
throw new Refused('NO_LANE', `no lane "${lane ?? ''}"; lanes: ${laneNames(ctx.config).slice(1).join(', ') || 'none yet, declare them in pullboard.json'}`);
@@ -730,9 +736,9 @@ function worktreeFor(io, lane, route) {
while (isTaken(n)) n += 1;
git(mainRoot, ['worktree', 'add', '-q', '-b', `${lane}/${n}`, pathFor(n), git(mainRoot, ['rev-parse', 'HEAD'])]);
const root = git(pathFor(n), ['rev-parse', '--show-toplevel']);
- const id = withBoard(ctx, (board) => store.register(board, { lane, path: root, route }));
+ const id = withBoard(ctx, (board) => store.register(board, { lane, path: root, route, family }));
io.result?.({ agent: id, lane, route, path: root, branch: `${lane}/${n}`, prompt: `You are ${id}, in the ${lane} lane. Work only in ${shellWord(root)}, and start every command with ${cdTo(root)}\nRead ${shellWord(join(root, 'AGENTS.md'))} first. Its rules govern this work, over any other repo's instructions you were given.` });
- io.say(`made ${root} on branch ${lane}/${n}, joined as ${id} in the ${lane} lane${route === 'light' ? ', on the light route' : ''}`);
+ io.say(`made ${root} on branch ${lane}/${n}, joined as ${id} in the ${lane} lane${route === 'light' ? ', on the light route' : ''}${family ? ` (${family})` : ''}`);
io.say(`Work only in that folder. A shell that starts each command in the main checkout acts as the coordinator there, so start every command with: ${cdTo(root)}`);
if (existsSync(join(root, 'package.json'))) io.say(` ${cdTo(root)} npm install (its own install, so its tests run its own code)`);
io.say(` ${cdTo(root)} pullboard inbox`);
@@ -851,11 +857,11 @@ function readCommands(io, { first, values }) {
io.say(`frozen at claim (${item.item_frozen_digest.slice(0, 12)}):`);
frozen.rows.forEach((row) => io.say(` ${row.id}: ${row.text}${row.gate ? ` | gate: ${row.gate}` : ''}`));
}
- if (item.item_commit) io.say(`submitted by ${item.item_built_by} at ${item.item_commit}`);
+ if (item.item_commit) io.say(`submitted by ${item.item_built_by}${item.item_builder_family ? ` (${item.item_builder_family})` : ''} at ${item.item_commit}`);
if (reviewer) io.say(`under review by ${reviewer} until ${item.item_review_until}`);
// Earlier verdicts as one line each, so an item sent back several times stays short to read
// (N30); --history prints every note in full.
- const verdictLine = (verdict) => `${verdict.verdict_decision} ${verdict.verdict_reason} by ${verdict.verdict_by} at ${verdict.verdict_commit.slice(0, 12)}`;
+ const verdictLine = (verdict) => `${verdict.verdict_decision} ${verdict.verdict_reason} by ${verdict.verdict_by}${verdict.verdict_verifier_family ? ` (${verdict.verdict_verifier_family})` : ''} at ${verdict.verdict_commit.slice(0, 12)}`;
const notes = verdicts.map((verdict, index) => (values.history || index === verdicts.length - 1 ? verdict.verdict_note : firstLineOf(verdict.verdict_note)));
verdicts.forEach((verdict, index) => io.say(`${verdictLine(verdict)}${notes[index] ? `: ${notes[index]}` : ''}`));
if (notes.some((note, index) => note !== verdicts[index].verdict_note)) io.say(`(earlier verdicts shortened; every note in full: pullboard show ${id} --history)`);
diff --git a/test/board.test.js b/test/board.test.js
index 66aab55b..e4bd75d8 100644
--- a/test/board.test.js
+++ b/test/board.test.js
@@ -11,6 +11,7 @@ import { beforeEach, test } from 'node:test';
import * as store from '../src/board.js';
import { main } from '../src/cli.js';
import { briefFiles } from '../src/brief.js';
+import { JSON_SHAPES } from '../src/json.js';
const HOUR = 3_600_000;
const SHA_A = 'a'.repeat(40);
@@ -28,6 +29,49 @@ const freeze = (item) => ({ text: item.item_title, digest: `digest:${item.item_t
*/
const claimAs = (id, agentId, lane) => store.claim(board, id, { agentId, lane, leaseMs: 2 * HOUR, freeze });
+/**
+ * Run one CLI command with captured text and JSON output streams.
+ *
+ * @param {string} cwd
+ * @param {string[]} argv
+ * @returns {Promise<{ code: number, stdout: string, stderr: string }>}
+ */
+async function runMain(cwd, argv) {
+ let stdout = '';
+ let stderr = '';
+ const code = await main(argv, {
+ cwd,
+ stdout: { isTTY: false, write: (text) => { stdout += text; } },
+ stderr: { write: (text) => { stderr += text; } },
+ });
+ return { code, stdout, stderr };
+}
+
+/**
+ * Freeze the real spec row shape that `show` renders for the family integration fixture.
+ *
+ * @returns {{ text: string, digest: string }}
+ */
+function familyFreeze() {
+ return {
+ text: JSON.stringify({ rows: [{ id: 'G1', text: 'Families are recorded.', gate: 'true' }] }),
+ digest: 'digest:family',
+ };
+}
+
+/**
+ * Check every required top-level JSON result field against the shared CLI catalog.
+ *
+ * @param {any} result
+ * @param {string} command
+ */
+function assertJsonShape(result, command) {
+ for (const [key, type] of Object.entries(JSON_SHAPES.commands[command].required)) {
+ const correct = type === 'array' ? Array.isArray(result[key]) : typeof result[key] === type;
+ assert.equal(correct, true, `${command} JSON field ${key}`);
+ }
+}
+
beforeEach(() => {
let at = Date.parse('2026-10-04T12:00:00Z');
clock = { now: () => new Date(at), advance: (ms) => { at += ms; } };
@@ -281,22 +325,26 @@ 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 by an older version is migrated on open', () => {
+test('a board made by an older version is migrated on open [O3]', () => {
const dir = mkdtempSync(join(tmpdir(), 'pullboard-migrate-'));
try {
const file = join(dir, 'board.sqlite');
const old = store.openBoard(file, clock);
- for (const column of ['item_after', 'item_brief', 'item_route', 'item_check', 'item_claim_head', 'item_files']) old.db.exec(`ALTER TABLE item DROP COLUMN ${column}`);
- old.db.exec('ALTER TABLE agent DROP COLUMN agent_route');
+ for (const column of ['item_after', 'item_brief', 'item_route', 'item_check', 'item_claim_head', 'item_files', 'item_builder_family']) old.db.exec(`ALTER TABLE item DROP COLUMN ${column}`);
+ for (const column of ['agent_route', 'agent_family']) old.db.exec(`ALTER TABLE agent DROP COLUMN ${column}`);
+ old.db.exec('ALTER TABLE verdict DROP COLUMN verdict_verifier_family');
old.db.exec('DROP TABLE hold');
store.closeBoard(old);
const reopened = store.openBoard(file, clock);
const columns = (table) => reopened.db.prepare(`PRAGMA table_info(${table})`).all().map((column) => column.name);
- const [items, agents, holds] = [columns('item'), columns('agent'), columns('hold')];
+ const [items, agents, verdicts, holds] = [columns('item'), columns('agent'), columns('verdict'), columns('hold')];
store.closeBoard(reopened);
for (const column of ['item_after', 'item_brief', 'item_route', 'item_check', 'item_claim_head', 'item_files']) assert.ok(items.includes(column), column);
assert.ok(holds.includes('hold_reason'));
assert.ok(agents.includes('agent_route'));
+ assert.ok(agents.includes('agent_family'));
+ assert.ok(items.includes('item_builder_family'));
+ assert.ok(verdicts.includes('verdict_verifier_family'));
} finally {
rmSync(dir, { recursive: true, force: true });
}
@@ -524,3 +572,125 @@ test('a builder reworks its own rejected item beside its one claim; nothing else
claimAs(nav, 'web-2', 'web');
assert.throws(() => claimAs(aside, 'web-2', 'web'), /ONE_CLAIM/, "another agent's rejected item is no rework of web-2's");
});
+
+test('[O3] declared families travel from join through submit and verdict, and absent family is allowed', async (t) => {
+ const directory = mkdtempSync(join(tmpdir(), 'pullboard-families-'));
+ t.after(() => rmSync(directory, { recursive: true, force: true }));
+ const previousHome = process.env.PULLBOARD_HOME;
+ process.env.PULLBOARD_HOME = join(directory, 'pullboard-home');
+ t.after(() => {
+ if (previousHome === undefined) delete process.env.PULLBOARD_HOME;
+ else process.env.PULLBOARD_HOME = previousHome;
+ });
+ const repo = join(directory, 'repo');
+ mkdirSync(repo);
+ const env = {
+ ...process.env,
+ GIT_CONFIG_GLOBAL: '/dev/null',
+ GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Test Agent',
+ GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Test Agent',
+ GIT_COMMITTER_EMAIL: '[email protected]',
+ };
+ /** Run Git with isolated identity and configuration in the fixture repository. */
+ const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();
+ git(repo, 'init', '-q', '-b', 'main');
+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({
+ gate: 'true',
+ spec: 'SPEC.md',
+ verify: 'any',
+ lanes: { web: { owns: ['web/'], specs: [] }, review: { owns: ['review/'], specs: [] } },
+ shared: [],
+ }));
+ writeFileSync(join(repo, 'SPEC.md'), '# Family test\n\n## G · Goals\n- G1 [approved, must] Families are recorded. | gate: true\n');
+ git(repo, 'add', '-A');
+ git(repo, 'commit', '-q', '-m', 'chore: initialize family test');
+
+ const made = await runMain(repo, ['worktree', 'web', '--family', 'Family Alpha', '--json']);
+ assert.equal(made.code, 0, made.stderr || made.stdout);
+ const worktree = JSON.parse(made.stdout);
+ assertJsonShape(worktree, 'worktree');
+ const builderPath = worktree.path;
+ const reviewerPath = join(directory, 'reviewer');
+ git(repo, 'worktree', 'add', '-q', '-b', 'review/one', reviewerPath, 'main');
+ const reviewerRoot = git(reviewerPath, 'rev-parse', '--show-toplevel');
+ const joined = await runMain(reviewerRoot, ['join', 'review', '--family', 'Family Beta', '--json']);
+ assert.equal(joined.code, 0, joined.stderr || joined.stdout);
+ const joinResult = JSON.parse(joined.stdout);
+ assertJsonShape(joinResult, 'join');
+ const noFamilyPath = join(directory, 'no-family');
+ git(repo, 'worktree', 'add', '-q', '-b', 'web/two', noFamilyPath, 'main');
+ const noFamilyRoot = git(noFamilyPath, 'rev-parse', '--show-toplevel');
+ const joinedWithout = await runMain(noFamilyRoot, ['join', 'web']);
+ assert.equal(joinedWithout.code, 0, joinedWithout.stderr || joinedWithout.stdout);
+
+ const file = join(repo, '.git', 'pullboard', 'board.sqlite');
+ const persistent = store.openBoard(file);
+ t.after(() => store.closeBoard(persistent));
+ assert.equal(store.agentAt(persistent, builderPath).agent_family, 'Family Alpha');
+ assert.equal(store.agentAt(persistent, reviewerRoot).agent_family, 'Family Beta');
+ assert.equal(store.agentAt(persistent, noFamilyRoot).agent_family, null);
+ store.register(persistent, { lane: 'coordinator', path: repo });
+ assert.equal(store.agentAt(persistent, repo).agent_family, null, 'the core supplies no family for itself');
+ store.register(persistent, { lane: 'coordinator', path: repo, family: 'Family Coordinator' });
+ const coordinatorResume = await runMain(repo, ['resume']);
+ assert.match(coordinatorResume.stdout, /resume: coordinator \(Family Coordinator\), coordinator lane/);
+ const coordinatorJson = await runMain(repo, ['resume', '--json']);
+ assert.equal(JSON.parse(coordinatorJson.stdout).me.family, 'Family Coordinator');
+
+ const id = store.addItem(persistent, { by: 'coordinator', lane: 'web', title: 'Family feature' });
+ store.claim(persistent, id, { agentId: 'web-1', lane: 'web', leaseMs: 2 * HOUR, freeze: familyFreeze });
+ store.submit(persistent, id, { agentId: 'web-1', commit: SHA_A, tree: 'tree-a' });
+ assert.equal(store.getItem(persistent, id).item_builder_family, 'Family Alpha');
+ store.verify(persistent, id, {
+ agentId: 'review-1', decision: 'ACCEPT', note: 'checked the saved family fields',
+ head: SHA_A, digest: 'digest:family', policy: 'any',
+ });
+ const [recorded] = store.verdictsFor(persistent, id);
+ assert.equal(recorded.verdict_verifier_family, 'Family Beta');
+
+ const shown = await runMain(repo, ['show', String(id), '--json']);
+ assert.equal(shown.code, 0, shown.stderr || shown.stdout);
+ const shownJson = JSON.parse(shown.stdout);
+ assertJsonShape(shownJson, 'show');
+ assert.equal(shownJson.item_builder_family, 'Family Alpha');
+ assert.equal(shownJson.verdicts[0].verdict_verifier_family, 'Family Beta');
+ const shownText = await runMain(repo, ['show', String(id)]);
+ assert.match(shownText.stdout, /submitted by web-1 \(Family Alpha\)/);
+ assert.match(shownText.stdout, /ACCEPT CRITERION_MET by review-1 \(Family Beta\)/);
+
+ const redeclared = await runMain(reviewerRoot, ['join', 'review', '--family', 'Family Gamma', '--json']);
+ assert.equal(redeclared.code, 0, redeclared.stderr || redeclared.stdout);
+ assert.equal(JSON.parse(redeclared.stdout).agent, 'review-1', 'redeclaring keeps the existing agent id');
+ assert.equal(store.agentAt(persistent, reviewerRoot).agent_family, 'Family Gamma');
+ assert.equal(store.verdictsFor(persistent, id)[0].verdict_verifier_family, 'Family Beta', 'a later declaration leaves the old verdict unchanged');
+ const rejoined = await runMain(reviewerRoot, ['join', 'review', '--json']);
+ assert.equal(rejoined.code, 0, rejoined.stderr || rejoined.stdout);
+ assert.equal(store.agentAt(persistent, reviewerRoot).agent_family, 'Family Gamma', 'omitting --family preserves the declaration');
+ const historicalShow = await runMain(repo, ['show', String(id)]);
+ assert.match(historicalShow.stdout, /ACCEPT CRITERION_MET by review-1 \(Family Beta\)/);
+
+ const resumed = await runMain(builderPath, ['resume']);
+ assert.match(resumed.stdout, /resume: web-1 \(Family Alpha\), web lane/);
+ const resumedJson = await runMain(builderPath, ['resume', '--json']);
+ assert.equal(resumedJson.code, 0, resumedJson.stderr || resumedJson.stdout);
+ const resumedShape = JSON.parse(resumedJson.stdout);
+ assertJsonShape(resumedShape, 'resume');
+ assert.equal(resumedShape.me.family, 'Family Alpha');
+
+ const unverified = store.addItem(persistent, { by: 'coordinator', lane: 'review', title: 'No-family verdict' });
+ store.claim(persistent, unverified, { agentId: 'review-1', lane: 'review', leaseMs: 2 * HOUR, freeze: familyFreeze });
+ store.submit(persistent, unverified, { agentId: 'review-1', commit: SHA_B, tree: 'tree-b' });
+ store.verify(persistent, unverified, {
+ agentId: 'web-2', decision: 'ACCEPT', note: 'checked without a family declaration',
+ head: SHA_B, digest: 'digest:family', policy: 'any',
+ });
+ const [unattributed] = store.verdictsFor(persistent, unverified);
+ assert.equal(unattributed.verdict_verifier_family, null);
+
+ const unclaimed = store.addItem(persistent, { by: 'coordinator', lane: 'web', title: 'No-family submission' });
+ store.claim(persistent, unclaimed, { agentId: 'web-2', lane: 'web', leaseMs: 2 * HOUR, freeze: familyFreeze });
+ store.submit(persistent, unclaimed, { agentId: 'web-2', commit: SHA_A, tree: 'tree-c' });
+ assert.equal(store.getItem(persistent, unclaimed).item_builder_family, null);
+});