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.

chore(core): refresh merged receipt work from main [R3,R1]

Corey Olsonf7150e322423
diff --cc docs/api.md
index 46478e05,db354ee5..fa7c0049
--- a/docs/api.md
+++ b/docs/api.md
@@@ -10,10 -10,16 +10,18 @@@ A successful command returns the field
`pullboard settings` reads machine-wide settings from `~/.pullboard/settings.json`; `pullboard settings gateSlots <n>` changes the gate queue capacity, which defaults to `2`. Capacity changes are refused while a gate is running or waiting, so existing holders and FIFO order remain intact.
- When `add` or `edit` supplies a new nonempty check, Pullboard measures it once in a temporary checkout of the current `main` commit. The item returned by `add`, `edit`, `show`, and `next --verify` may include `item_check_baseline`: `{command, main, result, seconds?, reason?, warning?}`. `main` is the commit id or `null`, and `result` is `green`, `red`, or `unavailable`. A green result carries `warning: "CRITERION_PROVES_NOTHING"`; text output names that warning when filing, showing, or reserving the item for review. An exact match with the project gate configured at that main commit records green with `reason: "repo gate"` without running it again. A missing main records unavailable with `reason: "no main"` and still files the item. Changing the check replaces this observation; clearing it removes the observation. The captured observation travels with the board move, so replicas store the result without executing the command.
+ When `add` or `edit` supplies a new nonempty check, it records the item before measuring that check in a background temporary checkout of the captured `main` commit. Use `--wait` to wait for the measurement before returning, or `args.wait: true` for an HTTP add/edit move. The item returned by `add`, `edit`, `show`, and `next --verify` may include `item_check_baseline`: `{command, main, result, request?, seconds?, reason?, warning?}`. `main` is the commit id or `null`, and `result` is `pending`, `green`, `red`, or `unavailable`. A background request carries an opaque `request` identity; an older completion cannot overwrite a newly edited or cleared check.
+
+ The board-state API's item projection includes `check` and, when recorded, `checkBaseline` with the same observation fields. A green result carries `warning: "CRITERION_PROVES_NOTHING"`; text output names that warning when showing or reserving the item for review, and when filing it with `--wait`. An exact match with the project gate configured at that main commit records green with `reason: "repo gate"` without running it again. A missing main records unavailable with `reason: "no main"` and still files the item. Changing the check replaces this observation; clearing it removes the observation. Captured observations and completions travel through ordered board moves, so replicas store results without executing commands. A completed result awaiting relay delivery stays on the measuring device and is retried by the next normal CLI command.
+
+ `pullboard stats [--since <date>] --json` returns `{version: 1, stats: {...}}` from the append-only event log. `submissions` and `rejections` count moves, including repeated attempts; `rejectionShare` is rejections divided by submissions (zero when the window has no submissions). `merged` counts distinct items with a merge move; `mergedWithoutAccept` counts those whose merge lacks an earlier acceptance of the latest submitted commit. That audit uses earlier history even when the acceptance falls before the selected window. Current item and verdict rows do not replace event evidence.
+
+ `firstEventAt` and `lastEventAt` are the first and latest dates in the selected window, or `null` when it is empty. `since` is the inclusive boundary as an ISO UTC timestamp, or `null` for the full history. Dates accept `YYYY-MM-DD` or an ISO UTC timestamp ending in `Z`; invalid dates return `BAD_SINCE` with repair guidance.
+
+ `agentCount` counts distinct event actors other than `board` and `person`; the coordinator and join moves are included. `agents` lists `{id, moves, families}` for each actor. `families` lists `{name, agents, moves}` by recorded family label, and `familyCount` counts these buckets, including `unknown`. Labels are not inferred from a model name or current agent, item, or verdict rows. A family's first recorded event snapshot applies to that move and following moves, until another snapshot changes or clears it; earlier unattributed moves remain `unknown`. Date windows preserve earlier recorded declarations but count only selected moves. Arrays are sorted by identifier or label. Local HTTP board state carries the same full-history object as `state.proofStats`.
+`merged <id> <commit>` records only a commit reachable from the primary checkout's branch that contains the item's submitted commit or has the same stable patch id as the item's change from its claim base. Other commits are refused with `NOT_MERGED`; `--note "why"` records an exceptional receipt and keeps the note in that item's `merged` event.
+
<!-- api-command-shapes:start -->
| Command | Required top-level fields |
| --- | --- |
diff --cc src/cli.js
index 31681c98,e9c51ddd..2c418094
--- a/src/cli.js
+++ b/src/cli.js
@@@ -9,12 -9,13 +9,13 @@@ import { basename, dirname, isAbsolute
import { pathToFileURL } from 'node:url';
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 { CONFIG_FILE, COORDINATOR, DOCTRINE_FILE, LEGACY_DOCTRINE_FILE, loadConfig } from './config.js';
+ import { doctrineHistory, loadDoctrine } from './doctrine.js';
+ import { agentSessionDigest, requirePersonChannel } from './person.js';
+ import { bindLocalSession } from './agent-session.js';
import { decisionProjection, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';
- import { digestOf, gateReport, runGate, runShell } from './gate.js';
- import { bareWorktreeFinding, contains, differFromHead, git, headCommit, headTree, isClean, mainCheckout, patchId, repoInfo, resolveCommit, tryGit, untracked } from './git.js';
+ import { digestOf, gateReport, runGate, runShell, runSubmitGate, submitGateReport, withGateSlot } from './gate.js';
-import { bareWorktreeFinding, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';
++import { bareWorktreeFinding, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, patchId, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';
import {
FIX_NOTE,
applyFixers,
@@@ -1845,27 -2220,18 +2220,36 @@@ function workCommands(io, args)
done: async () => submitHere(context(io), idArg(first)),
verify: () => verifyHere(context(io), idArg(first), args),
merged: () => act(async (ctx, board, me) => {
+ const recovered = await relayCommandReceipt(ctx.info.root, io.relayCommand);
+ if (recovered) {
+ for (const event of recovered.events) io.onEvent?.(event);
+ const commit = recovered.move.args[1].commit;
+ io.result?.({ id: idArg(first), commit });
+ io.say(`#${first} merged as ${commit.slice(0, 12)}`);
+ await relayCommandReceiptReported(ctx.info.root, recovered.move.id);
+ return 0;
+ }
const commit = resolveCommit(ctx.info.root, second ?? '');
if (!commit) throw new Refused('NO_COMMIT', `no commit "${second ?? ''}" in this repo`);
- await ordered(ctx, board, 'merged', [idArg(first), { agentId: me.id, commit }]);
+ const id = idArg(first);
+ const note = (textArg(io, values, 'note') ?? '').trim();
+ const item = store.getItem(board, id);
+ if (item.item_status === 'verified') {
+ const trunk = mainCheckout(ctx.info.root);
+ const itemCommit = item.item_commit;
+ const itemOnCandidate = contains(ctx.info.root, itemCommit, commit);
+ const candidateOnTrunk = Boolean(trunk?.commit && contains(ctx.info.root, commit, trunk.commit));
+ const parent = tryGit(ctx.info.root, ['rev-parse', '--verify', '--quiet', `${commit}^`]);
+ const itemPatch = item.item_claim_head ? patchId(ctx.info.root, item.item_claim_head, itemCommit) : null;
+ const candidatePatch = parent.status === 0 ? patchId(ctx.info.root, parent.stdout, commit) : null;
+ const carriesPatch = Boolean(itemPatch && candidatePatch && itemPatch === candidatePatch);
+ if (!note && !(candidateOnTrunk && (itemOnCandidate || carriesPatch))) {
+ const trunkName = trunk?.branch ?? 'the unavailable primary trunk';
+ const trunkAt = trunk?.commit ? ` at ${trunk.commit}` : '';
+ throw new Refused('NOT_MERGED', `commit ${commit} is not on trunk ${trunkName}${trunkAt}, or does not contain item commit ${itemCommit} or carry its patch; merge that work onto ${trunkName}, or use --note "why"`);
+ }
+ }
+ await ordered(ctx, board, 'merged', [id, { agentId: me.id, commit, note }]);
io.result?.({ id: idArg(first), commit });
io.say(`#${first} merged as ${commit.slice(0, 12)}`);
return 0;
diff --cc src/git.js
index f0a271ce,bd425b4d..900dd60f
--- a/src/git.js
+++ b/src/git.js
@@@ -1,8 -1,9 +1,9 @@@
/**
* The few git facts pullboard needs: where the repo is, which worktree this is, what HEAD holds,
- * and whether the tree is clean. Every call is a plain `git` child process.
+ * and whether the tree is clean (R3). Every call is a plain `git` child process.
*/
import { execFileSync, spawnSync } from 'node:child_process';
+ import { AsyncLocalStorage } from 'node:async_hooks';
import { existsSync, readdirSync, statSync } from 'node:fs';
import { dirname, join, resolve } from 'node:path';
import { Refused } from './refused.js';