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(merge): a gate that rejects everything is an alarm, not a [C7,D1]
Corey Olson8705fc7593e0
diff --cc src/health.jsindex f8067f73,0b4c6f6a..73a5449a--- a/src/health.js+++ b/src/health.js@@@ -15,14 -15,11 +15,15 @@@ importmainCheckout,tryGit,} from './git.js';+ import { gateControlFindings } from './gate-control.js';import {boardBusyError,+ buildOrder,+ canTake,+ listItems,openBoardReadOnly,PERSON,+ ROUTES,roadmap,rowDecisions,unverifiedSubmissions,diff --cc test/health.test.jsindex 1ab6348e,2130bc77..3365df20--- a/test/health.test.js+++ b/test/health.test.js@@@ -339,88 -340,63 +340,149 @@@ test('item history survives garbage colassert.equal(child.stdout, '50', 'every item with events has a history entry');});+test('health names a route with open work and no agent [N2,B13]', async (t) => {+ const box = repo(t);+ const { board, at } = boardAt(box);+ at(HOUR / 12);+ store.register(board, { lane: 'coordinator', path: box.root });+ const light = store.register(board, { lane: 'core', route: 'light', path: join(box.dir, 'core-light') });+ const waiting = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Mid work', route: 'mid',+ criterion: 'The mid work is done when its test passes.', check: 'true', brief: 'Files:\n- src/mid.js\nTest:\n- the mid work runs' });+ store.closeBoard(board);+ const result = await cli(box.root, ['health', '--json']);+ assert.equal(result.code, 1, `a queue fault is stuck work: ${result.stderr}`);+ const report = JSON.parse(result.stdout);+ const route = report.stuck.find((entry) => entry.key === 'ROUTE_UNSERVED:route:mid');+ assert.ok(route, `health names the route nobody serves: ${result.stdout}`);+ assert.deepEqual(route.owner, { role: 'coordinator', who: 'coordinator' }, 'the coordinator starts an agent on the route');+ assert.ok(route.why.includes(`#${waiting}`), `the finding names the waiting item: ${route.why}`);+ assert.equal(route.command, 'pullboard worktree core --route mid', `the command starts an agent on the route: ${route.command}`);+ assert.ok(route.next.includes('pullboard worktree core --route mid') && route.next.includes('PULLBOARD_MODEL'), `the next step names the worktree command and the model: ${route.next}`);+ assert.ok(!route.command.includes('pullboard join'), 'join from the main checkout would enroll the coordinator, not start an agent');+ assert.ok(!report.stuck.some((entry) => entry.owner?.who === light && entry.key.startsWith('ROUTE_UNSERVED')), 'the light agent is not named for a mid route');+});++test('health names a rank inversion [N2,B13]', async (t) => {+ const box = repo(t);+ const { board, at } = boardAt(box);+ at(HOUR / 12);+ store.register(board, { lane: 'coordinator', path: box.root });+ const builder = store.register(board, { lane: 'core', path: join(box.dir, 'core-1') });+ const earlier = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Earlier work' });+ const later = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Later work' });+ store.claim(board, later, { agentId: builder, lane: 'core', leaseMs: 2 * HOUR, freeze });+ store.closeBoard(board);+ const result = await cli(box.root, ['health', '--json']);+ const report = JSON.parse(result.stdout);+ const inversion = report.stuck.find((entry) => entry.key === `RANK_INVERSION:item:${later}`);+ assert.ok(inversion, `health names the claim that ranks behind a free item: ${result.stdout}`);+ assert.deepEqual(inversion.owner, { role: 'builder', who: builder }, 'the holder owns its own rank inversion');+ assert.ok(inversion.why.includes(`#${earlier}`), `the finding names the free item ahead: ${inversion.why}`);+ assert.ok(inversion.next.includes(`claim #${earlier}`), `the next step claims it: ${inversion.next}`);+});++test('every printed next step runs as pasted through main() [N2,B13]', async (t) => {+ // Each next step health prints runs from the directory a person would use: the worktree commands from+ // the main checkout, and the agent steps from that agent's own worktree (#798).+ const box = repo(t);+ const brief = { criterion: 'The item is done when its test passes.', check: 'true', brief: 'Files:\n- src/mid.js\nTest:\n- the mid work runs' };+ const { board, at } = boardAt(box);+ at(40 * HOUR);+ store.register(board, { lane: 'coordinator', path: box.root });+ const idlePath = join(box.dir, 'core-idle');+ box.git(['worktree', 'add', '-q', idlePath, '-b', 'core-idle']);+ const idle = store.register(board, { lane: 'core', route: 'strong', path: idlePath });+ at(HOUR / 12);+ const holderPath = join(box.dir, 'core-holder');+ box.git(['worktree', 'add', '-q', holderPath, '-b', 'core-holder']);+ const holder = store.register(board, { lane: 'core', route: 'mid', path: holderPath });+ store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Earlier mid', route: 'mid', ...brief });+ const later = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Later mid', route: 'mid', ...brief });+ const strong = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Strong work' });+ store.claim(board, later, { agentId: holder, lane: 'core', leaseMs: 2 * HOUR, freeze });+ store.closeBoard(board);++ const before = await cli(box.root, ['health', '--json']);+ const printed = JSON.parse(before.stdout).stuck.filter((entry) => entry.command);+ const keys = printed.map((entry) => entry.key);+ for (const key of [`ROUTE_UNSERVED:route:strong`, `ITEM_UNTAKEABLE:item:${strong}`, `IDLE_AGENT:agent:${idle}`, `RANK_INVERSION:item:${later}`]) {+ assert.ok(keys.includes(key), `health prints a next step for ${key}: ${keys.join(', ')}`);+ }+ const folders = { [idle]: idlePath, [holder]: holderPath };+ const saved = process.env.PULLBOARD_MODEL;+ process.env.PULLBOARD_MODEL = 'claude-haiku-5-5';+ try {+ for (const entry of printed) {+ assert.ok(!entry.command.startsWith('pullboard join'), `${entry.key} never runs join: ${entry.command}`);+ const argv = entry.command.match(/"[^"]*"|\S+/gu).slice(1).map((token) => token.replace(/^"|"$/gu, ''));+ const ran = await cli(folders[entry.owner.who] ?? box.root, argv);+ assert.equal(ran.code, 0, `${entry.key} runs as printed: pullboard ${argv.join(' ')}: ${ran.stderr}${ran.stdout}`);+ }+ } finally {+ if (saved === undefined) delete process.env.PULLBOARD_MODEL; else process.env.PULLBOARD_MODEL = saved;+ }+ const after = JSON.parse((await cli(box.root, ['health', '--json'])).stdout);+ assert.ok(!after.stuck.some((entry) => entry.key === 'ROUTE_UNSERVED:route:strong'), 'the worktree the next step starts serves the strong route');+ assert.ok(!after.stuck.some((entry) => entry.key === `RANK_INVERSION:item:${later}`), 'the release the next step names clears the rank inversion');+});+++ /** Commit a pullboard.json whose gate, and optional positive control, the next gate run reads. */+ function commitPolicy(box, policy) {+ writeFileSync(join(box.root, 'pullboard.json'), `${JSON.stringify({ gate: 'true', lanes: { core: { owns: ['src/'] }, docs: { owns: ['docs/'] }, review: { owns: [] } }, ...policy }, null, 2)}\n`);+ box.git(['add', 'pullboard.json']);+ box.git(['commit', '-q', '-m', 'chore: gate policy']);+ }++ /** Health at the real clock, since a gate run records the moment it actually ran. */+ async function healthNow(cwd) {+ let stdout = '';+ const code = await main(['health', '--json'], {+ cwd, stdout: { isTTY: false, write: (text) => { stdout += text; } }, stderr: { write: () => {} },+ });+ return { code, report: JSON.parse(stdout) };+ }++ test('health reports a gate whose positive control fails [C7,D1]', async (t) => {+ const box = repo(t);+ commitPolicy(box, { gate: 'true', positiveControl: 'false' });+ const ran = await cli(box.root, ['gate']);+ assert.equal(ran.code, 0, 'the gate itself is green, so only its known-good case betrays it');+ const { code, report } = await healthNow(box.root);+ assert.equal(code, 1, 'a failing positive control is stuck work, not green');+ const alarm = report.stuck.find((entry) => entry.cause === 'GATE_CONTROL_FAILED');+ assert.ok(alarm, 'health names the gate whose positive control failed');+ assert.equal(alarm.subject, 'gate');+ assert.match(alarm.why, /positive control/u);+ assert.equal(alarm.detail.positiveControl, 'false');+ assert.equal(alarm.detail.runs.at(-1).control, false, 'the finding carries the last run and its control result');+ });++ test('health reports a gate that refused every run [C7,D1]', async (t) => {+ const box = repo(t);+ commitPolicy(box, { gate: 'false' });+ for (let run = 1; run <= 2; run += 1) assert.equal((await cli(box.root, ['gate'])).code, 1, `run ${run} is refused`);+ assert.equal((await healthNow(box.root)).report.stuck.some((entry) => entry.cause === 'GATE_REFUSED_EVERY_RUN'), false, 'two refusals are not yet an alarm');+ assert.equal((await cli(box.root, ['gate'])).code, 1, 'run 3 is refused');+ const { code, report } = await healthNow(box.root);+ assert.equal(code, 1);+ const alarm = report.stuck.find((entry) => entry.cause === 'GATE_REFUSED_EVERY_RUN');+ assert.ok(alarm, 'health names a gate that refused every run in its window');+ assert.equal(alarm.subject, 'gate');+ assert.deepEqual(alarm.detail.runs.map((run) => run.green), [false, false, false], 'the finding lists the last runs, all refused');+ });++ test('a positive control inherits the gate slot it runs under [C7,D1]', async (t) => {+ const box = repo(t);+ const resources = pathToFileURL(resolve('src/resources.js')).href;+ // The control asks whether it inherited the gate's admission; a child that does not is refused and reads red.+ const probe = `node --input-type=module -e "const { inheritedGateSlot } = await import('${resources}'); process.exit(inheritedGateSlot({ root: process.cwd() }) ? 0 : 1)"`;+ commitPolicy(box, { gate: 'true', positiveControl: probe });+ const { runGate } = await import('../src/gate.js');+ const config = JSON.parse(readFileSync(join(box.root, 'pullboard.json'), 'utf8'));+ const gate = await runGate(box.root, config, { trustStamp: false });+ assert.equal(gate.isGreen, true, 'the gate itself is green');+ const run = gateRuns(box.root).at(-1);+ assert.equal(run.control, true, 'the positive control saw the inherited gate slot and passed');+ assert.ok(run.controlLog && existsSync(run.controlLog), 'the control keeps its raw output in the gate evidence');+ assert.ok(run.controlProfile && existsSync(run.controlProfile), 'the control keeps its timing profile in the gate evidence');+ });