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): show merged doctrine and sources [D3,N26]
Corey Olson4aa71c544531
diff --git a/src/cockpit.js b/src/cockpit.jsindex 8fd2337b..8c34951c 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -174,6 +174,8 @@ const codeRef = (ref, before) => {return '<button class="ref" data-code="' + esc(ref) + '"' + (before ? ' data-before="' + esc(before) + '"' : '') + ' type="button" aria-expanded="' + open + '">' + esc(ref) + '</button>' + shown;};const tone = (s) => s === 'approved' ? 'ok' : s === 'pending' ? 'no' : s === 'draft' ? 'warn' : '';+/** A doctrine rule's source, with a version only when it comes from the shipped standard. */+const ruleSource = (row) => row.origin === 'standard' ? 'standard ' + row.version : 'repo';const count = (n, one, many = one) => n + ' ' + (n === 1 ? one : many);// What needs the person in a project, as its Needs-you list counts it: only the person's calls (B26),// the decisions passed up to them, spec rows waiting for them, and held lanes, which only the main@@ -689,11 +691,20 @@ function render() {$(kind + '-list').innerHTML = shownRows.length ? shownRows.map((r) => {const head = r.section !== section ? '<h4>' + esc(r.section) + '</h4>' : '';section = r.section;- return head + '<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(r.status) + '</span></span><span>' + esc(r.text) + '</span></div>';+ const declined = kind === 'doctrine' && r.status === 'wont';+ const text = declined ? '<s>' + esc(r.standardText || r.text) + '</s>' : esc(r.text);+ const reason = declined && r.reason ? '<small class="rule-reason">Reason: ' + esc(r.reason) + '</small>' : '';+ const source = kind === 'doctrine' ? '<small class="rule-source">' + esc(ruleSource(r)) + '</small>' : '';+ return head + '<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(r.status) + '</span>' + source + '</span><span>' + text + reason + '</span></div>';}).join('') : '<div class="empty">' + (rows.length ? 'No rows match.' : kind === 'spec' ? 'No spec rows yet. Each requirement is one row in SPEC.md, such as G1 [draft, must] and a line; write them, or ask an agent to, and they show up here.' : 'No practice rows yet: they live in PRACTICE.md.') + '</div>';const row = rows.find((r) => r.id === view.row[kind]);const citing = row ? p.items.filter((i) => i.specs.includes(row.id)) : [];- $(kind + '-detail').innerHTML = row ? '<div class="stack tight"><h2><span>' + esc(row.id) + '</span>' + esc(row.text) + '</h2><div class="meta"><span class="chip ' + tone(row.status) + '">' + esc(row.status) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + '</div><dl class="kv"><dt>section</dt><dd>' + esc(row.section) + '</dd>' + (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) => '<button data-go="item:' + i.id + '" type="button">#' + i.id + ' ' + esc(i.title) + '</button>').join('') + '</div>' : '<div class="muted">None yet.</div>') + '</div><div class="muted">Rows change in ' + (kind === 'spec' ? 'SPEC.md' : 'PRACTICE.md') + ', and only you approve them.</div></div>' : '<div class="empty">Pick a row to see it, and the items that cite it.</div>';+ const declined = kind === 'doctrine' && row && row.status === 'wont';+ const text = row ? declined ? '<s>' + esc(row.standardText || row.text) + '</s>' : esc(row.text) : '';+ const source = kind === 'doctrine' && row ? '<span class="chip">' + esc(ruleSource(row)) + '</span>' : '';+ const reason = declined && row.reason ? '<dt>reason</dt><dd>' + esc(row.reason) + '</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.';+ $(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(row.status) + '</span>' + (row.tier ? '<span class="chip">' + esc(row.tier) + '</span>' : '') + source + '</div><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) => '<button data-go="item:' + i.id + '" type="button">#' + i.id + ' ' + esc(i.title) + '</button>').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>';}if (keep('pb.flow') !== 'hidden') $('flow').innerHTML = flowSvg(p);diff --git a/src/serve.js b/src/serve.jsindex 044fdf2c..b3d57d62 100644--- a/src/serve.js+++ b/src/serve.js@@ -15,6 +15,7 @@ import { dirname, join } from 'node:path';import * as store from './board.js';import { cockpitPage } from './cockpit.js';import { COORDINATOR, loadConfig } from './config.js';+import { loadDoctrine, standardDoctrine } from './doctrine.js';import { repoInfo, resolveCommit } from './git.js';import { productSummaries } from './products.js';import { registryFile } from './projects.js';@@ -90,6 +91,10 @@ export function projectState(root, { seen = null } = {}) {const all = store.listItems(board, { all: true });const status = new Map(all.map((item) => [item.item_id, item.item_status]));const rows = (file) => loadSpec(info.root, { ...config, spec: file }).rows.map(({ id, status: state, tier, text, gate, serves, section }) => ({ id, status: state, tier, text, gate, serves, section }));+ const doctrine = loadDoctrine(info.root, config);+ // A decline's text is its reason. Keep the inherited rule available so the page strikes the+ // rule itself, while showing the repo's reason beside it.+ const inherited = new Map(standardDoctrine().rows.map((row) => [row.id, row.text]));const verdict = (row) => ({ decision: row.verdict_decision, reason: row.verdict_reason, note: row.verdict_note, by: row.verdict_by, at: row.verdict_at, commit: row.verdict_commit });const log = store.events(board);// When each agent last moved on the board: the log is in order, so the last write wins.@@ -135,7 +140,10 @@ export function projectState(root, { seen = null } = {}) {agents: store.listAgents(board).map((agent) => ({ ...agent, lastMoveAt: lastMove.get(agent.agent_id) ?? null })),holds: store.laneHolds(board),spec: rows(config.spec),- practice: rows(config.practice),+ practice: doctrine.rows.map(({ id, status: state, tier, text, gate, serves, section, origin, version, reason }) => ({+ id, status: state, tier, text, gate, serves, section, origin, version, reason,+ ...(state === 'wont' && inherited.has(id) ? { standardText: inherited.get(id) } : {}),+ })),unseen: seen === null ? null : { since: seen, count: board.db.prepare('SELECT COUNT(*) AS n FROM shout WHERE shout_id > ?').get(seen).n },// Each product's progress, counted as pullboard status counts it (N28).products: productSummaries(config, loadSpec(info.root, config), all),diff --git a/src/view.css b/src/view.cssindex f830e067..fc6c72fb 100644--- a/src/view.css+++ b/src/view.css@@ -253,6 +253,8 @@ input:disabled { background: var(--surface-2); color: var(--ink-muted); }.srow:hover { background: var(--surface-2); }.srow.on { background: var(--accent-soft); }.srow code { font: 600 12px var(--mono); }+.rule-source, .rule-reason { display: block; color: var(--ink-muted); font-size: 11.5px; line-height: 1.5; }+.rule-reason { margin-top: 3px; }@media (width < 480px) { .srow { grid-template-columns: auto minmax(0, 1fr); } .srow > span:last-child { grid-column: 1 / -1; } }.flow { position: relative; margin: 0 0 12px; padding: 10px 12px 8px; overflow-x: auto; }.flow svg { display: block; width: 100%; min-width: 680px; max-width: 920px; height: auto; margin: 0 auto; }diff --git a/test/cockpit.test.js b/test/cockpit.test.jsindex 5d37565a..4deef8c7 100644--- a/test/cockpit.test.js+++ b/test/cockpit.test.js@@ -12,6 +12,7 @@ import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';import vm from 'node:vm';+import { loadDoctrine } from '../src/doctrine.js';import { MACHINE } from '../src/machine.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');@@ -1774,6 +1775,51 @@ test('times say which day they were [N26]', async () => {}});+test('the doctrine view carries and labels inherited, local, overridden and declined rules [D3,N26]', async () => {+ const box = machine();+ const alpha = project(box, 'alpha', SPEC, { practice: 'ways.md' });+ writeFileSync(join(alpha.repo, 'ways.md'), '# Local rules\n\n## Team\n- R1 [approved, must] Keep <b>local</b> evidence. | gate: review\n- PB2 [approved, must] Deletion needs <i>two</i> approvals. | gate: review\n- PB8 [wont] No <script>persistent</script> data is stored.\n');+ const view = await startView(box);+ try {+ const page = await openPage(view, { width: 375 });+ const state = JSON.parse(page.run('JSON.stringify(data.project)'));+ const merged = loadDoctrine(alpha.repo, { practice: 'ways.md' });+ /** Compare the merged reader's row fields without the view's extra display text. */+ const fields = ({ id, status, tier, text, gate, serves, section, origin, version, reason }) => ({ id, status, tier, text, gate, serves, section, origin, version, reason });+ assert.deepEqual(state.practice.map(fields), merged.rows.map(fields), 'state carries the exported merged doctrine, including every source and reason');+ assert.equal(state.practice.length, 13, 'twelve standard ids with two replaced, plus one local id');+ assert.equal(state.practice.filter((row) => row.id === 'PB2').length, 1);+ assert.equal(state.practice.filter((row) => row.id === 'PB8').length, 1);+ assert.equal(state.practice.find((row) => row.id === 'PB8').standardText, 'No secrets or sensitive info in the repo; test data is synthetic.');+ await page.click({ tab: 'doctrine' });+ const list = page.show('doctrine-list');+ assert.match(list, /data-row="doctrine:PB1"[^]*?<small class="rule-source">standard 1<\/small>/);+ assert.match(list, /data-row="doctrine:R1"[^]*?<small class="rule-source">repo<\/small>[^]*?Keep <b>local<\/b> evidence\./);+ assert.match(list, /data-row="doctrine:PB2"[^]*?<small class="rule-source">repo<\/small>[^]*?Deletion needs <i>two<\/i> approvals\./);+ assert.doesNotMatch(list, /Destructive or irreversible actions wait/);+ assert.match(list, /data-row="doctrine:PB8"[^]*?<small class="rule-source">repo<\/small>[^]*?<s>No secrets or sensitive info in the repo; test data is synthetic\.<\/s><small class="rule-reason">Reason: No <script>persistent<\/script> data is stored\.<\/small>/);+ assert.doesNotMatch(list, /<script>|<i>two<\/i>|<b>local<\/b>/, 'all repo text stays text');+ const style = await styleOf(view);+ assert.match(style, /\.rule-source, \.rule-reason \{ display: block; color: var\(--ink-muted\);/, 'labels and reasons remain separate readable lines');++ await page.click({ row: 'doctrine:PB1' });+ assert.match(page.show('doctrine-detail'), /<span class="chip">standard 1<\/span>/);+ await page.click({ row: 'doctrine:PB2' });+ assert.match(page.show('doctrine-detail'), /<span class="chip">repo<\/span>/);+ assert.match(page.show('doctrine-detail'), /Deletion needs <i>two<\/i> approvals\./);+ await page.click({ row: 'doctrine:PB8' });+ assert.match(page.show('doctrine-detail'), /<s>No secrets or sensitive info in the repo; test data is synthetic\.<\/s>/);+ assert.match(page.show('doctrine-detail'), /<dt>reason<\/dt><dd>No <script>persistent<\/script> data is stored\.<\/dd>/);++ writeFileSync(join(alpha.repo, 'ways.md'), '# Local rules\n\n## Team\n- R1 [approved, must] Keep newer evidence. | gate: review\n');+ await page.run('seen = ""; refresh()');+ assert.match(page.show('doctrine-list'), /Destructive or irreversible actions wait/);+ assert.doesNotMatch(page.show('doctrine-list'), /Deletion needs|rule-reason|<s>/, 'removing repo overrides restores the inherited rules');+ } finally {+ await view.stop();+ }+});+test('spec rows read across a phone [N26]', async () => {const box = machine();const alpha = project(box, 'alpha');@@ -1793,7 +1839,9 @@ test('spec rows read across a phone [N26]', async () => {const rows = (html) => html.split('<div class="srow').slice(1);const shape = /^[^>]*><code>[^<]+<\/code><span><span class="chip[^"]*">[^<]+<\/span><\/span><span>[^<]+<\/span><\/div>/;assert.deepEqual(rows(page.show('spec-list')).map((row) => /data-row="spec:([^"]+)"/.exec(row)[1]), ['G1', 'G2']);- for (const row of [...rows(page.show('spec-list')), ...rows(page.show('doctrine-list'))]) assert.match(row, shape);+ for (const row of rows(page.show('spec-list'))) assert.match(row, shape);+ const doctrineShape = /^[^>]*><code>[^<]+<\/code><span><span class="chip[^"]*">[^<]+<\/span><small class="rule-source">(?:standard 1|repo)<\/small><\/span><span>[^<]+<\/span><\/div>/;+ for (const row of rows(page.show('doctrine-list'))) assert.match(row, doctrineShape, 'the source fits inside the status column, keeping the same three-column structure');assert.ok(rows(page.show('doctrine-list')).length > 0, 'doctrine rows are drawn the same way');} finally {await view.stop();