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(submit): submit asks why when an existing test is edited [C7,V4]
Corey Olson4dbc338ec1ac
diff --git a/docs/api.md b/docs/api.mdindex 92ecace8..198c54d6 100644--- a/docs/api.md+++ b/docs/api.md@@ -34,6 +34,8 @@ Freshness never rewrites the stored ACCEPT or its verdict row. New accept/rejectFor a stale acceptance, merge current main into the submitted work and commit a clean review HEAD. Another agent runs `pullboard verify <id> accept --note "what was re-reviewed"`; its frozen check runs at that combined HEAD, and a new verdict appends to the history while retaining the original submitted commit. A main move during the check refuses `VERDICT_TRUNK_MOVED` and requires another review. `resume` keeps stale acceptances out of its merge list. `land` excludes stale items (and reports their file and commit); when none remain ready, it refuses `STALE_VERDICT`. Nothing in this observation changes the approved criterion or grants person authority.+A submit that edits a test file, `pullboard.json`, a githook or a file a gate command names, and that already existed at the claim, is refused with `INFRA_NOTE_REQUIRED` until it carries `--infra "<why>"`. The refusal names the files. The note and those files are recorded on the item's `submit` event as `infra: {note, files}`, and `pullboard show` prints them for the reviewer as `infra note:`. A new test file needs no note.+`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.`stats.bars` counts bar corrections, keyed by agent: `{corrections, barRejects, buildRejects}`. A correction is an `edit --criterion` or `--check` on an item that was ever claimed. It must carry `--reason "what the old bar got wrong"` (HTTP `args.reason`); without one it is refused with `BAR_REASON`. A correction that follows the item's newest, unexplained reject marks that reject as caused by the bar, counted to the correcting agent; every other reject counts to the build, under the agent who added the item. Text `stats` prints one `bars:` line per agent, and text `show` prints each correction with its reason.diff --git a/src/board.js b/src/board.jsindex 3c47a8e8..05263073 100644--- a/src/board.js+++ b/src/board.js@@ -1231,7 +1231,7 @@ export function release(board, id, agentId, note = '') {* @param {{ agentId: string, commit: string, tree: string, files?: string[], policyCommit?: string, note?: string }} at - `files`: what the* item's own commits changed since its claim; a rework adds to what the first attempt changed.*/-export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null, note, submissionProof: proof }) {+export function submit(board, id, { agentId, commit, tree, files = [], policyCommit = null, note, submissionProof: proof, infra = null }) {let recordedProof;if (note !== undefined && (typeof note !== 'string' || !note.trim() || /[\r\n\u2028\u2029]/u.test(note))) {throw new Refused('USAGE', 'a submission note, when present, is one nonempty line');@@ -1296,7 +1296,7 @@ export function submit(board, id, { agentId, commit, tree, files = [], policyCom...(policyCommit ? { policyCommit } : {}),...(criterionDigest ? { criterionDigest } : {}),...(note === undefined ? {} : { note: note.trim() }),- ...(recordedProof ? { submissionProof: recordedProof } : {}),+ ...(recordedProof ? { submissionProof: recordedProof } : {}), ...(infra ? { infra } : {}),});});}diff --git a/src/cli.js b/src/cli.jsindex bf20e2d4..a2e13bee 100644--- a/src/cli.js+++ b/src/cli.js@@ -451,6 +451,7 @@ import {waiverLine,} from './land.js';import { installStep } from './worktree.js';+import * as infraNotes from './infra-note.js';export { gateWaitReporter };const CHECKOUT_LEASES = new WeakMap();@@ -605,6 +606,7 @@ const OPTIONS = {'no-open': { type: 'boolean' },'no-permissions': { type: 'boolean' },note: { type: 'string' },+ infra: { type: 'string' },'note-file': { type: 'string' },by: { type: 'string' },key: { type: 'string' },@@ -2461,14 +2463,14 @@ function readCommands(io, { first, second, rest, values }) {show: () => {const ctx = context(io);const id = idArg(first);- const { item, verdicts, moves, thread, related, reviewer, agents, mainMerge } = withBoard(ctx, (board) => ({+ const { item, verdicts, moves, thread, related, reviewer, agents, mainMerge, infra } = withBoard(ctx, (board) => ({item: verdictProjector(ctx.info.root, board).project(store.getItem(board, id)),verdicts: store.verdictsFor(board, id),moves: store.events(board, { itemId: id }).filter((event) => ['attempt', 'escalate'].includes(event.event_kind)),thread: store.itemThread(board, id),related: store.relatedItems(board, store.getItem(board, id)),reviewer: store.reviewHolder(board, store.getItem(board, id)),- agents: store.listAgents(board), mainMerge: mainMergeFor(board, id),+ agents: store.listAgents(board), mainMerge: mainMergeFor(board, id), infra: infraNotes.infraNoteOf(store.events(board, { itemId: id })),}));const agentName = (id) => displayAgentName(agents.find((agent) => agent.agent_id === id) ?? { agent_id: id }, ctx.config.agents.names);if (values.json) {@@ -2496,6 +2498,7 @@ function readCommands(io, { first, second, rest, values }) {frozen.rows.forEach((row) => io.say(` ${row.id}: ${row.text}${row.gate ? ` | gate: ${row.gate}` : ''}`));}if (item.item_commit) io.say(`submitted by ${agentName(item.item_built_by)}${item.item_builder_family ? ` [family ${item.item_builder_family}]` : ''} at ${item.item_commit}`);+ if (infra) io.say(`infra note: ${infra.note} (files: ${infra.files.join(', ') || 'none'})`);if (reviewer) io.say(`under review by ${agentName(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.@@ -2674,7 +2677,7 @@ function readCommands(io, { first, second, rest, values }) {* @param {number} id* @returns {Promise<number>}*/-async function submitHere(ctx, id) {+async function submitHere(ctx, id, infra) {const { root } = ctx.info;const recovered = relayRecovered(root);if (recovered?.operation === 'submit' && recovered.args[0] === id) {@@ -2740,6 +2743,7 @@ async function submitHere(ctx, id) {if (!commit) throw new Refused('NO_COMMIT', 'nothing committed yet');const trunk = requireTrunkMerge(root, commit);withBoard(ctx, (board) => refuseUnverifiedStack(root, board, held, commit, trunk));+ const infraRecord = infraNotes.infraNote({ root, claimHead, files: filesSince(root, id, claimHead, commit), gates: [ctx.config.gate, acceptedMain.config.gate], infra });// Doctrine counts only fall: accepted main's rules, at this exact commit (D1). No rule, no change.const doctrine = hasSubmitRules(root, acceptedMain.commit, acceptedMain.config.practice)? await withGateSlot(root, () => holdDoctrine(root, { mainCommit: acceptedMain.commit, commit, practice: acceptedMain.config.practice, timeoutMs: acceptedMain.config.check?.timeoutMs }),@@ -2777,7 +2781,7 @@ async function submitHere(ctx, id) {refuseUnverifiedStack(root, board, store.getItem(board, id), commit, currentTrunk);// The waived run is written to the item's thread before the submission, so no waived proof reads as green.if (waived) await ordered(ctx, board, 'appendFact', [id, { agentId: me.id, kind: 'measurement', text: `submission proof at ${commit.slice(0, 12)} was red and is recorded as waived, not green; every failure is covered by a live person waiver:\n${waivedLines.join('\n')}` }]);- return await ordered(ctx, board, 'submit', [id, { agentId: me.id, commit, tree: headTree(root) ?? '', files: filesSince(root, id, claimHead, commit), policyCommit: acceptedMain.commit,+ return await ordered(ctx, board, 'submit', [id, { agentId: me.id, commit, tree: headTree(root) ?? '', files: filesSince(root, id, claimHead, commit), policyCommit: acceptedMain.commit, ...(infraRecord ? { infra: infraRecord } : {}),submissionProof: { version: 1, files: gate.files, full: gate.full, deferred: gate.deferred, reason: gate.reason },...(gate.deferred ? { note: 'full suite deferred to the landing gate' } : {}) }]);});@@ -3653,8 +3657,8 @@ function workCommands(io, args) {io.say(review ? `released the review of #${first}; the review is free again` : `released #${first}`);return 0;}),- submit: async () => submitHere(context(io), idArg(first)),- done: async () => submitHere(context(io), idArg(first)),+ submit: async () => submitHere(context(io), idArg(first), values.infra),+ done: async () => submitHere(context(io), idArg(first), values.infra),verify: () => verifyHere(context(io), idArg(first), args),land: () => act(async (ctx, board, me) => {if (me.id !== COORDINATOR || !ctx.info.isMain) throw new Refused('COORDINATOR_ONLY', 'only the coordinator lands verified batches; ask your coordinator to run pullboard land');diff --git a/src/help.js b/src/help.jsindex 676aceb0..529595c0 100644--- a/src/help.js+++ b/src/help.js@@ -116,6 +116,7 @@ Workpullboard claim <id> take or renew a lease; the first claim freezes the criterionpullboard release <id> [--note "why"] hand it back; a review release needs a one-line reasonpullboard submit <id> needs a clean tree, item check and affected tests green at HEAD (alias: done)+ --infra "<why>": required when the change edits an existing test or gate file; the reviewer reads it in showpullboard verify <id> accept --note "what you broke or which edge you tried, and what happened"pullboard verify <id> reject --reason TEST_FAILURE --note "what failed" [--cause <key>]a cause is test:<file>::<title>, refusal:<CODE>, row:<id> or doctrine:<id>diff --git a/src/infra-note.js b/src/infra-note.jsnew file mode 100644index 00000000..c01b490e--- /dev/null+++ b/src/infra-note.js@@ -0,0 +1,76 @@+/**+ * Infra notes: a submit that edits an existing test file, or a file the gate runs, must say why [C7,V4]. An+ * agent once swapped real listeners for in-memory parsers to get past a sandbox, and nobody asked the person.+ * The note and the files it covers are recorded on the submit event, and the reviewer reads them in show.+ */+import { Refused } from './refused.js';+import { tryGit } from './git.js';++/** A test file, by its name or by its folder. */+const TEST_FILE = /^test\/|\.(?:test|spec)\.[cm]?js$/u;+/** A token of a gate command that names a file: a path, or a script with a known extension. */+const GATE_FILE = /\.(?:[cm]?js|sh|json)$|\//u;++/**+ * The gate files a command names, relative to the checkout. A command like "node --test test/a.test.js" names+ * test/a.test.js; a flag or a URL names nothing.+ *+ * @param {string[]} commands the gate commands in force+ * @returns {Set<string>}+ */+function namedByGates(commands) {+ const named = new Set();+ for (const command of commands) {+ for (const token of String(command ?? '').split(/\s+/u)) {+ const word = token.replace(/^["']|["']$/gu, '');+ if (word && !word.startsWith('-') && !word.includes('://') && GATE_FILE.test(word)) named.add(word.replace(/^\.\//u, ''));+ }+ }+ return named;+}++/**+ * The files a submit changes that the claim already had, and that are a test file, the project's pullboard.json,+ * a githook, or a file a gate command names. A new file is not an edit of an existing one.+ *+ * @param {string} root the builder's checkout+ * @param {string} claimHead the commit the item was claimed at+ * @param {string[]} files the files the item changed since the claim+ * @param {string[]} gates the gate commands in force+ * @returns {string[]} the sorted files that need a note+ */+export function existingGuardedEdits(root, claimHead, files, gates) {+ const named = namedByGates(gates);+ const guarded = files.filter((path) => TEST_FILE.test(path) || path === 'pullboard.json' || path.startsWith('.githooks/') || named.has(path));+ return guarded.filter((path) => tryGit(root, ['cat-file', '-e', `${claimHead}:${path}`]).status === 0).sort();+}++/**+ * Decide whether a submit may proceed: refused with INFRA_NOTE_REQUIRED when it edits an existing guarded file and+ * carries no --infra reason, otherwise the note and the files it covers, to record on the submit event.+ *+ * @param {{ root: string, claimHead: string, files: string[], gates: string[], infra: string | undefined }} submit+ * @returns {{ note: string, files: string[] } | null} the infra record, or null when none is needed or given+ * @throws {Refused} INFRA_NOTE_REQUIRED, or USAGE for a malformed --infra value+ */+export function infraNote({ root, claimHead, files, gates, infra }) {+ const edited = existingGuardedEdits(root, claimHead, files, gates);+ if (infra === undefined) {+ if (!edited.length) return null;+ throw new Refused('INFRA_NOTE_REQUIRED', `this change edits existing test or gate file${edited.length > 1 ? 's' : ''} ${edited.join(', ')}; say why with --infra "<why>"`,+ 'run pullboard submit <id> --infra "<why>", giving the reason the edit is needed');+ }+ if (typeof infra !== 'string' || !infra.trim() || /[\r\n]/u.test(infra)) throw new Refused('USAGE', '--infra "<why>" is one nonempty line');+ return { note: infra.trim(), files: edited };+}++/**+ * The infra record of an item's latest submit, for the reviewer to read; null when that submit gave none.+ *+ * @param {Array<{ event_kind: string, event_detail: string }>} events the item's events, oldest first+ * @returns {{ note: string, files: string[] } | null}+ */+export function infraNoteOf(events) {+ const latest = events.filter((event) => event.event_kind === 'submit').at(-1);+ return latest ? JSON.parse(latest.event_detail).infra ?? null : null;+}diff --git a/test/submit-gate.test.js b/test/submit-gate.test.jsindex f2da2bc6..f40a9e9b 100644--- a/test/submit-gate.test.js+++ b/test/submit-gate.test.js@@ -475,7 +475,7 @@ test('an item claimed before the gate existed submits once a gate exists [C7,B26commitAll(box, 'chore: expose an untrusted candidate gate');const marker = join(box.dir, 'gate-ran.log');box.env.GATE_MARKER = marker;- const submitted = box.run('submit', '1', '--json');+ const submitted = box.run('submit', '1', '--json', '--infra', 'the gate was configured after the claim');assert.equal(submitted.code, 0, `${submitted.out}\n${submitted.err}`);const receipt = JSON.parse(submitted.out);assert.equal(receipt.gate.green, true);@@ -593,7 +593,7 @@ test('a landing-gated project defers the full suite from submit to landing [V4,Cput(optedIn.box.root, 'src/cli.js', 'export const version = 2;\n');commitAll(optedIn.box, 'feat(core): change global source [G1]');- const deferred = optedIn.box.run('submit', '1', '--json');+ const deferred = optedIn.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(deferred.code, 0, deferred.err);const receipt = JSON.parse(deferred.out);assert.equal(receipt.gate.full, true, 'the selector still reports that it fell back to the whole suite');@@ -620,7 +620,7 @@ test('a landing-gated project defers the full suite from submit to landing [V4,Cput(candidateOnly.box.root, 'pullboard.json', JSON.stringify(candidateConfig));put(candidateOnly.box.root, 'src/cli.js', 'export const version = 2;\n');commitAll(candidateOnly.box, 'feat(core): try candidate-only deferral [G1]');- const ordinary = candidateOnly.box.run('submit', '1', '--json');+ const ordinary = candidateOnly.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(ordinary.code, 0, ordinary.err);const ordinaryReceipt = JSON.parse(ordinary.out);assert.equal(ordinaryReceipt.gate.deferred, false, 'a candidate-only setting is not trusted');@@ -631,7 +631,7 @@ test('a landing-gated project defers the full suite from submit to landing [V4,Cconst named = project('landing');put(named.box.root, 'src/a.js', 'export const value = 2;\n');commitAll(named.box, 'feat(core): change one selected source [G1]');- const selected = named.box.run('submit', '1', '--json');+ const selected = named.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(selected.code, 0, selected.err);const selectedReceipt = JSON.parse(selected.out);assert.equal(selectedReceipt.gate.full, false);@@ -683,14 +683,14 @@ test("a landing-gated submit runs the project's invariant tests [V4,C7]", (t) =>const empty = project();change(empty.box);- const unchanged = empty.box.run('submit', '1', '--json');+ const unchanged = empty.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(unchanged.code, 0, unchanged.err);assert.equal(existsSync(empty.marker), false, 'the empty default adds no tests');unstamped(empty.box);const mandatory = project(['test/invariant.test.js']);change(mandatory.box);- const guarded = mandatory.box.run('submit', '1', '--json');+ const guarded = mandatory.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(guarded.code, 0, guarded.err);const guardedReceipt = JSON.parse(guarded.out);assert.equal(guardedReceipt.gate.full, true, 'the selector still reports an uncertain full fallback');@@ -702,7 +702,7 @@ test("a landing-gated submit runs the project's invariant tests [V4,C7]", (t) =>const red = project(['test/invariant.test.js'], true);change(red.box);- const refused = red.box.run('submit', '1', '--json');+ const refused = red.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.notEqual(refused.code, 0, 'a failing configured invariant must refuse the submit');assert.match(refused.err + refused.out, /GATE_RED/u);assert.ok(existsSync(red.marker), 'the listed invariant actually ran');@@ -720,7 +720,7 @@ test("a landing-gated submit runs the project's invariant tests [V4,C7]", (t) =>candidate.submitInvariants = ['test/c.test.js'];put(trusted.box.root, 'pullboard.json', JSON.stringify(candidate));change(trusted.box);- const ignored = trusted.box.run('submit', '1', '--json');+ const ignored = trusted.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.notEqual(ignored.code, 0, 'accepted main policy overrides both the claim-time list and candidate edit');assert.match(ignored.err + ignored.out, /GATE_RED/u);assert.ok(existsSync(trusted.marker), 'the accepted-main invariant still ran');@@ -730,14 +730,14 @@ test("a landing-gated submit runs the project's invariant tests [V4,C7]", (t) =>const missing = project(['test/invariant.test.js']);rmSync(join(missing.box.root, 'test/invariant.test.js'));change(missing.box);- const absent = missing.box.run('submit', '1', '--json');+ const absent = missing.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.notEqual(absent.code, 0, 'deleting a mandatory file cannot make the guard disappear');assert.match(absent.err + absent.out, /submitInvariants file test\/invariant\.test\.js is missing or unreadable/u);unstamped(missing.box);const named = project(['test/invariant.test.js', 'test/invariant.test.js']);change(named.box, false);- const selected = named.box.run('submit', '1', '--json');+ const selected = named.box.run('submit', '1', '--json', '--infra', 'the landing fixture edits its pullboard.json');assert.equal(selected.code, 0, selected.err);const receipt = JSON.parse(selected.out);assert.equal(receipt.gate.full, false);@@ -1488,7 +1488,7 @@ test('a submit runs the static style checks first [C7]', t => {put(box.root, 'src/cli.js', "import { join, resolve } from 'node:path';\nexport const fixture = join;\n");commitAll(box, 'feat(core): expose the missed static guard [G1]');rmSync(marker, { force: true });- const submitted = box.run('submit', '1', '--json');+ const submitted = box.run('submit', '1', '--json', '--infra', 'the static guard fixture edits its pullboard.json');assert.notEqual(submitted.code, 0, 'submit must refuse a static import violation before any item proof');assert.match(submitted.out + submitted.err, /src\/cli\.js:1: one import binding per line/u);assert.equal(existsSync(marker), false, 'the frozen item check must not run after an early static refusal');diff --git a/test/submit-infra.test.js b/test/submit-infra.test.jsnew file mode 100644index 00000000..84b55ffb--- /dev/null+++ b/test/submit-infra.test.js@@ -0,0 +1,129 @@+/** @pullboard-test-input test-tree */+/** @pullboard-test-input source-tree */+/**+ * Submit asks why when a change edits an existing test or gate file, and a new test file needs no reason [C7,V4].+ */+import assert from 'node:assert/strict';+import { runFixtureChild, runFixtureGit } from './fixture-child.js';+import { appendFileSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, symlinkSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';+import { dirname, join } from 'node:path';+import { after, test } from 'node:test';++const BIN = join(import.meta.dirname, '../bin/pullboard.js');+const SPEC = '# Submit proof fixture\n\n## G · Goals\n- G1 [approved, must] The selected test proves the change. | gate: test\n';+const dirs = [];++after(() => {+ for (const dir of dirs) rmSync(dir, { recursive: true, force: true });+});++/** Write a fixture file, creating its parent directory when needed. */+function put(root, path, text) {+ const file = join(root, path);+ mkdirSync(dirname(file), { recursive: true });+ writeFileSync(file, text);+}++/** Commit the fixture state using a valid Pullboard message. */+function commitAll(box, message = 'chore: fixture state') {+ box.git('add', '-A');+ box.git('commit', '-q', '-m', message);+ return box.git('rev-parse', 'HEAD');+}++/** Create a private Git repository with a deterministic identity and isolated Pullboard home. */+function privateRepo(t) {+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-submit-infra-')));+ dirs.push(dir);+ t.after(() => rmSync(dir, { recursive: true, force: true }));+ const root = join(dir, 'repo');+ mkdirSync(root);+ const env = {+ ...process.env,+ GIT_CONFIG_GLOBAL: '/dev/null',+ GIT_CONFIG_NOSYSTEM: '1',+ GIT_AUTHOR_NAME: 'Test Agent',+ GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Test Agent',+ GIT_COMMITTER_EMAIL: '[email protected]',+ PULLBOARD_HOME: join(dir, 'home'),+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'),+ };+ delete env.PULLBOARD_RELAY_TOKEN;+ delete env.NODE_TEST_CONTEXT;+ /** Run real Git in this fixture with only the fixture's configured identity. */+ const git = (...args) => runFixtureGit(args, { cwd: root, env });+ /** Run the real local CLI, retaining JSON stdout and refusal stderr separately. */+ const run = (...args) => {+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '', failure: result.failure };+ };+ git('init', '-q', '-b', 'main');+ assert.equal(run('init').code, 0);+ mkdirSync(join(root, 'node_modules/.bin'), { recursive: true });+ symlinkSync(BIN, join(root, 'node_modules/.bin/pullboard'));+ appendFileSync(join(root, '.git/info/exclude'), '\nnode_modules/\n');+ put(root, 'SPEC.md', SPEC);+ put(root, 'package.json', '{"type":"module"}\n');+ return { dir, root, env, git, run };+}++/** Create a real joined builder while the coordinator stays on its unchanged trunk. */+function builderRepo(box) {+ const config = JSON.parse(readFileSync(join(box.root, 'pullboard.json'), 'utf8'));+ config.lanes = { build: { owns: ['src/', 'test/'], specs: ['G'] } };+ put(box.root, 'pullboard.json', JSON.stringify(config));+ commitAll(box);+ const made = box.run('worktree', 'build', '--json');+ assert.equal(made.code, 0, made.err);+ const root = JSON.parse(made.out).path;+ /** Run Git only in the joined builder. */+ const git = (...args) => runFixtureGit(args, { cwd: root, env: box.env });+ /** Run the real CLI with the joined builder identity. */+ const run = (...args) => {+ const result = runFixtureChild(process.execPath, [BIN, ...args], { cwd: root, env: box.env, encoding: 'utf8' });+ return { code: result.status, out: result.stdout ?? '', err: result.failure ?? result.stderr ?? '', failure: result.failure };+ };+ return { ...box, root, git, run, coordinator: box.run };+}++/** Commit one change to a builder checkout, then return the item's builder repository. */+function infraBox(t, { edit, existing = true }) {+ let box = privateRepo(t);+ put(box.root, 'pullboard.json', JSON.stringify({ gate: 'true', spec: 'SPEC.md' }));+ put(box.root, 'SPEC.md', SPEC);+ put(box.root, 'src/a.js', 'export const value = 1;\n');+ if (existing) put(box.root, 'test/existing.test.js', "import '../src/a.js';\n");+ commitAll(box);+ box = builderRepo(box);+ assert.equal(box.coordinator('add', 'build', 'Infra note fixture', '--check', 'true').code, 0);+ assert.equal(box.run('claim', '1').code, 0);+ edit(box);+ commitAll(box, 'feat(core): change the item [G1]');+ return box;+}++test('submit asks why when a change edits an existing test [C7,V4]', (t) => {+ const box = infraBox(t, { edit: (box) => put(box.root, 'test/existing.test.js', "import '../src/a.js';\n// a reason\n") });+ const refused = box.run('submit', '1');+ assert.equal(refused.code, 1, `${refused.out}\n${refused.err}`);+ const refusal = `${refused.out}\n${refused.err}`;+ assert.match(refusal, /INFRA_NOTE_REQUIRED/u, 'submit refuses an unexplained edit to an existing test');+ assert.match(refusal, /test\/existing\.test\.js/u, 'the refusal names the file');+ assert.match(refusal, /--infra/u, 'the refusal says how to give the reason');++ const submitted = box.run('submit', '1', '--infra', 'the listener shim hid a real socket');+ assert.equal(submitted.code, 0, `${submitted.out}\n${submitted.err}`);+ const shown = box.run('show', '1');+ assert.equal(shown.code, 0, shown.err);+ assert.match(shown.out, /infra note: the listener shim hid a real socket/u, 'the reviewer reads the note in show');+ assert.match(shown.out, /test\/existing\.test\.js/u, 'show names the edited file');+});++test('a new test file needs no note [C7,V4]', (t) => {+ const box = infraBox(t, { existing: true, edit: (box) => put(box.root, 'test/brand-new.test.js', "import '../src/a.js';\n") });+ const submitted = box.run('submit', '1');+ assert.equal(submitted.code, 0, `${submitted.out}\n${submitted.err}`);+ assert.doesNotMatch(`${submitted.out}\n${submitted.err}`, /INFRA_NOTE_REQUIRED/u);+});