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(tour): scripted seats run as their own agent session [N10]
Corey Olson5974ced65536
diff --git a/src/tour.js b/src/tour.jsindex 03110731..99b5e21c 100644--- a/src/tour.js+++ b/src/tour.js@@ -13,12 +13,20 @@ import {writeFileSync,} from 'node:fs';import { tmpdir } from 'node:os';-import { join } from 'node:path';+import { basename, join } from 'node:path';import { fileURLToPath } from 'node:url';+import { CHECKOUT_SESSION_TOKEN_ENV } from './agent-session.js';import { displayAgentName } from './agent-names.js';import { loadConfig } from './config.js';+import { AGENT_SESSION_IDS, AGENT_SHELL_MARKERS } from './person.js';import { registerProjectAndLink } from './projects.js';+/**+ * The caller's agent-session identity and checkout lease. A scripted seat must never inherit them: a seat that did+ * would be recorded under the caller's session, and its verify would then be refused as self-verification (#952).+ */+const CALLER_SESSION_NAMES = new Set([...AGENT_SHELL_MARKERS, ...AGENT_SESSION_IDS, CHECKOUT_SESSION_TOKEN_ENV]);+const BIN = fileURLToPath(new URL('../bin/pullboard.js', import.meta.url));const SPEC = `# Greeter@@ -97,13 +105,22 @@ export async function tour(io) {writeFileSync(join(shims, 'pullboard'), `#!/bin/sh\nexec "${process.execPath}" "${BIN}" "$@"\n`);chmodSync(join(shims, 'pullboard'), 0o755);// Nothing of the person's git setup reaches the tour: no config files, and no GIT_ variable, such- // as GIT_DIR from a hook or GIT_CONFIG_COUNT pairs, which git reads as config too.- const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_') && name !== 'NODE_TEST_CONTEXT'));+ // as GIT_DIR from a hook or GIT_CONFIG_COUNT pairs, which git reads as config too. The caller's agent session+ // stays out as well, so each seat is judged as its own session below (#952).+ const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_') && name !== 'NODE_TEST_CONTEXT' && !CALLER_SESSION_NAMES.has(name)));Object.assign(env, { PATH: `${shims}:${process.env.PATH}`, GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1', PULLBOARD_HOME: join(dir, '.pullboard') });const repo = join(dir, 'greeter');const app = `${repo}-app-1`;const review = `${repo}-review-1`;const where = { coordinator: repo, 'app-1': app, 'review-1': review };+ /**+ * The agent session a scripted seat runs as (#952). Each seat has its own session identifier, derived from this+ * run's unique folder, so the builder and the reviewer are two sessions and neither is the caller's.+ *+ * @param {string} who+ * @returns {Record<string, string>}+ */+ const seatSession = (who) => ({ CLAUDECODE: '1', CLAUDE_CODE_SESSION_ID: `${basename(dir)}-${who}` });/*** Run one command as an agent, show it and the lines of its output worth reading.@@ -114,7 +131,7 @@ export async function tour(io) {const result = spawnSync(file, args, {cwd: where[who],encoding: 'utf8',- env: { ...env, GIT_AUTHOR_NAME: who, GIT_AUTHOR_EMAIL: `${who}@tour.invalid`, GIT_COMMITTER_NAME: who, GIT_COMMITTER_EMAIL: `${who}@tour.invalid` },+ env: { ...env, ...seatSession(who), GIT_AUTHOR_NAME: who, GIT_AUTHOR_EMAIL: `${who}@tour.invalid`, GIT_COMMITTER_NAME: who, GIT_COMMITTER_EMAIL: `${who}@tour.invalid` },});if ((result.status === 0) === fails) {const said = `${result.stdout ?? ''}${result.stderr ?? ''}${result.error?.message ?? ''}`;diff --git a/test/e2e.test.js b/test/e2e.test.jsindex be8325a3..d83e6f75 100644--- a/test/e2e.test.js+++ b/test/e2e.test.js@@ -16,6 +16,7 @@ import {symlinkSync,writeFileSync,} from 'node:fs';+import { createHash } from 'node:crypto';import { tmpdir } from 'node:os';import { request } from 'node:http';import { connect } from 'node:net';@@ -444,3 +445,32 @@ test('explicit and trunk pre-push landings jump the machine gate line and show iawait Promise.all(pushChildren.map((child) => child.closed));}});++/** The digest the agent-session ledger stores for one session identifier, as src/person.js computes it. */+function sessionDigest(name, value) {+ return createHash('sha256').update(JSON.stringify([name, value])).digest('hex');+}++test('the tour finishes when an agent session runs it [N10]', () => {+ // A caller in Claude Code or Codex runs the tour; the scripted seats must not inherit the caller's session, so the+ // reject-and-rework still verifies (#952). The caller's own digest must appear on no item the tour moved.+ for (const [name, value] of [['CLAUDE_CODE_SESSION_ID', 'caller-session-952'], ['CODEX_THREAD_ID', 'caller-thread-952']]) {+ const box = sandbox();+ const callerEnv = { ...box.env, TMPDIR: box.dir, CLAUDECODE: '1', [name]: value };+ delete callerEnv.PULLBOARD_MODEL;+ delete callerEnv.NO_COLOR;+ delete callerEnv.FORCE_COLOR;+ const shown = spawnSync(process.execPath, [BIN, 'tour'], { cwd: box.dir, env: callerEnv, encoding: 'utf8' });+ assert.equal(shown.status, 0, `${name}: ${shown.stdout}${shown.stderr}`);+ assert.match(shown.stdout, /^Nothing shipped until a second agent verified it\.$/mu);+ assert.match(shown.stdout, /verified #1: CRITERION_MET/);+ assert.doesNotMatch(shown.stdout, /SELF_SESSION_VERIFY/);++ const repo = /Look around: cd (\S+) && pullboard log/.exec(shown.stdout)[1];+ const ledger = readFileSync(join(repo, '.git', 'pullboard', 'item-sessions.jsonl'), 'utf8').trim().split('\n').map((line) => JSON.parse(line));+ const digests = ledger.map((row) => row.digest);+ // The ledger holds the builder's claim and submit; the reviewer's verify passing already proves it is another session.+ assert.ok(digests.length > 0, `${name}: the builder's claim and submit are recorded`);+ assert.equal(digests.includes(sessionDigest(name, value)), false, `${name}: the caller's session is no seat's builder`);+ }+});