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): bind full rows and committed execution [E22,H16]
Corey Olson7a6879a8f01f
diff --git a/relay/browser-client.js b/relay/browser-client.jsindex d0d172ad..5086e32f 100644--- a/relay/browser-client.js+++ b/relay/browser-client.js@@ -837,9 +837,11 @@ export async function createTransport({ onUpdate = () => {}, onOpenBoard = () =>await flushOutbox(entry);await snapshot(entry); await catchUp(entry);// A signed row decision names the exact text of each row this page shows; the passkey confirms that text.- if (entry.state.personSigning?.signed && ['spec-approve', 'spec-decline'].includes(value.move.verb) && !value.rows) {- value = preparePersonRequest(value.move, value.id, value.move.args.ids.split(/[\s,]+/u).filter(Boolean).map(id => ({ id,- text: (id.startsWith('doctrine:') ? entry.state.practice : entry.state.spec).find(row => row.id === id.replace(/^doctrine:/u, ''))?.text ?? '' })));+ if (entry.state.personSigning?.signed && ['spec-approve', 'spec-decline', 'spec-answer'].includes(value.move.verb) && !value.rows) {+ const ids = value.move.verb === 'spec-answer' ? [value.move.args.row] : value.move.args.ids.split(/[\s,]+/u).filter(Boolean);+ const rows = ids.map(id => entry.state.personRows?.find(row => row.id === id));+ if (rows.some(row => !row || typeof row.source !== 'string')) throw new Refused('STALE_ROW_DECISION', 'Refresh this board to read each exact row, gate and signer list before confirming.');+ value = preparePersonRequest(value.move, value.id, rows);}if (entry.state.personSigning?.signed && !presences.has(value.id)) {presences.set(value.id, await passkeyPresence((path, options) => documentAt(path, denied, { ...options, signal: access.signal }), entry.id, value));diff --git a/relay/browser-passkeys.js b/relay/browser-passkeys.jsindex 090ea6d8..8b487339 100644--- a/relay/browser-passkeys.js+++ b/relay/browser-passkeys.js@@ -110,7 +110,7 @@ export function installPersonPasskeys(doc, { documentAt, boards, confirm, signalfor (const proposal of entry.state.personProposals ?? []) {if (done.has(proposal.id) || Date.parse(proposal.expires) <= Date.now()) continue;const card = doc.createElement('div'); card.className = 'phone-approval'; card.dataset.proposal = proposal.id;- const text = doc.createElement('p'); text.className = 'phone-approval-title'; text.textContent = proposalText(proposal.move) + (proposal.rows?.length ? '\n' + proposal.rows.map(row => `${row.id}: ${row.text}`).join('\n') : '');+ const text = doc.createElement('p'); text.className = 'phone-approval-title'; text.textContent = proposalText(proposal.move) + (proposal.rows?.length ? '\n' + proposal.rows.map(row => `${row.id}: ${row.source ?? row.text}`).join('\n') : '');const button = doc.createElement('button'); button.type = 'button'; button.id = 'person-confirm-' + proposal.id; button.textContent = 'Confirm with passkey';button.onclick = async () => {button.disabled = true;diff --git a/src/commands/spec.js b/src/commands/spec.jsindex 9ab83526..8b69c705 100644--- a/src/commands/spec.js+++ b/src/commands/spec.js@@ -65,6 +65,7 @@ import {pendingAnswers,planRowApply,prepareRowDecisions,+ shownDecisionRows,restoreRowApply,rowDecisionView,writeRowApply,@@ -208,15 +209,16 @@ export async function specCommand(io, { first, second, rest, values }) {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 sources = shownDecisionRows(ctx.info.root, ctx.config, ids);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 })));+ ...(values.text === undefined ? {} : { text: values.text }), ...(values.reason === undefined ? {} : { reason: values.reason }) } }, sources);if (confirmed !== null) return confirmed;requirePersonChannel(io.personChannel);if (!ctx.info.isMain || me.id !== COORDINATOR) throw new Refused('B26_PERSON_APPROVAL', 'only the person from the main checkout approves or declines rows; use pullboard view for the person to decide');if (personSigning(board).signed) {const decidable = [...spec.rows, ...(practice.rows ?? []).map((row) => ({ ...row, id: `doctrine:${row.id}` }))];refuseNamedSigners(decidable, ids);- requireShownRows(board, io.personRequest, decidable, ids);+ requireShownRows(board, io.personRequest, decidable, ids, sources);}// An approve keeps a pending answer: plain, it approves the answered text; --text says what it replaces.const signedDecision = personSigning(board).signed;@@ -251,7 +253,7 @@ export async function specCommand(io, { first, second, rest, values }) {const evidence = ids.map(id => ({ id, ...rowEvidence(ctx.info.root, id, { ...proof, testFiles }) }));const missing = evidence.filter(row => !row.files.length && !row.verified.length).map(row => row.id);if (missing.length) throw new Refused('NO_EVIDENCE', `${missing.join(', ')} has no evidence; build it or cite its id in a test first`);- const completed = await requireSignedPerson(ctx, board, whoAmI(ctx, board), { verb: 'spec-approve', args: { ids: ids.join(',') } }, rows.map(({ id, text }) => ({ id, text })));+ const completed = await requireSignedPerson(ctx, board, whoAmI(ctx, board), { verb: 'spec-approve', args: { ids: ids.join(',') } }, shownDecisionRows(ctx.info.root, ctx.config, ids));if (completed === null) throw new Refused('PERSON_SIGNED', 'confirm optional sign-off as a row approval through its original terminal request', 'run spec approve <ids> with your passkey');io.result?.({ count: ids.length, by: 'person', ids, evidence, ...io.personConfirmation });return completed;@@ -262,7 +264,7 @@ export async function specCommand(io, { first, second, rest, values }) {const row = spec.rows.find(entry => entry.id === second);if (!row) throw new Refused('NO_ROW', `${second} is not a row in ${ctx.config.spec}`);if (personSigning(board).signed) refuseNamedSigners([row], [second]);- return requireSignedPerson(ctx, board, whoAmI(ctx, board), { verb: 'spec-answer', args: { row: second, answer: rest.join(' ').trim() } }, [{ id: row.id, text: row.text }]);+ return requireSignedPerson(ctx, board, whoAmI(ctx, board), { verb: 'spec-answer', args: { row: second, answer: rest.join(' ').trim() } }, shownDecisionRows(ctx.info.root, ctx.config, [row.id]));}) : null;if (completed !== null) return completed;requirePersonChannel(io.personChannel, process.env, { command: personCommand(primaryCheckoutRoot(ctx.info) ?? ctx.info.root, ['spec', 'answer', second, rest.join(' ')]) });@@ -274,7 +276,7 @@ export async function specCommand(io, { first, second, rest, values }) {const row = spec.rows.find((entry) => entry.id === second);if (!row) throw new Refused('NO_ROW', `${second} is not a row in ${ctx.config.spec}`, 'list the pending questions with pullboard spec --json, then answer one of them');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]);+ if (personSigning(board).signed) requireShownRows(board, io.personRequest, [row], [second], shownDecisionRows(ctx.info.root, ctx.config, [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, 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 }]);diff --git a/src/person-row-proof.js b/src/person-row-proof.jsindex 52457d37..29395e9c 100644--- a/src/person-row-proof.js+++ b/src/person-row-proof.js@@ -25,7 +25,7 @@ export function signedRowDecisionsMatch(request, rows) {const decision = verb === 'spec-decline' ? 'decline' : 'approve';const text = verb === 'spec-answer' ? answerQuestion(shown.text, args.answer, args.row).text: args.text === undefined ? shown.text : args.text.trim();- return shown && original && kindId === id && original.id === row.id && original.text === shown.text && !original.signers?.length+ return shown && original && kindId === id && original.id === row.id && original.text === shown.text && typeof shown.source === 'string' && shown.source === row.source && !original.signers?.length&& row.decision === decision && row.text === text && row.by === 'person' && row.signature === undefined&& row.reason === (decision === 'decline' ? args.reason.trim() : '') && row.passkeyRequest === request.id&& row.replacement === rowDecisionReplacement(row.source, decision, text);@@ -51,6 +51,20 @@ export function verifiedPasskeyRowDecision(board, decision) {|| stamp?.board !== read('board_id') || stamp?.request !== request.id|| stamp?.digest !== createHash('sha256').update(request.encoded).digest('hex')|| !validPresence(stamp) || !pin || !presenceSigned(stamp, pin.publicKey) || !signedRowDecisionsMatch(request, request.result)) return false;+ const cursor = Number(read('relay_applied_sequence'));+ if (typeof request.resultMove !== 'string' || !/^[A-Za-z0-9_-]{1,100}$/u.test(request.resultMove)+ || !Number.isSafeInteger(cursor) || request.resultSequence > cursor || request.resultSequence <= request.sequence) return false;+ const receipt = JSON.parse(read('relay_receipt_' + request.resultMove) ?? 'null');+ const move = receipt && JSON.parse(receipt.move);+ if (!move || receipt.sequence !== request.resultSequence || move.id !== request.resultMove || move.operation !== 'recordRowDecisions'+ || move.personRequest?.id !== request.id || move.personRequest?.phase !== 'execute' || move.personRequest?.executor !== request.executor+ || move.personRequest?.digest !== stamp.digest || move.args?.[0]?.agentId !== 'person' || move.args?.[0]?.channel !== 'view'+ || !signedRowDecisionsMatch(request, move.args[0].decisions) || receipt.outcome?.error+ || !isDeepStrictEqual(receipt.outcome?.result, request.result)) return false;+ const committed = board.db.prepare('SELECT * FROM event WHERE event_id=?').get(decision.event);+ if (!committed || committed.event_kind !== 'row_decision' || committed.event_by !== 'person' || committed.event_at !== decision.at+ || !isDeepStrictEqual(JSON.parse(committed.event_detail).record, decisionBody(decision))+ || !receipt.outcome.events?.some(event => isDeepStrictEqual({ ...event }, { ...committed }))) return false;return request.result.some(record => record.event === decision.event && isDeepStrictEqual(decisionBody(record), decisionBody(decision)));} catch { return false; }}diff --git a/src/person-signing-cli.js b/src/person-signing-cli.jsindex eaba27d0..9a46bc4a 100644--- a/src/person-signing-cli.js+++ b/src/person-signing-cli.js@@ -179,10 +179,11 @@ export function refuseNamedSigners(rows, ids) {* @param {{ id: string, text: string }[]} rows - the spec rows, and doctrine rows as `doctrine:<id>`* @param {string[]} ids - the rows being decided*/-export function requireShownRows(board, personRequest, rows, ids) {+export function requireShownRows(board, personRequest, rows, ids, sources = []) {const record = personRequestRecords(board).find((entry) => entry.id === personRequest?.id && !entry.duplicateOf);const shown = record ? JSON.parse(record.encoded).rows : undefined;- const changed = ids.filter((id) => !Array.isArray(shown) || shown.find((row) => row.id === id)?.text !== rows.find((row) => row.id === id)?.text);+ const changed = ids.filter((id) => !Array.isArray(shown) || shown.find((row) => row.id === id)?.text !== rows.find((row) => row.id === id)?.text+ || typeof shown.find(row => row.id === id)?.source !== 'string' || shown.find(row => row.id === id)?.source !== sources.find(row => row.id === id)?.source);if (changed.length) {throw new Refused('STALE_ROW_DECISION', `${changed.join(', ')} changed after the person saw ${changed.length === 1 ? 'it' : 'them'}, or the passkey request did not show ${changed.length === 1 ? 'it' : 'them'}`,'read the rows again in the relay view and decide them again with your passkey');diff --git a/src/relay-presentation.js b/src/relay-presentation.jsindex 05b4af28..dee23291 100644--- a/src/relay-presentation.js+++ b/src/relay-presentation.js@@ -10,6 +10,9 @@ import {} from './git.js';import { Refused } from './refused.js';import { loadConfig } from './config.js';+import { loadSpec } from './spec.js';+import { loadDoctrine } from './doctrine.js';+import { shownDecisionRows } from './row-decisions.js';import { projectState } from './serve.js';import { personNeeds } from './needs.js';import { personBlockWords } from './blocks.js';@@ -48,8 +51,12 @@ function readRelayPresentation(root, providedBoard) {// The passkey device reads whether person moves are signed and which terminal-started moves wait for it [E22].const requested = new Set(personRequestRecords(board).map((record) => record.id));const personProposals = store.personProposals(board).filter((proposal) => !requested.has(proposal.id));+ const config = loadConfig(root);+ const signed = store.personSigning(board).signed;+ const ids = signed ? [...loadSpec(root, config).rows.map(row => row.id), ...loadDoctrine(root, config).repo.rows.map(row => `doctrine:${row.id}`)] : [];+ const personRows = signed ? shownDecisionRows(root, config, ids) : [];return { version: 1, state: { ...store.projectItemThreads(board, state), personRequests: personRequestStatuses(board),- personSigning: { signed: store.personSigning(board).signed }, personProposals }, config: loadConfig(root), shouts: store.allShouts(board) }; }+ personSigning: { signed }, personProposals, personRows }, config, shouts: store.allShouts(board) }; }finally { if (!providedBoard) store.closeBoard(board); }}/** Resolve one shout from the complete history carried only inside the sealed presentation. */diff --git a/src/row-decisions.js b/src/row-decisions.jsindex 22d82729..c45d0155 100644--- a/src/row-decisions.js+++ b/src/row-decisions.js@@ -35,6 +35,7 @@ import { staleRowDecision } from './row-decision-state.js';function decisionRows(root, config, ids) {const spec = loadSpec(root, config);const doctrine = loadDoctrine(root, config);+ const lines = new Map();return ids.map((reference) => {const kind = reference.startsWith('doctrine:') ? 'doctrine' : 'spec';const id = kind === 'doctrine' ? reference.slice('doctrine:'.length) : reference;@@ -42,11 +43,17 @@ function decisionRows(root, config, ids) {const matches = parsed.rows.filter((row) => row.id === id);if (matches.length !== 1) throw new Refused('NO_ROW', `${reference} names ${matches.length} repo rows; use one id from ${parsed.name}`);const file = kind === 'doctrine' ? doctrine.name : config.spec;- const source = readFileSync(join(root, file), 'utf8').split(/\r?\n/u)[matches[0].line - 1];+ if (!lines.has(file)) lines.set(file, readFileSync(join(root, file), 'utf8').split(/\r?\n/u));+ const source = lines.get(file)[matches[0].line - 1];return { kind, file, row: matches[0], source };});}+/** Capture the complete original source row a passkey confirms, including gate and required SSH signer fields. */+export function shownDecisionRows(root, config, ids) {+ return decisionRows(root, config, ids).map(({ kind, row, source }) => ({ id: kind === 'doctrine' ? `doctrine:${row.id}` : row.id, text: row.text, source }));+}+/*** Capture all source text and signatures before recording any decision on the board. An answer to* a pending question is an approval of its answered text and carries no separate answer field: the