Skip to content

Autonomous development for real products. Governed agents build from specs you approve, follow the rules you set, and nothing merges until another agent proves it. Your decisions, judgement and taste are the bar that work must clear. Declare your vision and let agents build it.

feat: house rules, the spec view and role guides [S6,S7,N6,I3]

Corey Olson6de4d282efe5
diff --git a/package.json b/package.json
index 79801499..32387744 100644
--- a/package.json
+++ b/package.json
@@ -14,6 +14,7 @@
"files": [
"bin",
"src",
+ "skills",
"docs",
"README.md",
"LICENSE",
diff --git a/skills/pullboard-decompose/SKILL.md b/skills/pullboard-decompose/SKILL.md
new file mode 100644
index 00000000..82e92cc5
--- /dev/null
+++ b/skills/pullboard-decompose/SKILL.md
@@ -0,0 +1,53 @@
+---
+name: pullboard-decompose
+description: Turn a client's ask into SPEC.md rows together with the person, one question at a time. Use when a project starts, when a brief or new requirements arrive, or when the person says "break this down" or "spec this out".
+---
+
+# Decompose an ask into the spec
+
+You turn what the client asked for into SPEC.md rows. You draft; the person decides.
+
+## Before you start
+
+- Read every document in `ask/`, or the brief the person points you to. Read SPEC.md and PRACTICE.md if they exist.
+- Run `pullboard spec check`, so you start from a clean spec.
+
+## The row format
+
+One requirement per line:
+
+```
+- G1.2 [draft, must] Same file twice is a no-op. | gate: idempotency test | serves: G1
+```
+
+- **id:** a track letter and a number. Never reuse one, even after a row is retired.
+- **status:** `approved` only on the person's word. Your rows are `draft`. An open question is `pending`, with its text phrased as the question.
+- **tier:** `must` or `aim`.
+- **text:** one requirement, under 20 words.
+- **gate:** the test or check that would prove it.
+
+## How to work
+
+1. Group the ask into tracks: the goals, the main things the product handles, money, people and roles, constraints, outside dependencies. One `##` section per track.
+2. Draft rows track by track. Each row traces to something the client said. Nothing the client did not ask for is ever approved.
+3. Sort what the ask leaves open:
+ - **A sensible default exists and a wrong guess is cheap:** write a draft row that states the assumption, such as "Reminders go by text; email can come later." The person can flip it.
+ - **It changes scope, money, safety or a must-row:** write a pending row phrased as a question.
+
+ Ask only what blocks a must-row; a spec with forty questions is a spec nobody answers.
+4. Look hard for what clients leave out:
+ - two statements that cannot both be true
+ - a number the system needs that nobody gave
+ - a need nobody mentioned: refunds, privacy, what happens when something runs out
+ - an outside party nobody chose: payments, an existing system
+ - a nice-to-have phrased as a must, or the reverse
+5. Show the person one track at a time. Ask the pending questions one at a time, the most consequential first, each with your recommended answer.
+6. After each answer, update the row and keep its id: pending becomes approved with the answer as its text, or draft becomes approved. Run `pullboard spec check`.
+7. Never mark a row approved without the person saying so. Never delete a row; retire it.
+
+## Done
+
+- Every part of the ask is covered by a row, or by a stated reason it is out of scope.
+- Every approved must-row names its gate.
+- What remains pending is only the questions the person has not answered yet.
+- `pullboard spec check` passes, and the spec is committed with a `docs(spec): ...` message.
diff --git a/skills/pullboard-signoff/SKILL.md b/skills/pullboard-signoff/SKILL.md
new file mode 100644
index 00000000..fde27bee
--- /dev/null
+++ b/skills/pullboard-signoff/SKILL.md
@@ -0,0 +1,31 @@
+---
+name: pullboard-signoff
+description: Walk the person through approved spec rows so they can sign off what is met, one batch at a time. Use when the person asks to sign off, to review what is done, or to prepare a handoff or demo, or before telling anyone the build matches the spec.
+---
+
+# Sign-off walkthrough
+
+Only a person signs. You show the evidence, row by row, and record their word. A sign-off keeps the row text the person read; if the row changes later, the sign-off goes stale on its own.
+
+## Prepare
+
+1. Run `pullboard spec unmet --must` to list the approved must-rows without a current sign-off.
+2. For each row, find:
+ - **Where to see it:** a command, a URL, a screen.
+ - **The proof:** its gate, and the test that cites its id.
+ - **Your read:** met, partly met, or not built.
+3. Group the rows into batches of five to ten, by section.
+
+## Walk
+
+For each batch, show one table: id · what it says · where to see it · the proof · your read.
+
+- Say "not built" plainly. Never present a partial as met.
+- Offer to run the proof in front of the person.
+- Ask which rows they sign, and record only those: `pullboard spec signoff <ids> --by <their initials>`.
+- If they disagree with what a row says, that is a spec change, not a sign-off. Draft the new text; once they approve it, the row is ready to be signed again.
+
+## Done
+
+- Every approved must-row is signed, or has a stated reason it is not yet met.
+- `.pullboard/signoffs.jsonl` is committed with a `docs(spec): sign-off ...` message.
diff --git a/skills/pullboard-spec-review/SKILL.md b/skills/pullboard-spec-review/SKILL.md
new file mode 100644
index 00000000..5f8de0b7
--- /dev/null
+++ b/skills/pullboard-spec-review/SKILL.md
@@ -0,0 +1,28 @@
+---
+name: pullboard-spec-review
+description: Review the spec, and the product built from it, against the client's ask, the way the client or an evaluator will see them. Use before a handoff, demo or submission, or when the person asks "what will they think of this".
+---
+
+# Spec review
+
+Verification checks the work against the spec. This checks the spec, and what was built from it, against the client. Read as the client will, not as the builder did.
+
+## Read
+
+- The ask (`ask/`, or the brief), SPEC.md, PRACTICE.md and the README.
+- The product itself: run it, open it, use it as the client would.
+
+## Look for
+
+- Asks with no row, and rows nobody asked for.
+- Rows met to the letter that miss what the client meant.
+- A number the client cares about shown blank or zero because an input is missing. Demonstrate the mechanism with a labelled assumption instead.
+- Test or demo data that borrows real names from the client's world.
+- Text meant for people that shows ids, field names, raw values or jargon.
+- Alerts with nothing at stake, and rankings that disagree with each other.
+- Docs that describe code that does not exist, and a README that no longer matches the product.
+- Anything that addresses the evaluator instead of the work.
+
+## Report
+
+Rank the findings by what the client would notice first. For each: what it is, where it is (a file and line, or a screen), why it matters to the client, and the fix. Put decisions that belong to the person at the top. Write the report to a file the person can hand to the build's coordinator.
diff --git a/skills/pullboard-verify/SKILL.md b/skills/pullboard-verify/SKILL.md
new file mode 100644
index 00000000..7be6bf61
--- /dev/null
+++ b/skills/pullboard-verify/SKILL.md
@@ -0,0 +1,20 @@
+---
+name: pullboard-verify
+description: Verify another agent's submitted item at its exact commit, against the criterion frozen when it was claimed, and record a typed verdict. Use when an item awaits verification, or when asked to verify, check or review a submitted item.
+---
+
+# Verify a submitted item
+
+You never verify your own work. You judge the frozen criterion as written, at the commit that was submitted.
+
+1. Pick a submitted item you did not build: `pullboard list --all`. Then `pullboard show <id>` gives the criterion as frozen at claim, and the submitted commit.
+2. Check out exactly that commit: `git switch --detach <commit>`.
+3. Run the gate. Then test the criterion itself, with the strongest proof you can get:
+ - **Break it and watch it fail.** Revert or break the change, show the check fails, restore it, show it passes.
+ - **Use the method the criterion names.** If it says "two real processes" or "after a restart", use exactly that; a weaker stand-in is not proof.
+ - **Run the behavior** and read the output.
+ - **Read the code** only when the criterion is about the code itself. It is the weakest proof.
+4. Decide:
+ - `pullboard verify <id> accept`, only when the criterion is met as written.
+ - `pullboard verify <id> reject --reason <CODE> --note "<what failed, and the proof that would settle it>"`. The codes are TEST_FAILURE, BEHAVIOR_MISMATCH, INSUFFICIENT_EVIDENCE, STALE_HEAD and OTHER.
+5. If the check could not run for reasons that are not the work's fault, such as a broken environment or a flaky run under load, do not reject. Shout the coordinator what happened.
diff --git a/src/cli.js b/src/cli.js
index 0f166a2a..ac063f65 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -2,8 +2,9 @@
* The pullboard command line: every command, bound to who is asking (B3). The main checkout is the
* coordinator; every other worktree is the agent that joined from it.
*/
-import { readFileSync } from 'node:fs';
-import { join } from 'node:path';
+import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { dirname, join, resolve } from 'node:path';
+import { pathToFileURL } from 'node:url';
import { parseArgs } from 'node:util';
import * as store from './board.js';
import { COORDINATOR, loadConfig } from './config.js';
@@ -18,6 +19,7 @@ import {
import { initRepo } from './init.js';
import { isLane, laneNames } from './lanes.js';
import { Refused } from './refused.js';
+import { promptFor } from './skills.js';
import {
frozenCriterion,
idProblems,
@@ -28,6 +30,7 @@ import {
standings,
unmetRows,
} from './spec.js';
+import { renderSpecView } from './view.js';
const PACKAGE = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
export const VERSION = PACKAGE.version;
@@ -62,7 +65,12 @@ Receipts
pullboard log [id] every move, in order
Spec
- pullboard spec check | show <id> | unmet [--must] | signoff <ids> --by <initials>
+ pullboard spec check lint SPEC.md and PRACTICE.md
+ pullboard spec view [--out file] the spec, open questions, sign-offs and practice as one page
+ pullboard spec show <id> | unmet [--must] | signoff <ids> --by <initials>
+
+Role guides
+ pullboard prompt decompose|signoff|review|verify how to do each role; Claude Code gets them as skills
Gate and hooks
pullboard gate run the configured gate
@@ -78,6 +86,7 @@ const OPTIONS = {
reason: { type: 'string' },
note: { type: 'string' },
by: { type: 'string' },
+ out: { type: 'string' },
all: { type: 'boolean' },
must: { type: 'boolean' },
json: { type: 'boolean' },
@@ -472,14 +481,36 @@ function specCommand(io, { first, second, rest, values }) {
const ctx = context(io);
const spec = loadSpec(ctx.info.root, ctx.config);
if (!spec.exists) throw new Refused('NO_SPEC', `no ${ctx.config.spec}; run: pullboard init`);
+ const practice = loadSpec(ctx.info.root, { ...ctx.config, spec: ctx.config.practice });
if (first === 'check' || first === undefined) {
- const findings = lintSpec(spec);
- findings.forEach((finding) => io.say(`${ctx.config.spec}:${finding.line} ${finding.id ?? ''} ${finding.level}: ${finding.message}`.replace(' ', ' ')));
- const errors = findings.filter((finding) => finding.level === 'error').length;
- io.say(`${spec.rows.length} rows, ${errors} errors, ${findings.length - errors} warnings`);
+ const files = [[ctx.config.spec, spec], ...(practice.exists ? [[ctx.config.practice, practice]] : [])];
+ let errors = 0;
+ for (const [name, parsed] of files) {
+ const findings = lintSpec(parsed);
+ findings.forEach((finding) => io.say(`${name}:${finding.line} ${finding.id ?? ''} ${finding.level}: ${finding.message}`.replace(' ', ' ')));
+ const fileErrors = findings.filter((finding) => finding.level === 'error').length;
+ errors += fileErrors;
+ io.say(`${name}: ${parsed.rows.length} rows, ${fileErrors} errors, ${findings.length - fileErrors} warnings`);
+ }
return errors ? 1 : 0;
}
const signoffs = readSignoffs(ctx.info.root);
+ if (first === 'view') {
+ const out = values.out ? resolve(ctx.io.cwd, values.out) : join(ctx.info.gitDir, 'pullboard', 'spec.html');
+ const html = renderSpecView({
+ title: spec.title,
+ spec,
+ practice,
+ signoffs,
+ generatedAt: new Date().toISOString().slice(0, 16).replace('T', ' '),
+ files: { spec: ctx.config.spec, practice: ctx.config.practice },
+ });
+ mkdirSync(dirname(out), { recursive: true });
+ writeFileSync(out, html);
+ io.say(`wrote ${out}`);
+ io.say(`open: ${pathToFileURL(out).href}`);
+ return 0;
+ }
if (first === 'show') {
const row = spec.rows.find((entry) => entry.id === second);
if (!row) throw new Refused('NO_ROW', `no row ${second ?? ''} in ${ctx.config.spec}`);
@@ -502,7 +533,7 @@ function specCommand(io, { first, second, rest, values }) {
io.say(`signed ${count} rows as ${values.by}; commit .pullboard/signoffs.jsonl`);
return 0;
}
- throw new Refused('USAGE', 'pullboard spec check | show <id> | unmet [--must] | signoff <ids> --by <initials>');
+ throw new Refused('USAGE', 'pullboard spec check | view | show <id> | unmet [--must] | signoff <ids> --by <initials>');
}
/**
@@ -589,6 +620,16 @@ export async function main(argv, streams) {
const args = { first, second, rest, values };
try {
if (command === 'spec') return specCommand(io, args);
+ if (command === 'prompt') {
+ let root = io.cwd;
+ try {
+ root = repoInfo(io.cwd).root;
+ } catch (error) {
+ if (!(error instanceof Refused)) throw error;
+ }
+ io.say(promptFor(root, first ?? '').trimEnd());
+ return 0;
+ }
if (command === 'hook') return await hookCommand(io, args);
if (command === 'gate') {
const ctx = context(io);
diff --git a/src/config.js b/src/config.js
index 549ffec2..092f600e 100644
--- a/src/config.js
+++ b/src/config.js
@@ -34,6 +34,7 @@ const COMMIT_TYPES = [
export function defaults() {
return {
spec: 'SPEC.md',
+ practice: 'PRACTICE.md',
gate: '',
lease: '2h',
verify: 'any',
@@ -124,6 +125,7 @@ function laneProblems(name, lane) {
export function configProblems(config) {
const problems = [];
if (typeof config.spec !== 'string' || !config.spec) problems.push('"spec" names a file');
+ if (typeof config.practice !== 'string' || !config.practice) problems.push('"practice" names a file');
if (typeof config.gate !== 'string') problems.push('"gate" is a shell command, like "npm test"');
if (!['any', COORDINATOR].includes(config.verify)) {
problems.push('"verify" is "any" (any other agent) or "coordinator"');
diff --git a/src/init.js b/src/init.js
index fb721a48..8f1dd200 100644
--- a/src/init.js
+++ b/src/init.js
@@ -9,7 +9,8 @@ import { basename, join } from 'node:path';
import { CONFIG_FILE, COORDINATOR } from './config.js';
import { installHooks } from './hooks.js';
import { Refused } from './refused.js';
-import { AGENTS_START, agentsBlock, configTemplate, specTemplate } from './templates.js';
+import { installSkills } from './skills.js';
+import { AGENTS_START, agentsBlock, configTemplate, practiceTemplate, specTemplate } from './templates.js';
const NPM_DEFAULT_TEST = 'echo "Error: no test specified" && exit 1';
@@ -101,8 +102,10 @@ export function initRepo({ info, openBoardHere, register, closeBoard }) {
const notes = [
writeNew(join(root, CONFIG_FILE), configTemplate(gate), CONFIG_FILE),
writeNew(join(root, 'SPEC.md'), specTemplate(basename(root)), 'SPEC.md'),
+ writeNew(join(root, 'PRACTICE.md'), practiceTemplate(), 'PRACTICE.md'),
...writeAgentDocs(root),
...installHooks(root),
+ ...installSkills(root),
];
const board = openBoardHere();
try {
diff --git a/src/skills.js b/src/skills.js
new file mode 100644
index 00000000..aa6ed1e6
--- /dev/null
+++ b/src/skills.js
@@ -0,0 +1,80 @@
+/**
+ * Role guides (N6): how an agent decomposes an ask with the person, walks them through sign-off,
+ * reviews the spec against the client, and verifies another agent's work. One source per role,
+ * three ways in: Claude Code skills that init installs, `pullboard prompt <role>` for any other
+ * agent, and a repo's own override in `.pullboard/prompts/<role>.md`.
+ */
+import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs';
+import { join } from 'node:path';
+import { fileURLToPath } from 'node:url';
+import { Refused } from './refused.js';
+
+const SKILLS_DIR = fileURLToPath(new URL('../skills/', import.meta.url));
+
+/**
+ * Each role and the skill that carries it.
+ */
+export const ROLES = {
+ decompose: 'pullboard-decompose',
+ signoff: 'pullboard-signoff',
+ review: 'pullboard-spec-review',
+ verify: 'pullboard-verify',
+};
+
+/**
+ * The skill file shipped with this package for a role.
+ *
+ * @param {string} role
+ * @returns {string}
+ */
+function shippedSkill(role) {
+ const name = ROLES[role];
+ if (!name) {
+ throw new Refused('NO_ROLE', `no role "${role}"; roles: ${Object.keys(ROLES).join(', ')}`);
+ }
+ return readFileSync(join(SKILLS_DIR, name, 'SKILL.md'), 'utf8');
+}
+
+/**
+ * A skill's text without its front matter, for agents that read plain instructions.
+ *
+ * @param {string} text
+ * @returns {string}
+ */
+export function withoutFrontMatter(text) {
+ return text.startsWith('---\n') ? text.slice(text.indexOf('\n---\n', 4) + 5).replace(/^\n+/, '') : text;
+}
+
+/**
+ * The guide for a role: the repo's own override when it has one, the shipped guide otherwise.
+ *
+ * @param {string} root
+ * @param {string} role
+ * @returns {string}
+ */
+export function promptFor(root, role) {
+ const override = join(root, '.pullboard', 'prompts', `${role}.md`);
+ if (ROLES[role] && existsSync(override)) return readFileSync(override, 'utf8');
+ return withoutFrontMatter(shippedSkill(role));
+}
+
+/**
+ * Install the role guides as Claude Code skills under `.claude/skills/`, never replacing a file
+ * that is already there (I2).
+ *
+ * @param {string} root
+ * @returns {string[]} What happened.
+ */
+export function installSkills(root) {
+ const written = [];
+ for (const [role, name] of Object.entries(ROLES)) {
+ const file = join(root, '.claude', 'skills', name, 'SKILL.md');
+ if (existsSync(file)) continue;
+ mkdirSync(join(root, '.claude', 'skills', name), { recursive: true });
+ writeFileSync(file, shippedSkill(role));
+ written.push(name);
+ }
+ return written.length
+ ? [`wrote Claude Code skills: ${written.join(', ')}`]
+ : ['kept the Claude Code skills'];
+}
diff --git a/src/templates.js b/src/templates.js
index 914d39aa..16d384e4 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -16,6 +16,7 @@ export function configTemplate(gate) {
const config = {
gate,
spec: 'SPEC.md',
+ practice: 'PRACTICE.md',
verify: 'any',
lease: '2h',
lanes: {},
@@ -46,6 +47,58 @@ Statuses: approved = decided · draft = proposed · pending = open question · f
`;
}
+/**
+ * A starter PRACTICE.md: the house rules as rows, in the spec's own format. A standard to edit, not
+ * a law: the project keeps, changes or retires each row, and approves what it keeps. A row whose gate
+ * names a check is enforced by that check; a row gated by review guides agents and reviewers.
+ *
+ * @returns {string}
+ */
+export function practiceTemplate() {
+ return `# Practice
+
+How this project is built: the house rules, as rows. SPEC.md says what to build; this file says how. Edit it for your project: keep, change or retire each row, and approve what you keep. A row whose gate names a check fails the build when broken; a row gated by review guides agents and reviewers.
+
+Statuses: approved = in force · draft = proposed · retired = dropped, id kept. Tiers: must · aim.
+
+## W · Writing
+- W1 [approved, must] Numbers over adjectives. No hedges, no filler. | gate: review
+- W2 [approved, must] Commit headers are type(scope): subject [ids], 72 characters at most. | gate: commit-msg hook
+- W3 [draft, aim] Ban the filler words basically, simply, just, very, robust, seamless, leverage. | gate: commit-msg hook, commits.banned
+- W4 [approved, must] Spec ids go in commits and code headers, never in words meant for people. | gate: review
+- W5 [draft, aim] One record per decision, at most 100 words, citing rows and naming who decided. | gate: review
+
+## C · Code
+- C1 [draft, must] Files under 1,000 lines; functions under 60; complexity 10; nesting 3; parameters 3. | gate: linter
+- C2 [draft, must] Every exported function has a doc comment saying why, not restating its name. | gate: linter
+- C3 [draft, must] Comments explain why and sit above the code; no commented-out code in the main line. | gate: linter, review
+- C4 [draft, must] Errors and logs never echo input values. | gate: review
+- C5 [draft, aim] Plain over clever: early returns, named intermediate values, one idea per line. | gate: review
+- C6 [draft, must] No inline ignore comments; exceptions live in config, each with its reason. | gate: linter
+
+## T · Tests
+- T1 [approved, must] Every feature and fix cites the spec rows it serves, and a test proves each one. | gate: commit-msg hook, review
+- T2 [draft, must] A test fails when the code is wrong: break the code once and watch it go red. | gate: mutation testing on critical code
+- T3 [draft, must] No test marked as expected to fail without an open item. | gate: review
+- T4 [draft, aim] Tests use real dependencies where practical, not mocks of them. | gate: review
+
+## G · Git and the gate
+- G1 [approved, must] The gate passes on a clean tree before every push. | gate: pre-push hook
+- G2 [approved, must] Never bypass a hook. Never rewrite the main line, except to remove a secret. | gate: review
+- G3 [approved, must] Work stays in its lane; changes elsewhere go through the lane's owner. | gate: pre-commit lane check
+- G4 [approved, must] The builder never verifies its own work. | gate: pullboard verify
+
+## D · Dependencies
+- D1 [draft, must] A new dependency states its need, the built-in it replaces, and what it pulls in. | gate: review
+- D2 [draft, aim] Install scripts only from native drivers. | gate: package manager allowlist
+
+## S · Security and data
+- S1 [approved, must] No secrets and no env files in git. | gate: pre-commit secret scan
+- S2 [draft, must] Real customer data never enters the repo or an agent's context; test data is synthetic. | gate: review
+- S3 [draft, must] Every entry point declares who may use it; anything undeclared is denied. | gate: review
+`;
+}
+
/**
* The agent instructions, between markers so init can find its own block and never touch the rest.
*
@@ -59,6 +112,10 @@ This repo runs on pullboard: a work board, lanes and a spec that live in git. No
**Source of truth.** \`SPEC.md\` holds every requirement as a row with an id, like \`G1.2\`. Code follows the spec. Commits cite the ids they serve: \`feat(scope): subject [G1.2]\`. Only a person approves or changes an approved row.
+**House rules.** \`PRACTICE.md\` holds how this project is built, in the same row format. Its approved rows are in force; follow them as you would the spec.
+
+**Role guides.** \`pullboard prompt decompose\`, \`signoff\`, \`review\` and \`verify\` print the guide for each role. Claude Code also has them as skills.
+
**Who you are.** An agent is its worktree. The main checkout is the coordinator. Every other agent works in its own worktree and joins one lane:
git worktree add ../<repo>-<lane> -b <lane>/<slug>
diff --git a/src/view.js b/src/view.js
new file mode 100644
index 00000000..fa7ec40b
--- /dev/null
+++ b/src/view.js
@@ -0,0 +1,189 @@
+/**
+ * `pullboard spec view` (S7): the spec, its open questions, its sign-offs and the house rules as one
+ * page for people. One self-contained HTML file: no server, no network, nothing to install. Every
+ * piece of text from the files is escaped, so a row can never inject markup into the page.
+ */
+import { standings } from './spec.js';
+
+const ESCAPES = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#39;' };
+
+/**
+ * Text made safe to place in HTML.
+ *
+ * @param {unknown} text
+ * @returns {string}
+ */
+export const esc = (text) => String(text ?? '').replace(/[&<>"']/g, (char) => ESCAPES[char]);
+
+/**
+ * The sign-off cell for a row: who signed and when, stale, or not yet; blank unless approved.
+ *
+ * @param {any} row
+ * @param {Map<string, { met: any[], stale: any[] }>} by
+ * @returns {{ html: string, state: string }}
+ */
+function signoffCell(row, by) {
+ if (row.status !== 'approved') return { html: '', state: 'none' };
+ const standing = by.get(row.id);
+ if (standing?.met.length) {
+ const names = standing.met.map((entry) => `${esc(entry.by)} ${esc(entry.on)}`).join(', ');
+ return { html: `<span class="so so-met">signed ${names}</span>`, state: 'met' };
+ }
+ if (standing?.stale.length) {
+ return { html: '<span class="so so-stale">stale: text changed since sign-off</span>', state: 'stale' };
+ }
+ return { html: '<span class="so so-open">not signed</span>', state: 'open' };
+}
+
+/**
+ * One row as a table row, with its text kept in a data attribute for the search box.
+ *
+ * @param {any} row
+ * @param {Map<string, any>} by
+ * @param {boolean} withSignoff
+ * @returns {string}
+ */
+function rowHtml(row, by, withSignoff) {
+ const tier = row.tier ? ` <span class="tier">${esc(row.tier)}</span>` : '';
+ const serves = row.serves.length ? esc(row.serves.join(', ')) : '';
+ const search = esc(`${row.id} ${row.status} ${row.tier} ${row.text} ${row.gate}`.toLowerCase());
+ const signoff = withSignoff ? `<td>${signoffCell(row, by).html}</td>` : '';
+ return `<tr data-text="${search}"><td class="id">${esc(row.id)}</td><td><span class="st st-${esc(row.status)}">${esc(row.status)}</span>${tier}</td><td>${esc(row.text)}</td><td class="gate">${esc(row.gate)}</td><td class="id">${serves}</td>${signoff}</tr>`;
+}
+
+/**
+ * A table of rows under a heading.
+ *
+ * @param {string} heading
+ * @param {any[]} rows
+ * @param {Map<string, any>} by
+ * @param {boolean} withSignoff
+ * @returns {string}
+ */
+function tableHtml(heading, rows, by, withSignoff) {
+ if (!rows.length) return '';
+ const signoffHead = withSignoff ? '<th>Sign-off</th>' : '';
+ return `<h3>${esc(heading)}</h3><div class="scroll"><table><thead><tr><th>Id</th><th>Status</th><th>Row</th><th>Gate</th><th>Serves</th>${signoffHead}</tr></thead><tbody>${rows.map((row) => rowHtml(row, by, withSignoff)).join('')}</tbody></table></div>`;
+}
+
+/**
+ * A parsed spec's rows grouped under their section headings.
+ *
+ * @param {any} spec
+ * @param {Map<string, any>} by
+ * @param {boolean} withSignoff
+ * @returns {string}
+ */
+function sectionsHtml(spec, by, withSignoff) {
+ return spec.sections
+ .map((section) => tableHtml(section.name, spec.rows.filter((row) => row.section === section.name), by, withSignoff))
+ .join('');
+}
+
+/**
+ * The counts at the top: rows by status, and where the approved must-rows stand.
+ *
+ * @param {any} spec
+ * @param {Map<string, any>} by
+ * @returns {string}
+ */
+function summaryHtml(spec, by) {
+ const count = (status) => spec.rows.filter((row) => row.status === status).length;
+ const musts = spec.rows.filter((row) => row.status === 'approved' && row.tier === 'must');
+ const states = musts.map((row) => signoffCell(row, by).state);
+ const tally = (state) => states.filter((value) => value === state).length;
+ const items = [
+ [spec.rows.length, 'rows'],
+ [count('approved'), 'approved'],
+ [count('draft'), 'draft'],
+ [count('pending'), 'open questions'],
+ [`${tally('met')}/${musts.length}`, 'approved must-rows signed'],
+ [tally('stale'), 'sign-offs gone stale'],
+ ];
+ return `<div class="summary">${items.map(([value, label]) => `<div><b>${esc(value)}</b><span>${esc(label)}</span></div>`).join('')}</div>`;
+}
+
+const STYLE = `
+:root { --bg: #f4f6f3; --card: #fff; --ink: #17211b; --muted: #5a665f; --rule: #d7ddd8;
+ --approved: #1d7748; --draft: #5a665f; --pending: #8a5b0c; --fact: #2b55a3; --retired: #9aa39e; --stale: #a1453a; }
+@media (prefers-color-scheme: dark) { :root { --bg: #101512; --card: #161d19; --ink: #e5ebe7; --muted: #9aa69f;
+ --rule: #29322d; --approved: #57c48d; --draft: #9aa69f; --pending: #e0b25a; --fact: #86a9ee; --retired: #6f7a74; --stale: #e08a7e; color-scheme: dark; } }
+* { box-sizing: border-box; }
+body { margin: 0; background: var(--bg); color: var(--ink); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif; }
+.wrap { max-width: 1180px; margin: 0 auto; padding: 24px 16px 48px; }
+h1 { margin: 0 0 4px; font-size: 1.7rem; } h3 { margin: 22px 0 8px; font-size: 1.05rem; }
+.intro { color: var(--muted); max-width: 70ch; margin: 0 0 14px; }
+.summary { display: flex; flex-wrap: wrap; gap: 10px 26px; padding: 12px 0; border-block: 1px solid var(--rule); margin-bottom: 14px; }
+.summary div { display: grid; } .summary b { font-size: 1.25rem; font-variant-numeric: tabular-nums; } .summary span { color: var(--muted); font-size: .85rem; }
+.tabs > input { position: absolute; opacity: 0; pointer-events: none; }
+.tabs nav { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
+.tabs nav label { padding: 6px 12px; border: 1px solid var(--rule); border-radius: 999px; cursor: pointer; background: var(--card); }
+#t-spec:checked ~ nav label[for=t-spec], #t-questions:checked ~ nav label[for=t-questions],
+#t-signoff:checked ~ nav label[for=t-signoff], #t-practice:checked ~ nav label[for=t-practice] { border-color: var(--ink); font-weight: 600; }
+#t-spec:focus-visible ~ nav label[for=t-spec], #t-questions:focus-visible ~ nav label[for=t-questions],
+#t-signoff:focus-visible ~ nav label[for=t-signoff], #t-practice:focus-visible ~ nav label[for=t-practice] { outline: 2px solid var(--fact); outline-offset: 2px; }
+.panel { display: none; }
+#t-spec:checked ~ #p-spec, #t-questions:checked ~ #p-questions, #t-signoff:checked ~ #p-signoff, #t-practice:checked ~ #p-practice { display: block; }
+.search { width: 100%; max-width: 420px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: 6px; background: var(--card); color: var(--ink); margin-bottom: 6px; font: inherit; }
+.scroll { overflow-x: auto; border: 1px solid var(--rule); border-radius: 8px; background: var(--card); }
+table { border-collapse: collapse; width: 100%; font-size: .92rem; }
+th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
+th { color: var(--muted); font-weight: 600; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
+tr:last-child td { border-bottom: none; }
+td.id { font-family: ui-monospace, Menlo, Consolas, monospace; white-space: nowrap; color: var(--muted); }
+td.gate { color: var(--muted); }
+.st { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: .78rem; font-weight: 600; }
+.st-approved { color: var(--approved); } .st-draft { color: var(--draft); } .st-pending { color: var(--pending); }
+.st-fact { color: var(--fact); } .st-retired { color: var(--retired); text-decoration: line-through; }
+.tier { color: var(--muted); font-size: .78rem; }
+.so { font-size: .82rem; white-space: nowrap; } .so-met { color: var(--approved); } .so-stale { color: var(--stale); } .so-open { color: var(--muted); }
+.empty { color: var(--muted); }
+footer { margin-top: 28px; color: var(--muted); font-size: .82rem; }
+`;
+
+const SCRIPT = `
+document.querySelectorAll('.search').forEach(function (box) {
+ box.addEventListener('input', function () {
+ var query = box.value.trim().toLowerCase();
+ box.parentElement.querySelectorAll('tr[data-text]').forEach(function (row) {
+ row.hidden = query !== '' && row.getAttribute('data-text').indexOf(query) === -1;
+ });
+ });
+});
+`;
+
+/**
+ * The whole page.
+ *
+ * @param {{ title: string, spec: any, practice: any, signoffs: any[], generatedAt: string, files: { spec: string, practice: string } }} input
+ * @returns {string}
+ */
+export function renderSpecView({ title, spec, practice, signoffs, generatedAt, files }) {
+ const by = standings(spec.rows, signoffs);
+ const pending = spec.rows.filter((row) => row.status === 'pending');
+ const approved = spec.rows.filter((row) => row.status === 'approved');
+ const order = { open: 0, stale: 1, met: 2, none: 3 };
+ const bySignoff = [...approved].sort((first, second) => order[signoffCell(first, by).state] - order[signoffCell(second, by).state]);
+ const search = '<input class="search" type="search" placeholder="Filter rows" aria-label="Filter rows">';
+ const practicePanel = practice?.exists
+ ? sectionsHtml(practice, new Map(), false)
+ : `<p class="empty">No ${esc(files.practice)} yet. Run pullboard init to start from the standard practice.</p>`;
+ return `<!doctype html>
+<html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1">
+<title>${esc(title || 'Spec')}</title><style>${STYLE}</style></head>
+<body><div class="wrap">
+<h1>${esc(title || 'Spec')}</h1>
+${spec.intro.length ? `<p class="intro">${esc(spec.intro[0])}</p>` : ''}
+${summaryHtml(spec, by)}
+<div class="tabs">
+<input type="radio" name="tab" id="t-spec" checked><input type="radio" name="tab" id="t-questions"><input type="radio" name="tab" id="t-signoff"><input type="radio" name="tab" id="t-practice">
+<nav><label for="t-spec">Spec</label><label for="t-questions">Open questions (${pending.length})</label><label for="t-signoff">Sign-off</label><label for="t-practice">Practice</label></nav>
+<section class="panel" id="p-spec">${search}${sectionsHtml(spec, by, true)}</section>
+<section class="panel" id="p-questions">${pending.length ? tableHtml('Waiting on the person', pending, by, false) : '<p class="empty">No open questions.</p>'}</section>
+<section class="panel" id="p-signoff">${search}${approved.length ? tableHtml('Approved rows, unsigned first', bySignoff, by, true) : '<p class="empty">No approved rows yet.</p>'}</section>
+<section class="panel" id="p-practice">${search}${practicePanel}</section>
+</div>
+<footer>From ${esc(files.spec)}${practice?.exists ? ` and ${esc(files.practice)}` : ''} · generated ${esc(generatedAt)} · sign with: pullboard spec signoff &lt;ids&gt; --by &lt;initials&gt;</footer>
+</div><script>${SCRIPT}</script></body></html>
+`;
+}