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(core): preserve declared parents for current bar sessions [V1]

Corey Olsond30226656edc
diff --git a/src/bar-actor.js b/src/bar-actor.js
index 798053db..77b31c55 100644
--- a/src/bar-actor.js
+++ b/src/bar-actor.js
@@ -1,11 +1,23 @@
+import { agentParent } from './seats.js';
/** Current bar authorship survives native takeover without rewriting historical seats [V1,H16]. */
import { runtimeSessionIdentity, parentSessionDigest } from './parent-session.js';
import { Refused } from './refused.js';
/** Capture only this runtime's own session and discovered parent before sealing an ordered move. */
-export function nativeBarActor(environment = process.env) {
+export function nativeBarActor(environment = process.env, registered = {}) {
const identity = runtimeSessionIdentity(environment);
- return identity ? { session: parentSessionDigest(identity.session), parent: parentSessionDigest(identity.parent ?? identity.session) } : null;
+ if (!identity) return null;
+ const session = parentSessionDigest(identity.session);
+ 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');
+ return { session, parent };
+}
+
+/** A declared parent is usable only for the exact current native session that joined that seat. */
+export function nativeBarActorForSeat(board, agent, environment = process.env) {
+ const session = board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get(`agent_session:${agent}`)?.meta_value ?? null;
+ return nativeBarActor(environment, { session, parent: agentParent(board, agent) });
}
/** Unknown provenance stays unknown; a replay never consults another process's runtime. */
export function normalizeBarActor(value) {
diff --git a/src/cli.js b/src/cli.js
index 8e9de235..44f75ebd 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -1,4 +1,4 @@
-import { nativeBarActor } from './bar-actor.js';
+import { nativeBarActorForSeat } from './bar-actor.js';
import { barReadinessRequired, barReadiness, barReadySetting } from './bar-readiness.js';
import { barCoverageCommand, barCoverageForPolicy } from './bar-coverage.js';
/**
@@ -900,7 +900,8 @@ function relayOutboxSetting(root) {
export async function ordered(ctx, board, operation, args) {
if (['addItem','editItem','signBar'].includes(operation) && barReadySetting(board).enabled) {
const at = operation === 'addItem' ? 0 : 1;
- const barActor = ctx.io.personChannel === 'view' || ctx.io.personRequest ? null : nativeBarActor();
+ 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);
diff --git a/test/bar-coverage.test.js b/test/bar-coverage.test.js
index 79d80092..af6efa4c 100644
--- a/test/bar-coverage.test.js
+++ b/test/bar-coverage.test.js
@@ -140,3 +140,12 @@ test('[V1,H16] native authorship captures only the current runtime, not a histor
assert.equal(first.session,first.parent);
assert.notEqual(first.parent,second.parent);
});
+
+
+test('[V1,H16] a declared helper parent applies only to the actual session that joined', () => {
+ const env={CLAUDE_CODE_SESSION_ID:'synthetic-private-helper'};
+ const 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');
+});
diff --git a/test/claim-reopen.test.js b/test/claim-reopen.test.js
index 886af5a5..702a4dea 100644
--- a/test/claim-reopen.test.js
+++ b/test/claim-reopen.test.js
@@ -311,7 +311,7 @@ test('[B4,V1,H16] takeover authorship uses the captured current runtime, preserv
// This private move models the normal CLI's new runtime after takeover, not an identity rewrite.
const current = { session: 'e'.repeat(64), parent: 'e'.repeat(64) };
f.actors.coordinator=current;
- const child=store.register(f.board,{lane:'core',path:'/new-coordinator-helper',parent:'synthetic-new-parent',session:'synthetic-new-helper'});
+ const child=store.register(f.board,{lane:'core',path:'/new-coordinator-helper',parentDigest:'e'.repeat(64),sessionDigest:'f'.repeat(64)});
f.actors[child]={session:'f'.repeat(64),parent:'e'.repeat(64)};
setBarReady(f.board,{agentId:'coordinator',enabled:true});const id=readyItem(f);
assert.equal(f.board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key=?').get('agent_session:coordinator').meta_value,old);