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(review): keep runtime identities out of ordered moves [V1,B3]
Corey Olson1257f125287e
diff --git a/src/board.js b/src/board.jsindex 7564f016..ba99fde5 100644--- a/src/board.js+++ b/src/board.js@@ -16,7 +16,6 @@ export { verdictReviewProblem, verdictsFor, acceptedVerdict, checkedLandingCommiexport { landingLeaseMove, landingLeaseState } from './landing-lease.js';import { guardLandingWrite } from './landing-lease.js';import {- createHash,randomBytes,randomUUID,} from 'node:crypto';@@ -75,7 +74,7 @@ import { LOCAL_LANDING_ENGINE } from './land-engine.js';import { SPEC_APPROVAL_ENGINE } from './spec-approval-engine.js';import { Refused } from './refused.js';import { PARENT_SESSION_ENGINE } from './parent-session-engine.js';-import { parentIdentity } from './parent-session.js';+import { canonicalSessionDigest, parentSessionDigest } from './parent-session.js';import { itemAuthorProblem } from './item-authors.js';import { refuseMaskedExit } from './check-mask.js';import {@@ -610,14 +609,14 @@ function current(board, item) {* @param {{ lane: string, path: string, route?: string, family?: string | null, model?: string | null, parent?: string | null, session?: string | null, createdBy?: string, id?: string }} who* @returns {string} The agent's id.*/-export function register(board, { lane, path, route = 'strong', family, model, parent, session, createdBy, id: named }) {+export function register(board, { lane, path, route = 'strong', family, model, parent, session, parentDigest: recordedParent, sessionDigest: recordedSession, createdBy, id: named }) {const engine = board.executionEngineVersion ?? ENGINE_VERSION;if (engine < 8) model = undefined;if (engine < VERIFIER_STANDING_ENGINE) { createdBy = undefined; named = undefined; }- const parentDigest = engine >= PARENT_SESSION_ENGINE && parent != null- ? createHash('sha256').update(JSON.stringify(['parent-session', parentIdentity(parent)])).digest('hex') : null;- const sessionDigest = engine >= PARENT_SESSION_ENGINE && session != null- ? createHash('sha256').update(JSON.stringify(['parent-session', parentIdentity(session)])).digest('hex') : null;+ const parentDigest = engine < PARENT_SESSION_ENGINE ? null+ : recordedParent != null ? canonicalSessionDigest(recordedParent) : parent != null ? parentSessionDigest(parent) : null;+ const sessionDigest = engine < PARENT_SESSION_ENGINE ? null+ : recordedSession != null ? canonicalSessionDigest(recordedSession) : session != null ? parentSessionDigest(session) : null;checkRoute(route);if (lane === COORDINATOR && route !== 'strong') {throw new Refused('BAD_ROUTE', 'the coordinator plans, merges and verifies; it is always strong');diff --git a/src/commands/join.js b/src/commands/join.jsindex f70f4f72..2a9b4f2b 100644--- a/src/commands/join.js+++ b/src/commands/join.js@@ -1,4 +1,4 @@-import { joinParentSession, runtimeSessionIdentity } from '../parent-session.js';+import { parentIdentity, parentSessionDigest, runtimeSessionIdentity } from '../parent-session.js';/** The pullboard join command, in its own module so an item adding another command never edits these lines. */import {displayAgentName,@@ -28,15 +28,17 @@ import {/** Run `pullboard join` and return its exit code. */export async function run(io, { first, values }) {const ctx = context(io);- const parent = joinParentSession(values.parent);- const session = runtimeSessionIdentity()?.session;+ const runtime = runtimeSessionIdentity();+ const parent = values.parent === undefined ? runtime?.parent : parentIdentity(values.parent);+ const parentDigest = parent ? parentSessionDigest(parent) : undefined;+ const sessionDigest = runtime?.session ? parentSessionDigest(runtime.session) : undefined;if (ctx.info.isMain) {if (first !== COORDINATOR) throw new Refused('MAIN_IS_COORDINATOR', 'the main checkout is the coordinator; join from a worktree: git worktree add ../<dir>');const route = values.route ?? 'strong';const model = requiredModel(values.model, process.env, `join ${shellWord(COORDINATOR)}${values.route ? ` --route ${shellWord(values.route)}` : ''}${values.family ? ` --family ${shellWord(values.family)}` : ''}`);if (relayLinked(ctx.info.root)) refuseRemoteCoordinatorModel(ctx, 'join coordinator');const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [- { lane: COORDINATOR, path: ctx.info.root, route, family: values.family, model, parent, session },+ { lane: COORDINATOR, path: ctx.info.root, route, family: values.family, model, parentDigest, sessionDigest },]));const displayName = displayAgentName({ agent_id: id, agent_model: model }, ctx.config.agents.names);io.result?.({ agent: id, lane: COORDINATOR, route, path: ctx.info.root, model, displayName });@@ -48,7 +50,7 @@ export async function run(io, { first, values }) {}const route = values.route ?? 'strong';const model = requiredModel(values.model, process.env, `join ${shellWord(first)}${values.route ? ` --route ${shellWord(values.route)}` : ''}${values.family ? ` --family ${shellWord(values.family)}` : ''}`);- const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [{ lane: first, path: ctx.info.root, route, family: values.family, model, parent, session }]));+ const id = await withBoard(ctx, async (board) => await ordered(ctx, board, 'register', [{ lane: first, path: ctx.info.root, route, family: values.family, model, parentDigest, sessionDigest }]));const displayName = displayAgentName({ agent_id: id, agent_model: model }, ctx.config.agents.names);io.result?.({ agent: id, lane: first, route, path: ctx.info.root, model, displayName });io.say(`joined as ${displayName} in the ${first} lane${route === 'light' ? ', on the light route' : ''}`);diff --git a/src/parent-session.js b/src/parent-session.jsindex d549fc0a..3e8e5bc5 100644--- a/src/parent-session.js+++ b/src/parent-session.js@@ -3,6 +3,7 @@ import { closeSync, openSync, readSync, readdirSync } from 'node:fs';import { homedir } from 'node:os';import { join } from 'node:path';import { Refused } from './refused.js';+import { createHash } from 'node:crypto';/** Accept an opaque identity, never a path, whitespace, credential or arbitrary session metadata. */export function parentIdentity(value) {@@ -12,6 +13,17 @@ export function parentIdentity(value) {return value;}+/** Use one digest domain for explicit parents, discovered parents and a root's own session identity. */+export function parentSessionDigest(value) {+ return createHash('sha256').update(JSON.stringify(['parent-session', parentIdentity(value)])).digest('hex');+}++/** Validate canonical identities received in ordered registration, without rehashing them. */+export function canonicalSessionDigest(value) {+ if (typeof value !== 'string' || !/^[a-f0-9]{64}$/u.test(value)) throw new Refused('BAD_PARENT', 'the recorded parent session digest is invalid; join again from the runtime session');+ return value;+}+/** Read only the bounded first record; conversation history and other sessions' contents are never opened. */function ownSessionMetadata(file, session) {let descriptor;diff --git a/test/parent-session.test.js b/test/parent-session.test.jsindex 0f2223df..410afbbe 100644--- a/test/parent-session.test.js+++ b/test/parent-session.test.js@@ -4,7 +4,7 @@ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';-import { joinParentSession, runtimeParentSession } from '../src/parent-session.js';+import { joinParentSession, parentSessionDigest, runtimeParentSession } from '../src/parent-session.js';import * as store from '../src/board.js';import { runFixtureGit } from './fixture-child.js';import { submitFixture } from './board-submit-fixture.js';@@ -36,7 +36,8 @@ test('[V1,B3] ordered parent registration survives replay and board export withoconst boards = ['source', 'replica', 'imported'].map(name => store.openBoard(join(root, `${name}.sqlite`)));t.after(() => boards.forEach(board => store.closeBoard(board)));const [source, replica, imported] = boards;- const move = prepareEngineMove(source, 'register', [{ lane: 'web', path: '/fixture/child', parent: 'parent-P', session: 'child-C' }]);+ const move = prepareEngineMove(source, 'register', [{ lane: 'web', path: '/fixture/child', parentDigest: parentSessionDigest('parent-P'), sessionDigest: parentSessionDigest('child-C') }]);+ assert.doesNotMatch(JSON.stringify(move), /parent-P|child-C/u, 'ordered registration exposes only canonical digests');const receipt = applyEngineMove(replica, move, { sequence: 1, at: '2026-10-23T12:00:00.000Z' });assert.equal(receipt.error, undefined);const registered = store.agentAt(replica, '/fixture/child');