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(person): any SSH marker names a remote shell [B26,E22]

Corey Olsone7f52e502d0b
diff --git a/src/person.js b/src/person.js
index ed4f033c..82d19477 100644
--- a/src/person.js
+++ b/src/person.js
@@ -8,9 +8,17 @@ export const AGENT_SHELL_MARKERS = Object.freeze([
'CODEX_THREAD_ID', 'CODEX_SESSION_ID', 'CODEX_CI', 'CODEX_SHELL',
]);
-/** SSH transport markers removed from test child environments that act as the person. */
+/** SSH transport markers: any one names a remote shell, and test children acting as the person drop them all. */
export const SSH_SHELL_MARKERS = Object.freeze(['SSH_CONNECTION', 'SSH_CLIENT', 'SSH_TTY']);
+/**
+ * Tell whether this shell arrived over SSH by any of its markers [B26].
+ * One list serves the person check and relay on's SSH path, so a marker one honours the other honours too.
+ */
+export function remoteShell(environment = process.env) {
+ return SSH_SHELL_MARKERS.some((name) => Boolean(environment[name]));
+}
+
/** Session identifiers belong beside the shell markers; only their digest reaches the local checkout binding. */
export const AGENT_SESSION_IDS = Object.freeze(['CLAUDE_CODE_SESSION_ID', 'CODEX_THREAD_ID', 'CODEX_SESSION_ID']);
@@ -30,7 +38,7 @@ export function requirePersonChannel(channel = 'terminal', environment = process
if (channel === 'terminal' && AGENT_SHELL_MARKERS.some((name) => Boolean(environment[name]))) {
throw new Refused('B26_PERSON_CHANNEL', 'this terminal belongs to an agent; run pullboard view, the person’s channel, and let the person act there');
}
- if (channel === 'terminal' && (environment.SSH_CONNECTION || environment.SSH_TTY)) {
+ if (channel === 'terminal' && remoteShell(environment)) {
throw new Refused('B26_PERSON_CHANNEL', 'this is a remote SSH shell, not the person’s terminal; run pullboard view, the person’s channel, and let the person act there');
}
return channel;
diff --git a/src/relay.js b/src/relay.js
index 83b4326d..6767a6df 100644
--- a/src/relay.js
+++ b/src/relay.js
@@ -20,7 +20,7 @@ import { relaySenderProblem } from './relay-sender.js';
import { readRelayMachine, removeRecordedDevice, updateRelayMachine, wrapForRecordedDevice } from './relay-machine.js';
import { receivePersonRequest, requestMoveProblem } from './relay-requests.js';
import { nativePhoneAction, phoneProposal, publishPhoneApproval, warnPhoneApproval } from './relay-phone.js';
-import { requirePersonChannel, requireRelayOnChannel } from './person.js';
+import { remoteShell as isRemoteShell, requirePersonChannel, requireRelayOnChannel } from './person.js';
import { listApiProjects } from './projects.js';
export const DEFAULT_RELAY = 'https://app.pullboard.dev';
@@ -1305,7 +1305,7 @@ async function deviceSignIn(url, io, { signal, intent, onSignIn } = {}) {
/** Explicitly sign in through the relay and persist a sealed initial snapshot before uploading it. */
export async function relayOn(root, address, io, { session, credential, quiet = false, strict = false } = {}) {
- const remoteShell = io.personChannel !== 'view' && Boolean(process.env.SSH_CONNECTION || process.env.SSH_TTY);
+ const remoteShell = io.personChannel !== 'view' && isRemoteShell();
const reusableSession = remoteShell ? undefined : session;
const reusableCredential = remoteShell ? undefined : credential;
if (remoteShell) {
diff --git a/test/agent-session.test.js b/test/agent-session.test.js
index 71ada77c..16d2d679 100644
--- a/test/agent-session.test.js
+++ b/test/agent-session.test.js
@@ -9,6 +9,7 @@ import { join, resolve } from 'node:path';
import { after, test } from 'node:test';
import { DatabaseSync } from 'node:sqlite';
import { listResources } from '../src/resources.js';
+import { SSH_SHELL_MARKERS } from '../src/person.js';
const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
const DIRS = [];
@@ -40,8 +41,8 @@ function sandbox() {
return runFixtureGit(args, { cwd, env: base });
}
/** Run the actual CLI with an explicit agent session or markerless terminal. */
- function run(cwd, args, { session, sessionKey = 'CLAUDE_CODE_SESSION_ID', agent = true } = {}) {
- const env = { ...base };
+ function run(cwd, args, { session, sessionKey = 'CLAUDE_CODE_SESSION_ID', agent = true, extra = {} } = {}) {
+ const env = { ...base, ...extra };
if (agent) {
env.CLAUDECODE = '1';
if (session !== undefined) env[sessionKey] = session;
@@ -307,3 +308,36 @@ test('takeover waits for an active write and then refuses the old session [B3,B7
if (takeover) await takeover.closed;
}
});
+
+test('a remote shell is recognized by any SSH marker [B26,E22]', () => {
+ const box = project();
+ for (const key of SSH_SHELL_MARKERS) delete box.base[key];
+ writeFileSync(join(box.repo, 'SPEC.md'), `${SPEC}- G2 [draft, must] A probe row for person moves. | gate: true\n`);
+ box.git(box.repo, 'commit', '-qam', 'docs: draft a probe row');
+ const markers = {
+ SSH_CONNECTION: '192.0.2.10 12345 192.0.2.20 22',
+ SSH_CLIENT: '192.0.2.10 12345 22',
+ SSH_TTY: '/dev/pts/7',
+ };
+ const shells = [...Object.entries(markers).map(([key, value]) => ({ [key]: value })), markers];
+ const before = boardSnapshot(box.boardFile);
+ for (const extra of shells) {
+ const label = Object.keys(extra).join('+');
+ const refused = box.run(box.repo, ['spec', 'approve', 'G2', '--json'], { agent: false, extra });
+ assert.equal(refused.status, 1, `${label}: ${refused.stdout}${refused.stderr}`);
+ const error = JSON.parse(refused.stdout).error;
+ assert.equal(error.code, 'B26_PERSON_CHANNEL', `${label} gives the person-channel refusal`);
+ assert.match(error.message, /remote SSH shell/u, `${label} is named as a remote shell`);
+ assert.match(error.next, /pullboard view/u, `${label} points the person at the view`);
+ assert.deepEqual(boardSnapshot(box.boardFile), before, `${label} records no person decision`);
+ }
+ const local = box.run(box.repo, ['spec', 'approve', 'G2', '--json'], { agent: false });
+ assert.equal(local.status, 0, `no SSH marker allows the person move: ${local.stdout}${local.stderr}`);
+
+ box.git(box.repo, 'remote', 'add', 'origin', 'https://github.com/example/session-fixture.git');
+ const relay = box.run(box.repo, ['relay', 'on', '--url', 'http://127.0.0.1:9', '--json'], { agent: false, extra: { SSH_CLIENT: markers.SSH_CLIENT } });
+ const relayError = JSON.parse(relay.stdout || '{}').error;
+ assert.notEqual(relayError?.code, 'B26_PERSON_CHANNEL', `relay on over SSH keeps its own channel: ${relay.stdout}${relay.stderr}`);
+ assert.equal(relayError?.code, 'RELAY_UNAVAILABLE', 'relay on over SSH reaches the relay');
+ assert.match(relayError.message, /\/auth\/device\/start/u, 'relay on over SSH starts its device sign-in (#615)');
+});