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.

fix(resume): the coordinator commits a signed apply's receipt [I1,L3]

Corey Olson56642bc0ed0f
diff --git a/docs/api.md b/docs/api.md
index 046216e2..c55f33c4 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -37,7 +37,7 @@ The coordinator's `resume` ends with one `flow:` line if the measured review-wai
The coordinator's `resume` opens, after its header line, with its inbox: `inbox: <n> unread shouts, <n> open decisions for you`, then the newest three unread shouts by id, sender, age and first line, then `<n> more; read them all with pullboard inbox` when there are more. Only shouts to the coordinator, its lane or all count. While shouts are unread its `next:` reads `read your <n> unread shouts first: pullboard inbox; then ...`. Resume marks nothing read; `inbox` does. Coordinator resume JSON carries the same as `inbox: {unread, decisions, newest: [{id, from, at, text}], more, read}`.
-The coordinator's `resume` names who commits which uncommitted Pullboard file. A row file (the spec or the practice file) that is committed and changed, as `spec apply` leaves it, is the coordinator's: `The coordinator must commit the row file spec apply changed: <git add and git commit of exactly those files>`, and its `next:` reads `commit the applied row file first: <that command>; then ...`. Every other setup file that differs from the last commit, including a row file init wrote that is not committed yet, is the person's: `The person must commit Pullboard's setup files before agents can use worktrees: <git add of exactly those files>`. Each line appears only when it has files, and a dirty file that is not a setup file is never named. Coordinator resume JSON carries the same as `commits: {coordinator: {files, command} | null, person: {files, command} | null}`.
+The coordinator's `resume` names who commits which uncommitted Pullboard file. A row file (the spec or the practice file) that is committed and changed, as `spec apply` leaves it, is the coordinator's, together with any sign-off receipt a signed apply appended to `.pullboard/signoffs.jsonl`: `The coordinator must commit the row file spec apply changed: <git add and git commit of exactly those files>` (the line says `changed and its sign-off receipt:` when a receipt is included), and its `next:` reads `commit the applied row file first: <that command>; then ...`. Every other setup file that differs from the last commit, including a row file init wrote that is not committed yet, is the person's: `The person must commit Pullboard's setup files before agents can use worktrees: <git add of exactly those files>`. Each line appears only when it has files, and a dirty file that is not a setup file is never named. Coordinator resume JSON carries the same as `commits: {coordinator: {files, command} | null, person: {files, command} | null}`.
For example: `flow: review wait average 61 min (1 measured; > 60 min); bottleneck: build (66.67% of 300 measured cycle min); next: add a builder when open work is available`. An unmeasured trip reads `flow: unreviewed #1 waiting 181 min (> 180 min); bottleneck: not measured yet`.
diff --git a/src/resume.js b/src/resume.js
index 096efdcc..27260eae 100644
--- a/src/resume.js
+++ b/src/resume.js
@@ -8,6 +8,8 @@
* read, so a session that starts and stops never swallows a message nobody read.
*/
import * as store from './board.js';
+import { differFromHead } from './git.js';
+import { SIGNOFFS_FILE } from './spec.js';
/** How many of the newest unread shouts resume names; the rest are a count and a command. */
export const INBOX_NEWEST = 3;
@@ -87,7 +89,9 @@ function shellWord(text) {
* committed and now changed is the coordinator's to commit. Every other setup file that differs
* from HEAD, including a row file init wrote and nobody committed yet, is the person's. Only the
* setup files are ever named, so an unrelated dirty file never reaches either command. The
- * blueprint trial found resume blaming the person for the coordinator's own applied SPEC.md.
+ * blueprint trial found resume blaming the person for the coordinator's own applied SPEC.md. Any
+ * sign-off receipt spec apply appended (.pullboard/signoffs.jsonl) goes in the coordinator's commit
+ * too, or a signed apply's receipt would never reach the next worktree or clone.
*
* @param {{ path: string, how: string, ignored: boolean }[]} differ setup files that differ from HEAD
* @param {string[]} rowFiles the files `spec apply` writes
@@ -95,8 +99,10 @@ function shellWord(text) {
* @returns {{ coordinator: { files: string[], command: string } | null, person: { files: string[], command: string } | null }}
*/
export function commitOwners(differ, rowFiles, root) {
- const applied = differ.filter(({ path, how }) => how === 'changed' && rowFiles.includes(path));
- const setup = differ.filter((entry) => !applied.includes(entry));
+ const rows = differ.filter(({ path, how }) => how === 'changed' && rowFiles.includes(path));
+ const setup = differ.filter((entry) => !rows.includes(entry));
+ // A signed apply also appends its receipt; it ships with the rows it signs.
+ const applied = rows.length ? [...rows, ...differFromHead(root, [SIGNOFFS_FILE])] : rows;
const cd = `cd ${shellWord(root)} &&`;
/** One `git add` for these files, forced only when git ignores one of them. */
const add = (entries) => `${cd} git add${entries.some(({ ignored }) => ignored) ? ' -f' : ''} -- ${entries.map(({ path }) => shellWord(path)).join(' ')}`;
@@ -116,7 +122,7 @@ export function commitOwners(differ, rowFiles, root) {
*/
export function commitOwnerLines(owners) {
return [
- ...(owners.coordinator ? [`The coordinator must commit the row file spec apply changed: ${owners.coordinator.command}`] : []),
+ ...(owners.coordinator ? [`The coordinator must commit the row file spec apply changed${owners.coordinator.files.includes(SIGNOFFS_FILE) ? ' and its sign-off receipt' : ''}: ${owners.coordinator.command}`] : []),
...(owners.person ? [`The person must commit Pullboard's setup files before agents can use worktrees: ${owners.person.command}`] : []),
];
}
diff --git a/test/resume-flow.test.js b/test/resume-flow.test.js
index 2124dab1..ce48ed90 100644
--- a/test/resume-flow.test.js
+++ b/test/resume-flow.test.js
@@ -1,6 +1,6 @@
/** Coordinator flow alerts reuse the real Git/SQLite statistics and documented thresholds [N32,R1,R2]. */
import assert from 'node:assert/strict';
-import { cpSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';
+import { cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, statSync, symlinkSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
@@ -150,6 +150,30 @@ test('resume asks the coordinator to commit an applied row file [I1,L3]', t => {
coordinator: { files: ['SPEC.md'], command: commit(mixed, ['SPEC.md']) },
person: { files: ['pullboard.json'], command: add(mixed, ['pullboard.json']) },
});
+
+ // A signed apply: the receipt spec apply appended goes in the coordinator's commit with the row.
+ const signed = releaseFixture(t, { freshSetup: true, historyBeforeInit: true });
+ const keyPath = join(signed.root, 'co-signing-key');
+ const keyed = runFixtureChild('ssh-keygen', ['-q', '-t', 'ed25519', '-N', '', '-C', '[email protected]', '-f', keyPath], { encoding: 'utf8' });
+ assert.equal(keyed.status, 0, keyed.failure || keyed.stderr);
+ signed.git(signed.repo, 'config', 'user.signingkey', keyPath);
+ const signer = signed.run(signed.repo, 'spec', 'signers', 'add', '--key', `${keyPath}.pub`, '--by', 'CO');
+ assert.equal(signer.status, 0, signer.failure || signer.stderr || signer.stdout);
+ writeFileSync(join(signed.repo, 'SPEC.md'), `${readFileSync(join(signed.repo, 'SPEC.md'), 'utf8').trimEnd()}\n\n## G · Goals\n- G1 [draft, must] The person signs this row. | gate: true | signers: CO\n`);
+ signed.git(signed.repo, 'add', '-A');
+ signed.git(signed.repo, 'add', '-f', '--', ...['.pullboard/signers', '.pullboard/signers.initial', '.pullboard/first-commit'].filter((file) => existsSync(join(signed.repo, file))));
+ signed.git(signed.repo, 'commit', '-q', '-m', 'chore: set up pullboard');
+ for (const args of [['spec', 'approve', 'G1', '--by', 'CO'], ['spec', 'apply']]) {
+ const ran = signed.run(signed.repo, ...args);
+ assert.equal(ran.status, 0, ran.failure || ran.stderr || ran.stdout);
+ }
+ const receipted = resume(signed);
+ assert.deepEqual(receipted.card.commits.coordinator?.files, ['SPEC.md', '.pullboard/signoffs.jsonl'], 'the receipt spec apply appended is the coordinator\'s to commit with the row');
+ assert.ok(receipted.lines.some((line) => line.startsWith('The coordinator must commit the row file spec apply changed and its sign-off receipt: ')), receipted.lines.join('\n'));
+ const landed = runFixtureChild('sh', ['-c', receipted.card.commits.coordinator.command], { cwd: signed.repo, env: signed.env, encoding: 'utf8' });
+ assert.equal(landed.status, 0, landed.failure || landed.stderr || landed.stdout);
+ assert.equal(signed.git(signed.repo, 'cat-file', '-t', 'HEAD:.pullboard/signoffs.jsonl').trim(), 'blob', 'the printed command commits the receipt, so the next worktree or clone has it');
+ assert.deepEqual(resume(signed).card.commits, { coordinator: null, person: null }, 'nothing is left for either owner');
});
test('resume says what is new once after an upgrade [N19]', t => {