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
chore(merge): integrate accepted async check baselines [V2]
Corey Olson8896959308b3
diff --cc docs/formats.mdindex 32787c86,399f3d54..dfe7b424--- a/docs/formats.md+++ b/docs/formats.md@@@ -70,11 -72,13 +72,13 @@@ The board file is in the repository's G| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |- | `move engine` | `2` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+ | `move engine` | `3` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->-Pullboard 0.6.1 released engine 1. The first change to released move semantics raises the engine once for the next release; later changes developed before that release keep the same version. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Older clients refuse engine-2 moves before changing rows or replay cursors; engine 2 still accepts engine-1 moves.+Pullboard 0.6.1 released engine 1. The first change to released move semantics raises the engine once for the next release; later changes developed before that release keep the same version. Engine 2 records a fresh explicit-build claim's skipped-review snapshot and captured background-baseline completions. Older clients refuse engine-2 moves before changing rows or replay cursors; engine 2 still accepts engine-1 moves.+ Engine 3 checks each move or request against the relay's authenticated sender before replay. An agent token acts only as its named agent and cannot act as the person. Refused attribution attempts advance the sequence with a `relay_refusal_<sequence>` receipt and a `relay_refused` event naming the sender, attempted actor and refusal code. They change no item, shout or verdict and do not reserve the forged operation id. Snapshot restoration requires a person sender. The event log remains version 1.+A board without `event_log_version` is a legacy version-0 event log. Opening an older board writes the current marker without replacing its events. Opening a newer event log refuses with `EVENT_LOG_VERSION`, naming the stored and supported versions and asking you to upgrade Pullboard. `doctor` reports that version conflict read-only.A native board export includes the marker in its `board_meta` rows. Import refuses a newer event-log version before changing the destination; an older export upgrades its marker in place. Static view exports put `eventLogVersion` beside the data in both `state.json` and `events.json`, separately from the API envelope's `version`.diff --cc src/api-moves.jsindex 00000000,3f72fda0..a6df268amode 000000,100644..100644--- a/src/api-moves.js+++ b/src/api-moves.js@@@ -1,0 -1,58 +1,58 @@@+ /** Literal API-to-CLI argument translation shared by native and sealed person requests [A2,H12]. */+ import { Refused } from './refused.js';++ /** Declarative CLI forms keep API calls on the same argument parser and engine as terminal moves. */+ const MOVES = {+ 'spec-approve': { prefix: ['spec', 'approve'], positions: ['ids'], flags: ['by', 'text'] },+ 'spec-decline': { prefix: ['spec', 'decline'], positions: ['ids'], flags: ['reason'] },- add: { positions: ['lane', 'title'], flags: ['criterion', 'specs', 'parent', 'after', 'brief', 'route', 'check'] },- edit: { item: true, flags: ['criterion', 'brief', 'route', 'check'] },++ add: { positions: ['lane', 'title'], flags: ['criterion', 'specs', 'parent', 'after', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },++ edit: { item: true, flags: ['criterion', 'brief', 'route', 'check'], booleans: ['wait'], booleans: ['wait'] },+ fact: { item: true, positions: ['kind', 'text'], flags: ['supersedes', 'ref'] },+ claim: { item: true },+ release: { item: true },+ submit: { item: true },+ done: { item: true },+ verify: { item: true, positions: ['decision'], flags: ['reason', 'note', 'as'] },+ merged: { item: true, positions: ['commit'] },+ withdraw: { item: true, positions: ['reason'] },+ refreeze: { item: true },+ escalate: { item: true, flags: ['note'] },+ hold: { positions: ['lane'], flags: ['reason'], booleans: ['off'] },+ shout: { positions: ['to', 'text'], optional: ['to'], booleans: ['decision'], flags: ['evidence', 'outcome', 'item', 'commit'] },+ answer: { item: true, positions: ['text'], flags: ['as'] },+ pass: { item: true, positions: ['note'] },+ next: { flags: ['as'], booleans: ['verify', 'build'] },+ };++ /** Reject unsupported fields, then pass values as distinct argv entries, never a shell command. */+ export function moveArgs({ verb, item, args = {} }) {+ if (verb === 'accept' || verb === 'reject') return moveArgs({ verb: 'verify', item, args: { ...args, decision: verb } });+ const form = Object.hasOwn(MOVES, verb) ? MOVES[verb] : null;+ if (!form) throw new Refused('BAD_REQUEST', `no API move ${String(verb)}; use a board move such as add, claim, submit, verify, shout or answer`);+ if (!args || typeof args !== 'object' || Array.isArray(args)) throw new Refused('BAD_REQUEST', 'args needs a JSON object containing this move\'s arguments');+ const allowed = [...(form.positions ?? []), ...(form.flags ?? []), ...(form.booleans ?? [])];+ for (const key of Object.keys(args)) if (!allowed.includes(key)) throw new Refused('BAD_REQUEST', `${verb} does not take args.${key}; use only this CLI move's arguments`);+ const argv = form.prefix ? [...form.prefix] : [verb];+ if (form.item) {+ if (!Number.isSafeInteger(item) || item < 1) throw new Refused('BAD_REQUEST', `${verb} needs a positive integer item; use the item id from the board state`);+ argv.push(String(item));+ } else if (item !== undefined && item !== null) throw new Refused('BAD_REQUEST', `${verb} does not take item; put its arguments in args`);+ const positional = [];+ for (const key of form.positions ?? []) {+ if (args[key] === undefined && form.optional?.includes(key)) continue;+ if (typeof args[key] !== 'string' || !args[key].trim()) throw new Refused('BAD_REQUEST', `${verb} needs args.${key} as nonempty text; supply the CLI move's argument`);+ positional.push(args[key]);+ }+ for (const key of form.flags ?? []) if (args[key] !== undefined) {+ if (typeof args[key] !== 'string') throw new Refused('BAD_REQUEST', `args.${key} needs text; supply the CLI flag's value`);+ argv.push(`--${key}=${args[key]}`);+ }+ for (const key of form.booleans ?? []) if (args[key] !== undefined) {+ if (typeof args[key] !== 'boolean') throw new Refused('BAD_REQUEST', `args.${key} needs true or false`);+ if (args[key]) argv.push(`--${key}`);+ }+ // Positionals follow -- so titles and notes beginning with a dash never become CLI flags.+ argv.push('--json', '--', ...positional);+ return argv;+ }+diff --cc src/api.jsindex 1d4893e2,2110b4b6..3e074c81--- a/src/api.js+++ b/src/api.js@@@ -203,17 -152,16 +152,21 @@@ export function createLocalApiHandler(state.board = board.id;const projectData = withBoard(board.root, (db) => ({requests: store.openRequests(db),+ personRequests: personRequestStatuses(db),milestones: milestoneRoadmap(board.root, db),rowDecisions: store.rowDecisions(db),+ checks: new Map(store.listItems(db, { all: true }).map((item) => store.getItem(db, item.item_id)).map((item) => [item.item_id, {+ check: item.item_check,+ ...(item.item_check_baseline ? { checkBaseline: item.item_check_baseline } : {}),+ }])),+ threads: new Map(store.listItems(db, { all: true }).map((item) => [item.item_id, store.itemThread(db, item.item_id)])),}));state.requests = projectData.requests;+ state.personRequests = projectData.personRequests;state.milestones = projectData.milestones;+ state.items = state.items.map((item) => ({ ...item, ...projectData.checks.get(item.id) }));state = projectRowDecisions(projectData.rowDecisions, state);+ state.items = state.items.map((item) => ({ ...item, thread: projectData.threads.get(item.id) ?? [] }));return state;},code: (board, ref) => codeAt(board.root, ref),diff --cc src/check-baseline.jsindex ed115f2d,35282779..a7c83070--- a/src/check-baseline.js+++ b/src/check-baseline.js@@@ -36,15 -36,6 +36,16 @@@ export function checkBaseline(root, com}}+/** Capture the authorized check's immutable base without running its shell command [V2,H16]. */+export function prepareCheckBaseline(root, command) {- const main = tryGit(root, ['rev-parse', '--verify', 'refs/heads/main^{commit}']);- if (main.status !== 0) return { command, main: null, result: 'unavailable', reason: 'no main' };- const base = { command, main: main.stdout };++ const primary = mainCheckout(root);++ if (!primary) return { command, main: null, result: 'unavailable', reason: 'coordinator checkout is detached' };++ if (!primary.commit) return { command, main: null, result: 'unavailable', reason: 'no main' };++ const base = { command, main: primary.commit };+ if (command === gateOnMain(root, base.main)) return { ...base, result: 'green', reason: 'repo gate' };+ return { ...base, result: 'pending', request: randomUUID() };+}+/** Use main's committed gate for the shortcut; a dirty local config cannot manufacture a green base. */function gateOnMain(root, main) {const config = tryGit(root, ['show', `${main}:${CONFIG_FILE}`]);diff --cc src/relay-sender.jsindex 00000000,5ac1a9da..48cc61f0mode 000000,100644..100644--- a/src/relay-sender.js+++ b/src/relay-sender.js@@@ -1,0 -1,32 +1,32 @@@+ /** Compare sealed actors with the relay's independently authenticated sender [H2,H16]. */+ import { Refused } from './refused.js';++ /** Read only the actor field used by each public engine operation; unknown operations fail closed. */+ export function relayMoveActor(move) {+ const args = move?.args;+ if (!Array.isArray(args)) return null;+ if (move.operation === 'addItem') return args[0]?.by ?? null;+ if (move.operation === 'shout') return args[0]?.from ?? null;+ if (['holdLane', 'releaseLane'].includes(move.operation) && args[1]?.asPerson) return 'person';+ if (move.operation === 'release') return args[1] ?? null;+ if (['reserveNextReview', 'addMilestone', 'recordRowDecisions', 'applyRowDecisions'].includes(move.operation)) return args[0]?.agentId ?? null;- if (['appendFact', 'editItem', 'escalate', 'recordAttempt', 'claim', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze',++ if (['completeCheckBaseline', 'appendFact', 'editItem', 'escalate', 'recordAttempt', 'claim', 'submit', 'reserveReview', 'verify', 'merged', 'withdraw', 'refreeze',+ 'passDecision', 'answerDecision', 'holdLane', 'releaseLane', 'editMilestoneItems', 'moveMilestone', 'editMilestone', 'removeMilestone'].includes(move.operation)) return args[1]?.agentId ?? null;+ return null;+ }++ /** Make the same authorization decision on every device, without inspecting its shell or checkout. */+ export function relaySenderProblem(move, sender, kind) {+ if (!sender || !['person', 'agent'].includes(sender.kind) || typeof sender.userId !== 'string' || !sender.userId.length || sender.userId.length > 256 ||+ (sender.kind === 'agent' && (typeof sender.agent !== 'string' || !sender.agent.length || sender.agent.length > 256))) {+ return new Refused('RELAY_SENDER', 'this relay record has no authenticated sender; restore attribution before replaying it');+ }+ if (sender.kind === 'person') return null;+ if (kind === 'snapshot' || move?.operation === 'recordRowDecisions' || move?.operation === 'answerDecision' && move.args?.[1]?.asPerson ||+ move?.operation === 'shout' && move.args?.[0]?.request || relayMoveActor(move) === 'person') {+ return new Refused('RELAY_PERSON_ONLY', `agent ${sender.agent} cannot make a person-only relay ${kind}; use the person's authenticated session`);+ }+ const actor = relayMoveActor(move);+ if (actor !== sender.agent) return new Refused('RELAY_SENDER_MISMATCH', `agent ${sender.agent} cannot act as ${typeof actor === 'string' ? actor : '(no declared agent)'}; send this operation as the authenticated agent`);+ return null;+ }diff --cc test/trunk.test.jsindex 00000000,96fca8f8..4ad1c772mode 000000,100644..100644--- a/test/trunk.test.js+++ b/test/trunk.test.js@@@ -1,0 -1,137 +1,137 @@@+ /** Branch-name-independent check baselines and lane merge ownership [B34,P2,L3]. */+ import assert from 'node:assert/strict';+ import { execFileSync, spawnSync } from 'node:child_process';+ import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';+ import { tmpdir } from 'node:os';+ import { join, resolve } from 'node:path';+ import { after, test } from 'node:test';+ import { mainPolicy } from '../src/trusted-policy.js';++ const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');+ const TEMP_DIRS = [];+ const SPEC = '# Trunk fixture\n\n## G · Goals\n- G1 [approved, must] The fixture works. | gate: true\n';++ /** Remove isolated fixture repositories after their child processes finish. */+ function cleanupFixtures() {+ for (const dir of TEMP_DIRS) rmSync(dir, { recursive: true, force: true });+ }++ after(cleanupFixtures);++ /** Build an offline CLI fixture with private Git identity and machine settings. */+ function sandbox() {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-trunk-'));+ 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 = { ...process.env };+ for (const key of Object.keys(env)) if (key.startsWith('GIT_')) delete env[key];+ Object.assign(env, {+ HOME: join(dir, 'home'),+ PULLBOARD_HOME: join(dir, 'pullboard-home'),+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ GIT_CONFIG_GLOBAL: '/dev/null',+ GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Trunk fixture',+ GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Trunk fixture',+ GIT_COMMITTER_EMAIL: '[email protected]',+ PATH: `${bin}:${process.env.PATH}`,+ });+ /** Run isolated Git commands. */+ function git(cwd, ...args) {+ return execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ }+ /** Run a real Pullboard CLI process in the fixture environment. */+ function run(cwd, ...args) {+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8', timeout: 30_000 });+ return { code: result.status, out: result.stdout, err: result.stderr };+ }+ return { dir, env, git, run };+ }++ /** Quote a shell word for the fixture's local Pullboard executable. */+ function shellWord(value) {+ return `'${String(value).replaceAll("'", "'\\''")}'`;+ }++ /** Initialize a committed repo whose primary branch has the supplied name. */+ function project(branch) {+ const box = sandbox();+ const repo = join(box.dir, 'repo');+ mkdirSync(repo);+ box.git(repo, 'init', '-q', '-b', 'main');+ assert.equal(box.run(repo, 'init').code, 0);+ const configPath = join(repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ config.gate = 'true';+ config.lanes = { web: { owns: ['web/'], specs: ['G1'] } };+ writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');+ writeFileSync(join(repo, 'SPEC.md'), SPEC);+ mkdirSync(join(repo, 'web'));+ writeFileSync(join(repo, 'web', 'result.txt'), 'ready\n');+ box.git(repo, 'add', '-A');+ box.git(repo, 'commit', '-q', '-m', 'chore: initialize trunk fixture');+ if (branch !== 'main') box.git(repo, 'branch', '-m', branch);+ return { ...box, repo };+ }++ for (const branch of ['master', 'trunk']) {+ test(`[B34,P2] add --check captures the ${branch} baseline without a remote`, () => {+ const box = project(branch);+ const head = box.git(box.repo, 'rev-parse', 'HEAD');+ assert.equal(mainPolicy(box.repo).commit, head, 'trusted policy resolves the primary checkout rather than a fixed branch name');- const added = box.run(box.repo, 'add', 'web', `baseline on ${branch}`, '--specs', 'G1', '--criterion', 'a real check baseline is recorded', '--check', 'node -e "process.exit(1)"', '--json');++ const added = box.run(box.repo, 'add', 'web', `baseline on ${branch}`, '--specs', 'G1', '--criterion', 'a real check baseline is recorded', '--check', 'node -e "process.exit(1)"', '--wait', '--json');+ assert.equal(added.code, 0, `${added.out}${added.err}`);+ const item = JSON.parse(added.out).item;+ assert.equal(item.item_check_baseline.main, head, `${branch} baseline points at the primary checkout commit`);+ assert.equal(item.item_check_baseline.result, 'red', `${branch} baseline actually ran instead of being unavailable`);+ assert.notEqual(item.item_check_baseline.reason, 'no main');+ });+ }++ for (const branch of ['master', 'trunk']) {+ test(`[B34,P2,L3] a lane can resolve an owned conflict while retaining ${branch} files`, () => {+ const box = project(branch);+ const web = join(box.dir, 'web-worktree');+ box.git(box.repo, 'worktree', 'add', '-q', web, '-b', 'web/agent');+ assert.equal(box.run(web, 'join', 'web').code, 0);+ writeFileSync(join(web, 'web', 'result.txt'), `resolved by web lane from ${branch}\n`);+ box.git(web, 'add', 'web/result.txt');+ box.git(web, 'commit', '-q', '-m', 'feat(web): update owned fixture [G1]');+ writeFileSync(join(box.repo, 'web', 'result.txt'), `updated by ${branch}\n`);+ writeFileSync(join(box.repo, 'coordinator.txt'), `owned by ${branch}\n`);+ box.git(box.repo, 'add', 'web/result.txt', 'coordinator.txt');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: update trunk fixture');+ const trunkHead = box.git(box.repo, 'rev-parse', 'HEAD');+ const merged = spawnSync('git', ['merge', '--no-ff', '--no-commit', branch], {+ cwd: web, env: box.env, encoding: 'utf8', timeout: 30_000,+ });+ assert.equal(merged.status, 1, `${merged.stdout}${merged.stderr}`);+ assert.equal(box.git(web, 'rev-parse', 'MERGE_HEAD'), trunkHead, 'the merge is against the primary checkout tip');+ assert.ok(box.git(web, 'status', '--porcelain').includes('UU web/result.txt'), 'the primary and lane edits conflict on an owned file');+ writeFileSync(join(web, 'web', 'result.txt'), `resolved by web lane from ${branch}\n`);+ box.git(web, 'add', 'web/result.txt');++ const committed = spawnSync('git', ['commit', '-m', `Merge ${branch} into web/agent`], {+ cwd: web, env: box.env, encoding: 'utf8', timeout: 30_000,+ });+ assert.equal(committed.status, 0, `${committed.stdout}${committed.stderr}`);+ assert.equal(box.git(web, 'show', 'HEAD:web/result.txt'), `resolved by web lane from ${branch}`);+ assert.equal(box.git(web, 'show', 'HEAD:coordinator.txt'), `owned by ${branch}`);+ assert.equal(box.git(web, 'rev-list', '--parents', '-n', '1', 'HEAD').split(' ').length, 3, 'the lane committed a two-parent merge');+ });+ }++ test('[B34,P2] add --check reports an unavailable baseline for a detached coordinator', () => {+ const box = project('master');+ box.git(box.repo, 'checkout', '--detach', '-q', 'HEAD');+ const added = box.run(box.repo, 'add', 'web', 'detached baseline', '--specs', 'G1', '--criterion', 'detached baseline is unavailable', '--check', 'true', '--json');+ assert.equal(added.code, 0, `${added.out}${added.err}`);+ const item = JSON.parse(added.out).item;+ assert.deepEqual(item.item_check_baseline, {+ command: 'true', main: null, result: 'unavailable', reason: 'coordinator checkout is detached',+ });+ });