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.

feat(view): show agent approval decisions [S1,B26,P6,N26]

Corey Olson8db3586dd128
diff --git a/src/cockpit.js b/src/cockpit.js
index b17a2813..44d0a9d7 100644
--- a/src/cockpit.js
+++ b/src/cockpit.js
@@ -38,6 +38,7 @@ import { pageScriptPart1 } from './view/page-script-1.js';
import { pageScriptPart2 } from './view/page-script-2.js';
import { pageScriptPart3 } from './view/page-script-3.js';
import { pageScriptPart4 } from './view/page-script-4.js';
+import { agentApprovalScript } from './view/agent-approval.js';
import { historyLoadingScript } from './view/history-loading.js';
/** The CLI's default phrases, ordered by depth for the existing prose inventory guard. */
@@ -1103,17 +1104,18 @@ function render() {
// on the board with who holds it; it is the agents' to move.
const personalNeeds = personNeeds(p);
// Adapt display targets and the existing hold age without reimplementing which calls belong here.
- const needs = personalNeeds.filter((row) => !['draft', 'rigor-draft', 'sentinel-draft'].includes(row.kind)).map((row) => row.kind === 'decision'
+ const needs = personalNeeds.filter((row) => !['draft', 'rigor-draft', 'sentinel-draft', 'agent-approved'].includes(row.kind)).map((row) => row.kind === 'decision'
? ['decide:' + row.id, row.ref, row.text, 'decide', row.at]
: row.kind === 'pending' ? ['spec:' + row.id, row.ref, row.text, 'answer ' + row.ref] // the person's words; agents get the command (#875)
: ['tab:shouts', row.ref, row.text, row.what, p.holds.find((hold) => hold.hold_lane === row.id)?.hold_at]);
const drafts = personalNeeds.find((row) => row.kind === 'draft')?.count ?? 0;
const rigorDrafts = personalNeeds.filter((row) => row.kind === 'rigor-draft');
const sentinelDrafts = personalNeeds.filter((row) => row.kind === 'sentinel-draft');
+ const agentApprovals = personalNeeds.filter((row) => row.kind === 'agent-approved');
// Each of the person's calls is a row at the head of Active, shaped like an item: what it is first, then NEEDS YOU and
// its kind where an item has its lane, and what to do at the right. Every call is a row; the draft rows are one row
// with their count. Read-only, a row is its words, opening nothing.
- $('needs').hidden = (!needs.length && !drafts && !rigorDrafts.length && !sentinelDrafts.length) || view.state !== 'active' || Boolean(view.lane);
+ $('needs').hidden = (!needs.length && !drafts && !rigorDrafts.length && !sentinelDrafts.length && !agentApprovals.length) || view.state !== 'active' || Boolean(view.lane);
const needRow = ([target, ref, text, what, at], kind, action) => '<li class="row ask"' + (readOnly ? '' : ' data-go="' + esc(target) + '"') + '><span class="dot ask"></span><div><div class="t">' + (ref ? '<span>' + esc(ref) + '</span>' : '') + rich(text, titles, !readOnly) + '</div>'
+ (at ? '<span class="row-age">' + age(at) + '</span>' : '') + '<div class="meta"><span class="why"><b>NEEDS YOU</b> ' + esc(kind) + '</span></div></div><span class="chip warn">' + esc(action) + '</span></li>';
const needKind = (entry) => entry[3] === 'decide' ? needRow([entry[0], '', entry[2], entry[3], entry[4]], 'a decision, asked by ' + entry[1], 'decide')
@@ -1121,6 +1123,7 @@ function render() {
$('needs').innerHTML = needs.map(needKind).join('')
+ rigorDrafts.map(row => needRow([row.target, row.ref, row.text], 'a proved Rigor draft', 'Approve or Decline')).join('')
+ sentinelDrafts.map(row => sentinelDraftRow(row)).join('')
+ + agentApprovals.map(row => agentApprovalRow(row)).join('')
+ (drafts ? needRow(['tab:spec', String(drafts), 'draft spec rows to approve or drop'], 'Spec rows waiting on you', 'review') : '');
const lanes = p.lanes;
@@ -1450,7 +1453,7 @@ function render() {
* it, so it stays closed across reloads, and across restarts of the view, which serves from the
* same address again, until they open it. While hidden it is not drawn.
*/
-${pageScriptPart4(pageScope)}${historyLoadingScript()}</script>
+${agentApprovalScript()}${pageScriptPart4(pageScope)}${historyLoadingScript()}</script>
</body>
</html>`;
}
diff --git a/src/view.css b/src/view.css
index 29bdcd3f..f7b96cf1 100644
--- a/src/view.css
+++ b/src/view.css
@@ -1007,3 +1007,7 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }
.hosted-page.loading .shell { display: none; }
.hosted-page.loading .hosted-mark { display: grid; place-items: center; min-height: 100vh; color: var(--ink-muted); }
.hosted-page.loading .hosted-mark svg { width: 56px; height: 56px; }
+
+/* Approval provenance is literal text, including an unabridged commit on a phone. */
+.agent-approval p { margin: 6px 0; overflow-wrap: anywhere; }
+.agent-approval .actions { display: flex; flex-wrap: wrap; gap: 8px; }
diff --git a/src/view/agent-approval.js b/src/view/agent-approval.js
new file mode 100644
index 00000000..9b5aab0e
--- /dev/null
+++ b/src/view/agent-approval.js
@@ -0,0 +1,19 @@
+/** Render core-projected agent approval calls without inferring who approved a row [S1,B26,P6,N26]. */
+
+/** Embed a Needs-you row renderer that reuses the existing person decision pipeline. */
+export function agentApprovalScript() {
+ return `
+/** Render literal core attribution, with only core-advertised person moves. */
+function agentApprovalRow(row) {
+ const person = !snapshot && (!readOnly || requests);
+ const allowed = verb => person && Array.isArray(row.actions) && row.actions.some(action => action.verb === verb && action.args?.ids === row.id);
+ const button = (decision, label) => '<button type="button" data-row-kind="spec" data-row-id="' + esc(row.id) + '" data-row-decision="' + decision + '">' + label + '</button>';
+ const feedback = view.specFeedback?.root === view.root && view.specFeedback.kind === 'spec' && view.specFeedback.id === row.id ? view.specFeedback : null;
+ const controls = (allowed('spec-approve') ? button('approve', 'Confirm') : '') + (allowed('spec-decline') ? button('decline', 'Decline') : '');
+ return '<li class="row ask agent-approval" data-agent-approved="' + esc(row.id) + '"><span class="dot ask"></span><div><div class="t"><span>' + esc(row.ref ?? row.id) + '</span>agent-approved</div>'
+ + '<p>' + esc(row.attribution ?? 'Attribution unavailable') + ': ' + esc(row.agent ?? 'unknown') + '</p><p>Commit: <code>' + esc(row.commit ?? 'unavailable') + '</code></p>'
+ + (feedback ? specFeedback(feedback) : '')
+ + '<div class="meta"><span class="why"><b>NEEDS YOU</b> confirm or decline this row</span></div></div>' + (controls ? '<div class="actions">' + controls + '</div>' : '') + '</li>';
+}
+`;
+}
diff --git a/test/cockpit/agent-approval-fixture.js b/test/cockpit/agent-approval-fixture.js
new file mode 100644
index 00000000..424a7234
--- /dev/null
+++ b/test/cockpit/agent-approval-fixture.js
@@ -0,0 +1,94 @@
+/** Real standalone API authority for agent-approved row browser proofs [A9,B26,P6]. */
+import assert from 'node:assert/strict';
+import { join } from 'node:path';
+import { startFixtureChild } from '../fixture-child.js';
+import { fetchLive } from './fixture.js';
+
+/** Start the real private API, whose session key grants board access but no person channel. */
+export async function approvalAgentApi(box, root) {
+ const bin = join(import.meta.dirname, '../../bin/pullboard.js');
+ const child = startFixtureChild(process.execPath, [bin, 'serve', '--port', '0'], { cwd: root, env: box.env });
+ child.stderr.resume();
+ let stopPromise;
+ /** Stop only this fixture-owned server and wait for its process to exit. */
+ const stop = () => {
+ if (!stopPromise) stopPromise = new Promise(done => {
+ if (child.exitCode !== null || child.signalCode !== null) return done();
+ child.once('exit', done);
+ child.kill('SIGTERM');
+ });
+ return stopPromise;
+ };
+ let url;
+ try {
+ url = await new Promise((resolve, reject) => {
+ let output = '';
+ // Startup hang ceiling for a private process and socket, not a performance claim.
+ const timer = setTimeout(() => reject(new Error('private agent API did not publish its address')), 15_000);
+ child.once('exit', code => { clearTimeout(timer); reject(new Error('private agent API exited ' + code)); });
+ child.stdout.on('data', chunk => {
+ output += chunk;
+ const found = /Pullboard API v1: (http:\/\/127\.0\.0\.1:\d+\/api\/v1\/boards\?k=\S+)/u.exec(output);
+ if (found) { clearTimeout(timer); resolve(new URL(found[1])); }
+ });
+ });
+ } catch (error) { await stop(); throw error; }
+ const headers = { 'x-pullboard-key': url.searchParams.get('k') };
+ /** Exercise the actual HTTP authentication and person-channel refusal with this agent key. */
+ const call = async (path, body) => {
+ const response = await fetchLive(url.origin + path, {
+ method: body === undefined ? 'GET' : 'POST',
+ headers: { ...headers, ...(body === undefined ? {} : { 'content-type': 'application/json' }) },
+ ...(body === undefined ? {} : { body: JSON.stringify(body) }),
+ });
+ const document = await response.json();
+ return { status: response.status, document };
+ };
+ try {
+ const listed = await call('/api/v1/boards');
+ assert.equal(listed.status, 200);
+ return { call, stop };
+ } catch (error) { await stop(); throw error; }
+}
+
+/** Hold actual HTTP state responses in DevTools, without modifying requests, auth or payloads. */
+export async function approvalReadGate(chrome, origin) {
+ let holding = false;
+ const held = [];
+ const observers = new Set();
+ const failures = [];
+ /** Continue an unchanged network response, retaining unexpected interception failures. */
+ const proceed = requestId => chrome.send('Fetch.continueResponse', { requestId }).catch(error => { failures.push(error.message); });
+ /** Delay only read responses; person POSTs still reach the actual backend immediately. */
+ const listener = ({ data }) => {
+ const message = JSON.parse(String(data));
+ if (message.method !== 'Fetch.requestPaused') return;
+ const { requestId } = message.params;
+ if (holding) { held.push(requestId); for (const observe of observers) observe(); }
+ else void proceed(requestId);
+ };
+ chrome.socket.addEventListener('message', listener);
+ try {
+ await chrome.send('Fetch.enable', { patterns: [{ urlPattern: origin + '/api/v1/boards/*/state*', requestStage: 'Response' }] });
+ } catch (error) { chrome.socket.removeEventListener('message', listener); throw error; }
+ /** Release the real responses only after the isolated spec has been restored. */
+ const release = async () => {
+ holding = false;
+ await Promise.all(held.splice(0).map(proceed));
+ assert.deepEqual(failures, [], 'read gate continues original HTTP responses unchanged');
+ };
+ /** Require a real response to be paused, with a bounded hang ceiling and no fabricated read. */
+ const waitForHeld = () => new Promise((resolve, reject) => {
+ if (held.length) return resolve(held.length);
+ const observe = () => { clearTimeout(timer); observers.delete(observe); resolve(held.length); };
+ // Fixture coordination hang ceiling, not a response-time performance requirement.
+ const timer = setTimeout(() => { observers.delete(observe); reject(new Error('no actual state response entered the read gate')); }, 10_000);
+ observers.add(observe);
+ });
+ /** Unlock every held read and remove only this fixture's DevTools interception. */
+ const close = async () => {
+ try { await release(); }
+ finally { await chrome.send('Fetch.disable'); chrome.socket.removeEventListener('message', listener); }
+ };
+ return { hold: () => { holding = true; }, heldCount: () => held.length, waitForHeld, release, close };
+}
diff --git a/test/cockpit/needs.test.js b/test/cockpit/needs.test.js
index 0ee747a2..6017f315 100644
--- a/test/cockpit/needs.test.js
+++ b/test/cockpit/needs.test.js
@@ -1,15 +1,27 @@
/** @pullboard-test-input source-tree */
/** Cockpit needs checks, using the shared real-board fixtures [N26]. */
import assert from 'node:assert/strict';
-import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
+import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { createServer } from 'node:http';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { test } from 'node:test';
import { SPEC, machine, project, build, sendBack, startView, styleOf, element, openPage, projectRows, agentEntries, needEntries, itemRow, shoutNameText, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, chooseFilter, boardId, boardOf, fetchLive, serveFolder } from './fixture.js';
import { cockpitPage } from '../../src/cockpit.js';
+import { runFixtureChild } from '../fixture-child.js';
+import { approvalAgentApi, approvalReadGate } from './agent-approval-fixture.js';
import { personNeeds } from '../../src/needs.js';
+/** Confirm the fixture's baseline approvals through the real person-view channel. */
+async function confirmBaseline(view, repo) {
+ const id = await boardId(view, repo);
+ const reply = await fetchLive(view.base + '/api/v1/boards/' + id + '/moves', {
+ method: 'POST', headers: { 'content-type': 'application/json', 'x-pullboard-key': view.key },
+ body: JSON.stringify({ verb: 'spec-approve', args: { ids: 'G1,G2' } }),
+ });
+ assert.equal(reply.status, 200, 'the real private view confirms the baseline G1/G2 approvals');
+}
+
test('every Needs-you surface follows the shared builder [N26,A9]', async () => {
const box = machine();
const alpha = project(box, 'builder substitution', `${SPEC}- G3 [pending] Raw board question. | gate: review\n- G4 [draft, aim] Raw board draft. | gate: review\n`);
@@ -17,6 +29,7 @@ test('every Needs-you surface follows the shared builder [N26,A9]', async () =>
box.run(alpha.repo, 'hold', 'web', '--reason', 'Raw board hold');
const view = await startView(box);
try {
+ await confirmBaseline(view, alpha.repo);
const page = await openPage(view);
const calls = [
{ kind: 'decision', id: 701, ref: 'reviewer', text: 'Builder decision one?', what: 'decision' },
@@ -68,6 +81,7 @@ test("the page's Needs-you comes from the shared builder [N26]", { timeout: 180_
let snapshotHost, relayServer, chrome;
const profiles = [];
try {
+ await confirmBaseline(view, alpha.repo);
const id = await boardId(view, alpha.repo);
const approved = await fetchLive(view.base + '/api/v1/boards/' + id + '/moves', {
method: 'POST', headers: { 'content-type': 'application/json', 'x-pullboard-key': view.key },
@@ -245,6 +259,7 @@ test("needs-you holds only the person's calls; the rest show on the board with w
box.run(alpha.repo, 'hold', 'web', '--reason', 'G3 is open');
const view = await startView(box);
try {
+ await confirmBaseline(view, alpha.repo);
const page = await openPage(view);
const needs = page.show('needs');
assert.deepEqual(needEntries(needs).map(([go, ref, words]) => [go.split(':')[0], ref, words]), [
@@ -277,9 +292,10 @@ test("needs-you holds only the person's calls; the rest show on the board with w
test('needs-you lines keep their titles on a phone [N26]', async () => {
const box = machine();
- project(box, 'alpha', `${SPEC}- G3 [pending] Should a greeting with a title long enough to need the room wrap? | gate: review\n`);
+ const alpha = project(box, 'alpha', `${SPEC}- G3 [pending] Should a greeting with a title long enough to need the room wrap? | gate: review\n`);
const view = await startView(box);
try {
+ await confirmBaseline(view, alpha.repo);
const page = await openPage(view, { width: 375 });
const style = await styleOf(view);
// A need is an item's row: its reference and words on the title line, NEEDS YOU and its kind below, its action at the right.
@@ -335,6 +351,7 @@ test('needs you and the asks sit in their lists [N26]', { timeout: 180_000 }, as
})())`));
const click = (selector) => chrome.click(`document.querySelector(${JSON.stringify(selector)})`);
try {
+ await confirmBaseline(view, alpha.repo);
chrome = await openSnapshotChrome(executable, view.link.href, profile);
await chrome.waitFor("typeof data === 'object' && data?.project?.decisions?.length === 1 && data.project.asked.length === 1 && data.project.holds.length === 1");
for (const scheme of ['light', 'dark']) {
@@ -426,3 +443,98 @@ test('needs you and the asks sit in their lists [N26]', { timeout: 180_000 }, as
await view.stop();
}
});
+
+
+test('an agent-approved row shows in Needs you with its agent and commit and a confirm and decline move [S1,B26,P6,N26]', { timeout: 120_000 }, async () => { // budget: isolated real Git/API setup and two owned browser profiles, not a performance claim.
+ const box = machine();
+ box.env.GIT_AUTHOR_NAME = 'Agent & \"unconfirmed\" seat';
+ const alpha = project(box, 'agent approval');
+ const view = await startView(box);
+ let chrome, snapshotHost, agentApi, reads;
+ try {
+ const initial = await boardOf(view, alpha.repo);
+ const flagged = initial.needs.filter(row => row.kind === 'agent-approved');
+ assert.deepEqual(flagged.map(row => row.id), ['G1', 'G2']);
+ const page = await openPage(view);
+ for (const row of flagged) {
+ assert.ok(page.show('needs').includes(`data-agent-approved="${row.id}"`), 'agent-approved calls have their own Needs-you row');
+ assert.equal(row.agent, 'Agent & \"unconfirmed\" seat');
+ assert.ok(page.show('needs').includes('Agent &amp; &quot;unconfirmed&quot; seat'), 'author text is escaped rather than promoted into markup');
+ assert.ok(page.show('needs').includes(row.commit));
+ assert.ok(page.show('needs').includes(row.attribution));
+ }
+ assert.match(page.show('needs'), />Confirm</u);
+ assert.match(page.show('needs'), />Decline</u);
+ const executable = chromeExecutable();
+ assert.ok(executable, 'Chrome is required to prove real person clicks and read-only agent viewing');
+ agentApi = await approvalAgentApi(box, alpha.repo);
+ const id = await boardId(view, alpha.repo);
+ const agentState = await agentApi.call('/api/v1/boards/' + id + '/state');
+ assert.equal(agentState.status, 200, 'an API-key reader can see the flagged rows');
+ for (const verb of ['spec-approve', 'spec-decline']) {
+ const attempt = await agentApi.call('/api/v1/boards/' + id + '/moves', { verb, args: { ids: 'G1', ...(verb === 'spec-decline' ? { reason: 'An agent must not decide this.' } : {}) } });
+ assert.equal(attempt.status, 409);
+ assert.equal(attempt.document.error.code, 'B26_PERSON_CHANNEL');
+ }
+ assert.ok((await boardOf(view, alpha.repo)).needs.some(row => row.kind === 'agent-approved' && row.id === 'G1'), 'refused agent writes leave the call unchanged');
+ const output = join(box.dir, 'agent-read-only');
+ box.run(alpha.repo, 'view', '--export', output);
+ snapshotHost = await serveFolder(output, '/agent/');
+ chrome = await openSnapshotChrome(executable, snapshotHost.base + '/agent/', join(box.dir, 'agent-approval-readonly-chrome'));
+ await chrome.waitFor('document.querySelectorAll("#needs [data-agent-approved]").length === 2');
+ const agentRows = await chrome.stable('document.querySelector("#needs").innerHTML');
+ assert.match(agentRows, /agent-approved/u);
+ assert.doesNotMatch(agentRows, /data-row-decision|<button/u, 'a read-only reader sees attribution without a person move');
+ await closeSnapshotChrome(chrome); chrome = null;
+ const refused = runFixtureChild(process.execPath, [join(import.meta.dirname, '../../bin/pullboard.js'), 'spec', 'approve', 'G1', '--json'], {
+ cwd: alpha.web, env: { ...box.env, CLAUDECODE: '1' }, encoding: 'utf8',
+ });
+ assert.equal(refused.status, 1);
+ assert.equal(JSON.parse(refused.stdout).error.code, 'B26_PERSON_CHANNEL');
+ chrome = await openSnapshotChrome(executable, 'about:blank', join(box.dir, 'agent-approval-person-chrome'));
+ reads = await approvalReadGate(chrome, view.base);
+ await chrome.send('Page.navigate', { url: view.link.href });
+ await chrome.waitFor('document.querySelectorAll("#needs [data-agent-approved]").length === 2');
+ await chrome.click(`document.querySelector('[data-agent-approved="G1"] [data-row-decision="approve"]')`);
+ await chrome.waitFor('document.querySelector(\'[data-agent-approved="G1"]\') === null');
+ const confirmed = await boardOf(view, alpha.repo);
+ assert.equal(confirmed.spec.find(row => row.id === 'G1').agentApproval, null);
+ assert.equal(confirmed.needs.some(row => row.kind === 'agent-approved' && row.id === 'G1'), false);
+ await chrome.click(`document.querySelector('[data-agent-approved="G2"] [data-row-decision="decline"]')`);
+ await chrome.waitFor('document.querySelector("#spec-decline-dialog").hidden === false');
+ await chrome.click('document.querySelector("#spec-decline-cancel")');
+ assert.ok((await boardOf(view, alpha.repo)).needs.some(row => row.kind === 'agent-approved' && row.id === 'G2'), 'cancelling records no decision');
+ const specFile = join(alpha.repo, 'SPEC.md');
+ const specText = readFileSync(specFile, 'utf8');
+ reads.hold();
+ try {
+ await chrome.stable('void refresh(); true');
+ await reads.waitForHeld();
+ assert.ok(reads.heldCount() > 0, 'an actual state HTTP response is withheld during the stale-row refusal');
+ writeFileSync(specFile, specText.split('\n').filter(line => !line.startsWith('- G2 ')).join('\n'));
+ await chrome.click(`document.querySelector('[data-agent-approved="G2"] [data-row-decision="approve"]')`);
+ await chrome.waitFor('document.querySelector(\'[data-agent-approved="G2"] .spec-feedback.no\') !== null');
+ const refusal = await chrome.stable('document.querySelector(\'[data-agent-approved="G2"] .spec-feedback.no\').textContent');
+ assert.match(refusal, /G2/u, 'the actual backend refusal is visible beside the initiating Needs-you row');
+ assert.ok(reads.heldCount() > 0, 'real state responses remain held until refusal is observed and SPEC is restored');
+ } finally { writeFileSync(specFile, specText); await reads.release(); }
+ await chrome.stable('refresh()');
+ await chrome.waitFor('document.querySelector(\'[data-agent-approved="G2"]\') !== null');
+ await chrome.click(`document.querySelector('[data-agent-approved="G2"] [data-row-decision="decline"]')`);
+ await chrome.click('document.querySelector("#spec-decline-reason")');
+ await chrome.send('Input.insertText', { text: 'The person declines this unconfirmed requirement.' });
+ await chrome.click('document.querySelector("#spec-decline-submit")');
+ await chrome.waitFor('document.querySelector(\'[data-agent-approved="G2"]\') === null');
+ const declined = await boardOf(view, alpha.repo);
+ const row = declined.spec.find(entry => entry.id === 'G2');
+ assert.equal(row.decision.decision, 'decline');
+ assert.match(row.decision.reason, /person declines/u);
+ assert.equal(declined.needs.some(entry => entry.kind === 'agent-approved' && entry.id === 'G2'), false);
+ } finally {
+ const cleanupErrors = [];
+ for (const cleanup of [() => reads?.close(), () => chrome && closeSnapshotChrome(chrome), () => snapshotHost?.close(), () => agentApi?.stop(), () => view.stop()]) {
+ try { await cleanup(); } catch (error) { cleanupErrors.push(error); }
+ }
+ if (cleanupErrors.length) throw new AggregateError(cleanupErrors, 'owned approval fixtures failed cleanup');
+ }
+});