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(next): next --verify skips a review its own session built [N2,B13]
Corey Olson858c811950a6
diff --git a/src/board.js b/src/board.jsindex 3d8f786d..bfa99b41 100644--- a/src/board.js+++ b/src/board.js@@ -1497,12 +1497,12 @@ export function reserveReview(board, id, who) {* transaction, so no other verifier can take it between the look and the reservation.** @param {any} board- * @param {{ agentId: string, lane: string, leaseMs: number, policy: string, familyPolicy?: string, runnable?: boolean, routes?: string[] }} who+ * @param {{ agentId: string, lane: string, leaseMs: number, policy: string, familyPolicy?: string, runnable?: boolean, routes?: string[], skipIds?: number[] }} who - skipIds: items the caller's own session built, never offered (verify refuses them too)* @returns {{ item: any | null, reasons: string[] }}*/-export function reserveNextReview(board, { agentId, lane, leaseMs, policy, familyPolicy = 'off', runnable, routes }) {+export function reserveNextReview(board, { agentId, lane, leaseMs, policy, familyPolicy = 'off', runnable, routes, skipIds = [] }) {return atomic(board, () => {- const { item, reasons } = nextFor(board, { agentId, lane, verify: true, familyPolicy, runnable, routes });+ const { item, reasons } = nextFor(board, { agentId, lane, verify: true, familyPolicy, runnable, routes, skipIds });return item ? { item: reserveWithin(board, item.item_id, { agentId, leaseMs, policy, familyPolicy }), reasons: [] } : { item: null, reasons };});}@@ -2293,13 +2293,14 @@ export function buildOrder(board, { warm = [] } = {}) {* With `runnable`, only items that carry a check command, which an unattended runner needs; with* `routes`, only items on those routes, the ones a runner has an agent command for. With `warm`, the* files the agent worked in lately, an item that shares more of them comes first within its tier,- * and `shared` names them (N20). A held lane offers nothing new (N22).+ * and `shared` names them (N20). A held lane offers nothing new (N22). With `skipIds`, a verifier is+ * never offered those items: the ones its own agent session built, which verify refuses anyway.** @param {any} board- * @param {{ agentId: string, lane: string, verify?: boolean, policy?: string, familyPolicy?: string, runnable?: boolean, routes?: string[], warm?: string[], priority?: number[], lanes?: string[] }} who+ * @param {{ agentId: string, lane: string, verify?: boolean, policy?: string, familyPolicy?: string, runnable?: boolean, routes?: string[], warm?: string[], priority?: number[], lanes?: string[], skipIds?: number[] }} who* @returns {{ item: any | null, reasons: string[], shared?: string[] }}*/-export function nextFor(board, { agentId, lane, verify = false, policy = 'any', familyPolicy = 'off', runnable = false, routes = ROUTES, warm = [], priority = [], lanes }) {+export function nextFor(board, { agentId, lane, verify = false, policy = 'any', familyPolicy = 'off', runnable = false, routes = ROUTES, warm = [], priority = [], lanes, skipIds = [] }) {const route = routeOf(board, agentId);const tier = (entry) => ROUTES.indexOf(entry.item_route);const allItems = listItems(board).reverse();@@ -2311,7 +2312,7 @@ export function nextFor(board, { agentId, lane, verify = false, policy = 'any',if (verify) {const family = board.db.prepare('SELECT agent_family FROM agent WHERE agent_id = ?').get(agentId)?.agent_family ?? null;const hasDifferentFamily = (entry) => Boolean(family && entry.item_builder_family && family !== entry.item_builder_family);- const unrelated = items.filter((entry) => entry.item_status === 'submitted' && entry.item_built_by !== agentId);+ const unrelated = items.filter((entry) => entry.item_status === 'submitted' && entry.item_built_by !== agentId && !skipIds.includes(entry.item_id));const standingRefusal = unrelated.map((entry) => standingProblem(board, agentId, entry.item_built_by, entry.item_id)).find(Boolean);let reviewable = unrelated.filter((entry) => !standingProblem(board, agentId, entry.item_built_by, entry.item_id));if (policy === COORDINATOR && agentId !== COORDINATOR) reviewable = reviewable.filter((entry) => entry.item_lane === COORDINATOR);diff --git a/src/next-review.js b/src/next-review.jsindex 39b450ab..680e421e 100644--- a/src/next-review.js+++ b/src/next-review.js@@ -37,6 +37,22 @@ export async function returnUnmergeable(root, board, me, { ordered, trunkMerge }return returned;}+/**+ * The submitted items this agent session built or submitted, by the very rule verify refuses them under+ * (refuseSelfSession), so next --verify never reserves a review its own session could not give. The session+ * ledger lives in this repository's Git directory and never on the board, so the ids travel with the move.+ *+ * @param {{ commonDir: string }} info+ * @param {any} board+ * @returns {number[]}+ */+export function ownSessionReviews(info, board) {+ return store.listItems(board).filter((item) => item.item_status === 'submitted').flatMap((item) => {+ try { refuseSelfSession(info, item); return []; }+ catch (error) { if (error instanceof Refused && error.code === 'SELF_SESSION_VERIFY') return [item.item_id]; throw error; }+ });+}+/*** The review half of one next loop: return heads that no longer merge, then reserve the named review or the next one.*@@ -59,5 +75,5 @@ export async function nextReview(ctx, board, me, values, { ordered, idArg, trunkreturn { item: await ordered('reserveReview', [id, reservation]), reasons: [] };}return await ordered('reserveNextReview', [{ agentId: me.id, lane: me.lane, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy,- familyPolicy: ctx.config.verify.family, runnable: values.runnable, routes: values.routes }]);+ familyPolicy: ctx.config.verify.family, runnable: values.runnable, routes: values.routes, skipIds: ownSessionReviews(ctx.info, board) }]);}diff --git a/test/next-order.test.js b/test/next-order.test.jsindex a62acbad..4653a551 100644--- a/test/next-order.test.js+++ b/test/next-order.test.js@@ -487,3 +487,27 @@ test('a cross-checkout claim leads with its seat and other checkouts cannot actassert.doesNotMatch(again.out, /you hold #/u, 'a checkout is never told it holds an item another seat holds');assert.notEqual(web.agent, api.agent);});++test('next --verify skips an item whose builder seat shares the reviewer\'s session [N2,B13]', (t) => {+ const box = crossLaneFixture(t);+ const mine = box.seat('own-builder', 'web', box.session);+ const other = box.seat('other-builder', 'web', 'unrelated-session');+ const reviewer = box.seat('own-reviewer', 'api', box.session);+ const own = box.add('web', 'Built by the reviewer\'s own session');+ const outside = box.add('web', 'Built by another session');+ box.milestone('first', own);+ box.milestone('later', outside);+ const commit = box.git(box.repo, 'rev-parse', 'HEAD').trim(), tree = box.git(box.repo, 'rev-parse', 'HEAD^{tree}').trim();+ const board = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try {+ for (const [id, builder] of [[own, mine.agent], [outside, other.agent]]) {+ store.claim(board, id, { agentId: builder, lane: 'web', leaseMs: HOUR, freeze: FREEZE });+ submitFixture(board, id, { agentId: builder, commit, tree });+ }+ } finally { store.closeBoard(board); }+ const next = box.json(box.runAs(box.session, reviewer.root, 'next', '--verify', '--json'));+ assert.equal(next.item.item_id, outside, 'the review goes to an item this session did not build');+ const after = store.openBoard(join(box.repo, '.git', 'pullboard', 'board.sqlite'));+ try { assert.equal(store.getItem(after, own).item_review_by, null, 'the session\'s own item is never reserved'); }+ finally { store.closeBoard(after); }+});