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(person): apply exact passkey decisions without SSH [E22,H16]
Corey Olson0420e9066715
diff --git a/src/commands/spec.js b/src/commands/spec.jsindex 81f5cb99..eef92c77 100644--- a/src/commands/spec.js+++ b/src/commands/spec.js@@ -1,4 +1,5 @@/** The pullboard spec command, in its own module so an item adding another command never edits these lines. */+import { verifiedPasskeyRowDecision } from '../person-signing.js';import {fitCommand,} from '../blueprint-fit-command.js';@@ -221,7 +222,7 @@ export async function specCommand(io, { first, second, rest, values }) {const signedDecision = personSigning(board).signed;const kept = first === 'approve' ? pendingAnswers(ctx.info.root, ctx.config, ids, store.rowDecisions(board)) : new Map();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 decide = { decision: first, reason: values.reason, by: signedDecision ? 'person' : values.by, sshSign: !signedDecision, passkeyRequest: signedDecision ? io.personRequest?.id : undefined, 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 }]);@@ -275,7 +276,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, sshSign: !personSigning(board).signed, by: personSigning(board).signed ? 'person' : undefined, 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, passkeyRequest: personSigning(board).signed ? io.personRequest?.id : undefined, 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) }));@@ -293,7 +294,7 @@ export async function specCommand(io, { first, second, rest, values }) {const drafted = pendingRowDrafts(loadSpec(ctx.info.root, ctx.config), store.rowDrafts(board)).map((draft) => draftRow(ctx.info.root, ctx.config, { target: 'spec', text: draft.text, gate: draft.gate, tier: draft.tier, section: /^(.*?)\d+$/u.exec(draft.id)[1], id: draft.id }));drafted.forEach((row) => io.say(`${row.file}: ${row.id} drafted from a lane, for the person to approve`));clashingRowDrafts(loadSpec(ctx.info.root, ctx.config), store.rowDrafts(board)).forEach((draft) => io.say(`${ctx.config.spec}: ${draft.id} holds other text, so the draft by ${draft.by} was not written; shout ${draft.by} to run pullboard spec draft again and cite the new id`));- const plan = planRowApply(ctx.info.root, ctx.config, store.rowDecisions(board));+ const plan = planRowApply(ctx.info.root, ctx.config, store.rowDecisions(board), { passkeyDecision: record => verifiedPasskeyRowDecision(board, record) });writeRowApply(ctx.info.root, plan);let applied;try { applied = await ordered(ctx, board, 'applyRowDecisions', [{ agentId: me.id, events: plan.records.map((record) => record.event) }]); }diff --git a/src/person-signing.js b/src/person-signing.jsindex 21712062..5ccaf3f8 100644--- a/src/person-signing.js+++ b/src/person-signing.js@@ -14,11 +14,13 @@ import {SIGNED_EVENT_LOG_VERSION,} from './board.js';import { createHash } from 'node:crypto';+import { isDeepStrictEqual } from 'node:util';import { Refused } from './refused.js';import { validatePersonRequest } from './person-request.js';import {personRequestRecords,requestIntentDigest,+ requestRowDecisionsMatch,} from './relay-requests.js';import { validPresence } from './relay-sender.js';import { presenceSigned } from './person-presence.js';@@ -207,6 +209,16 @@ export function requestPresence(board, id, { strict = true } = {}) {&& stampHolds(board, presence, strict) ? presence : null;}+/** Verify an optional row's exact committed result against the original relay-attested passkey intent. */+export function verifiedPasskeyRowDecision(board, decision) {+ if (typeof decision.passkeyRequest !== 'string' || decision.by !== 'person' || decision.signature !== undefined) return false;+ const request = personRequestRecords(board).find(record => record.id === decision.passkeyRequest && !record.duplicateOf);+ if (!request || !Number.isSafeInteger(request.resultSequence) || !requestPresence(board, request.id)+ || !requestRowDecisionsMatch(board, request, request.result)) return false;+ const strip = ({ event, at, applied, appliedAt, ...value }) => value;+ return request.result.some(record => record.event === decision.event && isDeepStrictEqual(strip(record), strip(decision)));+}+/** Whether this command or move carries out a person request a passkey confirmed. */export function passkeyConfirmed(board, personRequest, { strict = true } = {}) {return personRequest?.phase === 'execute' && typeof personRequest.id === 'string' && Boolean(requestPresence(board, personRequest.id, { strict }));diff --git a/src/relay-requests.js b/src/relay-requests.jsindex 3c269253..96a4c673 100644--- a/src/relay-requests.js+++ b/src/relay-requests.js@@ -5,6 +5,8 @@ import { recordedRefusal } from './recorded-refusal.js';import { Refused } from './refused.js';import { answerQuestion } from './blueprints.js';import { personSigning } from './person-signing.js';+import { parseSpec } from './spec.js';+import { rowDecisionReplacement } from './row-decision-text.js';import { parseImplies } from './implies.js';import { validatePersonRequest } from './person-request.js';import { relayMoveActor } from './relay-sender.js';@@ -141,7 +143,7 @@ function fulfilsIntent(record, move, board) {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].by === 'person'- && value.decisions[0].signature === undefined;+ && value.decisions[0].signature === undefined && boundSignedRow(record, value.decisions[0], args.row, text);}if (intent.verb === 'hold') return value === args.lane && options?.asPerson === true && options.channel === 'view'&& (args.off || options.reason === (args.reason ?? ''));@@ -160,7 +162,7 @@ function fulfilsIntent(record, move, board) {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;+ const requiresShown = personSigning(board, { strict: false }).signed || Array.isArray(rows) && rows.some(row => row.passkeyRequest !== undefined);let shown;try { shown = JSON.parse(record.encoded).rows; } catch { return false; }if (requiresShown && (!Array.isArray(shown) || shown.length !== ids.length)) return false;@@ -169,7 +171,24 @@ function fulfilsIntent(record, move, board) {&& row.decision === (intent.verb === 'spec-approve' ? 'approve' : 'decline')&& (intent.verb !== 'spec-decline' || row.reason === args.reason.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));+ && (!requiresShown || row.by === 'person' && row.signature === undefined && boundSignedRow(record, row, ids[index], row.text)));+}++/** A signed decision cannot substitute the source text, named SSH identity or unrelated row fields. */+function boundSignedRow(request, row, id, text) {+ let shown;+ let original;+ try {+ shown = JSON.parse(request.encoded).rows?.find(entry => entry.id === id);+ original = parseSpec(`## Decision\n${row.source}\n`).rows[0];+ } catch { return false; }+ return Boolean(shown && original && original.id === row.id && original.text === shown.text && !original.signers?.length+ && row.passkeyRequest === request.id && row.replacement === rowDecisionReplacement(row.source, row.decision, text));+}++/** Recheck the entire committed row-result effect against its original signed request, independently of mutable flags. */+export function requestRowDecisionsMatch(board, request, rows) {+ return Array.isArray(rows) && fulfilsIntent(request, { operation: 'recordRowDecisions', args: [{ agentId: 'person', channel: 'view', decisions: rows }] }, board);}/** The item ids a request's `implies` text names, parsed as `--implies` is, or null when it names none validly. */diff --git a/src/row-decision-text.js b/src/row-decision-text.jsnew file mode 100644index 00000000..5077e973--- /dev/null+++ b/src/row-decision-text.js@@ -0,0 +1,6 @@+/** Preserve a row's gate, signer list and other fields while changing only its decided status and text [S1,E22]. */+export function rowDecisionReplacement(source, decision, text) {+ const status = decision === 'approve' ? 'approved' : 'wont';+ return source.replace(/\[([a-z]+)(,\s*[a-z]+)?\]/u, (_, old, tier = '') => `[${status}${tier}]`)+ .replace(/(\]\s+)([^|]*)(?=\s*\||$)/u, (_, prefix, old) => `${prefix}${text}${old.match(/\s+$/u)?.[0] ?? ''}`);+}diff --git a/src/row-decisions.js b/src/row-decisions.jsindex 3fc47422..22d82729 100644--- a/src/row-decisions.js+++ b/src/row-decisions.js@@ -23,8 +23,11 @@ import {hasSignerFile,signRowDecision,verifyRowDecision,+ verifySignedRecords,+ readRawRecords,} from './signature.js';import { Refused } from './refused.js';+import { rowDecisionReplacement } from './row-decision-text.js';import { rowDecisionContext } from './row-decision-state.js';import { staleRowDecision } from './row-decision-state.js';@@ -49,7 +52,7 @@ 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 = '', sshSign = true }) {+export function prepareRowDecisions(root, config, { ids, decision, reason = '', text: proposedText, by, on, commit = '', note = '', sshSign = true, passkeyRequest }) {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"');@@ -59,9 +62,8 @@ export function prepareRowDecisions(root, config, { ids, decision, reason = '',return decisionRows(root, config, ids).map(({ kind, file, row, source }) => {const status = decision === 'approve' ? 'approved' : 'wont';const text = decision === 'approve' ? proposedText?.trim() ?? row.text : row.text;- const replacement = source.replace(/\[([a-z]+)(,\s*[a-z]+)?\]/u, (_, old, tier = '') => `[${status}${tier}]`)- .replace(/(\]\s+)([^|]*)(?=\s*\||$)/u, (_, prefix, old) => `${prefix}${text}${old.match(/\s+$/u)?.[0] ?? ''}`);- const record = { version: 1, type: 'row-decision', kind, file, id: row.id, source, replacement, text, decision, reason: decision === 'decline' ? reason.trim() : '', by: principal, on, commit, note };+ const replacement = rowDecisionReplacement(source, decision, text);+ const record = { ...(passkeyRequest ? { passkeyRequest } : {}), version: 1, type: 'row-decision', kind, file, id: row.id, source, replacement, text, decision, reason: decision === 'decline' ? reason.trim() : '', by: principal, on, commit, note };return signed ? signRowDecision(root, record) : record;});}@@ -176,11 +178,13 @@ export function handAnsweredQuestions(before, after, readDecisions) {function decisionReceipt({ event, at, applied, appliedAt, ...record }) { return record; }/** Preflight every file and signature before an apply writes even its first byte. */-export function planRowApply(root, config, records) {+export function planRowApply(root, config, records, { passkeyDecision = () => false } = {}) {const pending = records.filter((record) => !record.applied);const files = new Map();for (const record of pending) {- verifyRowDecision(root, record);+ const verifiedPasskey = passkeyDecision(record);+ if (verifiedPasskey) verifySignedRecords(root, readRawRecords(root));+ else verifyRowDecision(root, record);const file = record.kind === 'spec' ? config.spec : loadDoctrine(root, config).name;const aliases = new Set(['DOCTRINE.md', 'PRACTICE.md']);if (file !== record.file && !(record.kind === 'doctrine' && aliases.has(file) && aliases.has(record.file))) throw new Refused('STALE_ROW_DECISION', `${record.id}'s file changed; ask the person to approve its current row again`);@@ -189,6 +193,7 @@ export function planRowApply(root, config, records) {const lines = (change.after ?? change.before).split('\n');const parsed = loadSpec(root, { ...config, spec: file });const matches = parsed.rows.filter((row) => row.id === record.id);+ if (verifiedPasskey && matches[0]?.signers?.length) throw new Refused('PERSON_SIGNER_REQUIRED', `${record.id} names its SSH signers ${matches[0].signers.join(', ')}`, 'a passkey does not claim any named SSH identity');const index = matches.length === 1 ? matches[0].line - 1 : -1;const source = index < 0 ? '' : lines[index].replace(/\r$/u, '');if (source !== record.source && source !== record.replacement) throw new Refused('STALE_ROW_DECISION', `${record.id}'s exact row changed after the person's decision; ask the person to approve its current text again`);