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(publish): record gate runs and paired flakes [C7,D1]
Corey Olsonc16b6d79fac1
diff --git a/src/commands/publish.js b/src/commands/publish.jsindex 03104295..88323a69 100644--- a/src/commands/publish.js+++ b/src/commands/publish.js@@ -3,9 +3,13 @@ import { publishTrunk } from '../publish.js';import { COORDINATOR } from '../config.js';import { mainPolicy } from '../trusted-policy.js';import { Refused } from '../refused.js';+import * as nativeFlakes from '../native-flake-cli.js';import {actOn,gateWaitReporter,+ ordered,+ resourceAgent,+ withBoard,} from '../cli.js';/** Run `pullboard publish` and return its exit code. */@@ -13,7 +17,9 @@ export async function run(io, { first, second, rest }) {return actOn(io, async (ctx, board, me) => {if (me.id !== COORDINATOR || !ctx.info.isMain) throw new Refused('COORDINATOR_ONLY', 'only the coordinator publishes the trunk; ask your coordinator to run pullboard publish');if (first || second || rest.length) throw new Refused('USAGE', 'pullboard publish');- const result = await publishTrunk({ root: ctx.info.root, board, config: mainPolicy(ctx.info.root).config, say: io.say, onWait: gateWaitReporter(io) });+ const config = mainPolicy(ctx.info.root).config;+ const onFailure = nativeFlakes.observer(ctx, { kind: 'land', board, config }, { ordered, withBoard, resourceAgent });+ const result = await publishTrunk({ root: ctx.info.root, board, config, say: io.say, onWait: gateWaitReporter(io), onFailure });io.result?.(result);return result.published || result.waiting ? 0 : 1;});diff --git a/src/publish.js b/src/publish.jsindex 59ba47ad..2775aaae 100644--- a/src/publish.js+++ b/src/publish.js@@ -61,10 +61,10 @@ function touchedBy(root, board, published, head, files) {* green; otherwise report every failing test with the landed items that touched its file, and remember the head so* the next publish waits for a new one.*- * @param {{ root: string, board: any, config: any, say: (line: string) => void, onWait?: Function }} options+ * @param {{ root: string, board: any, config: any, say: (line: string) => void, onWait?: Function, onFailure?: Function }} options* @returns {Promise<{ head: string, published: boolean, red: Array<{ file: string|null, name: string, items: number[] }>, waiting?: boolean }>}*/-export async function publishTrunk({ root, board, config, say, onWait }) {+export async function publishTrunk({ root, board, config, say, onWait, onFailure }) {const trunk = mainCheckout(root);if (!trunk?.commit) throw new Refused('LAND_TRUNK', 'publish needs the coordinator’s primary branch; return its checkout to the trunk');const branch = trunk.branch.replace(/^refs\/heads\//u, '');@@ -85,7 +85,7 @@ export async function publishTrunk({ root, board, config, say, onWait }) {git(root, ['worktree', 'add', '--detach', directory, head]);let gate;try {- gate = await runGate(directory, config, { trustStamp: false, landing: true, agent: 'coordinator', onWait });+ gate = await runGate(directory, config, { trustStamp: false, landing: true, agent: 'coordinator', onWait, onFailure });// Push from the worktree that ran the suite, so the pre-push hook reads that run's green stamp instead of rerunning it.if (gate.isGreen) {const pushed = tryGit(directory, ['push', remote, `HEAD:refs/heads/${branch}`]);diff --git a/test/land.test.js b/test/land.test.jsindex 3689fd6e..5061f369 100644--- a/test/land.test.js+++ b/test/land.test.js@@ -1429,3 +1429,52 @@ test('an accepted item lands on the local trunk before the whole suite runs [B3,assert.equal(box.git(box.remote, 'rev-parse', 'main'), result.batch.tip);assert.equal(calls(box).length - start, 1, 'publish ran the whole suite once');});++test('a publish gate run is recorded and a red and green pair it sees files the flake [C7,D1]', () => {+ const box = landProject();+ const configFile = join(box.repo, 'pullboard.json');+ const config = JSON.parse(readFileSync(configFile, 'utf8'));+ writeFileSync(configFile, JSON.stringify({ ...config, flakes: { rerun: false } }, null, 2));+ assert.equal(commitFile(box, box.repo, FILES[0], 'RED\n', 'test: commit the publish target [G1]').status, 0);+ const tree = box.git(box.repo, 'rev-parse', 'HEAD^{tree}');+ const firstHead = box.git(box.repo, 'rev-parse', 'HEAD');+ const remoteBefore = box.git(box.remote, 'rev-parse', 'main');+ const before = calls(box).length;+ const red = box.run(box.repo, 'publish', '--json');+ assert.equal(red.code, 1, red.err);+ /** Read only the receipts actual gate executions wrote. */+ const runs = () => onBoard(box, board => store.gateRuns(board));+ /** Count repair items independently of unrelated diagnostic observations. */+ const flakes = () => onBoard(box, board => store.listItems(board, { all: true }).filter(item => item.item_title.startsWith('Flaky test:')));+ const [failed] = runs();+ assert.ok(failed, 'the red publish records its authentic gate receipt');+ assert.equal(failed.tree, tree);+ assert.equal(failed.green, false);+ assert.equal(failed.by, 'coordinator');+ assert.equal(failed.failures[0].file, FILES[0]);+ assert.equal(flakes().length, 0, 'one red run alone does not prove a flake');+ assert.equal(box.git(box.remote, 'rev-parse', 'main'), remoteBefore, 'the red head stays local');+ assert.equal(json(box, box.repo, 'publish').waiting, true, 'the same red HEAD still waits');+ assert.equal(runs().length, 1, 'waiting records no fabricated execution');+ assert.equal(calls(box).length - before, 1);++ // New commit, unchanged tree: publish may try again without bypassing its same-HEAD retry guard.+ box.env.LAND_SUPPRESS_RED = '1';+ box.git(box.repo, 'commit', '--allow-empty', '-q', '-m', 'test: observe the same tree again [G1]');+ const greenHead = box.git(box.repo, 'rev-parse', 'HEAD');+ assert.notEqual(greenHead, firstHead);+ assert.equal(box.git(box.repo, 'rev-parse', 'HEAD^{tree}'), tree);+ assert.equal(json(box, box.repo, 'publish').published, true);+ assert.equal(box.git(box.remote, 'rev-parse', 'main'), greenHead);+ assert.deepEqual(runs().map(run => [run.tree, run.green]), [[tree, false], [tree, true]]);+ const [repair] = flakes();+ assert.equal(flakes().length, 1, 'publish alone proves the same-tree flake and files it once');+ assert.ok(repair.item_brief.includes(failed.id) && repair.item_brief.includes(runs()[1].id), 'the item cites both actual publish receipts');+ assert.equal(onBoard(box, board => store.flakeQuarantines(board)).length, 1);++ box.git(box.repo, 'commit', '--allow-empty', '-q', '-m', 'test: observe a third publish [G1]');+ assert.equal(json(box, box.repo, 'publish').published, true);+ assert.deepEqual(runs().map(run => [run.tree, run.green]), [[tree, false], [tree, true], [tree, true]]);+ assert.equal(flakes().length, 1, 'another publish receipt creates no duplicate flake item');+ assert.equal(calls(box).length - before, 3, 'each receipt represents one actual full publish gate');+});