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.

fix(verify): refuse every historical item author [V1,B3,C7]

Corey Olsona18fccd32252
diff --git a/src/board.js b/src/board.js
index eba7f82f..389549a4 100644
--- a/src/board.js
+++ b/src/board.js
@@ -73,6 +73,7 @@ import {
import { LOCAL_LANDING_ENGINE } from './land-engine.js';
import { SPEC_APPROVAL_ENGINE } from './spec-approval-engine.js';
import { Refused } from './refused.js';
+import { itemAuthorProblem } from './item-authors.js';
import { refuseMaskedExit } from './check-mask.js';
import {
ROUTES,
@@ -88,7 +89,6 @@ import {
routeOf,
saveAgentModel,
seatLineage,
- standingProblem,
} from './seats.js';
import {
newRigorNotices,
@@ -1470,8 +1470,7 @@ export function reviewOffer(board, { agentId, lane, policy = 'any', familyPolicy
function reviewerChecks(board, { agentId, policy, familyPolicy = 'off' }) {
const family = board.db.prepare('SELECT agent_family FROM agent WHERE agent_id = ?').get(agentId)?.agent_family ?? null;
return {
- notBuilder: (found) => (found.item_built_by === agentId ? new Refused('SELF_VERIFY', 'the builder never verifies its own work; another agent must')
- : standingProblem(board, agentId, found.item_built_by, found.item_id)),
+ notBuilder: (found) => itemAuthorProblem(board, found, agentId),
routeAllows: (found) => {
const route = routeOf(board, agentId);
return canTake(route, found.item_route) ? null : new Refused('ROUTE', `item #${found.item_id} needs a ${found.item_route} verifier; you joined on the ${route} route`);
@@ -2313,8 +2312,8 @@ export function nextFor(board, { agentId, lane, verify = false, policy = 'any',
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 && !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));
+ const standingRefusal = unrelated.map((entry) => itemAuthorProblem(board, entry, agentId)).find(Boolean);
+ let reviewable = unrelated.filter((entry) => !itemAuthorProblem(board, entry, agentId));
if (policy === COORDINATOR && agentId !== COORDINATOR) reviewable = reviewable.filter((entry) => entry.item_lane === COORDINATOR);
if (familyPolicy === 'require') reviewable = reviewable.filter(hasDifferentFamily);
if (familyPolicy === 'prefer') reviewable.sort((first, second) => Number(hasDifferentFamily(second)) - Number(hasDifferentFamily(first)));
diff --git a/src/commands/verify.js b/src/commands/verify.js
index 177a5faa..c9a5e95b 100644
--- a/src/commands/verify.js
+++ b/src/commands/verify.js
@@ -31,6 +31,7 @@ import {
parseImplies,
} from '../implies.js';
import * as itemSessions from '../item-sessions.js';
+import { itemAuthors } from '../item-authors.js';
import * as nativeFlakes from '../native-flake-cli.js';
import {
Refused,
@@ -116,7 +117,7 @@ export async function verifyHere(ctx, id, { second, values }) {
return await ordered(ctx, board, 'verify', recovered.args);
}
const item = store.getItem(board, id);
- itemSessions.refuseSelfSession(ctx.info, item);
+ itemSessions.refuseSelfSession(ctx.info, item, undefined, itemAuthors(board, 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/historical-authors-engine.js b/src/historical-authors-engine.js
new file mode 100644
index 00000000..f5aa1b9c
--- /dev/null
+++ b/src/historical-authors-engine.js
@@ -0,0 +1,2 @@
+/** Historical claim and submit authors remain ineligible reviewers [V1,B3]. */
+export const HISTORICAL_AUTHORS_ENGINE = 79;
diff --git a/src/item-authors.js b/src/item-authors.js
new file mode 100644
index 00000000..59ae9b73
--- /dev/null
+++ b/src/item-authors.js
@@ -0,0 +1,23 @@
+/** Review independence follows every claim and submit author, never just the latest owner [V1,B3]. */
+import { ENGINE_VERSION } from './machine.js';
+import { HISTORICAL_AUTHORS_ENGINE } from './historical-authors-engine.js';
+import { Refused } from './refused.js';
+import { standingProblem } from './seats.js';
+
+/** Read one item's indexed author history; older ordered moves retain their original current-builder rule. */
+export function itemAuthors(board, item) {
+ if ((board.executionEngineVersion ?? ENGINE_VERSION) < HISTORICAL_AUTHORS_ENGINE) return [item.item_built_by].filter(Boolean);
+ const authors = new Set([item.item_built_by, item.item_owner].filter(Boolean));
+ for (const event of board.db.prepare("SELECT DISTINCT event_by FROM event WHERE item_id = ? AND event_kind IN ('claim', 'submit')").all(item.item_id)) {
+ if (typeof event.event_by === 'string' && event.event_by) authors.add(event.event_by);
+ }
+ return [...authors];
+}
+
+/** Apply the same author and linked-seat independence rule to explicit reviews and queue selection. */
+export function itemAuthorProblem(board, item, reviewer) {
+ const authors = itemAuthors(board, item);
+ if (authors.includes(reviewer)) return new Refused('SELF_VERIFY', 'the builder never verifies its own work; another agent must');
+ return (authors.length ? authors : [item.item_built_by])
+ .map(author => standingProblem(board, reviewer, author, item.item_id)).find(Boolean) ?? null;
+}
diff --git a/src/item-sessions.js b/src/item-sessions.js
index cedc8db9..0e37afe5 100644
--- a/src/item-sessions.js
+++ b/src/item-sessions.js
@@ -85,14 +85,16 @@ function boundSeats(info, digest) {
/**
* 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.
+ * is bound right now to any seat in its recorded author history. 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
+ * @param {string|null} [digest] - Current local session digest.
+ * @param {string[]} [authors] - Historical author seats from the board's claim and submit events.
*/
-export function refuseSelfSession(info, item, digest = agentSessionDigest()) {
+export function refuseSelfSession(info, item, digest = agentSessionDigest(), authors = []) {
if (!digest) return;
- const builders = [item.item_built_by, item.item_owner].filter(Boolean);
+ const builders = [item.item_built_by, item.item_owner, ...authors].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`,
diff --git a/src/next-review.js b/src/next-review.js
index 680e421e..2e6392fd 100644
--- a/src/next-review.js
+++ b/src/next-review.js
@@ -5,6 +5,7 @@
import * as store from './board.js';
import { Refused } from './refused.js';
import { refuseSelfSession } from './item-sessions.js';
+import { itemAuthors } from './item-authors.js';
import { shownPath } from './trunk-conflict.js';
/**
@@ -48,7 +49,7 @@ export async function returnUnmergeable(root, board, me, { ordered, trunkMerge }
*/
export function ownSessionReviews(info, board) {
return store.listItems(board).filter((item) => item.item_status === 'submitted').flatMap((item) => {
- try { refuseSelfSession(info, item); return []; }
+ try { refuseSelfSession(info, item, undefined, itemAuthors(board, item)); return []; }
catch (error) { if (error instanceof Refused && error.code === 'SELF_SESSION_VERIFY') return [item.item_id]; throw error; }
});
}
@@ -71,7 +72,8 @@ export async function nextReview(ctx, board, me, values, { ordered, idArg, trunk
const reservation = { agentId: me.id, leaseMs: ctx.config.reviewLeaseMs, policy: ctx.config.verify.policy, familyPolicy: ctx.config.verify.family };
if (values.verifyId !== undefined) {
const id = idArg(values.verifyId, 'an item id after --verify');
- refuseSelfSession(ctx.info, store.getItem(board, id));
+ const item = store.getItem(board, id);
+ refuseSelfSession(ctx.info, item, undefined, itemAuthors(board, item));
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,