Skip to content

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.

feat(verify): a verdict from the building session is refused [V1]

Corey Olson31dbd03376ee
diff --git a/docs/lifecycle.md b/docs/lifecycle.md
index c1cbf050..ee226e8f 100644
--- a/docs/lifecycle.md
+++ b/docs/lifecycle.md
@@ -57,9 +57,9 @@ Each move checks its guards in this order and refuses with the first one that do
| release | claimed | open | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), reviewReleaseExplained (NOTE_REQUIRED) |
| lapse | claimed | open | clock, when its lease runs out | none |
| submit | claimed | submitted | agent, coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_YOURS), isHolder (NOT_YOURS), correctionRefrozen (PENDING_REFREEZE), checkProvesSomething (CRITERION_PROVES_NOTHING), criterionUnchanged (CRITERIA_CHANGED), treeClean (DIRTY), nothingUntracked (UNTRACKED), hasCommit (NO_COMMIT), withinLane (OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), doctrineHolds (RATCHET_ROSE or RATCHET_UNCOUNTED), gateConfigured (NO_GATE), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), gateGreen (GATE_RED or PIPEFAIL_UNAVAILABLE), treeStillDuringGate (MOVED_DURING_GATE), submissionProofValid (SUBMISSION_PROOF), childrenDone (CHILDREN_OPEN), headIsNew (HEAD_NOT_NEW) |
-| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |
-| accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
-| reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) |
+| reserve | submitted | submitted | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), roadmapReadable (MILESTONES_CORRUPT), itemExists (NO_ITEM), inState (NOT_SUBMITTED), reviewCooldownElapsed (REVIEW_COOLDOWN), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD) |
+| accept | submitted, verified | verified | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonIsMet (BAD_REASON), trunkMergeClean (MERGE_CONFLICT or MERGE_CHECK_FAILED or NO_POLICY or NO_TRUNK), noUnverifiedStack (STACKED_ON_UNVERIFIED), queuedItemLease (ITEM_LEASE_LOST or A5_GRAMMAR_VERSION or SPEC_BEHIND_MAIN or NOT_A_REPO or NO_CONFIG), itemCheckGreen (CHECK_RED or CHECK_UNVERIFIED), proofNoted (PROOF_REQUIRED), result (LAND_HEADER), result (ENGINE_VERSION) |
+| reject | submitted, verified | open | agent, coordinator | coordinatorSaysAs (MAIN_IS_COORDINATOR), joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), atSubmittedCommit (NOT_AT_COMMIT or OUTSIDE_LANE or NO_POLICY or BAD_CONFIG or GIT_GRAFTS), notMerged (ALREADY_MERGED), verdictReviewRecorded (BAD_VERDICT_REVIEW), reviewTreeCurrent (STALE_VERDICT or DIRTY or UNTRACKED or VERDICT_TRUNK_MOVED), notBuilder (SELF_VERIFY or VERIFIER_STANDING or SELF_SESSION_VERIFY), routeAllows (ROUTE), policyAllows (COORDINATOR_VERIFIES), familyAllows (O2_FAMILY_MATCH), reviewFree (REVIEW_HELD), criterionUnchanged (CRITERIA_CHANGED), reasonCoded (BAD_REASON), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), result (LAND_HEADER), result (ENGINE_VERSION), result (NOT_YOURS), result (CLOSED) |
| reopen | submitted, verified | open | coordinator | joined (NOT_JOINED), itemExists (NO_ITEM), inState (NOT_SUBMITTED), coordinatorOnly (COORDINATOR_ONLY), noteGiven (NOTE_REQUIRED), causeWellFormed (BAD_CAUSE), notMerged (ALREADY_MERGED), landingFailureRecorded (LANDING_FAILURE_REQUIRED), trunkConflicts (NOT_CONFLICTING or CONFLICT_FILES or NO_TRUNK or MERGE_CHECK_FAILED), conflictAccepted (NOT_ACCEPTED or BAD_CONFLICT or ENGINE_VERSION) |
| escalate | open, claimed | open | agent, coordinator | joined (NOT_JOINED), noteGiven (NOTE_REQUIRED), itemExists (NO_ITEM), holderOrCoordinator (NOT_YOURS), inState (CLOSED) |
| refreeze | open, claimed, submitted | open | coordinator, when there is no live claim awaiting a coordinator correction | joined (NOT_JOINED), coordinatorOnly (COORDINATOR_ONLY), itemExists (NO_ITEM), inState (CLOSED), rowsInForce (UNKNOWN_SPEC or A5_GRAMMAR_VERSION or NO_POLICY or BAD_CONFIG or SPEC_BEHIND_MAIN) |
@@ -147,8 +147,9 @@ Each move checks its guards in this order and refuses with the first one that do
| DIRTY | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit the reviewed composition before re-reviewing |
| UNTRACKED | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | commit or ignore untracked files before re-reviewing |
| VERDICT_TRUNK_MOVED | a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check | merge the latest main and re-review the clean composition |
-| SELF_VERIFY | the caller did not build it; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | another agent verifies it: pullboard next --verify |
-| VERIFIER_STANDING | the caller did not build it; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>" |
+| SELF_VERIFY | the caller did not build it, and its agent session did not build or submit it under any seat; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | another agent verifies it: pullboard next --verify |
+| VERIFIER_STANDING | the caller did not build it, and its agent session did not build or submit it under any seat; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>" |
+| SELF_SESSION_VERIFY | the caller did not build it, and its agent session did not build or submit it under any seat; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join | ask another agent session to verify it: pullboard next --verify from that session's own worktree |
| COORDINATOR_VERIFIES | the repo's verify policy lets the caller verify this lane's work | the coordinator verifies it |
| O2_FAMILY_MATCH | the builder and verifier have different declared families; an undeclared family counts as a match, only when verify.family is require | ask the coordinator for a verifier from another declared family |
| REVIEW_HELD | no other agent holds its review under a live lease | pullboard next --verify, which passes over reviews another agent holds |
diff --git a/src/cli.js b/src/cli.js
index fd7449a1..25c8e1e0 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -41,6 +41,8 @@ import {
refuseNextIdle,
} from './next-steps.js';
import { reviewerStartup } from './next-steps.js';
+import { recordItemSession } from './item-sessions.js';
+import { refuseSelfSession } from './item-sessions.js';
import * as store from './board.js';
import {
CONFIG_FILE,
@@ -964,6 +966,9 @@ async function reserveRow(ctx, row, written) {
}
/** Dispatch a board mutation locally, or seal it before any linked replica applies it. */
+/** Note the session behind a claim or submit (#921), then hand back the move's result unchanged. */
+function tapItemSession(info, operation, args, result) { if (operation === 'claim' || operation === 'submit') recordItemSession(info, args[0], operation); return result; }
+
async function ordered(ctx, board, operation, args) {
// Every engine-27 registration records the seat that made it: the coordinator from the main
// checkout, the joined agent from its worktree, or `machine` for a join no seat made (#579).
@@ -973,8 +978,8 @@ async function ordered(ctx, board, operation, args) {
}
const command = ['add', 'edit', 'merged'].includes(ctx.io.relayCommand?.cliOperation) ? ctx.io.relayCommand : undefined;
/** Dispatch while this session holds the checkout, including long-running next/run loops. */
- const execute = () => relayLinked(ctx.info.root) || relayRecovered(ctx.info.root)
- ? relayOperation(ctx.info.root, operation, args, ctx.io, command, () => store[operation](board, ...args)) : store[operation](board, ...args);
+ const execute = async () => tapItemSession(ctx.info, operation, args, await (relayLinked(ctx.info.root) || relayRecovered(ctx.info.root)
+ ? relayOperation(ctx.info.root, operation, args, ctx.io, command, () => store[operation](board, ...args)) : store[operation](board, ...args)));
const digest = agentSessionDigest();
const boardOnly = CHECKOUT_BOARD_ONLY.get(ctx.io);
const boardOnlyOperation = (boardOnly === 'shout' && operation === 'shout') || (boardOnly === 'fact' && operation === 'appendFact');
@@ -2973,6 +2978,7 @@ async function verifyHere(ctx, id, { second, values }) {
return await ordered(ctx, board, 'verify', recovered.args);
}
const item = store.getItem(board, id);
+ refuseSelfSession(ctx.info, item);
const reReview = item.item_status === 'verified' && !item.item_merged_commit;
const stale = reReview ? verdictProjector(root, board).state(item) : null;
if (item.item_status !== 'submitted' && !stale) {
diff --git a/src/item-sessions.js b/src/item-sessions.js
new file mode 100644
index 00000000..cd63f7f6
--- /dev/null
+++ b/src/item-sessions.js
@@ -0,0 +1,75 @@
+/**
+ * Which agent session built an item (#921). A seat name is not a session: one session can hold the coordinator's
+ * checkout and a review worktree at once, and then "never verify your own work" holds only by name. Claims and submits
+ * record the session's digest beside the board, in this repository's own Git directory, never on the shared board or
+ * the relay, and a verdict from a session that built or submitted the item is refused.
+ */
+import { appendFileSync } from 'node:fs';
+import { existsSync } from 'node:fs';
+import { mkdirSync } from 'node:fs';
+import { readFileSync } from 'node:fs';
+import { readdirSync } from 'node:fs';
+import { join } from 'node:path';
+import { agentSessionDigest } from './person.js';
+import { Refused } from './refused.js';
+
+/** The local ledger of item moves by session digest, shared by every worktree of this repository. */
+function ledgerFile(info) {
+ return join(info.commonDir, 'pullboard', 'item-sessions.jsonl');
+}
+
+/** Record that this session claimed or submitted an item. A ledger that cannot be written never fails the move. */
+export function recordItemSession(info, item, move, digest = agentSessionDigest()) {
+ if (!digest || !Number.isInteger(Number(item))) return;
+ try {
+ mkdirSync(join(info.commonDir, 'pullboard'), { recursive: true, mode: 0o700 });
+ appendFileSync(ledgerFile(info), JSON.stringify({ item: Number(item), move, digest, at: new Date().toISOString() }) + '\n', { mode: 0o600 });
+ } catch { /* The binding scan below still covers a session that holds the builder's checkout. */ }
+}
+
+/** The digests recorded for one item's claims and submits. */
+function ledgerDigests(info, item) {
+ const file = ledgerFile(info);
+ if (!existsSync(file)) return new Set();
+ return new Set(readFileSync(file, 'utf8').split('\n').flatMap((line) => {
+ try {
+ const row = JSON.parse(line);
+ return row.item === item && typeof row.digest === 'string' ? [row.digest] : [];
+ } catch { return []; }
+ }));
+}
+
+/** The seats this session's digest is bound to now, in the main checkout and every worktree. */
+function boundSeats(info, digest) {
+ const files = [join(info.commonDir, 'pullboard-checkout-session.json')];
+ const worktrees = join(info.commonDir, 'worktrees');
+ if (existsSync(worktrees)) {
+ for (const entry of readdirSync(worktrees, { withFileTypes: true })) {
+ if (entry.isDirectory()) files.push(join(worktrees, entry.name, 'pullboard-checkout-session.json'));
+ }
+ }
+ const seats = new Set();
+ for (const file of files) {
+ try {
+ const binding = JSON.parse(readFileSync(file, 'utf8'));
+ if (binding.digest === digest && typeof binding.agent === 'string') seats.add(binding.agent);
+ } catch { /* A missing or damaged peer binding names no seat. */ }
+ }
+ return seats;
+}
+
+/**
+ * Refuse a verdict from the agent session that built or submitted the item: its digest is on the item's ledger, or it
+ * is bound right now to the seat that built it. A shell with no agent session (the person's terminal) is never refused.
+ *
+ * @param {{ commonDir: string }} info
+ * @param {{ item_id: number, item_built_by?: string|null, item_owner?: string|null }} item
+ */
+export function refuseSelfSession(info, item, digest = agentSessionDigest()) {
+ if (!digest) return;
+ const builders = [item.item_built_by, item.item_owner].filter(Boolean);
+ const seats = boundSeats(info, digest);
+ if (!ledgerDigests(info, item.item_id).has(digest) && !builders.some((builder) => seats.has(builder))) return;
+ throw new Refused('SELF_SESSION_VERIFY', `this agent session built or submitted #${item.item_id}, so its verdict would be its own work under another seat's name`,
+ 'ask another agent session to verify it: pullboard next --verify from that session\'s own worktree');
+}
diff --git a/src/machine.js b/src/machine.js
index 96cde24f..851bc9e8 100644
--- a/src/machine.js
+++ b/src/machine.js
@@ -177,7 +177,7 @@ export const GUARDS = [
{ id: 'atSubmittedCommit', refuse: 'NOT_AT_COMMIT', alsoRefuses: [{ code: 'OUTSIDE_LANE', next: 'restore foreign paths before accepting' }, { code: 'NO_POLICY', next: 'restore the frozen policy objects' }, { code: 'BAD_CONFIG', next: 'repair the committed coordinator configuration' }, { code: 'GIT_GRAFTS', next: 'ask the coordinator to remove the Git graft file before retrying' }], rule: "the caller's checkout contains the submitted commit", next: 'git switch --detach <commit>', source: 'cli' },
{ id: 'verdictReviewRecorded', refuse: 'BAD_VERDICT_REVIEW', rule: 'a new review binds the submitted commit, its exact checked commit, a valid trunk commit and canonical candidate paths', next: 'restore the submitted Git objects and retry the review with current Pullboard', source: 'board' },
{ id: 'reviewTreeCurrent', refuse: 'STALE_VERDICT', alsoRefuses: [{ code: 'DIRTY', next: 'commit the reviewed composition before re-reviewing' }, { code: 'UNTRACKED', next: 'commit or ignore untracked files before re-reviewing' }, { code: 'VERDICT_TRUNK_MOVED', next: 'merge the latest main and re-review the clean composition' }], rule: 'a stale acceptance is re-reviewed at a clean HEAD containing the current trunk, which stays fixed through its check', next: 'merge current main into the submitted commit and re-review it', source: 'cli' },
- { id: 'notBuilder', refuse: 'SELF_VERIFY', alsoRefuses: [{ code: 'VERIFIER_STANDING', next: 'the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"' }], rule: 'the caller did not build it; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
+ { id: 'notBuilder', refuse: 'SELF_VERIFY', alsoRefuses: [{ code: 'VERIFIER_STANDING', next: 'the coordinator makes an independent verifier from the main checkout: pullboard worktree <lane> --model "<model name>"' }, { code: 'SELF_SESSION_VERIFY', next: 'ask another agent session to verify it: pullboard next --verify from that session\'s own worktree' }], rule: 'the caller did not build it, and its agent session did not build or submit it under any seat; on a linked board, at engine 48 or newer, the caller was enrolled through the relay by a line of creating seats from the coordinator that includes neither the builder nor a machine join', next: 'another agent verifies it: pullboard next --verify', source: 'board' },
{ id: 'policyAllows', refuse: 'COORDINATOR_VERIFIES', rule: "the repo's verify policy lets the caller verify this lane's work", next: 'the coordinator verifies it', source: 'board' },
{ id: 'familyAllows', refuse: 'O2_FAMILY_MATCH', rule: 'the builder and verifier have different declared families; an undeclared family counts as a match', next: 'ask the coordinator for a verifier from another declared family', source: 'board', when: 'only when verify.family is require' },
{ id: 'reviewFree', refuse: 'REVIEW_HELD', rule: 'no other agent holds its review under a live lease', next: 'pullboard next --verify, which passes over reviews another agent holds', source: 'board' },
diff --git a/src/next-review.js b/src/next-review.js
index 1b906f13..39b450ab 100644
--- a/src/next-review.js
+++ b/src/next-review.js
@@ -4,6 +4,7 @@
*/
import * as store from './board.js';
import { Refused } from './refused.js';
+import { refuseSelfSession } from './item-sessions.js';
import { shownPath } from './trunk-conflict.js';
/**
@@ -52,7 +53,11 @@ export async function nextReview(ctx, board, me, values, { ordered, idArg, trunk
if (ctx.io.stderr) ctx.io.stderr.write(line + '\n'); else ctx.io.err?.(line);
}
const reservation = { agentId: me.id, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family };
- if (values.verifyId !== undefined) return { item: await ordered('reserveReview', [idArg(values.verifyId, 'an item id after --verify'), reservation]), reasons: [] };
+ if (values.verifyId !== undefined) {
+ const id = idArg(values.verifyId, 'an item id after --verify');
+ refuseSelfSession(ctx.info, store.getItem(board, id));
+ return { 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 }]);
}
diff --git a/src/next-steps.js b/src/next-steps.js
index fa5403c1..89a245a4 100644
--- a/src/next-steps.js
+++ b/src/next-steps.js
@@ -506,6 +506,7 @@ export const NEXT_STEPS = Object.freeze({
SEAL_VERSION: 'upgrade Pullboard on this device: npm install -g pullboard@latest',
SELF_SHOUT: 'name another agent, a lane or all: pullboard shout all "<text>"',
SELF_VERIFY: 'ask a different agent to verify it; from main create its worktree with pullboard worktree <lane> --model "<model name>"',
+ SELF_SESSION_VERIFY: 'ask another agent session to verify it: pullboard next --verify from that session\'s own worktree',
SERVICE_ERROR: 'retry the call; if it repeats, restart pullboard serve',
SHALLOW_BEFORE_OPT_IN: 'git fetch --unshallow, then pullboard spec signers add',
SHOUT_NOT_AVAILABLE: 'read shouts with pullboard inbox, or refresh the snapshot with a current CLI',
diff --git a/test/agent-session.test.js b/test/agent-session.test.js
index 1fcb47f3..9accf728 100644
--- a/test/agent-session.test.js
+++ b/test/agent-session.test.js
@@ -347,3 +347,35 @@ test('a remote shell is recognized by any SSH marker [B26,E22]', () => {
assert.equal(relayError?.code, 'RELAY_UNAVAILABLE', 'relay on over SSH reaches the relay');
assert.match(relayError.message, /\/auth\/device\/start/u, 'relay on over SSH starts its device sign-in (#615)');
});
+
+test('a verdict from the agent session that built the item is refused under any seat [V1,B3]', () => {
+ const box = project();
+ const builder = 'codex-thread-secret-builder-921';
+ const build = (args) => box.run(box.web, args, { session: builder, sessionKey: 'CODEX_THREAD_ID' });
+ assert.equal(build(['claim', '1', '--json']).status, 0);
+ writeFileSync(join(box.web, 'web', 'page.txt'), 'built\n');
+ box.git(box.web, 'commit', '-qam', 'feat(web): build the fixture item [G1]');
+ const submitted = build(['submit', '1', '--json']);
+ assert.equal(submitted.status, 0, `${submitted.stdout}${submitted.stderr}`);
+ // The same session opens a review seat of its own: a different seat name, the same session.
+ const review = join(box.dir, 'review-seat');
+ box.git(box.repo, 'worktree', 'add', '-q', '--detach', review, box.git(box.web, 'rev-parse', 'HEAD'));
+ const reviewAs = (session, args) => box.run(review, args, { session, sessionKey: 'CODEX_THREAD_ID' });
+ assert.equal(reviewAs(builder, ['join', 'web', '--json']).status, 0);
+ const before = boardSnapshot(box.boardFile);
+ const own = reviewAs(builder, ['verify', '1', 'accept', '--note', 'checked the page', '--json']);
+ assert.notEqual(own.status, 0, 'the building session cannot accept its own item from another seat');
+ const error = JSON.parse(own.stdout).error;
+ assert.equal(error.code, 'SELF_SESSION_VERIFY');
+ assert.match(error.message, /this agent session built or submitted #1/u);
+ assert.match(error.next, /another agent session/u);
+ assert.deepEqual(boardSnapshot(box.boardFile), before, 'the refused verdict records nothing');
+ assertNoRawSession(box, box.web, [builder], 'CODEX_THREAD_ID');
+ const ledger = readFileSync(resolve(box.repo, box.git(box.repo, 'rev-parse', '--git-common-dir'), 'pullboard', 'item-sessions.jsonl'), 'utf8');
+ assert.equal(ledger.includes(builder), false, 'the local item ledger keeps only the session digest');
+ // Another session takes over that review seat and gives the verdict.
+ const other = 'codex-thread-secret-reviewer-921';
+ assert.equal(reviewAs(other, ['takeover', '--json']).status, 0);
+ const accepted = reviewAs(other, ['verify', '1', 'accept', '--note', 'checked the page', '--json']);
+ assert.equal(accepted.status, 0, `${accepted.stdout}${accepted.stderr}`);
+});