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(checks): next and run claims also wait for a held check [C7,V4]
Corey Olson0b99888cb778
diff --git a/src/check-accept.js b/src/check-accept.jsindex 33fe9731..74431057 100644--- a/src/check-accept.js+++ b/src/check-accept.js@@ -7,6 +7,7 @@ import { PERSON, atomic, getItem, itemById, logEvent } from './board.js';import { COORDINATOR } from './config.js';import { requirePersonChannel } from './person.js';import { Refused } from './refused.js';+import { mainPolicy } from './trusted-policy.js';/** The engine that first replays a person's check acceptance; older engines refuse the move unread [H16]. */export const CHECK_ACCEPT_ENGINE = 24;@@ -90,6 +91,20 @@ export function refuseProvesNothing(mainConfig, board, item) {`the coordinator sets a check that fails before the work (pullboard edit ${item.item_id} --check "<command>"), or the person accepts this one: pullboard check accept ${item.item_id}`);}+/**+ * Refuse any claim of an open or claimed item whose check is held, reading accepted main's setting.+ * Claim, next, next --build and pullboard run all order their claim through the CLI's one claim+ * helper, which calls this first, so no route records a claim on a held item.+ *+ * @param {string} root+ * @param {any} board+ * @param {number} id+ */+export function refuseClaimProvesNothing(root, board, id) {+ const item = getItem(board, id);+ if (['open', 'claimed'].includes(item.item_status)) refuseProvesNothing(() => mainPolicy(root).config, board, item);+}+/*** Run pullboard check accept <id>: the person accepts an item's check as it reads now, which lifts a* hold on a check already green on main. A person-only move (P6): an agent shell, a remote shell, adiff --git a/src/cli.js b/src/cli.jsindex 09eac853..efeb9b21 100644--- a/src/cli.js+++ b/src/cli.js@@ -65,7 +65,7 @@ import { answerQuestion, bundledBlueprints, landBlueprint, planBlueprint, readBlimport { briefFiles } from './brief.js';import { commitFirst, commitOwnerLines, commitOwners, coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';import { checkBaseline, prepareCheckBaseline, refuseCheckSyntax, sayCheckBaseline } from './check-baseline.js';-import { checkAcceptCommand, refuseProvesNothing } from './check-accept.js';+import { checkAcceptCommand, refuseClaimProvesNothing, refuseProvesNothing } from './check-accept.js';import { retryCheckBaselines, startCheckBaseline } from './check-baseline-worker.js';import { compareMainFailures, mainRedMessage, mainRedReworkItems } from './main-red.js';import { runItems } from './run.js';@@ -596,6 +596,12 @@ async function ordered(ctx, board, operation, args) {finally { lease.release(); }}+/** Order a claim on every route (claim, next, run) only after a check green on main is not held [V4]. */+async function claimOrdered(ctx, board, args) {+ refuseClaimProvesNothing(ctx.info.root, board, args[0]);+ return await ordered(ctx, board, 'claim', args);+}+/** Check ownership before sync or command side effects; reads and authenticated person channels keep their identity. */async function bindCheckoutSession(io, positionals, values) {if (values.help || values.version || io.personChannel === 'view' || io.personRequest) return;@@ -2689,7 +2695,7 @@ async function nextOnce(ctx, values) {const reviewSkipped = values.build && !held? { offeredItem: offer?.item.item_id ?? null, ratio: ctx.config.verify.reviewRatio, ...store.reviewQueue(board) } : null;try {- await ordered(ctx, board, 'claim', [item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root), reviewSkipped }]);+ await claimOrdered(ctx, board, [item.item_id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root), reviewSkipped }]);} catch (error) {if (error instanceof MainSpecMerged) return { retry: true, specMerged: { item: item.item_id, rows: error.rows } };if (error instanceof Refused && ['HELD', 'ITEM_HELD', 'BLOCKED', 'ONE_CLAIM'].includes(error.code)) return { retry: true };@@ -3009,7 +3015,7 @@ function workCommands(io, args) {io.say(`#${id} escalated ${moved.from} -> ${moved.to}; it is open for a ${moved.to} agent`);return 0;}),- run: () => runItems(io, values, { context, withBoard, whoAmI, nextOnce, submitHere, freezer, ordered }),+ run: () => runItems(io, values, { context, withBoard, whoAmI, nextOnce, submitHere, freezer, ordered, claim: claimOrdered }),sweep: () => act((ctx, board, me) => sweepHere(ctx, board, me, values)),next: () => nextHere(io, { ...values, verifyId: first }),check: async () => {@@ -3056,12 +3062,10 @@ function workCommands(io, args) {},claim: () => act(async (ctx, board, me) => {const id = idArg(first);- const claimable = store.getItem(board, id);- if (['open', 'claimed'].includes(claimable.item_status)) refuseProvesNothing(() => mainPolicy(ctx.info.root).config, board, claimable);let result;for (;;) {try {- result = await ordered(ctx, board, 'claim', [id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root) }]);+ result = await claimOrdered(ctx, board, [id, { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: claimFreezer(ctx), head: headCommit(ctx.info.root) }]);break;} catch (error) {if (!(error instanceof MainSpecMerged)) throw error;diff --git a/src/run.js b/src/run.jsindex cf450722..483e803c 100644--- a/src/run.js+++ b/src/run.js@@ -299,7 +299,8 @@ async function tryItem(ctx, item, { command, attempts, minutes, deps, me, start,for (let attempt = 1; attempt <= attempts; attempt += 1) {const { fresh, related } = await deps.withBoard(ctx, async (board) => {const options = { agentId: me.id, lane: me.lane, leaseMs: ctx.config.leaseMs, freeze: deps.freezer(ctx) };- if (deps.ordered) await deps.ordered(ctx, board, 'claim', [id, options]);+ if (deps.claim) await deps.claim(ctx, board, [id, options]);+ else if (deps.ordered) await deps.ordered(ctx, board, 'claim', [id, options]);else store.claim(board, id, options);const claimed = store.getItem(board, id);return { fresh: claimed, related: store.relatedItems(board, claimed) };@@ -391,7 +392,7 @@ async function buildItem(ctx, item, { agents, attempts, minutes, deps, me }) {** @param {any} io* @param {any} values- * @param {{ context: Function, withBoard: Function, whoAmI: Function, nextOnce: Function, submitHere: Function, freezer: Function }} deps+ * @param {{ context: Function, withBoard: Function, whoAmI: Function, nextOnce: Function, submitHere: Function, freezer: Function, ordered?: Function, claim?: Function }} deps - claim orders a claim through the CLI's one claim route, held checks included* @returns {Promise<number>}*/export async function runItems(io, values, deps) {diff --git a/test/check-baseline.test.js b/test/check-baseline.test.jsindex 07dea484..e3982660 100644--- a/test/check-baseline.test.js+++ b/test/check-baseline.test.js@@ -551,12 +551,21 @@ test('[V2,V4,B26,P6] a check green on main holds the item until the person accepassert.equal(board.db.prepare("SELECT COUNT(*) AS n FROM event WHERE event_kind = 'check_accept'").get().n, 0, 'no refused path recorded an acceptance');});assert.equal(refusal(box.run(box.web, ['claim', id, '--json']), 'claim after refusals').code, 'CRITERION_PROVES_NOTHING');+ for (const route of [['next'], ['next', '--build']]) {+ const routed = refusal(box.run(box.web, [...route, '--json']), route.join(' '));+ assert.equal(routed.code, 'CRITERION_PROVES_NOTHING', `${route.join(' ')} is refused like claim`);+ assert.ok(routed.message.includes(green), `${route.join(' ')} names the check: ${routed.message}`);+ }+ const claims = () => withBoard(file, (board) => board.db.prepare("SELECT COUNT(*) AS n FROM event WHERE event_kind = 'claim' AND item_id = ?").get(item.item_id).n);+ assert.equal(claims(), 0, 'no refused route recorded a claim');+ assert.equal(showItem(box, id).item.item_status, 'open');const accepted = box.run(box.repo, ['check', 'accept', id, '--json'], undefined, { env });assert.equal(accepted.status, 0, `${accepted.stdout}${accepted.stderr}`);assert.deepEqual(JSON.parse(accepted.stdout).digest, digest, 'the acceptance binds to the exact check text');- const claimed = box.run(box.web, ['claim', id, '--json']);- assert.equal(claimed.status, 0, `the person's acceptance lifts the hold: ${claimed.stdout}${claimed.stderr}`);+ const claimed = box.run(box.web, ['next', '--build', '--json']);+ assert.equal(claimed.status, 0, `the person's acceptance lifts the hold for next --build: ${claimed.stdout}${claimed.stderr}`);+ assert.equal(showItem(box, id).item.item_owner, 'web-1', 'next --build claimed the accepted item');const changed = fileCheck('green', 'changed-check-marker.txt');const edited = box.run(box.repo, ['edit', id, '--check', changed, '--reason', 'the fixture changes the check', '--wait', '--json'], undefined, { env });@@ -576,6 +585,16 @@ test('[V2,V4,B26,P6] a check green on main holds the item until the person accepconst submitted = box.run(box.web, ['submit', id, '--json']);assert.equal(submitted.status, 0, `a red new baseline lifts the hold: ${submitted.stdout}${submitted.stderr}`);+ const second = addChecked(box, 'Second held green check', fileCheck('green', 'second-check-marker.txt')).item;+ const nextHeld = refusal(box.run(box.web, ['next', '--json']), 'next on a second held item');+ assert.equal(nextHeld.code, 'CRITERION_PROVES_NOTHING', 'next refuses the second held item');+ const reset = box.run(box.repo, ['edit', String(second.item_id), '--check', fileCheck('done', 'second-red-marker.txt'), '--wait', '--json'], undefined, { env });+ assert.equal(reset.status, 0, `${reset.stdout}${reset.stderr}`);+ assert.equal(JSON.parse(reset.stdout).item.item_check_baseline.result, 'red');+ const nextClaimed = box.run(box.web, ['next', '--json']);+ assert.equal(nextClaimed.status, 0, `a changed check with a red baseline lifts the hold for next: ${nextClaimed.stdout}${nextClaimed.stderr}`);+ assert.equal(showItem(box, second.item_id).item.item_status, 'claimed', 'next claimed the item once its check was red on main');+const plain = project({ content: 'green', worktrees: true });const { result: warned, item: open } = addChecked(plain, 'Unheld green check', fileCheck('green', 'plain-check-marker.txt'));assert.match(warned.stdout, /CRITERION_PROVES_NOTHING/u, 'a board with no setting keeps today’s warning');