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(bar): refuse unknown helper parent after takeover [V1,H16]
Corey Olson93ea8f101921
diff --git a/src/bar-actor.js b/src/bar-actor.jsindex 77b31c55..ac221a90 100644--- a/src/bar-actor.js+++ b/src/bar-actor.js@@ -8,6 +8,9 @@ export function nativeBarActor(environment = process.env, registered = {}) {const identity = runtimeSessionIdentity(environment);if (!identity) return null;const session = parentSessionDigest(identity.session);+ if (!identity.parent && registered.session && registered.session !== session && registered.parent && registered.parent !== registered.session) {+ throw new Refused('BAR_PARENT_UNKNOWN', 'this helper seat belongs to an earlier native session and its current parent is unknown; join a fresh worktree with the current parent before authoring or signing a bar');+ }const declared = registered.session === session ? registered.parent : null;const parent = identity.parent ? parentSessionDigest(identity.parent) : declared ?? session;if (identity.parent && declared && parent !== declared) throw new Refused('BAR_PARENT_UNKNOWN', 'the native parent and this session’s joined declaration disagree; use a fresh correctly joined worktree before authoring or signing a bar');diff --git a/src/bar-readiness.js b/src/bar-readiness.jsindex cee7af51..5ea3c975 100644--- a/src/bar-readiness.js+++ b/src/bar-readiness.js@@ -1,6 +1,6 @@import { normalizeBarActor } from './bar-actor.js';import { normalizeBarCoverage, barCoverageDigest } from './bar-coverage.js';-/** Readiness is a revision-bound peer judgement, with mechanical prerequisites [U113]. */+/** Readiness is a revision-bound peer judgement, with mechanical prerequisites [B4,V1,V2,H16]. */import { createHash } from 'node:crypto';import { atomic, itemById, logEvent } from './board.js';import { itemCheckBaseline } from './item-check-baseline.js';diff --git a/src/cli.js b/src/cli.jsindex 44f75ebd..12b0b0a1 100644--- a/src/cli.js+++ b/src/cli.js@@ -897,13 +897,14 @@ function relayOutboxSetting(root) {try { return configFromSource(coordinatorFile(root, CONFIG_FILE).stdout).relay?.outbox === true; } catch { return false; }}+/** Capture bar provenance only at author/sign commands, never during unrelated lifecycle dispatch. */+export function barActorForCommand(ctx, board) {+ if (!barReadySetting(board).enabled || ctx.io.personChannel === 'view' || ctx.io.personRequest) return null;+ const actor = ctx.info.isMain ? COORDINATOR : store.agentAt(board, ctx.info.root)?.agent_id;+ return nativeBarActorForSeat(board, actor);+}+export async function ordered(ctx, board, operation, args) {- if (['addItem','editItem','signBar'].includes(operation) && barReadySetting(board).enabled) {- const at = operation === 'addItem' ? 0 : 1;- const actor = ctx.info.isMain ? COORDINATOR : store.agentAt(board, ctx.info.root)?.agent_id;- const barActor = ctx.io.personChannel === 'view' || ctx.io.personRequest ? null : nativeBarActorForSeat(board, actor);- args = args.map((value, index) => index === at ? { ...value, barActor } : value);- }const initialBaseline = initialSpecApprovalBaseline(ctx, board, operation);// Only a reject or a reopen can open a builder's first-refusal window (#954), so an accept never reads the coordinator's policy.if (operation === 'reopen' || operation === 'verify' && args[1]?.decision === 'REJECT') args = firstRefusalArgs(operation, args, configFromSource(coordinatorFile(ctx.info.root, CONFIG_FILE).stdout));diff --git a/src/commands/add.js b/src/commands/add.jsindex 14a8b247..0d743907 100644--- a/src/commands/add.js+++ b/src/commands/add.js@@ -22,6 +22,7 @@ import {} from '../spec.js';import {actOn,+ barActorForCommand,briefArg,briefInLane,buildInFilelessLane,@@ -70,6 +71,7 @@ export async function run(io, args) {const { command } = store.validateItemAddition(board, item);if (command) refuseCheckSyntax(command);if (command) item.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);+ item.barActor = barActorForCommand(ctx, board);const id = await ordered(ctx, board, 'addItem', [item]);if (item.checkBaseline?.result === 'pending') await launchBaseline(ctx, board, id, item.checkBaseline);io.result?.({ item: store.getItem(board, id) });diff --git a/src/commands/bar.js b/src/commands/bar.jsindex b5fe98c5..81aee12a 100644--- a/src/commands/bar.js+++ b/src/commands/bar.js@@ -1,9 +1,9 @@import { prepareBarCoverage } from '../bar-coverage.js';import { mainPolicy } from '../trusted-policy.js';-/** Inspect, enable and independently sign acceptance bars [U113]. */+/** Inspect, enable and independently sign acceptance bars [B4,V1,V2,H16]. */import { getItem } from '../board.js';import { barReadiness, barReadySetting } from '../bar-readiness.js';-import { actOn, idArg, ordered } from '../cli.js';+import { actOn, barActorForCommand, idArg, ordered } from '../cli.js';import { Refused } from '../refused.js';/** Run the board-scoped readiness setting or show/sign one exact revision. */@@ -28,7 +28,7 @@ export async function run(io, { first, second, rest, values }) {}io.say(`Sign-off asks: can the builder meet this bar, and would two reviewers grade it the same? Check the named baseline, every measurement method, coverage and reviewer edges in pullboard show ${id}.`);const coverage = prepareBarCoverage(ctx.info.root, item, mainPolicy(ctx.info.root), values['coverage-file']);- const signed = await ordered(ctx, board, 'signBar', [id, { agentId: me.id, revision: status.revision?.revision, digest: status.revision?.digest, note: values.note, coverage }]);+ const signed = await ordered(ctx, board, 'signBar', [id, { agentId: me.id, revision: status.revision?.revision, digest: status.revision?.digest, note: values.note, coverage, barActor: barActorForCommand(ctx, board) }]);io.result?.({ signed });io.say(`signed #${id} revision ${signed.revision}; any bar edit needs a fresh signature`);return 0;diff --git a/src/commands/edit.js b/src/commands/edit.jsindex b2c7188e..5fed8790 100644--- a/src/commands/edit.js+++ b/src/commands/edit.js@@ -13,6 +13,7 @@ import {} from '../relay.js';import {actOn,+ barActorForCommand,briefArg,briefInLane,editAfter,@@ -50,6 +51,7 @@ export async function run(io, args) {const { item, command } = store.validateItemEdit(board, id, change);if (command && command !== item.item_check) refuseCheckSyntax(command);if (command && (command !== item.item_check || barReadySetting(board).enabled)) change.checkBaseline = values.wait ? checkBaseline(ctx.info.root, command) : prepareCheckBaseline(ctx.info.root, command);+ change.barActor = barActorForCommand(ctx, board);await ordered(ctx, board, 'editItem', [id, change]);if (change.checkBaseline?.result === 'pending') await launchBaseline(ctx, board, id, change.checkBaseline);io.result?.({ item: store.getItem(board, id) });diff --git a/test/bar-coverage.test.js b/test/bar-coverage.test.jsindex af6efa4c..74f4587a 100644--- a/test/bar-coverage.test.js+++ b/test/bar-coverage.test.js@@ -147,5 +147,7 @@ test('[V1,H16] a declared helper parent applies only to the actual session thatconst own=nativeBarActor(env);const parent='e'.repeat(64);assert.equal(nativeBarActor(env,{session:own.session,parent}).parent,parent);- assert.equal(nativeBarActor(env,{session:'f'.repeat(64),parent}).parent,own.session,'a replacement native runtime cannot borrow the old coordinator parent');+ const formerRoot='f'.repeat(64);+ assert.equal(nativeBarActor(env,{session:formerRoot,parent:formerRoot}).parent,own.session,'a replacement coordinator captures its own root identity');+ assert.throws(()=>nativeBarActor(env,{session:formerRoot,parent}),{code:'BAR_PARENT_UNKNOWN'},'a restarted known helper has no evidence of an independent parent');});