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): share item rows with spec and doctrine [N26]
Corey Olson41e9f1b949e3
diff --git a/src/cockpit.js b/src/cockpit.jsindex 02670155..d10cab19 100644--- a/src/cockpit.js+++ b/src/cockpit.js@@ -381,10 +381,14 @@ function factCodeRef(ref) {return ref.path + ':' + lines + '@' + ref.commit;}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. */-// Where a rule comes from, in words: Pullboard's standard rules, or this repo's own; the standard's version is on hover.-const ruleSource = (row) => row.origin === 'standard' ? 'From Pullboard' : 'This repo';-const ruleSourceTitle = (row) => row.origin === 'standard' ? 'Pullboard standard rules, version ' + row.version : 'Written in this repo';+/** Name a rule's actual packaged version or its repository source, including explicit overrides. */+const ruleSource = (row) => row.standardVersion != null ? 'Pullboard v' + row.standardVersion + (row.overrides ? row.status === 'wont' ? ', declined here' : ', overridden here' : '') : 'this repo';+/** Keep the full source label available when a narrow row clips it. */+const ruleSourceTitle = (row) => ruleSource(row);+/** Render the two-line record shared by Items, Spec and Doctrine, with one grid and type hierarchy. */+function recordRow({ tag = 'li', classes = '', attributes, title, state, primary, secondary, rightTop = '', rightBottom = '' }) {+ return '<' + tag + ' class="' + (tag === 'div' ? 'srow ' : '') + 'row s-' + state + (classes ? ' ' + classes.trim() : '') + '" ' + attributes + ' title="' + esc(title) + '"><span class="dot ' + state + '"></span><div><div class="t srow-text">' + primary + '</div>' + (rightTop ? '<span class="row-age">' + rightTop + '</span>' : '') + '<div class="meta">' + secondary + '</div></div>' + rightBottom + '</' + tag + '>';+}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@@ -1435,11 +1439,11 @@ function render() {const tag = s === 'building' && i.owner ? '<span class="chip busy" title="building, held by ' + esc(agentName(i.owner)) + '">' + esc(agentName(i.owner)) + '</span>': s === 'verify' && i.reviewer ? '<span class="chip warn" title="reviewing until ' + esc(when(i.reviewUntil)) + '">' + esc(agentName(i.reviewer)) + ' reviewing</span>': s === 'open' ? openChip(i) : chip(s);- return '<li class="row s-' + s + (view.item === i.id ? ' on' : '') + (gated ? ' gated' : '') + '" data-item="' + i.id + '" title="' + esc(i.title) + '"><span class="dot ' + s + '"></span><div><div class="t"><span>#' + i.id + '</span>' + rich(i.title, titles) + '</div><span class="row-age">' + age(i.updatedAt) + '</span><div class="meta">'+ return recordRow({ classes: (view.item === i.id ? 'on ' : '') + (gated ? 'gated ' : ''), attributes: 'data-item="' + i.id + '"', title: i.title, state: s,+ primary: '<span>#' + i.id + '</span>' + rich(i.title, titles), rightTop: age(i.updatedAt), rightBottom: tag,// A rejected row's second line is its verdict; any other row's is its lane and the spec ids it serves.- + (rejected(i) ? '<span class="why"><b>' + esc(i.verdict.reason) + '</b> ' + linked(firstLine(visibleVerdictNote(i.verdict.reason, i.verdict.note)), titles) + '</span>'- : '<span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span class="specs" title="' + esc(i.specs.join(', ')) + '">' + esc(i.specs.slice(0, 3).join(', ') + (i.specs.length > 3 ? ' +' + (i.specs.length - 3) : '')) + '</span>' : ''))- + pills + '</div></div>' + tag + '</li>';+ secondary: (rejected(i) ? '<span class="why"><b>' + esc(i.verdict.reason) + '</b> ' + linked(firstLine(visibleVerdictNote(i.verdict.reason, i.verdict.note)), titles) + '</span>'+ : '<span>' + esc(i.lane) + '</span>' + (i.specs.length ? '<span class="specs" title="' + esc(i.specs.join(', ')) + '">' + esc(i.specs.slice(0, 3).join(', ') + (i.specs.length > 3 ? ' +' + (i.specs.length - 3) : '')) + '</span>' : '')) + pills });}).join('') : '<li class="empty">' + (items.length ? 'No items match.' : snapshot ? 'No items at this event.' : 'No items yet. Add the first one with New item.') + '</li>';const item = p.items.find((i) => i.id === view.item);@@ -1611,23 +1615,22 @@ function render() {const feedback = view.specFeedback?.kind === kind && view.specFeedback.root === view.root && view.specFeedback.from === 'list' ? view.specFeedback : null;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;- const implied = filter === 'decide' ? 'draft' : 'approved';- // A Doctrine section is usually all Pullboard's rules or all this repo's, so its header says which; a row says so only- // where it differs from its section, such as a standard rule this repo changed.- const sectionSource = new Map();- if (kind === 'doctrine') for (const r of rows) { const was = sectionSource.get(r.section); sectionSource.set(r.section, was === undefined || was === ruleSource(r) ? ruleSource(r) : null); }$(kind + '-list').innerHTML = shownRows.length ? shownRows.map((r) => {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) + (sectionSource.get(r.section) ? ' <small class="section-source" title="' + esc(ruleSourceTitle(r)) + '">' + esc(sectionSource.get(r.section)) + '</small>' : '') + '</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>' : '';+ const sectionCount = shownRows.filter((entry) => entry.section === r.section).length;+ const head = r.section !== section ? '<div class="spec-section-head"><h4>' + esc(r.section) + ' <span class="section-count">' + sectionCount + '</span></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';const text = declined ? '<s>' + linked(r.standardText || r.text, titles) + '</s>' : linked(r.text, titles);- const reason = declined && r.reason ? '<small class="rule-reason">Reason: ' + linked(r.reason, titles) + '</small>' : '';- // Most rules are Pullboard's own; only the exception, a rule this repo wrote or changed, is marked in the list.- const source = kind === 'doctrine' && sectionSource.get(r.section) !== ruleSource(r) ? '<small class="rule-source" title="' + esc(ruleSourceTitle(r)) + '">' + esc(ruleSource(r)) + '</small>' : '';- // A row reads as its id and its words; a chip only where its status is not the one the filter already says.- const chip = r.status === implied ? '' : '<span class="chip ' + tone(r.status) + '">' + esc(r.stage || r.status) + '</span>';- 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 class="srow-text">' + chip + source + text + reason + '</span></div>';+ const source = kind === 'doctrine' ? ruleSource(r) : 'this repo';+ const reason = declined && r.reason ? '<span class="rule-reason" title="' + esc(r.reason) + '">Reason: ' + linked(r.reason, titles) + '</span>' : '';+ const secondary = '<span class="rule-source" title="' + esc(source) + '">' + esc(source) + '</span>' + reason + (r.gate ? '<span class="gate" title="' + esc(r.gate) + '">' + esc(r.gate) + '</span>' : '');+ const statusShown = filter === 'all' || (filter === 'decide' && r.status !== 'draft');+ const badge = statusShown ? '<span class="chip ' + tone(r.status) + '">' + esc(r.stage || r.status) + '</span>' : r.tier ? '<span class="chip">' + esc(r.tier) + '</span>' : '';+ const citations = p.items.filter((item) => item.specs.includes(r.id)).length;+ return head + (feedback && feedbackId === r.id ? specFeedback(feedback) : '') + recordRow({ tag: 'div', classes: view.row[kind] === r.id ? 'on' : '', attributes: 'data-row="' + kind + ':' + esc(r.id) + '"', title: r.text,+ state: r.status === 'approved' ? 'verified' : r.status === 'wont' ? 'back' : 'open', primary: '<span class="row-id">' + esc(r.id) + '</span>' + text,+ secondary, rightTop: citations ? count(citations, 'item', 'items') : '', rightBottom: badge });}).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 doctrine rows yet: they live in DOCTRINE.md.') + '</div>';if (feedback && !shownRows.length) $(kind + '-list').innerHTML += specFeedback(feedback);const row = rows.find((r) => r.id === view.row[kind]);@@ -1639,7 +1642,7 @@ function render() {const home = kind === 'doctrine' && row && row.origin === 'standard' ? 'Standard rules come with Pullboard; override or decline one in DOCTRINE.md.' : 'Rows change in ' + (kind === 'spec' ? 'SPEC.md' : 'DOCTRINE.md') + ', and only you approve them.';const rowStatus = row?.stage || row?.status;const rowDecisionActions = !snapshot && (!readOnly || requests) && row && undecided(row) && (kind === 'spec' || row.origin !== 'standard')- ? '<div class="spec-decision-actions detail-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-kind="' + kind + '" data-row-id="' + esc(row.id) + '" title="Approve (A, from the list)" type="button">Approve</button><button class="decline-row" data-row-decision="decline" data-row-kind="' + kind + '" data-row-id="' + esc(row.id) + '" title="Decline (D, from the list)" type="button">Decline</button></div>'+ ? '<div class="spec-decision-actions detail-decision-actions"><button class="approve-row" data-row-decision="approve" data-row-kind="' + kind + '" data-row-id="' + esc(row.id) + '" title="Approve (A, from the list)" type="button">Approve <kbd>A</kbd></button><button class="decline-row" data-row-decision="decline" data-row-kind="' + kind + '" data-row-id="' + esc(row.id) + '" title="Decline (D, from the list)" type="button">Decline <kbd>D</kbd></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?.kind === kind && 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>';}@@ -2266,6 +2269,9 @@ for (const kind of ['spec', 'doctrine']) $(kind + '-list').addEventListener('keyevent.preventDefault();const next = ids[Math.min(ids.length - 1, Math.max(0, at + (event.key === 'ArrowDown' ? 1 : -1)))];if (next && next !== view.row[kind]) { view.row[kind] = next; render(); event.currentTarget.querySelector('.srow.on')?.scrollIntoView({ block: 'nearest' }); }+ } else if (event.key === 'Enter' && view.row[kind]) {+ event.preventDefault();+ $(kind + '-detail').scrollIntoView({ block: 'start', behavior: 'instant' });} else if ((event.key === 'a' || event.key === 'd') && view.row[kind] && $(kind + '-detail').querySelector('.approve-row')) {// Only a row still waiting on the person has a decision to make; the detail shows it.event.preventDefault();diff --git a/src/serve.js b/src/serve.jsindex d88c0481..b38305d2 100644--- a/src/serve.js+++ b/src/serve.js@@ -257,7 +257,8 @@ export function projectState(root, { seen = null, board: providedBoard = null }holds: store.laneHolds(board),spec: rows(config.spec),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, added: origin === 'standard' ? null : doctrineAges.get(id) ?? 0,+ id, status: state, tier, text, gate, serves, section, origin, version, reason,+ standardVersion: inherited.has(id) ? doctrine.version : null, overrides: origin === 'repo' && inherited.has(id), added: origin === 'standard' ? null : doctrineAges.get(id) ?? 0,...(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 },diff --git a/src/view.css b/src/view.cssindex afcb44a3..93e1be9c 100644--- a/src/view.css+++ b/src/view.css@@ -458,18 +458,19 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }.lane:first-child { border-top: 0; }.rows-filter { display: flex; padding: 10px 10px 2px; }.rows { padding: 4px 10px 10px; }-.section-source { margin-left: 6px; color: var(--ink-faint); font: 500 11.5px var(--sans); letter-spacing: 0; text-transform: none; }+.section-count { margin-left: 6px; color: var(--ink-faint); font: 500 11.5px var(--mono); }.spec-section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 12px 0 4px; }.rows h4 { margin: 0; font-size: 12.5px; color: var(--ink-muted); }-/* Deciding a row is a quiet word beside it, no box: Approve in the accent, Decline in grey, each lit only on hover. */-.spec-section-approve, .approve-row, .decline-row { min-height: var(--tap); padding: 0 10px; border: 0; border-radius: 8px; background: none; font-weight: 600; white-space: nowrap; cursor: pointer; }-.spec-section-approve, .approve-row { color: var(--accent-strong); }-.decline-row { color: var(--ink-muted); }-.spec-section-approve:hover, .approve-row:hover { background: var(--accent-soft); }+.spec-section-approve, .approve-row, .decline-row { min-height: var(--tap); padding: 0 10px; border: 1px solid transparent; border-radius: 8px; background: none; font-weight: 600; white-space: nowrap; cursor: pointer; }+.spec-section-approve { border: 0; color: var(--accent-strong); }+.spec-section-approve:hover { background: var(--accent-soft); }+.approve-row { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }+.approve-row:hover { background: var(--accent-strong); border-color: var(--accent-strong); }+.decline-row { border-color: var(--line-strong); color: var(--ink-muted); }.decline-row:hover { background: var(--reject-soft); color: var(--reject); }-.spec-decision-actions { display: flex; align-items: center; gap: 2px; margin: -11px -6px -11px 0; cursor: default; }-.detail-decision-actions { margin: 4px 0 0 -10px; }+.spec-decision-actions { display: flex; align-items: center; gap: 8px; cursor: default; }.detail-decision-actions { margin: 0 0 12px; }+.detail-decision-actions kbd { margin-left: 6px; font: 11px var(--mono); opacity: .75; }.spec-reason-backdrop { position: fixed; z-index: 30; inset: 0; display: grid; place-items: center; padding: 16px; background: rgb(15 23 42 / 45%); }.spec-reason-dialog { width: min(100%, 420px); display: grid; gap: 12px; padding: 18px; border: 1px solid var(--line-strong); border-radius: 12px; background: var(--surface); box-shadow: 0 18px 60px rgb(0 0 0 / 24%); }.spec-reason-dialog h2 { margin: 0; font-size: 17px; }@@ -477,17 +478,11 @@ code.inline.long { white-space: break-spaces; overflow-wrap: anywhere; }.spec-reason-dialog input { width: 100%; min-height: var(--tap); padding: 7px 9px; border: 1px solid var(--line-strong); border-radius: 8px; background: var(--surface); color: var(--ink); font-size: 13px; }.spec-reason-dialog .actions { display: flex; flex-wrap: wrap; gap: 8px; }.spec-reason-dialog .actions button { min-height: var(--tap); }-.srow { display: grid; grid-template-columns: 3.4em minmax(0, 1fr); gap: 10px; padding: 9px 8px; border-top: 1px solid var(--line); align-items: baseline; cursor: pointer; }-.srow:hover { background: var(--surface-2); }-.srow.on { background: color-mix(in srgb, var(--ink) 7%, transparent); }-.srow code { font: 600 12px var(--mono); color: var(--ink-muted); }-.srow.on code { color: var(--ink); }-.srow-text .chip { margin-right: 6px; }#spec-list:focus, #doctrine-list:focus { outline: none; }#spec-list:focus-visible, #doctrine-list:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; border-radius: 8px; }-.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: 3em minmax(0, 1fr); gap: 8px; } }+.rule-source, .rule-reason { color: var(--ink-muted); font: inherit; }+.srow .meta > .gate { margin-left: 0; }+.srow .meta > .rule-reason { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }.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; }.flow figcaption { color: var(--ink-faint); font-size: 12px; padding: 2px 34px 0 2px; }diff --git a/test/cockpit/doctrine.test.js b/test/cockpit/doctrine.test.jsindex 71da3146..ac869285 100644--- a/test/cockpit/doctrine.test.js+++ b/test/cockpit/doctrine.test.js@@ -1,10 +1,11 @@/** Cockpit doctrine checks, using the shared real-board fixtures [N26]. */import assert from 'node:assert/strict';-import { writeFileSync } from 'node:fs';+import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { tmpdir } from 'node:os';import { join } from 'node:path';import { test } from 'node:test';-import { loadDoctrine } from '../../src/doctrine.js';-import { SPEC, machine, project, startView, styleOf, openPage } from './fixture.js';+import { loadDoctrine, standardDoctrine } from '../../src/doctrine.js';+import { tapTarget, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, press, SPEC, machine, project, startView, styleOf, openPage } from './fixture.js';test('the doctrine view carries and labels inherited, local, overridden and declined rules [D3,N26]', async () => {@@ -25,27 +26,26 @@ test('the doctrine view carries and labels inherited, local, overridden and declassert.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');- // A section says once where its rules come from; a row says so only where it differs from its section.- const sections = list.split('<div class="spec-section-head">').slice(1).map((chunk) => ({- source: /<small class="section-source" title="[^"]+">([^<]*)<\/small>/.exec(chunk)?.[1] ?? null,- rows: chunk.split('<div class="srow').slice(1).map((row) => [/data-row="doctrine:([^"]+)"/.exec(row)[1], /<small class="rule-source" title="[^"]+">([^<]*)<\/small>/.exec(row)?.[1] ?? null]),- }));- const where = (id) => { const section = sections.find((s) => s.rows.some(([row]) => row === id)); return [section?.source ?? null, section?.rows.find(([row]) => row === id)[1] ?? null]; };- assert.deepEqual(where('PB1'), ['From Pullboard', null], `a section of Pullboard's rules says so once, in its header: ${JSON.stringify(sections)}`);- assert.deepEqual(where('R1'), ['This repo', null], `a rule this repo wrote sits under a header that says so: ${JSON.stringify(sections)}`);+ /** Read each rendered row's own source label rather than relying on section metadata. */+ const where = (id) => {+ const row = list.split('<div class="srow').slice(1).find((chunk) => chunk.includes('data-row="doctrine:' + id + '"'));+ return /<span class="rule-source" title="[^"]+">([^<]*)<\/span>/.exec(row)?.[1] ?? null;+ };+ assert.equal(where('PB1'), 'Pullboard v' + merged.version, 'an inherited rule names its actual packaged version');+ assert.equal(where('R1'), 'this repo', 'a local row names the repo');assert.match(list, /data-row="doctrine:R1"[^]*?Keep <b>local<\/b> evidence\./);- assert.ok(['This repo,', ',This repo'].includes(where('PB2').join()), `the rule this repo changed says This repo, by its section or by itself: ${JSON.stringify(where('PB2'))}`);+ assert.equal(where('PB2'), 'Pullboard v' + merged.version + ', overridden here');assert.match(list, /data-row="doctrine:PB2"[^]*?Deletion needs <i>two<\/i> approvals\./);assert.doesNotMatch(list, /Destructive or irreversible actions wait/);- assert.match(list, /data-row="doctrine:PB8"[^]*?<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.match(list, /data-row="doctrine:PB8"[^]*?<s>No secrets or sensitive info in the repo; test data is synthetic\.<\/s>[^]*?<span class="rule-reason"[^>]*>Reason: No <script>persistent<\/script> data is stored\.<\/span>/);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');+ assert.match(style, /\.rule-source, \.rule-reason \{ color: var\(--ink-muted\); font: inherit;/, 'source and reason share the Items secondary-line type');await page.click({ row: 'doctrine:PB1' });- assert.match(page.show('doctrine-detail'), /<span class="chip" title="Pullboard standard rules, version \d+">From Pullboard<\/span>/);+ assert.match(page.show('doctrine-detail'), /<span class="chip" title="Pullboard v\d+">Pullboard v\d+<\/span>/);await page.click({ row: 'doctrine:PB2' });- assert.match(page.show('doctrine-detail'), /<span class="chip" title="Written in this repo">This repo<\/span>/);+ assert.match(page.show('doctrine-detail'), /<span class="chip" title="Pullboard v\d+, overridden here">Pullboard v\d+, overridden here<\/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>/);@@ -87,3 +87,119 @@ test('the doctrine pane names DOCTRINE.md and its rules doctrine [D1,N26]', asynawait view.stop();}});++// Hang ceiling: two real boards and six Chrome layouts, each using the shared two-frame stability wait.++/** Check real source metadata and the two-line presentation, including a repo overriding every packaged id. */+test('a doctrine row names its source under its id [N26]', { timeout: 300_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for Doctrine source-row checks.');++ const standard = standardDoctrine();+ assert.ok(standard.rows.length >= 3, 'the actual packaged doctrine supplies inherited and override rows');+ const [inherited, overridden, declined] = standard.rows;+ const box = machine();+ const repo = project(box, 'doctrine-source', SPEC, { practice: 'DOCTRINE.md' });+ const longText = 'This repo replaces the standard wording with a deliberately long sentence that must stay complete in the detail and end in an ellipsis in the compact row. '.repeat(4);+ const reason = 'The team declined this inherited rule because the local workflow already covers it.';+ writeFileSync(join(repo.repo, 'DOCTRINE.md'), `# Team doctrine\n\n## Local rules\n`+ + `- ${overridden.id} [approved, must] ${longText} | gate: focused source test | serves: G1\n`+ + `- ${declined.id} [wont] ${reason} | gate: focused source test | serves: G2\n`+ + '- R1 [approved, must] A rule written only for this repository. | gate: local review | serves: G1\n');+ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-doctrine-source-chrome-'));+ let chrome;++ /** Read only rendered geometry and labels after the shared two-frame stability wait. */+ const readRow = async (id) => JSON.parse(await chrome.stable(`JSON.stringify((() => {+ const row = document.querySelector('#doctrine-list [data-row="doctrine:${id}"]');+ const box = element => { const r = element?.getBoundingClientRect(); return r && { left:r.left, right:r.right, top:r.top, bottom:r.bottom, height:r.height, width:r.width }; };+ const title = row?.querySelector('.t'), meta = row?.querySelector('.meta');+ const source = meta?.querySelector('.rule-source'), gate = meta?.querySelector('.gate');+ const reason = row?.querySelector('.rule-reason'), idBox = row?.querySelector('.row-id');+ return { text: title?.textContent ?? null, textBox: box(title), textStyle: title && { overflow:getComputedStyle(title).textOverflow, lines:Math.ceil(title.getBoundingClientRect().height / parseFloat(getComputedStyle(title).lineHeight)) },+ source: source?.textContent ?? null, sourceBox:box(source), gate:gate?.textContent ?? null, gateBox:box(gate), reason:reason?.textContent ?? null, reasonBox:box(reason), idBox:box(idBox), rowBox:box(row),+ overflow:document.documentElement.scrollWidth > document.documentElement.clientWidth };+ })())`));++ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor(`!!data?.project?.practice?.some(row => row.id === ${JSON.stringify(inherited.id)})`);+ await press(chrome, "document.querySelector('[data-tab=doctrine]')");+ await press(chrome, "document.querySelector('#doctrine-chips [data-rows=\"doctrine:all\"]')");+ const expected = new Map([+ [inherited.id, `Pullboard v${standard.version}`],+ [overridden.id, `Pullboard v${standard.version}, overridden here`],+ [declined.id, `Pullboard v${standard.version}, declined here`],+ ['R1', 'this repo'],+ ]);++ for (const theme of ['light', 'dark']) {+ for (const width of [375, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: theme }] });+ await chrome.waitFor(`innerWidth === ${width} && matchMedia('(prefers-color-scheme: ${theme})').matches`);+ for (const [id, source] of expected) {+ const row = await readRow(id);+ assert.equal(row.source, source, `${width}px ${theme}: ${id} names its actual source under its id`);+ assert.ok(row.rowBox.height >= tapTarget(width), `${width}px ${theme}: ${id} keeps the #371 target size: ${JSON.stringify(row.rowBox)}`);+ assert.ok(row.sourceBox && row.idBox && row.textBox && row.sourceBox.top > row.textBox.top && Math.abs(row.sourceBox.left - row.idBox.left) < 1,+ `${width}px ${theme}: ${id}'s source is visibly beneath the words in the id's content column: ${JSON.stringify(row)}`);+ assert.ok(row.gate && row.gateBox && Math.abs(row.gateBox.top - row.sourceBox.top) < 2 && row.gateBox.left > row.sourceBox.right,+ `${width}px ${theme}: ${id}'s gate follows its source: ${JSON.stringify(row)}`);+ assert.ok(!row.overflow, `${width}px ${theme}: ${id} does not create sideways page scrolling`);+ }+ const override = await readRow(overridden.id);+ assert.ok(override.text.includes('This repo replaces the standard wording'), `${width}px ${theme}: the title retains its words`);+ assert.equal(override.textStyle.overflow, 'ellipsis', `${width}px ${theme}: the first-line title is ellipsized`);+ assert.equal(override.textStyle.lines, 1, `${width}px ${theme}: the title stays on its first line`);+ assert.ok(override.textBox.width > 0, `${width}px ${theme}: the title is rendered`);+ const refused = await readRow(declined.id);+ assert.ok(refused.reason?.includes(reason) && refused.reasonBox && Math.abs(refused.reasonBox.top - refused.sourceBox.top) < 2 && refused.reasonBox.left > refused.sourceBox.right,+ `${width}px ${theme}: the declined rule's reason follows its source: ${JSON.stringify(refused)}`);++ await press(chrome, `document.querySelector('#doctrine-list [data-row="doctrine:${inherited.id}"]')`);+ await chrome.waitFor(`document.querySelector('#doctrine-detail h2 span')?.textContent === ${JSON.stringify(inherited.id)}`);+ const detail = JSON.parse(await chrome.stable(`JSON.stringify(document.querySelector('#doctrine-detail').innerText)`));+ assert.ok(detail.includes(inherited.text) && detail.includes(inherited.gate), `${width}px ${theme}: selecting the row opens its full rule and gate`);+ }+ }+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }++ const allBox = machine();+ const allRepo = project(allBox, 'doctrine-all-overridden', SPEC, { practice: 'DOCTRINE.md' });+ const allStandard = standardDoctrine();+ const rows = allStandard.rows.map((row) => {+ const state = 'approved, must';+ const fields = [row.gate && `gate: ${row.gate}`, row.serves?.length && `serves: ${row.serves.join(', ')}`].filter(Boolean);+ return `- ${row.id} [${state}] Repository wording for ${row.id} is intentionally distinct. ${fields.length ? `| ${fields.join(' | ')}` : ''}`;+ }).join('\n');+ writeFileSync(join(allRepo.repo, 'DOCTRINE.md'), `# All standard rows overridden\n\n## Local rules\n${rows}\n`);+ const allView = await startView(allBox);+ const allProfile = mkdtempSync(join(tmpdir(), 'pullboard-doctrine-all-overridden-chrome-'));+ let allChrome;+ try {+ allChrome = await openSnapshotChrome(executable, allView.link.href, allProfile);+ await allChrome.waitFor(`data?.project?.practice?.length === ${allStandard.rows.length}`);+ await press(allChrome, "document.querySelector('[data-tab=doctrine]')");+ await press(allChrome, "document.querySelector('#doctrine-chips [data-rows=\"doctrine:all\"]')");+ for (const [width, theme] of [[375, 'light'], [1280, 'dark']]) {+ await allChrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await allChrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: theme }] });+ await allChrome.waitFor(`innerWidth === ${width} && matchMedia('(prefers-color-scheme: ${theme})').matches`);+ const sources = await allChrome.stable(`JSON.stringify([...document.querySelectorAll('#doctrine-list .srow')].map(row => [row.dataset.row, row.querySelector('.meta .rule-source')?.textContent ?? null]))`);+ assert.deepEqual(JSON.parse(sources), allStandard.rows.map((row) => [`doctrine:${row.id}`, `Pullboard v${allStandard.version}, overridden here`]),+ `${width}px ${theme}: every actual standard rule is shown as overridden, not inferred from an id pattern`);+ const overflow = await allChrome.stable('document.documentElement.scrollWidth > document.documentElement.clientWidth');+ assert.equal(overflow, false, `${width}px ${theme}: the complete overridden doctrine fits without sideways scrolling`);+ }+ } finally {+ if (allChrome) await closeSnapshotChrome(allChrome);+ rmSync(allProfile, { recursive: true, force: true });+ await allView.stop();+ }+});diff --git a/test/cockpit/spec.test.js b/test/cockpit/spec.test.jsindex 45ebf3a2..6707cba8 100644--- a/test/cockpit/spec.test.js+++ b/test/cockpit/spec.test.js@@ -1,11 +1,12 @@/** Cockpit spec checks, using the shared real-board fixtures [N26]. */import assert from 'node:assert/strict';-import { mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join } from 'node:path';import { after, test } from 'node:test';+import { standardDoctrine } from '../../src/doctrine.js';import { loadConfig } from '../../src/config.js';-import { tapTarget, SPEC, machine, project, startView, styleOf, openPage, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, watchSpecDecisionWait, press } from './fixture.js';+import { tapTarget, SPEC, machine, project, build, startView, styleOf, openPage, boardOf, chromeExecutable, openSnapshotChrome, closeSnapshotChrome, watchSpecDecisionWait, press } from './fixture.js';test('spec rows read across a phone [N26,D1]', async () => {@@ -20,26 +21,24 @@ test('spec rows read across a phone [N26,D1]', async () => {assert.match(doctrineRows, /data-row="doctrine:W1"[^]*?Numbers over adjectives\./, 'W1 from the configured doctrine is shown');assert.match(doctrineRows, /data-row="doctrine:W2"[^]*?One record per decision\./, 'W2 from the configured doctrine is shown');const style = await styleOf(view);- assert.match(style, /\n\.srow \{ display: grid; grid-template-columns: 3\.4em minmax\(0, 1fr\);/, 'a row is its id in a slim gutter and its text at full width, with no decision in it');- const phone = /\n@media ([^{]+) \{ \.srow \{ grid-template-columns: 3em minmax\(0, 1fr\); gap: 8px; \} \}/.exec(style);- assert.ok(phone, 'on a phone the gutter narrows and the text keeps the rest');- assert.equal(phone[1], '(width < 480px)', 'under 480px only');-- // The rule holds because every row is the id, then its words, a chip first only where its status is not the filter's.+ assert.match(style, /\.row \{ grid-template-areas: "dot t age" "dot meta chip";/, 'all three lists use the Items two-line grid');await page.click({ rows: 'spec:all' });const rows = (html) => html.split('<div class="srow').slice(1);- const shape = /^[^>]*><code>[^<]+<\/code><span class="srow-text">(?:<span class="chip[^"]*">[^<]+<\/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'))) assert.match(row, shape);- const doctrineShape = /^[^>]*><code>[^<]+<\/code><span class="srow-text">(?:<span class="chip[^"]*">[^<]+<\/span>)?(?:<small class="rule-source" title="[^"]+">(?:From Pullboard|This repo)<\/small>)?[^<]+<\/span><\/div>/;- for (const row of rows(page.show('doctrine-list'))) assert.match(row, doctrineShape, "a rule is its id and its words, its source only where it differs from its section's, in the same two columns");- assert.ok(rows(page.show('doctrine-list')).length > 0, 'doctrine rows are drawn the same way');+ for (const kind of ['spec', 'doctrine']) {+ const drawn = rows(page.show(kind + '-list'));+ assert.ok(drawn.length > 0, kind + ' has rows');+ for (const row of drawn) {+ assert.match(row, /^ row s-[^"]*"[^]*?<span class="dot [^"]+"><\/span><div><div class="t srow-text"><span class="row-id">[^<]+<\/span>/, kind + ' shares the dot and primary line');+ assert.match(row, /<div class="meta"><span class="rule-source"/, kind + ' names its source on the secondary line');+ }+ }} finally {await view.stop();}});-test('Spec and Doctrine line up, open on a row and decide with quiet controls [N26, B26]', { timeout: 120_000 }, async (t) => {+test('Spec and Doctrine line up, open on a row and decide with filled and outlined controls [N26, B26]', { timeout: 120_000 }, async (t) => {const executable = chromeExecutable();if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for Spec layout checks.');@@ -60,9 +59,9 @@ test('Spec and Doctrine line up, open on a row and decide with quiet controls [Nconst line = text ? parseFloat(getComputedStyle(text).lineHeight) : 0;return { list: box(pane.querySelector('.rows-card')), detail: box(pane.querySelector('.detail')), picked: document.querySelector('#${kind}-list .srow.on')?.dataset.row ?? null,shown: document.querySelector('#${kind}-detail h2 span')?.textContent ?? null, first: document.querySelector('#${kind}-list .srow')?.dataset.row ?? null,- row: row && box(row), text: text && box(text), line, buttons: buttons.map((e) => ({ ...box(e), quiet: quiet(e), word: e.textContent })),- decide: [...document.querySelectorAll('#${kind}-detail [data-row-decision]')].map((e) => ({ ...box(e), quiet: quiet(e), word: e.textContent })),- section: [...document.querySelectorAll('#${kind}-list [data-section-approve], #${kind}-detail [data-row-decision]')].map((e) => quiet(e)),+ row: row && box(row), text: text && box(text), line, buttons: buttons.map((e) => ({ ...box(e), quiet: quiet(e), word: e.childNodes[0].textContent.trim(), filled: getComputedStyle(e).backgroundColor !== 'rgba(0, 0, 0, 0)', border: getComputedStyle(e).borderTopWidth, key: e.querySelector('kbd')?.textContent })),+ decide: [...document.querySelectorAll('#${kind}-detail [data-row-decision]')].map((e) => ({ ...box(e), quiet: quiet(e), word: e.childNodes[0].textContent.trim(), filled: getComputedStyle(e).backgroundColor !== 'rgba(0, 0, 0, 0)', border: getComputedStyle(e).borderTopWidth, key: e.querySelector('kbd')?.textContent })),+ section: [...document.querySelectorAll('#${kind}-list [data-section-approve]')].map((e) => quiet(e)),overflow: document.documentElement.scrollWidth > document.documentElement.clientWidth };})())`));try {@@ -76,10 +75,10 @@ test('Spec and Doctrine line up, open on a row and decide with quiet controls [Nif (width === 1280) assert.ok(Math.abs(spec.list.top - spec.detail.top) < 0.5, `${width}: the list and the detail start on one line: ${JSON.stringify([spec.list, spec.detail])}`);assert.deepEqual([spec.picked, spec.shown], ['spec:G1', 'G1'], `${width}: with nothing picked, the detail opens on the first row shown`);assert.deepEqual([spec.buttons.length, spec.decide.map((b) => b.word)], [0, ['Approve', 'Decline']], `${width}: a row carries no decision; the picked row's detail holds it once`);- assert.ok(spec.decide.every((b) => b.quiet && b.height >= tapTarget(width)), `${width}: quiet words, no box or fill until hovered, each a target: ${JSON.stringify(spec.decide)}`);- assert.ok(spec.section.length >= 3 && spec.section.every(Boolean), `${width}: Approve all and the detail's decision are quiet too`);+ assert.ok(spec.decide.every((b) => b.height >= tapTarget(width) && b.border === '1px') && spec.decide[0].filled && !spec.decide[1].filled && spec.decide.map((b) => b.key).join() === 'A,D', `${width}: filled Approve and outlined Decline show their keys and meet the target: ${JSON.stringify(spec.decide)}`);+ assert.ok(spec.section.length >= 1 && spec.section.every(Boolean), `${width}: Approve all stays quiet on the section header`);if (width === 1280) {- assert.ok(spec.row.height <= 60 && Math.round(spec.text.height / spec.line) <= 2, `${width}: a one-sentence row takes one or two lines: ${JSON.stringify([spec.row, spec.text, spec.line])}`);+ assert.ok(spec.row.height <= 2 * spec.line + 22 && Math.round(spec.text.height / spec.line) <= 2, `${width}: a one-sentence row takes one or two lines: ${JSON.stringify([spec.row, spec.text, spec.line])}`);}assert.ok(!spec.overflow, `${width}: nothing runs off the screen`);// A filter that hides the pick moves it to the new first row; one that keeps it keeps it.@@ -126,7 +125,7 @@ test('spec rows read as a list, decided in the panel [N26]', { timeout: 300_000const box = (e) => { const r = e.getBoundingClientRect(); return { left: r.left, right: r.right, top: r.top, bottom: r.bottom, width: r.width, height: r.height }; };const rows = [...document.querySelectorAll('#${kind}-list .srow')].map((row) => {const s = getComputedStyle(row), text = row.querySelector('.srow-text');- return { id: row.dataset.row.slice(${kind.length + 1}), chip: row.querySelector('.chip')?.textContent ?? null, gutter: box(row.querySelector('code')), text: box(text), row: box(row),+ return { id: row.dataset.row.slice(${kind.length + 1}), chip: row.querySelector('.chip')?.textContent ?? null, gutter: box(row.querySelector('.row-id')), text: box(text), row: box(row),lines: Math.round(text.getBoundingClientRect().height / parseFloat(getComputedStyle(text).lineHeight)), buttons: row.querySelectorAll('button').length,on: row.classList.contains('on'), tint: s.backgroundColor, edges: [s.borderLeftWidth, s.borderLeftColor].join() === [s.borderRightWidth, s.borderRightColor].join() };});@@ -134,8 +133,8 @@ test('spec rows read as a list, decided in the panel [N26]', { timeout: 300_000return {page: { width: document.documentElement.clientWidth, scroll: document.documentElement.scrollWidth, body: document.body.scrollWidth },rows, picked: view.row['${kind}'], shown: detail.querySelector('h2 span')?.textContent ?? null, viewport: innerHeight,- decide: [...detail.querySelectorAll('[data-row-decision]')].map((b) => ({ word: b.textContent, ...box(b) })),- section: [...document.querySelectorAll('#${kind}-list [data-section-approve]')].map((b) => ({ word: b.textContent, height: b.getBoundingClientRect().height, head: !!b.closest('.spec-section-head') })),+ decide: [...detail.querySelectorAll('[data-row-decision]')].map((b) => ({ word: b.childNodes[0].textContent.trim(), ...box(b) })),+ section: [...document.querySelectorAll('#${kind}-list [data-section-approve]')].map((b) => ({ word: b.childNodes[0].textContent.trim(), height: b.getBoundingClientRect().height, head: !!b.closest('.spec-section-head') })),};})())`));/** A tint is quiet when its colour channels sit close together: grey, not a hue. */@@ -181,10 +180,10 @@ test('spec rows read as a list, decided in the panel [N26]', { timeout: 300_000assert.ok(r.page.scroll <= r.page.width && r.page.body <= r.page.width, `${tab}: no sideways scroll`);// Each row is its id in a slim gutter and its words at full width; a chip only where the status is not the filter's.const undecidedNow = expected[kind].decide;- assert.deepEqual(r.rows.map((row) => [row.id, row.chip, row.buttons]), undecidedNow.map(([id, chip]) => [id, chip, 0]),- `${tab}: drafts carry no chip under Needs your decision, an open question says pending, and no row carries a decision`);+ assert.deepEqual(r.rows.map((row) => [row.id, row.chip, row.buttons]), undecidedNow.map(([id, chip]) => [id, chip || 'must', 0]),+ `${tab}: drafts carry their tier under Needs your decision, an open question says pending, and no row carries a decision`);for (const row of r.rows) {- assert.ok(row.gutter.width <= 52 && row.text.left - row.gutter.right <= 14 && row.row.right - row.text.right <= 12, `${tab}: ${row.id} is a slim gutter and full-width words: ${JSON.stringify(row)}`);+ assert.ok(row.gutter.width <= 52 && Math.abs(row.text.left - row.gutter.left) < 1 && row.text.right <= row.row.right, `${tab}: ${row.id} starts with its id on the same primary line: ${JSON.stringify(row)}`);if (width === 1280) assert.ok(row.lines <= 2, `${tab}: ${row.id}, one sentence, takes one or two lines: ${row.lines}`);}const picked = r.rows.find((row) => row.on);@@ -237,8 +236,8 @@ test('spec rows read as a list, decided in the panel [N26]', { timeout: 300_000r = await read(kind);const all = Object.fromEntries(r.rows.map((row) => [row.id, row.chip]));assert.deepEqual([all[first], all[second]], ['approved, pending apply', 'declined, pending apply'], `${tab}: under All rows the decided rows say so`);- if (kind === 'spec') assert.deepEqual([all.S2, all.S3], ['pending', null], `${tab}: the open question says pending; the approved row needs no chip`);- else assert.ok(r.rows.some((row) => row.id.startsWith('PB') && row.chip === null), `${tab}: Pullboard's own approved rules need no chip`);+ if (kind === 'spec') assert.deepEqual([all.S2, all.S3], ['pending', 'approved'], `${tab}: the open question says pending; All rows shows the approved row’s status too`);+ else assert.ok(r.rows.some((row) => row.id.startsWith('PB') && row.chip === 'approved'), `${tab}: All rows names the standard rules’ approved status`);}}}@@ -292,7 +291,7 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedoverflow: document.documentElement.scrollWidth > document.documentElement.clientWidth,controls: [...document.querySelectorAll('#spec-list button[data-row-decision],#spec-list button[data-section-approve]')].map(e=>({height:e.getBoundingClientRect().height})),rows: [...document.querySelectorAll('#spec-list .srow')].map(row=>{- const chip=row.querySelector('.srow-text .chip');+ const chip=row.querySelector(':scope > .chip');const words=[...(row.querySelector('.srow-text')?.childNodes||[])].find(n=>n.nodeType===3&&n.textContent.trim());if (!chip || !words) return {id:row.dataset.row, missing:true};const range=document.createRange(); range.selectNodeContents(words);@@ -323,7 +322,7 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedassert.equal(await chrome.stable("document.querySelector('#spec-chips [data-rows=\"spec:decide\"] b').textContent"), '30', `${width}: Needs your decision excludes the decided row`);if (width === 1280) assert.ok(await chrome.stable(`(() => {const row=document.querySelector('#spec-list [data-row="spec:G1"]');- const chip=row.querySelector('.srow-text .chip').getBoundingClientRect();+ const chip=row.querySelector(':scope > .chip').getBoundingClientRect();const words=[...row.querySelector('.srow-text').childNodes].find(n=>n.nodeType===3&&n.textContent.trim());const range=document.createRange(); range.selectNodeContents(words); const text=range.getClientRects()[0];return chip.right <= text.left || chip.bottom <= text.top || chip.top >= text.bottom;@@ -373,7 +372,7 @@ test('real Chrome records Spec row decisions from the row, detail and confirmedassert.equal(state.spec.find((row) => row.id === 'G3')?.decision, undefined, `${width}: other section rows remain undecided`);if (width === 1280) assert.ok(await chrome.stable(`['G1','G2','K1','K2'].every(id => {const row=document.querySelector('#spec-list [data-row="spec:'+id+'"]');- const chip=row.querySelector('.srow-text .chip').getBoundingClientRect();+ const chip=row.querySelector(':scope > .chip').getBoundingClientRect();const words=[...row.querySelector('.srow-text').childNodes].find(n=>n.nodeType===3&&n.textContent.trim());const range=document.createRange(); range.selectNodeContents(words); const text=range.getClientRects()[0];return chip.right <= text.left || chip.bottom <= text.top || chip.top >= text.bottom;@@ -441,3 +440,185 @@ test('the spec decision wait names its state on timeout [N26]', { timeout: 60_00}}});++// Hang ceiling: four three-tab layouts, native input and real Git/SQLite setup; two 120s journey budgets plus setup headroom.++/** Compare real Items, Spec and Doctrine rendering and native selection across four viewport/theme layouts. */+test('doctrine and spec rows share the items row [N26]', { timeout: 300_000 }, async (t) => {+ const executable = chromeExecutable();+ if (!executable) return t.skip('Install Chrome or set PULLBOARD_CHROME for shared-row checks.');++ const standard = standardDoctrine();+ const [inherited, overridden, declined] = standard.rows;+ const longGoal = 'A deliberately long requirement keeps all its words in the detail while the shared row cuts its title with an ellipsis. '.repeat(3);+ const longOverride = 'This repository replaces the standard wording with a long rule that must ellipsize in the shared row while remaining complete in the detail. '.repeat(3);+ const spec = '# Shared rows\n\n## G · Goals\n'+ + `- G1 [draft, must] ${longGoal} | gate: browser check | serves: G3\n`+ + '- G2 [pending, aim] A second undecided row keeps the section approval count honest. | gate: browser check\n'+ + '- G3 [approved, must] Approved text remains available in its detail. | gate: browser check\n';+ const box = machine();+ const demo = project(box, 'shared-rows', spec, { practice: 'DOCTRINE.md' });+ const reason = 'The local process already covers this inherited rule.';+ writeFileSync(join(demo.repo, 'DOCTRINE.md'), `# Team doctrine\n\n## Rules\n`+ + `- ${overridden.id} [draft, must] ${longOverride} | gate: doctrine check | serves: ${inherited.id}\n`+ + `- ${declined.id} [wont] ${reason} | gate: doctrine check | serves: ${inherited.id}\n`+ + '\n## Local\n- R1 [approved, must] The repository’s own rule stays in its source section. | gate: local check\n- G1 [approved, must] This doctrine rule shares the citing item. | gate: citation check\n');+ box.run(demo.repo, 'add', 'web', 'A real item citing G1', '--specs', 'G1', '--criterion', 'The requirement is represented by a built item.');+ build(box, demo, 1, 'shared-row.txt');++ const view = await startView(box);+ const profile = mkdtempSync(join(tmpdir(), 'pullboard-shared-rows-chrome-'));+ let chrome;+ /** Save a full-page proof of the actual rendered tab when a proof folder is requested. */+ const shot = async (kind, width, theme) => {+ if (!process.env.PULLBOARD_ROWS_PROOF) return;+ mkdirSync(process.env.PULLBOARD_ROWS_PROOF, { recursive: true });+ await chrome.stable('window.scrollTo(0, 0)');+ const cssContentSize = JSON.parse(await chrome.stable('JSON.stringify({width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight})'));+ const capture = await chrome.send('Page.captureScreenshot', { format: 'png', captureBeyondViewport: true, clip: { x: 0, y: 0, width: cssContentSize.width, height: cssContentSize.height, scale: 1 } });+ writeFileSync(join(process.env.PULLBOARD_ROWS_PROOF, kind + '-' + width + '-' + theme + '.png'), Buffer.from(capture.data, 'base64'));+ };+ /** Capture rendered row geometry and computed row/title type from the live DOM. */+ const rowState = async (selector) => JSON.parse(await chrome.stable(`JSON.stringify((() => {+ const row = document.querySelector(${JSON.stringify(selector)});+ const box = e => { if (!e) return null; const r=e.getBoundingClientRect(); return {x:r.x,y:r.y,right:r.right,bottom:r.bottom,width:r.width,height:r.height}; };+ const style = e => { if (!e) return null; const s=getComputedStyle(e); return {display:s.display,dotColumn:s.gridTemplateColumns.split(" ")[0],gridTemplateAreas:s.gridTemplateAreas,columnGap:s.columnGap,rowGap:s.rowGap,padding:s.padding,fontFamily:s.fontFamily,fontSize:s.fontSize,fontWeight:s.fontWeight,lineHeight:s.lineHeight}; };+ const title = row?.querySelector('.t'), meta = row?.querySelector('.meta'), source = row?.querySelector('.rule-source'), reason = row?.querySelector('.rule-reason');+ const age = row?.querySelector('.row-age');+ return {tag:row?.tagName ?? null, className:row?.className ?? '', title:title?.textContent ?? '', titleFull:row?.getAttribute('title') ?? '', titleBox:box(title), titleStyle:title&&{overflow:getComputedStyle(title).textOverflow,whiteSpace:getComputedStyle(title).whiteSpace,lines:Math.ceil(title.getBoundingClientRect().height/parseFloat(getComputedStyle(title).lineHeight))},+ rowBox:box(row), rowStyle:style(row), dot:!!row?.querySelector(':scope > .dot'), meta:meta?.textContent ?? '', metaBox:box(source), source:source?.textContent ?? null, sourceBox:box(source), reason:reason?.textContent ?? null, reasonBox:box(reason), gate:row?.querySelector('.meta .gate')?.textContent ?? null, gateBox:box(row?.querySelector('.meta .gate')),+ count:age?.textContent.trim() ?? null, countBox:box(age), status:row?.querySelector(':scope > .chip')?.textContent.trim() ?? null, statusBox:box(row?.querySelector(':scope > .chip')),+ overflow:document.documentElement.scrollWidth > document.documentElement.clientWidth, pageWidth:document.documentElement.clientWidth, pageScrollWidth:document.documentElement.scrollWidth};+ })())`));++ try {+ chrome = await openSnapshotChrome(executable, view.link.href, profile);+ await chrome.waitFor("data?.project?.spec?.some(row => row.id === 'G1') && data?.project?.practice?.some(row => row.id === 'R1')");+ for (const theme of ['light', 'dark']) {+ for (const width of [375, 1280]) {+ await chrome.send('Emulation.setDeviceMetricsOverride', { width, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setEmulatedMedia', { features: [{ name: 'prefers-color-scheme', value: theme }] });+ await chrome.waitFor(`innerWidth === ${width} && matchMedia('(prefers-color-scheme: ${theme})').matches`);+ await press(chrome, "document.querySelector('[data-tab=items]')");+ const item = await rowState('#chain .row[data-item="1"]');+ assert.ok(item?.dot, `${width}px ${theme}: the Items reference row has its status dot`);+ assert.equal(item.overflow, false, `${width}px ${theme}: the Items row has no horizontal overflow`);++ await press(chrome, "document.querySelector('[data-tab=spec]')");+ await press(chrome, "document.querySelector('#spec-chips [data-rows=\"spec:all\"]')");+ const g1 = await rowState('#spec-list [data-row="spec:G1"]');+ const g2 = await rowState('#spec-list [data-row="spec:G2"]');+ assert.match(g1.className, /(?:^|\s)srow(?:\s|$)/u);+ assert.match(g1.className, /(?:^|\s)row(?:\s|$)/u, `${width}px ${theme}: Spec uses the shared Items row component`);+ assert.equal(g1.dot, true);+ assert.equal(g1.overflow, false, `${width}px ${theme}: Spec has no horizontal overflow`);+ assert.match(g1.count, /^1(?:\s+items?)?$/u, `${width}px ${theme}: G1 shows one citing item at the right of line one`);+ assert.ok(g1.countBox.y < g1.metaBox.y && g1.countBox.right >= g1.rowBox.right - 12, `${width}px ${theme}: the citation count is right-aligned on line one`);+ assert.equal(g1.status, 'draft', `${width}px ${theme}: All rows shows an explicit non-implied status chip`);+ assert.ok(g1.statusBox.y > g1.countBox.y, `${width}px ${theme}: the status chip is on line two`);+ assert.equal(g2.count, null, `${width}px ${theme}: a row with no cited items shows no zero`);+ const zeroCount = await chrome.stable(`document.querySelector('#spec-list').innerText.includes('0')`);+ assert.equal(zeroCount, false, `${width}px ${theme}: Spec does not print a zero citation badge`);+ assert.deepEqual(g1.rowStyle, item.rowStyle, `${width}px ${theme}: Spec and Items share grid, spacing and type`);+ assert.equal(g1.titleStyle.overflow, 'ellipsis');+ assert.equal(g1.titleStyle.whiteSpace, 'nowrap');+ assert.equal(g1.titleStyle.lines, 1);+ assert.ok(g1.titleFull.includes(longGoal.slice(0, 40)), `${width}px ${theme}: the full title remains available on the row`);++ const header = JSON.parse(await chrome.stable(`JSON.stringify((() => { const e=document.querySelector('#spec-list .spec-section-head'); return {text:e?.innerText??'', count:e?.querySelector('.section-count')?.textContent.trim()??null, approve:e?.querySelector('[data-section-approve]')?.innerText??null, button:e?.querySelector('[data-section-approve]')?.getBoundingClientRect().height??0}; })())`));+ assert.match(header.text, /Goals/u);+ assert.equal(header.count, '3', `${width}px ${theme}: the section header shows its three rows`);+ assert.match(header.approve ?? '', /Approve all 2/u, `${width}px ${theme}: Spec keeps its two-undecided-row Approve all action`);+ assert.ok(header.button >= tapTarget(width), `${width}px ${theme}: Approve all meets the #371 target size`);++ await press(chrome, "document.querySelector('#spec-chips [data-rows=\"spec:decide\"]')");+ const draft = await rowState('#spec-list [data-row="spec:G1"]');+ const pending = await rowState('#spec-list [data-row="spec:G2"]');+ assert.equal(draft.status, 'must', `${width}px ${theme}: the filter-implied draft status gives way to its tier`);+ assert.equal(pending.status, 'pending', `${width}px ${theme}: a non-implied pending status remains explicit`);+ await press(chrome, "document.querySelector('#spec-chips [data-rows=\"spec:approved\"]')");+ const approved = await rowState('#spec-list [data-row="spec:G3"]');+ assert.equal(approved.status, 'must', `${width}px ${theme}: the approved filter-implied status gives way to its tier`);+ await press(chrome, "document.querySelector('#spec-chips [data-rows=\"spec:all\"]')");+ await press(chrome, "document.querySelector('#spec-list [data-row=\"spec:G1\"]')");+ await chrome.waitFor("document.querySelector('#spec-detail h2 span')?.textContent === 'G1'");+ let detail = await chrome.stable("document.querySelector('#spec-detail').innerText");+ assert.ok(detail.includes(longGoal.trim()) && detail.includes('browser check') && detail.includes('G3') && detail.includes('#1 A real item citing G1'), `${width}px ${theme}: clicking Spec opens full text, gate, served area and citing item`);+ let actions = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#spec-detail [data-row-decision]')].map(e=>({action:e.dataset.rowDecision,text:e.innerText,key:e.querySelector('kbd')?.innerText??null,height:e.getBoundingClientRect().height,background:getComputedStyle(e).backgroundColor,border:getComputedStyle(e).borderTopWidth})))`));+ assert.deepEqual(actions.map(e=>e.action), ['approve','decline']);+ assert.equal(actions[0].key, 'A'); assert.equal(actions[1].key, 'D');+ assert.notEqual(actions[0].background, 'rgba(0, 0, 0, 0)', 'Approve is filled');+ assert.equal(actions[1].background, 'rgba(0, 0, 0, 0)', 'Decline is outlined');+ assert.ok(actions.every(e=>e.height >= tapTarget(width) && e.border === '1px'), `${width}px ${theme}: detail actions meet #371 targets`);++ await shot('spec', width, theme);+ await press(chrome, "document.querySelector('[data-tab=doctrine]')");+ await press(chrome, "document.querySelector('#doctrine-chips [data-rows=\"doctrine:all\"]')");+ const pb1 = await rowState(`#doctrine-list [data-row="doctrine:${inherited.id}"]`);+ const pb2 = await rowState(`#doctrine-list [data-row="doctrine:${overridden.id}"]`);+ const pb3 = await rowState(`#doctrine-list [data-row="doctrine:${declined.id}"]`);+ const local = await rowState('#doctrine-list [data-row="doctrine:R1"]');+ assert.equal(pb1.source, `Pullboard v${standard.version}`, `${width}px ${theme}: an inherited standard row names its version`);+ assert.equal(pb2.source, `Pullboard v${standard.version}, overridden here`);+ assert.equal(pb3.source, `Pullboard v${standard.version}, declined here`);+ assert.equal(local.source, 'this repo');+ for (const row of [pb1,pb2,pb3,local]) {+ assert.match(row.className, /(?:^|\s)srow(?:\s|$)/u);+ assert.match(row.className, /(?:^|\s)row(?:\s|$)/u);+ assert.deepEqual(row.rowStyle, item.rowStyle, `${width}px ${theme}: every doctrine record shares Items geometry and type`);+ assert.ok(row.dot && !row.count && !row.overflow, `${width}px ${theme}: uncited rules have a dot, no zero-count marker, and no horizontal overflow`);+ }+ assert.ok(pb2.sourceBox.y > pb2.titleBox.y && Math.abs(pb2.sourceBox.x - pb2.titleBox.x) < 1);+ assert.ok(Math.abs(pb2.sourceBox.y - pb2.gateBox.y) < 2, `${width}px ${theme}: source and gate share the second line`);+ assert.ok(pb3.reason && Math.abs(pb3.reasonBox.y - pb3.sourceBox.y) < 2 && pb3.reasonBox.x > pb3.sourceBox.x, `${width}px ${theme}: a declined reason follows its source on the metadata line`);+ assert.equal(pb2.titleStyle.overflow, 'ellipsis');+ assert.equal(pb2.titleStyle.lines, 1);+ assert.ok(pb2.titleBox.width > 0, `${width}px ${theme}: the full-width detail rule still has a visible title line`);+ const sectionCounts = JSON.parse(await chrome.stable(`JSON.stringify([...document.querySelectorAll('#doctrine-list .spec-section-head')].map(e=>({name:e.querySelector('h4')?.innerText??'', count:e.querySelector('.section-count')?.textContent.trim()??null})))`));+ assert.ok(sectionCounts.some(e => e.count === String(standard.rows.length)), `${width}px ${theme}: the standard Rules header counts all merged standard ids`);+ assert.ok(sectionCounts.some(e => e.count === '2'), `${width}px ${theme}: the repo-only section keeps its own row count`);+ const citedRule = await rowState('#doctrine-list [data-row="doctrine:G1"]');+ assert.equal(citedRule.count, '1 item', `${width}px ${theme}: Doctrine counts its actual citing item on line one`);+ await press(chrome, "document.querySelector('#doctrine-list [data-row=\"doctrine:G1\"]')");+ const citedDetail = await chrome.stable("document.querySelector('#doctrine-detail').innerText");+ assert.ok(citedDetail.includes('This doctrine rule shares the citing item.') && citedDetail.includes('citation check') && citedDetail.includes('#1 A real item citing G1'), `${width}px ${theme}: Doctrine detail lists the actual item that cites it`);+ const allText = await chrome.stable('document.body.innerText.toLowerCase()');+ assert.equal(allText.includes('standard 1'), false, `${width}px ${theme}: the old label is absent`);++ await press(chrome, `document.querySelector('#doctrine-list [data-row="doctrine:${overridden.id}"]')`);+ await chrome.waitFor(`document.querySelector('#doctrine-detail h2 span')?.textContent === ${JSON.stringify(overridden.id)}`);+ await chrome.stable('window.scrollTo(0, 0)');+ await chrome.send('Input.dispatchKeyEvent', { type: 'keyDown', key: 'Enter', code: 'Enter' });+ await chrome.send('Input.dispatchKeyEvent', { type: 'keyUp', key: 'Enter', code: 'Enter' });+ const visibleDetail = JSON.parse(await chrome.stable("JSON.stringify((() => {const r=document.querySelector('#doctrine-detail h2').getBoundingClientRect(); return {top:r.top,bottom:r.bottom};})())"));+ assert.ok(visibleDetail.top >= -1 && visibleDetail.top < 900, `${width}px ${theme}: native Enter opens the picked detail in the viewport: ${JSON.stringify(visibleDetail)}`);+ detail = await chrome.stable("document.querySelector('#doctrine-detail').innerText");+ assert.ok(detail.includes(longOverride.trim()) && detail.includes('doctrine check') && detail.includes(inherited.id) && detail.toLowerCase().includes('items that cite it') && detail.includes('None yet.'), `${width}px ${theme}: Enter on the picked rule opens full detail: ${detail}`);+ assert.ok(!await chrome.stable('document.documentElement.scrollWidth > document.documentElement.clientWidth'), `${width}px ${theme}: no horizontal overflow`);+ await shot('doctrine', width, theme);+ }+ }+ // The same wide layout becomes touch-sized when its primary pointer is coarse.+ await chrome.send('Emulation.setDeviceMetricsOverride', { width: 1280, height: 900, deviceScaleFactor: 1, mobile: false });+ await chrome.send('Emulation.setTouchEmulationEnabled', { enabled: true, maxTouchPoints: 5 });+ await chrome.waitFor("matchMedia('(pointer: coarse)').matches");+ for (const kind of ['spec', 'doctrine']) {+ await press(chrome, `document.querySelector('[data-tab=${kind}]')`);+ await press(chrome, `document.querySelector('#${kind}-chips [data-rows="${kind}:all"]')`);+ const id = kind === 'spec' ? 'G1' : overridden.id;+ await press(chrome, `document.querySelector('#${kind}-list [data-row="${kind}:${id}"]')`);+ const targets = JSON.parse(await chrome.stable(`JSON.stringify((() => {+ const nodes = [...document.querySelectorAll('#${kind}-list [data-row], #${kind}-list [data-section-approve], #${kind}-detail [data-row-decision]')];+ return {coarse:matchMedia('(pointer: coarse)').matches, tap:getComputedStyle(document.documentElement).getPropertyValue('--tap').trim(),+ heights:nodes.map(node => ({name:node.dataset.row || node.textContent.trim(), height:node.getBoundingClientRect().height}))};+ })())`));+ assert.equal(targets.coarse, true, kind + ': the real wide Chrome viewport has a coarse primary pointer');+ assert.equal(targets.tap, '44px', kind + ': touch uses the accepted 44px sizing token');+ assert.ok(targets.heights.length > 2 && targets.heights.every(target => target.height >= 44), kind + ': rows and both detail decisions meet the touch target: ' + JSON.stringify(targets));+ }+ } finally {+ if (chrome) await closeSnapshotChrome(chrome);+ rmSync(profile, { recursive: true, force: true });+ await view.stop();+ }+});