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
feat(view): route row decisions as relay requests [H12,H5]
Corey Olsone63fc55ff527
diff --git a/src/cockpit.js b/src/cockpit.jsindex 569935e6..0c6e4cc5 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -559,6 +559,13 @@ function renderPersonRequests(project) {$('console').className = 'console' + (current.status === 'done' ? ' ok' : current.status === 'refused' ? ' no' : '');$('console').textContent = requestNotice(current);}+ const feedback = view.specFeedback;+ const rowRequest = feedback?.root === view.root && feedback.requestId && entries.find((request) => request.id === feedback.requestId);+ if (rowRequest) {+ feedback.status = rowRequest.status;+ feedback.tone = rowRequest.status === 'done' ? 'ok' : rowRequest.status === 'refused' ? 'no' : '';+ feedback.text = requestNotice(rowRequest);+ }}/** A board's sidebar counts, derived from the same API state the page displays. */@@ -1085,7 +1092,7 @@ function render() {const feedbackId = feedback && (shownRows.some((r) => r.id === feedback.id) ? feedback.id : shownRows.some((r) => r.id === feedback.next) ? feedback.next : shownRows[0]?.id);let section = null;$(kind + '-list').innerHTML = shownRows.length ? shownRows.map((r) => {- const sectionRows = !snapshot && !readOnly && kind === 'spec' && r.section !== section ? rows.filter((entry) => entry.section === r.section && undecided(entry)) : [];+ const sectionRows = !snapshot && (!readOnly || requests) && kind === 'spec' && r.section !== section ? rows.filter((entry) => entry.section === r.section && undecided(entry)) : [];const head = r.section !== section ? '<div class="spec-section-head"><h4>' + esc(r.section) + '</h4>' + (sectionRows.length ? '<button class="spec-section-approve" data-section-approve="' + esc(r.section) + '" type="button">Approve all ' + sectionRows.length + ' in this section</button>' : '') + '</div>' : '';section = r.section;const declined = kind === 'doctrine' && r.status === 'wont';@@ -1094,7 +1101,7 @@ function render() {const source = kind === 'doctrine' ? '<small class="rule-source">' + esc(ruleSource(r)) + '</small>' : '';const status = r.stage || r.status;/** Render person-only row decisions in both the list and its detail pane. */- const decisionActions = (!snapshot && !readOnly && kind === 'spec' && undecided(r))+ const decisionActions = (!snapshot && (!readOnly || requests) && kind === 'spec' && undecided(r))? '<div class="spec-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-id="' + esc(r.id) + '" type="button">Approve</button><button class="decline-row" data-row-decision="decline" data-row-id="' + esc(r.id) + '" type="button">Decline</button></div>': '';return head + (feedback && feedbackId === r.id ? specFeedback(feedback) : '') + '<div class="srow' + (view.row[kind] === r.id ? ' on' : '') + '" data-row="' + kind + ':' + esc(r.id) + '"><code>' + esc(r.id) + '</code><span><span class="chip ' + tone(r.status) + '">' + esc(status) + '</span>' + source + '</span><span>' + text + reason + decisionActions + '</span></div>';@@ -1108,7 +1115,7 @@ function render() {const reason = declined && row.reason ? '<dt>reason</dt><dd>' + linked(row.reason, titles) + '</dd>' : '';const home = kind === 'doctrine' && row && row.origin === 'standard' ? 'Standard rules come with Pullboard; override or decline one in PRACTICE.md.' : 'Rows change in ' + (kind === 'spec' ? 'SPEC.md' : 'PRACTICE.md') + ', and only you approve them.';const rowStatus = row?.stage || row?.status;- const rowDecisionActions = !snapshot && !readOnly && row && kind === 'spec' && undecided(row)+ const rowDecisionActions = !snapshot && (!readOnly || requests) && row && kind === 'spec' && undecided(row)? '<div class="spec-decision-actions detail-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-id="' + esc(row.id) + '" type="button">Approve</button><button class="decline-row" data-row-decision="decline" data-row-id="' + esc(row.id) + '" type="button">Decline</button></div>': '';$(kind + '-detail').innerHTML = row ? '<div class="stack tight"><h2><span>' + esc(row.id) + '</span>' + text + '</h2><div class="meta"><span class="chip ' + tone(row.status) + '">' + esc(rowStatus) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + source + '</div>' + rowDecisionActions + (kind === 'spec' && view.specFeedback?.root === view.root && view.specFeedback.from === 'detail' && view.specFeedback.id === row.id ? specFeedback(view.specFeedback) : '') + '<dl class="kv"><dt>section</dt><dd>' + esc(row.section) + '</dd>' + reason + (row.gate ? '<dt>gate</dt><dd>' + esc(row.gate) + '</dd>' : '') + (row.serves && row.serves.length ? '<dt>serves</dt><dd>' + esc(row.serves.join(', ')) + '</dd>' : '') + '</dl><div><h3>Items that cite it</h3>' + (citing.length ? '<div class="links">' + citing.map((i) => '<div class="links-item" data-item="' + i.id + '"><span>#' + i.id + ' ' + rich(i.title, titles) + '</span></div>').join('') + '</div>' : '<div class="muted">None yet.</div>') + '</div><div class="muted">' + home + '</div></div>' : '<div class="empty">Pick a row to see it, and the items that cite it.</div>';@@ -1334,7 +1341,7 @@ function specFeedback(feedback) {/** Record a Spec decision beside its row and retain the list's reading position (B26, N26). */async function decideSpec(command, args, anchor) {- if (snapshot) return false;+ if (snapshot || (readOnly && !requests)) return false;const root = view.root, scroll = window.scrollY;const ids = String(args.ids).split(/\s+/);const rows = [...$('spec-list').querySelectorAll('[data-row]')];@@ -1346,9 +1353,12 @@ async function decideSpec(command, args, anchor) {window.scrollTo({ top: scroll, behavior: 'instant' });try {const move = pageMove(command, args);- const result = await api(boardPath(root) + '/moves', move.body);- feedback.tone = 'ok';- feedback.text = moveMessage(move.body, result.result);+ const result = requests ? await sendPersonRequest(root, move.body) : await api(boardPath(root) + '/moves', move.body);+ const request = requests && result?.result?.request;+ if (requests && (!request?.id || !['waiting', 'done', 'refused'].includes(request.status))) throw new Error('The request did not include its status; refresh the board to check it.');+ feedback.tone = requests ? request.status === 'done' ? 'ok' : request.status === 'refused' ? 'no' : '' : 'ok';+ feedback.text = requests ? requestNotice(request) : moveMessage(move.body, result.result);+ if (requests) { feedback.requestId = request.id; feedback.status = request.status; }await refresh();} catch (error) {feedback.tone = 'no';@@ -1357,9 +1367,9 @@ async function decideSpec(command, args, anchor) {if (root === view.root && view.specFeedback === feedback) {render();window.scrollTo({ top: scroll, behavior: 'instant' });- setTimeout(() => { if (view.specFeedback === feedback) { view.specFeedback = null; render(); } }, 6000);+ if (!requests || feedback.status === 'done') setTimeout(() => { if (view.specFeedback === feedback) { view.specFeedback = null; render(); } }, 6000);}- return feedback.tone === 'ok';+ return requests ? Boolean(feedback.requestId) && feedback.status !== 'refused' : feedback.tone === 'ok';}/** Run a public API move beside its action and let only the latest one own the console and timer. */diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 2c6416b0..66e393d9 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -2712,7 +2712,8 @@ test('relay person requests stay explicit, read-only and visible [H12,H5]', { tiif (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME to run the person-request transport proof.');const box = machine();- const requestSpec = `# Person request fixture\n\n## G · Goals\n- G1 [approved, must] Existing item remains readable. | gate: test\n- G2 [draft, must] The person can approve this row. | gate: test\n`;+ const requestRows = Array.from({ length: 12 }, (_, index) => `- P${index + 1} [draft, must] Keep the reading position measurable. | gate: test`).join('\n');+ const requestSpec = `# Person request fixture\n\n## G · Goals\n- G1 [approved, must] Existing item remains readable. | gate: test\n${requestRows}\n- G2 [draft, must] The person can approve this row. | gate: test\n`;const app = project(box, 'person requests', requestSpec);box.run(app.repo, 'add', 'web', 'Existing private item', '--specs', 'G1', '--criterion', 'remains readable');box.run(app.repo, 'shout', 'person', 'Should this item ship?', '--decision');@@ -2731,9 +2732,15 @@ test('relay person requests stay explicit, read-only and visible [H12,H5]', { tiawait fetch('/request-status', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify({ id, status, error }) });await onUpdate();};+ window.__holdNextIntent = false;+ window.__releaseHeldIntent = null;return { async request(path, body) {window.__transportCalls.push({ path, body: body ?? null });if (body) {+ if (window.__holdNextIntent) {+ window.__holdNextIntent = false;+ await new Promise(resolve => { window.__releaseHeldIntent = resolve; });+ }const response = await fetch('/intent', { method: 'POST', headers: { 'content-type': 'application/json' }, body: JSON.stringify(body) });const document = await response.json();if (!response.ok) throw new Error(document.error?.message || String(response.status));@@ -2812,8 +2819,37 @@ test('relay person requests stay explicit, read-only and visible [H12,H5]', { tiawait chrome.evaluate("document.querySelector('[data-tab=\"shouts\"]').click(); document.querySelector('#shout-to').value = 'coordinator'; document.querySelector('#shout-text').value = 'Please review this item.'; document.querySelector('#shout-form').requestSubmit()");await chrome.waitFor("data?.project?.personRequests?.length === 1");assert.deepEqual(intents.at(-1), { verb: 'shout', args: { to: 'coordinator', text: 'Please review this item.' } });- assert.equal(await chrome.evaluate(`(async () => act('spec-approve', { ids: 'G2' }))()`), true);+ await chrome.evaluate("document.querySelector('[data-tab=\"spec\"]').click()");+ await chrome.waitFor("document.querySelector('#spec-list [data-row=\"spec:G2\"] button[data-row-decision=\"approve\"]')");+ assert.equal(await chrome.evaluate("document.querySelector('#spec-list [data-row=\"spec:G2\"] button[data-row-decision=\"approve\"]').getBoundingClientRect().height >= 44"), true, 'the real G2 approval control is usable at 375px');+ await chrome.evaluate("document.querySelector('#spec-list [data-row=\"spec:G2\"]').scrollIntoView({ block: 'center' })");+ await chrome.waitFor('window.scrollY > 0');+ await chrome.evaluate("document.querySelector('#spec-list [data-row=\"spec:G2\"]').click()");+ await chrome.waitFor("view.row.spec === 'G2'");+ const reading = JSON.parse(await chrome.evaluate(`JSON.stringify({ root: view.root, boardRoot: data.project.root, row: view.row.spec, scroll: window.scrollY })`));+ assert.equal(reading.root, reading.boardRoot, 'the selected spec row belongs to the displayed board');+ assert.equal(reading.row, 'G2', 'G2 is the selected reading row before approval');+ await chrome.evaluate('window.__holdNextIntent = true');+ await chrome.evaluate("document.querySelector('#spec-list [data-row=\"spec:G2\"] button[data-row-decision=\"approve\"]').click()");+ await chrome.waitFor("typeof window.__releaseHeldIntent === 'function' || document.querySelector('#spec-list .spec-feedback.no')");+ assert.equal(await chrome.evaluate("typeof window.__releaseHeldIntent"), 'function', 'the row decision reaches the sealed request transport instead of the refused generic API');+ await chrome.waitFor("document.querySelector('#spec-list .spec-feedback')?.textContent.trim() === 'Recording decision…'");+ await chrome.evaluate('window.__releaseHeldIntent()');+ await chrome.waitFor("document.querySelector('#spec-list .spec-feedback') && document.querySelector('#spec-list .spec-feedback').textContent.trim() !== 'Recording decision…'");+ assert.deepEqual(intents.at(-1), { verb: 'spec-approve', args: { ids: 'G2' } }, 'the row click creates the exact second literal intent');+ await chrome.waitFor("data?.project?.personRequests?.length === 2 && document.querySelector('[data-person-request=\"request-2\"] .request-status')?.textContent === 'Waiting'");+ assert.match(await chrome.evaluate("document.querySelector('#spec-list .spec-feedback')?.textContent.trim() || ''"), /G2/);+ const afterApproval = JSON.parse(await chrome.evaluate(`JSON.stringify({ root: view.root, row: view.row.spec, scroll: window.scrollY, selected: document.querySelector('#spec-list [data-row=\"spec:G2\"]')?.classList.contains('on'), visible: (() => { const row = document.querySelector('#spec-list [data-row=\"spec:G2\"]')?.getBoundingClientRect(); return !!row && row.top >= 0 && row.bottom <= innerHeight; })() })`));+ assert.deepEqual([afterApproval.root, afterApproval.row, afterApproval.selected], [reading.root, 'G2', true], 'the request keeps the selected board and G2 row');+ assert.ok(Math.abs(afterApproval.scroll - reading.scroll) <= 1, 'the request keeps the page at the same reading position');+ assert.equal(afterApproval.visible, true, 'G2 remains visible beside its inline feedback');assert.deepEqual(intents.at(-1), { verb: 'spec-approve', args: { ids: 'G2' } });+ assert.equal(await chrome.evaluate("data.project.spec.find(row => row.id === 'G2').decision === undefined"), true, 'waiting for a request never approves the row optimistically');+ await chrome.evaluate("window.__setPersonRequest('request-2', 'done')");+ assert.match(await chrome.evaluate("document.querySelector('#spec-list .spec-feedback')?.textContent || ''"), /^Done/, 'the same row feedback follows a matched done receipt');+ await chrome.evaluate("window.__setPersonRequest('request-2', 'refused', { code: 'REQUEST_DECLINED', message: 'Keep the row draft.', next: 'Ask the coordinator for the next step.' })");+ assert.match(await chrome.evaluate("document.querySelector('#spec-list .spec-feedback.no')?.textContent || ''"), /Refused[\s\S]*REQUEST_DECLINED[\s\S]*Keep the row draft\.[\s\S]*Ask the coordinator/, 'the same row retains the original refusal and next step');+ await chrome.evaluate("window.__setPersonRequest('request-2', 'waiting')");const ids = JSON.parse(await chrome.evaluate('JSON.stringify(data.project.personRequests.map(row => row.id))'));assert.deepEqual(ids, ['request-1', 'request-2']);@@ -2845,10 +2881,16 @@ test('relay person requests stay explicit, read-only and visible [H12,H5]', { tiawait chrome.send('Page.navigate', { url: `http://127.0.0.1:${pageServer.address().port}/without-capability` });await chrome.waitFor("typeof data === 'object' && !!data?.project && document.body?.classList.contains('read-only')");const beforeDisabled = intents.length;+ await chrome.evaluate("document.querySelector('[data-tab=\"spec\"]').click(); document.querySelector('#spec-list [data-row=\"spec:G2\"]').click()");+ await chrome.waitFor("view.row.spec === 'G2'");+ assert.equal(await chrome.evaluate(`(async () => decideSpec('spec-approve', { ids: 'G2' }, document.querySelector('#spec-list [data-row=\"spec:G2\"]')))()`), false, 'the decision handler itself refuses without request capability');+ assert.equal(await chrome.evaluate('!view.specFeedback'), true, 'a disabled decision refuses before creating decision feedback');+ assert.equal(intents.length, beforeDisabled, 'a direct no-capability decision never reaches the request transport');for (const [action, args] of allActions) assert.equal(await chrome.evaluate(`act(${JSON.stringify(action)}, ${JSON.stringify(args)})`), false, `${action} stays refused without the capability`);assert.equal(intents.length, beforeDisabled, 'read-only without the explicit request capability refuses every action');await chrome.send('Page.navigate', { url: `http://127.0.0.1:${pageServer.address().port}/snapshot` });await chrome.waitFor("typeof data === 'object' && !!data?.project && document.body?.classList.contains('snapshot')");+ assert.equal(await chrome.evaluate(`(async () => decideSpec('spec-approve', { ids: 'G2' }, null))()`), false, 'the decision handler itself refuses in a snapshot');for (const [action, args] of allActions) assert.equal(await chrome.evaluate(`act(${JSON.stringify(action)}, ${JSON.stringify(args)})`), false, `${action} stays refused in a snapshot`);assert.match(await chrome.evaluate(`(async () => { try { await api('/api/v1/boards/demo/moves', { verb: 'shout' }); return 'unexpected'; } catch (error) { return error.message; } })()`), /read-only snapshot/i);assert.equal(intents.length, beforeDisabled, 'snapshot mode cannot use the explicit request capability');