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.
JavaScript agentic-codingai-agentsai-governanceautonomous-agentsclaude-codeclicode-reviewcodexcoding-agentsdeveloper-toolsgit-hooksllmlocal-firstmulti-agentsoftware-factoryspec-driven-developmentverificationvibe-coding
feat(board): record accept check outcomes [V19,V8]
Corey Olsonc297289ff082
diff --git a/docs/formats.md b/docs/formats.mdindex 989ca7ac..81691652 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -227,7 +227,7 @@ Each connection also has a temporary `moving(token INTEGER)` table and `status_t## Event log-The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its append-only record format has the independent `EVENT_LOG_VERSION`. Each event has an increasing integer id, an ISO timestamp, the actor, the event kind, an optional item id, and a JSON object in `event_detail`. Board moves append their event inside the same immediate transaction as the move. Events are append-only; board triggers reject updates and deletes. The actor column is the acting agent id, except guard-repair events, which use `board`. The following rows name the emitted kinds and the union of their detail keys:+The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its append-only record format has the independent `EVENT_LOG_VERSION`. Each event has an increasing integer id, an ISO timestamp, the actor, the event kind, an optional item id, and a JSON object in `event_detail`. Board moves append their event inside the same immediate transaction as the move. Events are append-only; board triggers reject updates and deletes. The actor column is the acting agent id, except guard-repair events, which use `board`. The following rows name the emitted kinds and their established detail keys; CLI accept events additionally carry the frozen-check result described below:<!-- events:start -->| Kind | Actor | Detail fields |@@ -260,6 +260,8 @@ The `event` table is a SQLite schema object governed by `SCHEMA_VERSION`; its ap| `row_apply` | coordinator | `events` |<!-- events:end -->+A CLI `accept` event includes `check: "none"` when no frozen item check ran or `check: "green"` when it passed. Older accept events and records without this field read as `unknown`; the result stays in event detail and does not change the board schema or event-log version.+Item facts use the existing append-only `event` table and event-log version 1. A `fact` event's actor and timestamp stamp its author and time; its detail carries a stable string `id`, typed `kind`, exact `text`, optional `ref` binding or `null`, and superseded fact id or `null`. Allowed kinds are `capture`, `measurement`, `note`, `diff`, `decision`, `rejection`, `supersession` and `root-cause`. Judgement kinds and any correction using `supersedes` require the item's live holder or the coordinator. A correction must refer to a fact on the same item; it adds a new event and preserves every earlier fact.A binding is `{path, start, end, commit}`: a relative repository path, a positive ascending inclusive line range and a full 40-character hexadecimal commit id. It identifies code without storing source or requiring Git on a replica. Fact ids are generated UUIDs locally. A sealed `appendFact` operation uses its executable move id as its fact id, so replicas keep corrections bound to the same fact even when local event sequence ids differ. Native export/import retains these event rows without a separate fact table or schema upgrade.diff --git a/src/board.js b/src/board.jsindex 97f7b2c2..0be420f7 100644--- a/src/board.js+++ b/src/board.js@@ -1156,10 +1156,10 @@ function reserveWithin(board, id, { agentId, leaseMs, policy, familyPolicy = 'of** @param {any} board* @param {number} id- * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string }} verdict- * @returns {{ decision: string, reason: string }}+ * @param {{ agentId: string, decision: string, reason?: string, note?: string, head: string, digest: string, policy: string, familyPolicy?: string, check?: 'none' | 'green' }} verdict+ * @returns {{ decision: string, reason: string, check?: 'none' | 'green' }}*/-export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off' }) {+export function verify(board, id, { agentId, decision, reason, note = '', head, digest, policy, familyPolicy = 'off', check }) {const verb = { ACCEPT: 'accept', REJECT: 'reject' }[decision];if (!verb) throw new Refused('BAD_DECISION', 'the decision is accept or reject');const isAccept = verb === 'accept';@@ -1197,8 +1197,10 @@ export function verify(board, id, { agentId, decision, reason, note = '', head,},set: (found) => ({ item_verdict: decision, item_verified_by: isAccept ? agentId : null, item_owner: isAccept ? found.item_owner : null }),});- logEvent(board, agentId, verb, id, { reason: code, commit: item.item_commit });- return { decision, reason: code };+ const detail = { reason: code, commit: item.item_commit };+ if (isAccept && check !== undefined) detail.check = check;+ logEvent(board, agentId, verb, id, detail);+ return { decision, reason: code, ...(isAccept && check !== undefined ? { check } : {}) };});}@@ -1326,7 +1328,13 @@ export function getItem(board, id) {* @returns {any[]}*/export function verdictsFor(board, id) {- return board.db.prepare('SELECT * FROM verdict WHERE item_id = ? ORDER BY verdict_id').all(id);+ const verdicts = board.db.prepare('SELECT * FROM verdict WHERE item_id = ? ORDER BY verdict_id').all(id);+ const receipts = board.db.prepare("SELECT event_kind, event_detail FROM event WHERE item_id = ? AND event_kind IN ('accept', 'reject') ORDER BY event_id").all(id);+ return verdicts.map((verdict, index) => {+ let detail = {};+ try { detail = JSON.parse(receipts[index]?.event_detail ?? '{}'); } catch { /* Malformed legacy details remain unknown. */ }+ return { ...verdict, check: detail.check ?? 'unknown' };+ });}/**diff --git a/src/cli.js b/src/cli.jsindex 9d3bfd18..3e535d0c 100644--- a/src/cli.js+++ b/src/cli.js@@ -1270,7 +1270,7 @@ function readCommands(io, { first, second, rest, values }) {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}${verdict.verdict_verifier_family ? ` (${verdict.verdict_verifier_family})` : ''} 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)}; check: ${verdict.check ?? 'unknown'}`;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)`);@@ -1358,7 +1358,10 @@ function readCommands(io, { first, second, rest, values }) {ledger: () => {const ctx = context(io);const { items, stats } = withBoard(ctx, (board) => ({- items: store.listItems(board, { all: true }),+ items: store.listItems(board, { all: true }).map((item) => ({+ ...item,+ check: store.verdictsFor(board, item.item_id).at(-1)?.check ?? 'unknown',+ })),stats: store.stats(board),}));const built = items.filter((item) => item.item_built_by && item.item_status !== 'withdrawn').reverse();@@ -1366,10 +1369,10 @@ function readCommands(io, { first, second, rest, values }) {const cell = (text) => String(text ?? '').replace(/\|/g, '/').replace(/\s+/g, ' ');io.say(`${stats.items.verified} verified by a second agent · ${stats.items.submitted} awaiting verification · ${stats.rejected} rejection${stats.rejected === 1 ? '' : 's'} along the way`);io.say('');- io.say('| # | Lane | Item | Spec | Built by | Verified by | Commit | Merged |');- io.say('| --- | --- | --- | --- | --- | --- | --- | --- |');+ io.say('| # | Lane | Item | Spec | Built by | Verified by | Check | Commit | Merged |');+ io.say('| --- | --- | --- | --- | --- | --- | --- | --- | --- |');for (const item of built) {- io.say(`| ${item.item_id} | ${item.item_lane} | ${cell(item.item_title)} | ${cell(item.item_spec_ids)} | ${item.item_built_by} | ${item.item_verified_by ?? ''} | ${(item.item_commit ?? '').slice(0, 12)} | ${(item.item_merged_commit ?? '').slice(0, 12)} |`);+ io.say(`| ${item.item_id} | ${item.item_lane} | ${cell(item.item_title)} | ${cell(item.item_spec_ids)} | ${item.item_built_by} | ${item.item_verified_by ?? ''} | ${item.check === 'none' ? 'unchecked' : item.check} | ${(item.item_commit ?? '').slice(0, 12)} | ${(item.item_merged_commit ?? '').slice(0, 12)} |`);}return 0;},@@ -1486,6 +1489,7 @@ async function verifyHere(ctx, id, { second, values }) {throw new Refused('NOT_AT_COMMIT', `check out the submitted commit first: ${cdTo(root)} git switch --detach ${item.item_commit.slice(0, 12)}`);}let digest = 'missing';+ let check;try {digest = freezer(ctx)(item).digest;} catch (error) {@@ -1493,7 +1497,7 @@ async function verifyHere(ctx, id, { second, values }) {}if (decision === 'ACCEPT') {if (digest !== item.item_frozen_digest) throw new Refused('CRITERIA_CHANGED', 'the criterion changed; ask the coordinator to refreeze this item before checking it');- const check = checkAtCommit(root, item);+ check = checkAtCommit(root, item);if (check.state === 'unverified') throw new Refused('CHECK_UNVERIFIED', `the frozen ${check.stage} could not be verified at the submitted commit; restore the install or check environment, then retry verification; output digest:\n${check.report.replace(/^/gm, ' ')}`);if (check.state === 'red') throw new Refused('CHECK_RED', `the frozen item check is red at the submitted commit; check.install may be needed for dependencies; reject with the failing behavior or ask the builder to fix and resubmit; output digest:\n${check.report.replace(/^/gm, ' ')}`);const receipt = store.events(board, { itemId: id }).filter(event => event.event_kind === 'submit').map(event => JSON.parse(event.event_detail)).find(event => event.commit === commit);@@ -1508,10 +1512,13 @@ async function verifyHere(ctx, id, { second, values }) {digest,policy: ctx.config.verify.policy,familyPolicy: ctx.config.verify.family,+ ...(decision === 'ACCEPT' ? { check: check.checked ? 'green' : 'none' } : {}),}]);});ctx.io.result?.({ id, ...result });- ctx.io.say(result.decision === 'ACCEPT' ? `verified #${id}: ${result.reason}` : `rejected #${id}: ${result.reason}; it is open again for rework`);+ ctx.io.say(result.decision === 'ACCEPT'+ ? `verified #${id}: ${result.reason}${result.check === 'none' ? '; no frozen check ran' : ''}`+ : `rejected #${id}: ${result.reason}; it is open again for rework`);return 0;}diff --git a/test/verdict-check.test.js b/test/verdict-check.test.jsnew file mode 100644index 00000000..2b596b73--- /dev/null+++ b/test/verdict-check.test.js@@ -0,0 +1,168 @@+/** The frozen check outcome travels with accepts without changing the board schema [V19,V8]. */+import assert from 'node:assert/strict';+import { execFileSync, spawnSync } from 'node:child_process';+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { join, resolve } from 'node:path';+import { test } from 'node:test';+import * as store from '../src/board.js';++const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+const SPEC = '# Fixture\n\n## G · Goals\n- G1 [approved, must] The fixture item is complete. | gate: none\n';++/** Create a private CLI environment with isolated Git, home and board state. */+function sandbox() {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-verdict-check-'));+ const shimDir = join(dir, 'bin');+ mkdirSync(shimDir);+ writeFileSync(join(shimDir, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${BIN}" "$@"\n`);+ chmodSync(join(shimDir, 'pullboard'), 0o755);+ const env = Object.fromEntries(Object.entries(process.env).filter(([key]) => !key.startsWith('GIT_')));+ Object.assign(env, {+ PATH: `${shimDir}:${process.env.PATH}`,+ HOME: join(dir, 'home'),+ GIT_CONFIG_GLOBAL: '/dev/null',+ GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Fixture agent',+ GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Fixture agent',+ GIT_COMMITTER_EMAIL: '[email protected]',+ PULLBOARD_HOME: join(dir, 'pullboard-home'),+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ });+ mkdirSync(env.HOME);+ /** Run isolated Git commands for this fixture. */+ const git = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ /** Run the checked-out CLI without invoking any shared board. */+ const run = (cwd, ...args) => {+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout, err: result.stderr };+ };+ return { dir, env, git, run };+}++/** Initialize a real board repository and one joined builder worktree. */+function project(box) {+ const repo = join(box.dir, 'repo');+ const web = join(box.dir, 'web-1');+ mkdirSync(repo);+ box.git(repo, 'init', '-q', '-b', 'main');+ assert.equal(box.run(repo, 'init').code, 0);+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({+ gate: 'test ! -f RED', spec: 'SPEC.md', verify: { policy: 'any', family: 'off' },+ lease: '2h', lanes: { web: { owns: ['web/'], specs: ['G'] }, review: { owns: [], specs: [] } }, shared: [],+ }, null, 2) + '\n');+ writeFileSync(join(repo, 'SPEC.md'), SPEC);+ box.git(repo, 'add', '-A');+ box.git(repo, 'commit', '-q', '-m', 'chore: initialize fixture');+ box.git(repo, 'worktree', 'add', '-q', web, '-b', 'web/one');+ assert.match(box.run(web, 'join', 'web').out, /joined as web-1/);+ return { repo, web };+}++/** Run a fixture command and fail with its captured diagnostics if it refuses. */+function succeeds(box, cwd, ...args) {+ const result = box.run(cwd, ...args);+ assert.equal(result.code, 0, `${result.out}\n${result.err}`);+ return result.out;+}++/** Add, claim, commit and submit one real worktree item with its optional frozen check. */+function submitted(box, repo, web, title, check) {+ const args = ['add', 'web', title, '--specs', 'G1', '--criterion', 'The fixture item is complete.'];+ if (check) args.push('--check', check);+ const added = succeeds(box, repo, ...args);+ const id = Number(/#(\d+)/.exec(added)?.[1]);+ assert.ok(id > 0, added);+ succeeds(box, web, 'claim', String(id));+ mkdirSync(join(web, 'web'), { recursive: true });+ writeFileSync(join(web, 'web', `item-${id}.js`), 'export const complete = true;\n');+ box.git(web, 'add', '-A');+ box.git(web, 'commit', '-q', '-m', `feat(web): complete fixture ${id} [G1]`);+ succeeds(box, web, 'submit', String(id));+ box.git(repo, 'switch', '--detach', 'web/one');+ return { id, commit: box.git(web, 'rev-parse', 'HEAD') };+}++/** Remove all files created by a test's private repository and SQLite board. */+function clean(box) {+ rmSync(box.dir, { recursive: true, force: true });+}++test('accept records none or green in its event and JSON, and says when unchecked [V19,V8]', () => {+ const box = sandbox();+ try {+ const { repo, web } = project(box);+ const unchecked = submitted(box, repo, web, 'Unchecked accept');+ const noCheck = succeeds(box, repo, 'verify', String(unchecked.id), 'accept', '--as', 'coordinator', '--note', 'checked the submitted work');+ assert.match(noCheck, /no frozen check ran/);+ const uncheckedEvent = JSON.parse(succeeds(box, repo, 'log', String(unchecked.id), '--json')).events.find((event) => event.event_kind === 'accept');+ assert.equal(JSON.parse(uncheckedEvent.event_detail).check, 'none');+ const uncheckedShow = JSON.parse(succeeds(box, repo, 'show', String(unchecked.id), '--json'));+ assert.equal(uncheckedShow.verdicts.at(-1).check, 'none');+ assert.match(succeeds(box, repo, 'show', String(unchecked.id)), /check: none/);+ box.git(repo, 'switch', 'main');++ const uncheckedJson = JSON.parse(succeeds(box, repo, 'verify', String((submitted(box, repo, web, 'Unchecked JSON accept')).id), 'accept', '--as', 'coordinator', '--note', 'checked the submitted work', '--json'));+ assert.equal(uncheckedJson.check, 'none');+ box.git(repo, 'switch', 'main');++ const checked = submitted(box, repo, web, 'Checked accept', 'node --check web/item-3.js');+ const checkedJson = JSON.parse(succeeds(box, repo, 'verify', String(checked.id), 'accept', '--as', 'coordinator', '--note', 'the frozen check passed', '--json'));+ assert.equal(checkedJson.check, 'green');+ const checkedEvent = JSON.parse(succeeds(box, repo, 'log', String(checked.id), '--json')).events.find((event) => event.event_kind === 'accept');+ assert.equal(JSON.parse(checkedEvent.event_detail).check, 'green');+ const checkedShow = JSON.parse(succeeds(box, repo, 'show', String(checked.id), '--json'));+ assert.equal(checkedShow.verdicts.at(-1).check, 'green');+ assert.match(succeeds(box, repo, 'show', String(checked.id)), /check: green/);+ } finally { clean(box); }+});++test('rework keeps historical rejection unknown and shows the latest accept check [V19,V8]', () => {+ const box = sandbox();+ try {+ const { repo, web } = project(box);+ const item = submitted(box, repo, web, 'Reworked accept');+ succeeds(box, repo, 'verify', String(item.id), 'reject', '--as', 'coordinator', '--reason', 'BEHAVIOR_MISMATCH', '--note', 'the first version missed an edge');+ box.git(repo, 'switch', 'main');+ succeeds(box, web, 'claim', String(item.id));+ writeFileSync(join(web, 'web', `item-${item.id}.js`), 'export const complete = true; // revised\n');+ box.git(web, 'add', '-A');+ box.git(web, 'commit', '-q', '-m', `fix(web): correct fixture ${item.id} [G1]`);+ succeeds(box, web, 'submit', String(item.id));+ box.git(repo, 'switch', '--detach', 'web/one');+ const accepted = succeeds(box, repo, 'verify', String(item.id), 'accept', '--as', 'coordinator', '--note', 'the rework fixed the missed edge');+ assert.match(accepted, /no frozen check ran/);+ const shownJson = JSON.parse(succeeds(box, repo, 'show', String(item.id), '--json'));+ assert.deepEqual(shownJson.verdicts.map((verdict) => verdict.check), ['unknown', 'none']);+ const shown = succeeds(box, repo, 'show', String(item.id));+ assert.match(shown, /REJECT[\s\S]*check: unknown[\s\S]*ACCEPT[\s\S]*check: none/);+ const rows = succeeds(box, repo, 'ledger').split('\n').filter((line) => line.startsWith(`| ${item.id} |`));+ assert.equal(rows.length, 1);+ assert.match(rows[0], /\| unchecked \|/);+ assert.doesNotMatch(rows[0], /unknown/);+ } finally { clean(box); }+});++test('historical accepts read unknown in show and unchecked accepts are marked in ledger [V19,V8]', () => {+ const box = sandbox();+ try {+ const { repo, web } = project(box);+ const historical = submitted(box, repo, web, 'Historical accept');+ const common = box.git(repo, 'rev-parse', '--path-format=absolute', '--git-common-dir');+ const board = store.openBoard(join(common, 'pullboard', 'board.sqlite'));+ try {+ const item = store.getItem(board, historical.id);+ store.verify(board, historical.id, {+ agentId: 'coordinator', decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'legacy event fixture',+ head: historical.commit, digest: item.item_frozen_digest, policy: 'any', familyPolicy: 'off',+ });+ } finally { store.closeBoard(board); }+ const shown = succeeds(box, repo, 'show', String(historical.id));+ assert.match(shown, /check: unknown/);+ box.git(repo, 'switch', 'main');+ const unchecked = submitted(box, repo, web, 'Unchecked ledger row');+ succeeds(box, repo, 'verify', String(unchecked.id), 'accept', '--as', 'coordinator', '--note', 'fixture accept without a frozen check');+ assert.match(succeeds(box, repo, 'ledger'), new RegExp(`\\| ${unchecked.id} \\|[^\\n]*\\| unchecked \\|`));+ } finally { clean(box); }+});