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): bind row text and remove optional SSH calls [E22,H16]

Corey Olson3cd564594e11
diff --git a/src/commands/spec.js b/src/commands/spec.js
index cd7b9b8d..81f5cb99 100644
--- a/src/commands/spec.js
+++ b/src/commands/spec.js
@@ -203,7 +203,10 @@ export async function specCommand(io, { first, second, rest, values }) {
const ids = [second, ...rest].filter(Boolean).flatMap((text) => text.split(/[\s,]+/u)).filter(Boolean);
// With signed person moves on, the decision goes to the person's passkey; a named SSH signer has no passkey yet [E22].
const shown = [...spec.rows, ...(practice.rows ?? []).map(row => ({ ...row, id: `doctrine:${row.id}` }))].filter(row => ids.includes(row.id));
- if (personSigning(board).signed) refuseNamedSigners(shown, ids);
+ if (personSigning(board).signed) {
+ refuseNamedSigners(shown, ids);
+ if (values.by !== undefined && values.by !== 'person') throw new Refused('PERSON_SIGNER_REQUIRED', `the requested SSH signer ${values.by} has no passkey identity`, 'confirm as the person without --by, or wait until signing is off');
+ }
const confirmed = await requireSignedPerson(ctx, board, me, { verb: `spec-${first}`, args: { ids: ids.join(','),
...(values.text === undefined ? {} : { text: values.text }), ...(values.reason === undefined ? {} : { reason: values.reason }) } }, shown.map(({ id, text }) => ({ id, text })));
if (confirmed !== null) return confirmed;
@@ -215,8 +218,10 @@ export async function specCommand(io, { first, second, rest, values }) {
requireShownRows(board, io.personRequest, decidable, ids);
}
// An approve keeps a pending answer: plain, it approves the answered text; --text says what it replaces.
+ const signedDecision = personSigning(board).signed;
const kept = first === 'approve' ? pendingAnswers(ctx.info.root, ctx.config, ids, store.rowDecisions(board)) : new Map();
- const decide = { decision: first, reason: values.reason, by: values.by, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' };
+ if (signedDecision && values.text === undefined && kept.size) throw new Refused('STALE_ROW_DECISION', 'this row has a pending answer different from the original shown source', 'approve one row with --text containing the exact pending answer you want your passkey to confirm');
+ const decide = { decision: first, reason: values.reason, by: signedDecision ? 'person' : values.by, sshSign: !signedDecision, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' };
const records = values.text === undefined && kept.size ? ids.flatMap((id) => prepareRowDecisions(ctx.info.root, ctx.config, { ...decide, ids: [id], text: kept.get(id)?.text }))
: prepareRowDecisions(ctx.info.root, ctx.config, { ...decide, ids, text: values.text });
const decisions = await ordered(ctx, board, 'recordRowDecisions', [{ agentId: store.PERSON, channel: io.personChannel ?? 'terminal', decisions: records }]);
@@ -270,7 +275,7 @@ export async function specCommand(io, { first, second, rest, values }) {
if (row.status !== 'pending') throw new Refused('SPEC_ANSWER', `${second} is ${row.status}, not a pending question`, `read it with pullboard spec show ${second}; only a pending row takes an answer`);
if (personSigning(board).signed) requireShownRows(board, io.personRequest, [row], [second]);
const { text } = answerQuestion(row.text, given, second);
- const records = prepareRowDecisions(ctx.info.root, ctx.config, { ids: [second], decision: 'approve', text, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' });
+ const records = prepareRowDecisions(ctx.info.root, ctx.config, { ids: [second], decision: 'approve', text, sshSign: !personSigning(board).signed, by: personSigning(board).signed ? 'person' : undefined, on: new Date().toISOString(), commit: headCommit(ctx.info.root) ?? '' });
const decisions = await ordered(ctx, board, 'recordRowDecisions', [{ agentId: store.PERSON, channel: io.personChannel ?? 'terminal', decisions: records }]);
// The answer reported is read back from the signed text, never carried as a field of its own.
const answered = decisions.map((record) => ({ ...record, answer: decisionAnswer(record) }));
diff --git a/src/relay-requests.js b/src/relay-requests.js
index a71ce86b..3c269253 100644
--- a/src/relay-requests.js
+++ b/src/relay-requests.js
@@ -4,6 +4,7 @@ import { createHash } from 'node:crypto';
import { recordedRefusal } from './recorded-refusal.js';
import { Refused } from './refused.js';
import { answerQuestion } from './blueprints.js';
+import { personSigning } from './person-signing.js';
import { parseImplies } from './implies.js';
import { validatePersonRequest } from './person-request.js';
import { relayMoveActor } from './relay-sender.js';
@@ -101,7 +102,7 @@ export function receivePersonRequest(board, document, { sequence, at, sender })
}
/** Compare the requested literal arguments with the ordinary effect produced by the CLI. */
-function fulfilsIntent(record, move) {
+function fulfilsIntent(record, move, board) {
const intent = record.move;
const args = intent.args;
const value = move.args[0];
@@ -139,7 +140,8 @@ function fulfilsIntent(record, move) {
} catch { return false; }
return value?.agentId === 'person' && value.channel === 'view' && value.decisions?.length === 1
&& value.decisions[0].id === args.row && value.decisions[0].kind === 'spec'
- && value.decisions[0].decision === 'approve' && value.decisions[0].text === text;
+ && value.decisions[0].decision === 'approve' && value.decisions[0].text === text && value.decisions[0].by === 'person'
+ && value.decisions[0].signature === undefined;
}
if (intent.verb === 'hold') return value === args.lane && options?.asPerson === true && options.channel === 'view'
&& (args.off || options.reason === (args.reason ?? ''));
@@ -158,11 +160,16 @@ function fulfilsIntent(record, move) {
const rows = value?.decisions;
if (!['spec-approve', 'spec-decline', 'spec-answer'].includes(intent.verb) || typeof args.ids !== 'string') return false;
const ids = args.ids.split(/[\s,]+/u).filter(Boolean);
+ const requiresShown = personSigning(board, { strict: false }).signed;
+ let shown;
+ try { shown = JSON.parse(record.encoded).rows; } catch { return false; }
+ if (requiresShown && (!Array.isArray(shown) || shown.length !== ids.length)) return false;
return value?.agentId === 'person' && value.channel === 'view' && Array.isArray(rows) && rows.length === ids.length
&& rows.every((row, index) => (row.kind === 'doctrine' ? 'doctrine:' : '') + row.id === ids[index]
&& row.decision === (intent.verb === 'spec-approve' ? 'approve' : 'decline')
&& (intent.verb !== 'spec-decline' || row.reason === args.reason.trim())
- && (args.text === undefined || row.text === args.text.trim()));
+ && (args.text === undefined ? !requiresShown || row.text === shown.find(entry => entry.id === ids[index])?.text : row.text === args.text.trim())
+ && (!requiresShown || row.by === 'person' && row.signature === undefined));
}
/** The item ids a request's `implies` text names, parsed as `--implies` is, or null when it names none validly. */
@@ -221,7 +228,7 @@ export function requestMoveProblem(board, move, { checkExecutorLease = true } =
if (!['coordinator', 'person'].includes(actor)) return new Refused('PERSON_REQUEST_RECEIPT', 'only the coordinator fulfils an authenticated person request');
if (tag.phase === 'execute') {
const expected = { add: 'addItem', shout: 'shout', answer: 'answerDecision', hold: record.move.args.off ? 'releaseLane' : 'holdLane', 'spec-approve': 'recordRowDecisions', 'spec-decline': 'recordRowDecisions', 'spec-answer': 'recordRowDecisions', fact: 'appendFact', 'sentinel-approve': 'decideSentinel', 'sentinel-decline': 'decideSentinel', 'land-waive': 'recordLandingWaiver', signing: 'setPersonSigning' }[record.move.verb];
- if (move.operation !== expected || !fulfilsIntent(record, move)) return new Refused('PERSON_REQUEST_RECEIPT', 'the ordinary move does not fulfil this request; execute its original CLI intent');
+ if (move.operation !== expected || !fulfilsIntent(record, move, board)) return new Refused('PERSON_REQUEST_RECEIPT', 'the ordinary move does not fulfil this request; execute its original CLI intent');
}
if (move.engine >= 6 && ['claim', 'repo-request', 'refuse'].includes(tag.phase) && !fulfilsStage(record, move, tag)) return new Refused('PERSON_REQUEST_RECEIPT', 'publish only the exact stage for this authenticated phone request');
if (['claim', 'repo-request', 'refuse'].includes(tag.phase) && !(move.operation === 'shout' && move.args[0]?.from === 'person' && move.args[0]?.to === 'coordinator'
diff --git a/src/row-decisions.js b/src/row-decisions.js
index 3096527e..3fc47422 100644
--- a/src/row-decisions.js
+++ b/src/row-decisions.js
@@ -49,12 +49,12 @@ function decisionRows(root, config, ids) {
* a pending question is an approval of its answered text and carries no separate answer field: the
* answer shown is read back from the signed source and text by decisionAnswer.
*/
-export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, by, on, commit = '', note = '' }) {
+export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, by, on, commit = '', note = '', sshSign = true }) {
if (!ids.length) throw new Refused('USAGE', 'name rows: pullboard spec approve <ids> or spec decline <ids> --reason "why"');
if (!['approve', 'decline'].includes(decision)) throw new Refused('ROW_DECISION', 'use pullboard spec approve or decline');
if (decision === 'decline' && (!reason.trim() || /[\r\n|]/u.test(reason))) throw new Refused('ROW_DECISION', 'a decline needs a one-line reason without a field separator; use --reason "why"');
if (proposedText !== undefined && (decision !== 'approve' || ids.length !== 1 || !proposedText.trim() || /[\r\n|]/u.test(proposedText))) throw new Refused('ROW_DECISION', 'approve one row with --text "exact one-line text", without a field separator');
- const signed = decision === 'approve' && hasSignerFile(root);
+ const signed = sshSign && decision === 'approve' && hasSignerFile(root);
const principal = by ?? (signed ? defaultPrincipal(root) : 'person');
return decisionRows(root, config, ids).map(({ kind, file, row, source }) => {
const status = decision === 'approve' ? 'approved' : 'wont';
diff --git a/test/person-optional-apply-fixture.js b/test/person-optional-apply-fixture.js
new file mode 100644
index 00000000..a8639b18
--- /dev/null
+++ b/test/person-optional-apply-fixture.js
@@ -0,0 +1,95 @@
+/** Exact signed-request provenance must replace optional SSH signing at native apply, never named identity [E22,H16]. */
+import assert from 'node:assert/strict';
+import {
+ createHash,
+ generateKeyPairSync,
+ randomUUID,
+ sign,
+} from 'node:crypto';
+import {
+ mkdirSync,
+ readFileSync,
+ writeFileSync,
+} from 'node:fs';
+import { join } from 'node:path';
+import * as store from '../src/board.js';
+import * as signing from '../src/person-signing.js';
+import { presenceAttestation } from '../src/person-presence.js';
+import { preparePersonRequest } from '../src/person-request.js';
+import {
+ prepareRowDecisions,
+ planRowApply,
+} from '../src/row-decisions.js';
+import { loadConfig } from '../src/config.js';
+import {
+ applyRelayMove,
+ prepareEngineMove,
+} from '../src/engine.js';
+import {
+ receivePersonRequest,
+ personRequestRecords,
+ requestIntentDigest,
+ requestStageText,
+} from '../src/relay-requests.js';
+import { relayClientFixture } from './relay-client-fixture.js';
+import { runFixtureGit } from './fixture-child.js';
+
+/** A valid OpenSSH public line for a fixture-only public key; no SSH private key or signing subprocess exists. */
+function sshPublicLine(publicKey) {
+ const name = Buffer.from('ssh-ed25519');
+ const raw = publicKey.export({ format: 'der', type: 'spki' }).subarray(-32);
+ const length = value => { const bytes = Buffer.alloc(4); bytes.writeUInt32BE(value); return bytes; };
+ return `[email protected] namespaces="pullboard-signoff" ssh-ed25519 ${Buffer.concat([length(name.length), name, length(raw.length), raw]).toString('base64')}\n`;
+}
+
+/** Exercise actual engine receipt validation and native apply on an owned project, with a separately pinned fixture relay key. */
+export async function optionalPasskeyApply(t) {
+ const box = await relayClientFixture(t);
+ const specFile = join(box.root, 'SPEC.md');
+ const text = 'An optional SSH row approved by its exact passkey request.';
+ writeFileSync(specFile, readFileSync(specFile, 'utf8') + `\n- G21 [draft, must] ${text} | gate: review\n`);
+ const publicPair = generateKeyPairSync('ed25519');
+ const allowed = sshPublicLine(publicPair.publicKey);
+ mkdirSync(join(box.root, '.pullboard'), { recursive: true });
+ writeFileSync(join(box.root, '.pullboard', 'signers'), allowed);
+ writeFileSync(join(box.root, '.pullboard', 'signers.initial'), allowed);
+ writeFileSync(join(box.root, '.pullboard', 'first-commit'), runFixtureGit(['rev-list', '--max-parents=0', 'HEAD'], { cwd: box.root, env: box.env }) + '\n');
+ const board = store.openBoard(join(box.root, '.git', 'pullboard', 'board.sqlite'));
+ t.after(() => store.closeBoard(board));
+ const authority = generateKeyPairSync('ed25519');
+ signing.pinAuthority(board, 'https://fixture-relay.invalid', { version: 1, algorithm: 'Ed25519',
+ publicKey: authority.publicKey.export({ format: 'der', type: 'spki' }).toString('base64url') });
+ signing.setPersonSigning(board, { agentId: 'coordinator', signed: true });
+ const document = preparePersonRequest({ verb: 'spec-approve', args: { ids: 'G21' } }, randomUUID(), [{ id: 'G21', text }]);
+ const boardId = board.db.prepare("SELECT meta_value FROM board_meta WHERE meta_key='board_id'").get().meta_value;
+ const presence = { board: boardId, request: document.id, digest: createHash('sha256').update(JSON.stringify(document)).digest('hex'),
+ credential: 'fixture-passkey', at: Date.now() };
+ presence.signature = sign(null, presenceAttestation(presence), authority.privateKey).toString('base64url');
+ const at = new Date().toISOString();
+ receivePersonRequest(board, document, { sequence: 1, at, sender: { kind: 'person', userId: 'fixture-user', presence } });
+ const executor = 'fixture-executor';
+ let sequence = 1;
+ /** Execute normal sealed engine operations with actual stable request stage bindings. */
+ function execute(operation, args, phase) {
+ const record = personRequestRecords(board).find(entry => entry.id === document.id);
+ const move = prepareEngineMove(board, operation, args);
+ move.personRequest = { id: document.id, executor, phase, digest: requestIntentDigest(record) };
+ const outcome = applyRelayMove(board, move, { sequence: ++sequence, at, kind: 'move', sender: { kind: 'person', userId: 'fixture-user', presence } });
+ assert.equal(outcome.error, undefined, JSON.stringify(outcome));
+ return outcome.result;
+ }
+ const intake = personRequestRecords(board).find(entry => entry.id === document.id);
+ execute('shout', [{ from: 'person', to: 'coordinator', text: requestStageText(intake, 'claim'), lanes: Object.keys(loadConfig(box.root).lanes) }], 'claim');
+ const decisions = prepareRowDecisions(box.root, loadConfig(box.root), { ids: ['G21'], decision: 'approve', by: 'person',
+ sshSign: false, passkeyRequest: document.id, on: at, commit: runFixtureGit(['rev-parse', 'HEAD'], { cwd: box.root, env: box.env }) });
+ // Keep this explicit even before prepareRowDecisions retains the new provenance option.
+ decisions.forEach(record => { record.passkeyRequest = document.id; });
+ assert.equal(decisions[0].signature, undefined, 'optional passkey approval does not invoke SSH signing');
+ execute('recordRowDecisions', [{ agentId: 'person', channel: 'view', decisions }], 'execute');
+ const plan = planRowApply(box.root, loadConfig(box.root), store.rowDecisions(board), {
+ passkeyDecision: record => signing.verifiedPasskeyRowDecision(board, record),
+ });
+ assert.equal(plan.files.length, 1);
+ assert.match(plan.files[0].after, /- G21 \[approved, must\] An optional SSH row approved by its exact passkey request\./u);
+ assert.equal(readFileSync(specFile, 'utf8').includes('G21 [draft'), true, 'planning does not write before the caller commits its ordered apply');
+}
diff --git a/test/team.test.js b/test/team.test.js
index 843e5934..449d2462 100644
--- a/test/team.test.js
+++ b/test/team.test.js
@@ -54,6 +54,7 @@ import {
grantChallenge,
softwarePasskey,
} from './person-passkey-fixture.js';
+import { optionalPasskeyApply } from './person-optional-apply-fixture.js';
import { firstUnpairedAuthorityInsertion } from './person-first-pin-fixture.js';
import { refuseNamedSigners } from '../src/person-signing-cli.js';
import { createE2eHelpers } from './e2e-helpers.js';
@@ -1206,3 +1207,6 @@ test('person-only moves are signed [E22,B26,H16]', { timeout: relayWorkBudgetMs(
/** Keep the initial-unpaired local-edit clause distinct from the post-pin trigger controls. */
test('person-only moves are signed before the first authority pin [E22,B26,H16]', firstUnpairedAuthorityInsertion);
+
+/** Optional SSH policy must accept a genuinely bound passkey row decision without using an SSH key. */
+test('person-only moves are signed through optional SSH apply [E22,H16]', optionalPasskeyApply);