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
fix(resume): name who commits applied rows and setup files [I1,L3]
Corey Olson64a9905f7c9f
diff --git a/docs/api.md b/docs/api.mdindex b8fa1b91..046216e2 100644--- a/docs/api.md+++ b/docs/api.md@@ -37,6 +37,8 @@ The coordinator's `resume` ends with one `flow:` line if the measured review-waiThe 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}`.+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`.`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.diff --git a/src/cli.js b/src/cli.jsindex b55d8107..0d165703 100644--- a/src/cli.js+++ b/src/cli.js@@ -61,7 +61,7 @@ import {} from './spec.js';import { bundledBlueprints, planBlueprint, readBlueprint, saveBlueprint } from './blueprints.js';import { briefFiles } from './brief.js';-import { coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';+import { commitFirst, commitOwnerLines, commitOwners, coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';import { checkBaseline, prepareCheckBaseline, sayCheckBaseline } from './check-baseline.js';import { retryCheckBaselines, startCheckBaseline } from './check-baseline-worker.js';import { compareMainFailures, mainRedMessage, mainRedReworkItems } from './main-red.js';@@ -1349,10 +1349,8 @@ function resumeHere(io) {say(`${plural(dirty, 'file')} uncommitted in the main checkout`);}if (isMain) {- const setup = uncommittedSetup(root, ctx.config);- if (setup) {- say(`The person must commit Pullboard's setup files before agents can use worktrees: ${setup.stage}`);- }+ card.commits = commitOwners(uncommittedSetup(root, ctx.config)?.differ ?? [], [ctx.config.spec, ctx.config.practice], root);+ for (const line of commitOwnerLines(card.commits)) say(line);}for (const request of card.requests) say(`request #${request.shout_id}: ${request.shout_text}; answer with pullboard answer ${request.shout_id} done, or declined <reason>`);for (const item of card.holding) {@@ -1410,6 +1408,7 @@ function resumeHere(io) {else if (card.awaiting.length) next = 'pullboard next --wait 9 (minutes); a rejected item comes back to your lane';else next = 'nothing open in your lane; pullboard next --verify names work you can check';if (card.setup) next = card.setup.agentNext ?? card.setup.command;+ if (card.commits) next = commitFirst(card.commits, next);if (card.inbox) next = inboxFirst(card.inbox, next);io.result?.({ ...card, root, dirty, next });say(`next: ${next}`);@@ -1822,7 +1821,7 @@ function uncommittedSetup(mainRoot, config) {const words = differ.map(({ path }) => shellWord(path)).join(' ');const force = differ.some(({ ignored }) => ignored) ? ' -f' : '';return {- files: differ.map(({ path }) => path),+ files: differ.map(({ path }) => path), differ,stage: `${cdTo(mainRoot)} git add${force} -- ${words}`,};}diff --git a/src/resume.js b/src/resume.jsindex dbf1c8f4..096efdcc 100644--- a/src/resume.js+++ b/src/resume.js@@ -66,3 +66,70 @@ export function inboxFirst(inbox, next) {if (!inbox.unread) return next;return `read your ${inbox.unread === 1 ? 'unread shout' : `${inbox.unread} unread shouts`} first: ${inbox.read}; then ${next}`;}++/** The commit message resume hands the coordinator for the row files `spec apply` changed. */+const APPLY_MESSAGE = 'docs(spec): apply row decisions';++/**+ * Quote one word for a POSIX shell only when it needs it, as the CLI's own commands do.+ *+ * @param {string} text+ * @returns {string}+ */+function shellWord(text) {+ return /^[\w@%+=:,./-]+$/u.test(text) ? text : `'${text.replaceAll("'", "'\\''")}'`;+}++/**+ * Who commits which of the main checkout's uncommitted Pullboard files [I1,L3].+ *+ * `spec apply` is the coordinator's move, so a row file (the spec or the practice file) that is+ * 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.+ *+ * @param {{ path: string, how: string, ignored: boolean }[]} differ setup files that differ from HEAD+ * @param {string[]} rowFiles the files `spec apply` writes+ * @param {string} root the main checkout+ * @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 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(' ')}`;+ const words = applied.map(({ path }) => shellWord(path)).join(' ');+ return {+ coordinator: applied.length ? { files: applied.map(({ path }) => path), command: `${add(applied)} && git commit -q -m "${APPLY_MESSAGE}" -- ${words}` } : null,+ person: setup.length ? { files: setup.map(({ path }) => path), command: add(setup) } : null,+ };+}++/**+ * The resume lines naming who commits what: the coordinator's applied row files, then the person's+ * setup files, each only when it has files.+ *+ * @param {ReturnType<typeof commitOwners>} owners+ * @returns {string[]}+ */+export function commitOwnerLines(owners) {+ return [+ ...(owners.coordinator ? [`The coordinator must commit the row file spec apply changed: ${owners.coordinator.command}`] : []),+ ...(owners.person ? [`The person must commit Pullboard's setup files before agents can use worktrees: ${owners.person.command}`] : []),+ ];+}++/**+ * The coordinator's next step with an applied row file still uncommitted, so it commits first:+ * a worktree started before that commit would work from the old rows.+ *+ * @param {ReturnType<typeof commitOwners>} owners+ * @param {string} next the step the board names otherwise+ * @returns {string}+ */+export function commitFirst(owners, next) {+ if (!owners.coordinator) return next;+ return `commit the applied row file first: ${owners.coordinator.command}; then ${next}`;+}diff --git a/test/resume-flow.test.js b/test/resume-flow.test.jsindex 11f3e5c4..dabc004f 100644--- a/test/resume-flow.test.js+++ b/test/resume-flow.test.js@@ -78,6 +78,80 @@ test('a worktree names its main checkout\'s uncommitted init files [I1,I2]', (t)for (const path of ['pullboard.json', 'SPEC.md', 'DOCTRINE.md']) assert.ok(fromMain.stdout.includes(path), fromMain.stdout);});+/**+ * Prove resume gives each uncommitted file its right owner: the row file `spec apply` changed goes+ * to the coordinator, the setup files init wrote go to the person, and nothing else is named [I1,L3].+ * The blueprint trial found resume blaming the person for the coordinator's own applied SPEC.md+ * and handing them a commit of every setup file.+ */+test('resume asks the coordinator to commit an applied row file [I1,L3]', t => {+ const PERSON_LINE = "The person must commit Pullboard's setup files before agents can use worktrees: ";+ const ROW_LINE = 'The coordinator must commit the row file spec apply changed: ';+ /** Resume's text and JSON from the main checkout, both passing, and neither naming an unrelated dirty file. */+ const resume = (box) => {+ const text = box.run(box.repo, 'resume');+ assert.equal(text.status, 0, text.failure || text.stderr || text.stdout);+ const json = box.run(box.repo, 'resume', '--json');+ assert.equal(json.status, 0, json.failure || json.stderr || json.stdout);+ const lines = text.stdout.split('\n');+ const card = JSON.parse(json.stdout);+ for (const named of [...lines.filter((line) => line.startsWith(PERSON_LINE) || line.startsWith(ROW_LINE)), JSON.stringify(card.commits ?? null)]) {+ assert.doesNotMatch(named, /README\.md|notes\.txt/u, `an unrelated dirty file is never named: ${named}`);+ }+ return { lines, card };+ };+ /** The exact commands resume should print for one owner's files. */+ const add = (box, files) => `cd ${box.repo} && git add -- ${files.join(' ')}`;+ const commit = (box, files) => `${add(box, files)} && git commit -q -m "docs(spec): apply row decisions" -- ${files.join(' ')}`;+ /** A board whose init files are committed, with a drafted row the person approved and the coordinator applied. */+ const applied = () => {+ const box = releaseFixture(t, { freshSetup: true, historyBeforeInit: true });+ const drafted = box.run(box.repo, 'spec', 'draft', 'The person can name the project.');+ assert.equal(drafted.status, 0, drafted.failure || drafted.stderr || drafted.stdout);+ box.git(box.repo, 'add', '-A');+ box.git(box.repo, 'commit', '-q', '-m', 'chore: set up pullboard');+ for (const args of [['spec', 'approve', 'G1'], ['spec', 'apply']]) {+ const ran = box.run(box.repo, ...args);+ assert.equal(ran.status, 0, ran.failure || ran.stderr || ran.stdout);+ }+ writeFileSync(join(box.repo, 'README.md'), '# Existing repository\n\nAn unrelated edit.\n');+ writeFileSync(join(box.repo, 'notes.txt'), 'an unrelated new file\n');+ return box;+ };++ // Committed setup plus an applied SPEC.md: the coordinator commits it; the person is not asked.+ const clean = applied();+ const after = resume(clean);+ assert.ok(after.lines.includes(`${ROW_LINE}${commit(clean, ['SPEC.md'])}`), after.lines.join('\n'));+ assert.equal(after.lines.some((line) => line.startsWith(PERSON_LINE)), false, `the person commits nothing:\n${after.lines.join('\n')}`);+ assert.match(after.card.next, /^commit the applied row file first: cd .+ && git add -- SPEC\.md && git commit .+; then /u);+ assert.deepEqual(after.card.commits, { coordinator: { files: ['SPEC.md'], command: commit(clean, ['SPEC.md']) }, person: null });+ const committed = runFixtureChild('sh', ['-c', after.card.commits.coordinator.command], { cwd: clean.repo, env: clean.env, encoding: 'utf8' });+ assert.equal(committed.status, 0, committed.failure || committed.stderr || committed.stdout);+ assert.deepEqual(resume(clean).card.commits, { coordinator: null, person: null }, 'the command resume names commits the row file, and only it');++ // Uncommitted setup files: the person commits exactly those, and the coordinator is not asked.+ const fresh = releaseFixture(t, { freshSetup: true, historyBeforeInit: true });+ writeFileSync(join(fresh.repo, 'notes.txt'), 'an unrelated new file\n');+ const setup = resume(fresh);+ const initFiles = ['.githooks/commit-msg', '.githooks/pre-commit', '.githooks/pre-merge-commit', '.githooks/pre-push', 'AGENTS.md', 'DOCTRINE.md', 'SPEC.md', 'pullboard.json'];+ assert.ok(setup.lines.includes(`${PERSON_LINE}${add(fresh, initFiles)}`), setup.lines.join('\n'));+ assert.equal(setup.lines.some((line) => line.startsWith(ROW_LINE)), false, `the coordinator commits nothing:\n${setup.lines.join('\n')}`);+ assert.deepEqual(setup.card.commits, { coordinator: null, person: { files: initFiles, command: add(fresh, initFiles) } });++ // Both at once: each owner gets exactly its own files, and an unrelated dirty file is never setup.+ const mixed = applied();+ const config = JSON.parse(readFileSync(join(mixed.repo, 'pullboard.json'), 'utf8'));+ writeFileSync(join(mixed.repo, 'pullboard.json'), JSON.stringify({ ...config, gate: 'pullboard spec check' }, null, 2) + '\n');+ const both = resume(mixed);+ assert.ok(both.lines.includes(`${ROW_LINE}${commit(mixed, ['SPEC.md'])}`), both.lines.join('\n'));+ assert.ok(both.lines.includes(`${PERSON_LINE}${add(mixed, ['pullboard.json'])}`), both.lines.join('\n'));+ assert.deepEqual(both.card.commits, {+ coordinator: { files: ['SPEC.md'], command: commit(mixed, ['SPEC.md']) },+ person: { files: ['pullboard.json'], command: add(mixed, ['pullboard.json']) },+ });+});+test('resume says what is new once after an upgrade [N19]', t => {const box = releaseFixture(t, { previous: '0.8.5' });const otherCheckout = join(box.root, 'other-checkout');