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(health): name every stuck item, why and who moves it next [A6]

Corey Olsoncce49c7fb712
diff --git a/docs/api.md b/docs/api.md
index 6d09e627..3b423788 100644
--- a/docs/api.md
+++ b/docs/api.md
@@ -82,6 +82,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec
| `stats` | `version:number`, `stats:object` |
| `status` | `version:number`, `me:object`, `mine:array`, `stats:object`, `reviewQueue:object`, `unread:number`, `relay:object` |
| `doctor` | `version:number`, `problems:array` |
+| `health` | `version:number`, `asOf:string`, `thresholds:object`, `stuck:array`, `waiting:array` |
| `skills` | `version:number`, `updated:array`, `current:array`, `customized:array` |
| `inbox` | `version:number`, `shouts:array` |
| `decisions` | `version:number`, `decisions:array` |
@@ -154,6 +155,44 @@ When outstanding reviews reach `verify.reviewRatio` times the active reviewers (
For HTTP `next`, a review offer returns success with `event: null`, `offer` and the ordinary CLI `result`. Send `args.build: true` to claim as before and receive the actual claim event. The unattended `run` command always supplies explicit build intent, records it on fresh claims, and prints the review backlog each iteration.
+## Board health
+
+`pullboard health` scans the board read-only and lists every stuck item with its cause, since when, the one next step and who takes it. It opens the board through a read-only connection, records no event, skips relay sync and asks git only `merge-tree`, which never touches a HEAD, index or working tree. It exits 0 when nothing is stuck and 1 when something is; the text form then prints `nothing is stuck`, or one line per finding: `#12 claim lapsed, since 2026-10-17 10:00 (2h): web-3's lease ran out and nobody is building it. Next, web-3 (builder): renew it with pullboard claim 12.`
+
+`health --json` returns `{version: 1, asOf, thresholds: {stuck, holds, release}, stuck: [...], waiting: [...]}`. `asOf` is the board clock's ISO time. Each finding in `stuck` and `waiting` is `{key, cause, item, subject, title, since, ageMinutes, why, next, command, owner: {role, who}, detail}`:
+
+- `key` names the cause and what is stuck, like `CLAIM_LAPSED:item:12`, `HOLD_STALE:lane:docs`, `DECISION_UNANSWERED:shout:40` or `RELEASE_OVERDUE:release:v0.9.0`; it stays the same while the finding persists, so a watcher can post it once and notice when it clears.
+- `item` is the item id, or `null` for a lane hold, a decision or a release; `subject` is the same thing as text (`#12`, `lane docs`, `decision #40`, `release v0.9.0`).
+- `since` is when the wait began, in ISO time; `ageMinutes` counts whole minutes from it to `asOf`.
+- `why` and `next` are plain sentences; `command` is the exact command for the next step, or `null` when the step has none.
+- `owner.role` is `builder`, `reviewer`, `coordinator` or `person`; `owner.who` is the agent, lane, `coordinator` or `person`, and `null` when any reviewer may take it.
+- `detail` holds the cause's facts: `holder`, `reviewer`, `builder`, `commit`, `files` and `trunk` for a conflict, `parent` for a stacked item, `reason` and `by` for a hold, `withdrawn`, `after`, `move` and `milestone`, `shout`, `from` and `to`, or `release` and `landed`.
+
+The causes, each with its owner:
+
+| cause | stuck when | owner |
+|---|---|---|
+| `CLAIM_LAPSED` | a claim's lease ran out; `since` is when it ran out | the holder |
+| `REVIEW_LAPSED` | a review reservation's lease ran out with no verdict | a reviewer |
+| `NO_REVIEWER` | a submission has had no reviewer past `health.stuck` | a reviewer |
+| `UNLANDED_CONFLICT` | accepted past `health.stuck` and its commit conflicts with the trunk; `detail.files` names the files | its builder |
+| `UNLANDED_HELD` | accepted past `health.stuck` and held; `detail.reason` names the hold | who holds it |
+| `UNLANDED_STACKED` | accepted past `health.stuck` and carrying another item's commit that has no accept | a reviewer, or that item's builder |
+| `UNLANDED_WAITING` | accepted past `health.stuck` and waiting on an item it lands after | the coordinator |
+| `UNLANDED_READY` | accepted past `health.stuck`, merges cleanly and nobody landed it | the coordinator |
+| `HOLD_STALE` | an item or lane hold older than `health.holds` | who holds it |
+| `CONFLICT_HOLD_CLEARS` | a hold whose reason names a conflict, on an item whose commit now merges cleanly | who holds it |
+| `REWORK_UNCLAIMED` | rejected or reopened in the current release and unclaimed past `health.stuck` | its builder |
+| `REWORK_LATER` | the same in a later milestone; listed in `waiting` | its builder |
+| `AFTER_WITHDRAWN` | an unfinished item waits on a withdrawn item | the coordinator |
+| `DECISION_UNANSWERED` | a decision to the coordinator or the person is unanswered past `health.stuck` | the coordinator or the person |
+| `REQUEST_UNANSWERED` | a person's request is not done or declined past `health.stuck` | the coordinator |
+| `RELEASE_OVERDUE` | landed work waits and the newest version tag is older than `health.release` | the coordinator |
+
+The current release is the roadmap's first milestone with unverified local work; an unplanned item counts as current. A release is the newest tag named like `v1.2.3` or `1.2.3`, dated by its creation, and its landed work is every item first recorded merged after it. A repository with no such tag has no release deadline. The trunk is the primary checkout's branch, or the retained trunk when that checkout is detached.
+
+`pullboard.json` sets the thresholds under `health`, each a duration like `90m`, `2h` or `1d`: `stuck` (default `1h`), `holds` (default `1d`) and `release` (default `1d`). A value that is not a duration is refused as `BAD_CONFIG`.
+
## Item threads
`pullboard fact <id> <kind> "<text>"` appends a fact to an existing item. The observation kinds are `capture`, `measurement`, `note` and `diff`; any registered agent may append them. The judgement kinds are `decision`, `rejection`, `supersession` and `root-cause`; only the item's live lease holder or the coordinator may append them. An expired lease gives no judgement permission. Facts do not change the item's status or its claim.
diff --git a/src/cli.js b/src/cli.js
index ccf54309..df976532 100644
--- a/src/cli.js
+++ b/src/cli.js
@@ -81,6 +81,7 @@ import { forgetView, portHolder, rememberView, runningView } from './view-sessio
import { serveApi } from './api.js';
import { serveMcp } from './mcp.js';
import { doctorProblems, doctrineProblems } from './doctor.js';
+import { boardHealth, healthLines } from './health.js';
import { staleFrozenItems, staleItemFinding } from './approved-rows.js';
import { mainPolicy, policyAt, itemPolicy, submissionPaths, frozenCheck, checkAtCommit, dependencySnapshots, requireTrunkMerge, trunkRef } from './trusted-policy.js';
import { proofStats } from './stats.js';
@@ -2162,6 +2163,13 @@ function readCommands(io, { first, second, rest, values }) {
for (const problem of problems) if (problem !== checkpointProblem) io.say(`problem: ${problem.message}; repair: ${problem.next}`);
return 1;
},
+ health: () => {
+ const ctx = context(io);
+ const report = boardHealth(ctx.file, { root: ctx.info.root, config: ctx.config, now: ctx.clock.now() });
+ io.result?.(report);
+ for (const line of healthLines(report)) io.say(line);
+ return report.stuck.length ? 1 : 0;
+ },
inbox: () => {
const ctx = context(io);
const { shouts, agents } = withBoard(ctx, (board) => ({
@@ -4001,7 +4009,7 @@ async function runMain(argv, streams) {
positionals: parsed.positionals.slice(1),
values: Object.fromEntries(Object.keys(parsed.values).filter(key => key !== 'json').sort().map(key => [key, parsed.values[key]])) };
sync = Boolean(command) && !parsed.values.help && !parsed.values.version
- && !['help', 'version', 'hook', 'init', 'relay', 'tour', 'mcp'].includes(command)
+ && !['help', 'version', 'hook', 'init', 'relay', 'tour', 'mcp', 'health'].includes(command)
// A coordinator declaration on a linked clone must refuse before auto-link or relay sync.
&& !(command === 'join' && parsed.positionals[1] === COORDINATOR);
needsRepo = !(parsed.values.help || parsed.values.version || command === 'help' || command === 'version');
diff --git a/src/health.js b/src/health.js
new file mode 100644
index 00000000..6ed86963
--- /dev/null
+++ b/src/health.js
@@ -0,0 +1,435 @@
+/**
+ * `pullboard health`: every stuck item on the board, why it is stuck, since when, the one next step
+ * and who takes it [A6]. Doctor checks a board's integrity; health checks its flow, so nobody has
+ * to remember to look for a dead claim, an idle review or accepted work that never landed.
+ *
+ * It reads the board through a read-only SQLite connection and asks git only questions that leave
+ * every checkout alone: merge-tree writes a tree object and never an index or a working tree.
+ */
+import { existsSync } from 'node:fs';
+import { COORDINATOR, durationMs } from './config.js';
+import { mainCheckout, tryGit } from './git.js';
+import { boardBusyError, openBoardReadOnly, PERSON, roadmap, unverifiedSubmissions } from './board.js';
+import { localReleaseRank } from './release-queue.js';
+import { trunkRef } from './trusted-policy.js';
+
+/** Each threshold's pullboard.json key under "health" and its default. */
+export const HEALTH_DEFAULTS = Object.freeze({ stuck: '1h', holds: '1d', release: '1d' });
+
+/** Moves that start or end an item's wait, in the order the event log records them. */
+const LIFECYCLE = new Set(['add', 'claim', 'release', 'submit', 'accept', 'reject', 'reopen', 'refreeze', 'escalate', 'withdraw']);
+
+/**
+ * Read the thresholds from pullboard.json's "health" group, each a duration like 90m, 2h or 1d.
+ *
+ * @param {any} config
+ * @returns {{ stuck: string, holds: string, release: string, ms: { stuck: number, holds: number, release: number } }}
+ */
+export function healthThresholds(config = {}) {
+ const raw = config?.health ?? {};
+ const chosen = { ...HEALTH_DEFAULTS, ...(raw && typeof raw === 'object' && !Array.isArray(raw) ? raw : {}) };
+ const ms = Object.fromEntries(Object.keys(HEALTH_DEFAULTS).map((key) => [key, durationMs(chosen[key], `health.${key}`)]));
+ return { stuck: chosen.stuck, holds: chosen.holds, release: chosen.release, ms };
+}
+
+/**
+ * Scan a board file read-only. A missing board has nothing on it, so nothing is stuck.
+ *
+ * @param {string} file
+ * @param {{ root: string, config?: any, now: Date }} options
+ * @returns {ReturnType<typeof healthReport>}
+ */
+export function boardHealth(file, { root, config, now }) {
+ if (!existsSync(file)) return healthReport({ db: null, root, config, now });
+ const startedAt = Date.now();
+ let db;
+ try {
+ db = openBoardReadOnly(file);
+ return healthReport({ db, root, config, now });
+ } catch (error) {
+ throw boardBusyError(file, startedAt, error);
+ } finally {
+ db?.close();
+ }
+}
+
+/**
+ * Every stuck finding on an open board connection, and the rework that waits for a later release.
+ *
+ * @param {{ db: any, root: string, config?: any, now: Date }} options
+ * @returns {{ asOf: string, thresholds: { stuck: string, holds: string, release: string }, stuck: Finding[], waiting: Finding[] }}
+ */
+export function healthReport({ db, root, config, now }) {
+ const limits = healthThresholds(config);
+ const asOf = now.toISOString();
+ const report = { asOf, thresholds: { stuck: limits.stuck, holds: limits.holds, release: limits.release }, stuck: [], waiting: [] };
+ if (!db) return report;
+ const at = now.getTime();
+ const age = (iso) => at - Date.parse(iso);
+ const board = { db, clock: { now: () => now } };
+ const items = db.prepare('SELECT * FROM item ORDER BY item_id').all();
+ const byId = new Map(items.map((item) => [item.item_id, item]));
+ const history = itemHistory(db);
+ const trunk = trunkTip(root);
+ const releases = roadmap(board);
+ const found = (list, finding) => list.push(finding);
+ let stacks;
+ /** Load the unverified submitted heads once, only when an accepted item needs them. */
+ const stacked = () => (stacks ??= unverifiedSubmissions(board));
+
+ for (const item of items) {
+ const id = item.item_id;
+ const events = history.get(id) ?? { last: new Map(), lifecycle: null };
+ const status = item.item_status;
+ if (status === 'withdrawn' || (status === 'verified' && item.item_merged_commit)) continue;
+ let holdReported = false;
+
+ if (status === 'claimed' && (item.item_lease_until ?? '') <= asOf) {
+ const holder = item.item_owner;
+ found(report.stuck, finding('CLAIM_LAPSED', item, {
+ since: item.item_lease_until ?? item.item_updated_at, now: at,
+ title: 'claim lapsed',
+ why: `${holder}'s lease ran out and nobody is building it`,
+ next: `renew it with pullboard claim ${id}`, command: `pullboard claim ${id}`,
+ owner: { role: 'builder', who: holder }, detail: { holder },
+ }));
+ }
+
+ if (status === 'submitted') {
+ const reviewer = item.item_review_by;
+ const lapsed = reviewer && (item.item_review_until ?? '') <= asOf;
+ const submittedAt = events.last.get('submit')?.event_at ?? item.item_updated_at;
+ if (lapsed) {
+ found(report.stuck, finding('REVIEW_LAPSED', item, {
+ since: item.item_review_until ?? submittedAt, now: at,
+ title: 'review lapsed',
+ why: `${reviewer} reserved its review and the reservation ran out with no verdict`,
+ next: `take the review with pullboard next --verify ${id}`, command: `pullboard next --verify ${id}`,
+ owner: { role: 'reviewer', who: null }, detail: { reviewer, commit: item.item_commit },
+ }));
+ } else if (!reviewer && age(submittedAt) >= limits.ms.stuck) {
+ found(report.stuck, finding('NO_REVIEWER', item, {
+ since: submittedAt, now: at,
+ title: 'no reviewer',
+ why: `${item.item_built_by} submitted ${short(item.item_commit)} and nobody has reserved its review`,
+ next: `take the review with pullboard next --verify ${id}`, command: `pullboard next --verify ${id}`,
+ owner: { role: 'reviewer', who: null }, detail: { builder: item.item_built_by, commit: item.item_commit },
+ }));
+ }
+ }
+
+ if (status === 'verified') {
+ const acceptedAt = events.last.get('accept')?.event_at ?? item.item_updated_at;
+ if (age(acceptedAt) >= limits.ms.stuck) {
+ found(report.stuck, unlanded(item, { since: acceptedAt, now: at, trunk, root, byId, stacked }));
+ holdReported = Boolean(item.item_hold_reason);
+ }
+ }
+
+ if (status === 'open' && !item.item_hold_reason && ['reject', 'reopen'].includes(events.lifecycle?.event_kind)) {
+ const move = events.lifecycle;
+ if (age(move.event_at) >= limits.ms.stuck) {
+ const rank = localReleaseRank(releases, id);
+ const later = rank > 0 && rank < releases.length;
+ const builder = item.item_built_by;
+ const owner = builder ? { role: 'builder', who: builder } : { role: 'builder', who: item.item_lane };
+ const reason = move.event_kind === 'reject' ? `rejected by ${move.event_by}${rejectReason(move)}` : `reopened by ${move.event_by}`;
+ const milestone = later ? releases[currentRelease(releases) + rank]?.name : null;
+ found(later ? report.waiting : report.stuck, finding(later ? 'REWORK_LATER' : 'REWORK_UNCLAIMED', item, {
+ since: move.event_at, now: at,
+ title: later ? 'rework waits for a later release' : 'rework unclaimed',
+ why: later ? `${reason}; it is planned for ${milestone}, after the current release` : `${reason} and nobody has claimed it since`,
+ next: `claim it with pullboard claim ${id}`, command: `pullboard claim ${id}`,
+ owner, detail: { move: move.event_kind, by: move.event_by, ...(later ? { milestone } : {}) },
+ }));
+ }
+ }
+
+ if (['open', 'claimed', 'submitted'].includes(status)) {
+ const after = String(item.item_after ?? '').split(',').filter(Boolean).map(Number);
+ const gone = after.filter((other) => byId.get(other)?.item_status === 'withdrawn');
+ if (gone.length) {
+ const rest = after.filter((other) => !gone.includes(other));
+ const first = byId.get(gone[0]);
+ const since = history.get(gone[0])?.last.get('withdraw')?.event_at ?? first.item_updated_at;
+ found(report.stuck, finding('AFTER_WITHDRAWN', item, {
+ since, now: at,
+ title: 'waits on withdrawn work',
+ why: `it waits on ${gone.map((other) => `#${other}`).join(', ')}, withdrawn: ${firstLine(first.item_withdrawn_reason)}`,
+ next: `drop the wait with pullboard edit ${id} --after ${rest.join(',') || 'none'}`,
+ command: `pullboard edit ${id} --after ${rest.join(',') || 'none'}`,
+ owner: { role: 'coordinator', who: COORDINATOR }, detail: { withdrawn: gone },
+ }));
+ }
+ }
+
+ if (item.item_hold_reason && !holdReported) {
+ const holder = item.item_hold_by ?? COORDINATOR;
+ const owner = holder === PERSON ? { role: 'person', who: PERSON } : { role: 'coordinator', who: holder };
+ const clears = /conflict/iu.test(item.item_hold_reason) && item.item_commit && trunk
+ && conflictFiles(root, trunk.commit, item.item_commit)?.length === 0;
+ if (clears || age(item.item_hold_at) >= limits.ms.holds) {
+ found(report.stuck, finding(clears ? 'CONFLICT_HOLD_CLEARS' : 'HOLD_STALE', item, {
+ since: item.item_hold_at, now: at,
+ title: clears ? 'conflict hold now clears' : 'hold left on',
+ why: clears
+ ? `${holder} held it for a conflict (${firstLine(item.item_hold_reason)}), and ${short(item.item_commit)} now merges cleanly onto ${trunk.name}`
+ : `${holder} held it: ${firstLine(item.item_hold_reason)}`,
+ next: `lift the hold with pullboard hold ${id} --off`, command: `pullboard hold ${id} --off`,
+ owner, detail: { reason: item.item_hold_reason, by: holder },
+ }));
+ }
+ }
+ }
+
+ for (const hold of db.prepare('SELECT * FROM hold ORDER BY hold_lane').all()) {
+ if (age(hold.hold_at) < limits.ms.holds) continue;
+ const owner = hold.hold_by === PERSON ? { role: 'person', who: PERSON } : { role: 'coordinator', who: hold.hold_by };
+ found(report.stuck, finding('HOLD_STALE', null, {
+ subject: `lane ${hold.hold_lane}`, key: `HOLD_STALE:lane:${hold.hold_lane}`,
+ since: hold.hold_at, now: at,
+ title: 'hold left on',
+ why: `${hold.hold_by} held the ${hold.hold_lane} lane: ${firstLine(hold.hold_reason)}`,
+ next: `lift the hold with pullboard hold ${hold.hold_lane} --off`, command: `pullboard hold ${hold.hold_lane} --off`,
+ owner, detail: { lane: hold.hold_lane, reason: hold.hold_reason, by: hold.hold_by },
+ }));
+ }
+
+ for (const ask of unansweredAsks(db)) {
+ if (age(ask.shout_at) < limits.ms.stuck) continue;
+ const toPerson = ask.shout_to === PERSON;
+ const request = Boolean(ask.shout_request);
+ const command = request ? `pullboard answer ${ask.shout_id} done <what you did>`
+ : toPerson ? `pullboard answer ${ask.shout_id} "..." --as person` : `pullboard answer ${ask.shout_id} "..."`;
+ found(report.stuck, finding(request ? 'REQUEST_UNANSWERED' : 'DECISION_UNANSWERED', null, {
+ subject: `${request ? 'request' : 'decision'} #${ask.shout_id}`, key: `${request ? 'REQUEST_UNANSWERED' : 'DECISION_UNANSWERED'}:shout:${ask.shout_id}`,
+ since: ask.shout_at, now: at,
+ title: 'unanswered',
+ why: `${ask.shout_from} asked ${toPerson ? 'the person' : 'the coordinator'}: ${clip(firstLine(ask.shout_text))}`,
+ next: toPerson ? `answer it in the view, or with ${command}` : `answer it with ${command}`,
+ command,
+ owner: toPerson ? { role: 'person', who: PERSON } : { role: 'coordinator', who: COORDINATOR },
+ detail: { shout: ask.shout_id, from: ask.shout_from, to: ask.shout_to },
+ }));
+ }
+
+ const overdue = releaseOverdue(db, root, at, limits.ms.release, history);
+ if (overdue) found(report.stuck, overdue);
+ return report;
+}
+
+/**
+ * @typedef {{ key: string, cause: string, item: number|null, subject: string, title: string, since: string,
+ * ageMinutes: number, why: string, next: string, command: string|null,
+ * owner: { role: 'builder'|'reviewer'|'coordinator'|'person', who: string|null }, detail: object }} Finding
+ */
+
+/**
+ * Build one finding in the stable shape docs/api.md documents. Its key names the cause and what is
+ * stuck, so a sentinel can post each finding once and notice when it clears.
+ *
+ * @returns {Finding}
+ */
+function finding(cause, item, { subject, key, since, now, title, why, next, command = null, owner, detail = {} }) {
+ const label = subject ?? `#${item.item_id}`;
+ return {
+ key: key ?? `${cause}:item:${item.item_id}`, cause, item: item?.item_id ?? null, subject: label, title,
+ since, ageMinutes: Math.max(0, Math.floor((now - Date.parse(since)) / 60_000)), why, next, command, owner, detail,
+ };
+}
+
+/**
+ * Say why accepted work has not landed: a hold, a conflict with the trunk (naming its files and its
+ * builder), a stacked commit still in review, a dependency not landed yet, or nothing at all.
+ */
+function unlanded(item, { since, now, trunk, root, byId, stacked }) {
+ const id = item.item_id;
+ const builder = item.item_built_by;
+ if (item.item_hold_reason) {
+ const holder = item.item_hold_by ?? COORDINATOR;
+ const owner = holder === PERSON ? { role: 'person', who: PERSON } : { role: 'coordinator', who: holder };
+ const clears = /conflict/iu.test(item.item_hold_reason) && trunk && conflictFiles(root, trunk.commit, item.item_commit)?.length === 0;
+ return finding(clears ? 'CONFLICT_HOLD_CLEARS' : 'UNLANDED_HELD', item, {
+ since, now, title: clears ? 'conflict hold now clears' : 'accepted, held',
+ why: clears
+ ? `accepted and held for a conflict (${firstLine(item.item_hold_reason)}), and ${short(item.item_commit)} now merges cleanly onto ${trunk.name}`
+ : `accepted and held by ${holder}: ${firstLine(item.item_hold_reason)}`,
+ next: `lift the hold with pullboard hold ${id} --off${clears ? '' : ' once that is settled'}`, command: `pullboard hold ${id} --off`,
+ owner, detail: { reason: item.item_hold_reason, by: holder, commit: item.item_commit },
+ });
+ }
+ const files = trunk ? conflictFiles(root, trunk.commit, item.item_commit) : null;
+ if (files?.length) {
+ return finding('UNLANDED_CONFLICT', item, {
+ since, now, title: 'accepted, conflicts with the trunk',
+ why: `${short(item.item_commit)} conflicts with ${trunk.name} in ${files.slice(0, 5).join(', ')}${files.length > 5 ? ` and ${files.length - 5} more` : ''}`,
+ next: `merge ${trunk.name} into its branch, resolve ${files.length === 1 ? 'that file' : 'those files'}, and shout the coordinator the new head`,
+ command: `git merge ${trunk.name}`,
+ owner: { role: 'builder', who: builder }, detail: { files, trunk: trunk.name, commit: item.item_commit },
+ });
+ }
+ const parent = trunk && stacked().find((other) => other.item_id !== id
+ && tryGit(root, ['merge-base', '--is-ancestor', other.item_commit, item.item_commit]).status === 0
+ && tryGit(root, ['merge-base', '--is-ancestor', other.item_commit, trunk.commit]).status !== 0);
+ if (parent) {
+ const under = byId.get(parent.item_id);
+ const inReview = under?.item_status === 'submitted' && under.item_commit === parent.item_commit;
+ return finding('UNLANDED_STACKED', item, {
+ since, now, title: 'accepted, stacked on unaccepted work',
+ why: `it carries #${parent.item_id}'s commit ${short(parent.item_commit)}, which is ${inReview ? 'waiting for its review' : `${under?.item_status ?? 'missing'} and has no accept`}`,
+ next: inReview ? `verify #${parent.item_id} with pullboard next --verify ${parent.item_id}`
+ : `bring #${parent.item_id} back to review, or rebuild #${id} without it`,
+ command: inReview ? `pullboard next --verify ${parent.item_id}` : null,
+ owner: inReview ? { role: 'reviewer', who: null } : { role: 'builder', who: under?.item_built_by ?? builder },
+ detail: { parent: parent.item_id, commit: parent.item_commit },
+ });
+ }
+ const waits = String(item.item_after ?? '').split(',').filter(Boolean).map(Number)
+ .filter((other) => byId.get(other) && !byId.get(other).item_merged_commit && byId.get(other).item_status !== 'withdrawn');
+ if (waits.length) {
+ return finding('UNLANDED_WAITING', item, {
+ since, now, title: 'accepted, waits for its dependencies to land',
+ why: `it lands after ${waits.map((other) => `#${other}`).join(', ')}, which ${waits.length === 1 ? 'has' : 'have'} not landed`,
+ next: `land ${waits.map((other) => `#${other}`).join(', ')} first`, command: null,
+ owner: { role: 'coordinator', who: COORDINATOR }, detail: { after: waits },
+ });
+ }
+ return finding('UNLANDED_READY', item, {
+ since, now, title: 'accepted, not landed',
+ why: trunk ? `${short(item.item_commit)} merges cleanly onto ${trunk.name} and nobody has landed it` : 'nobody has landed it, and the trunk is unknown',
+ next: 'land it with pullboard land', command: 'pullboard land',
+ owner: { role: 'coordinator', who: COORDINATOR }, detail: { commit: item.item_commit },
+ });
+}
+
+/**
+ * A release past its deadline while landed work waits: the deadline runs from the newest version
+ * tag (v1.2.3 or 1.2.3), and the work is every item first recorded merged after that tag.
+ */
+function releaseOverdue(db, root, now, deadlineMs, history) {
+ const tags = tryGit(root, ['for-each-ref', '--sort=-creatordate', '--format=%(refname:short)%09%(creatordate:iso-strict)', 'refs/tags']);
+ if (tags.status !== 0 || !tags.stdout) return null;
+ const latest = tags.stdout.split('\n').map((line) => line.split('\t')).find(([name]) => /^v?\d+\.\d+\.\d+$/u.test(name ?? ''));
+ if (!latest) return null;
+ const [tag, dated] = latest;
+ const published = Date.parse(dated);
+ if (!Number.isFinite(published) || now - published < deadlineMs) return null;
+ const landed = [];
+ for (const item of db.prepare("SELECT item_id FROM item WHERE item_status = 'verified' AND item_merged_commit IS NOT NULL ORDER BY item_id").all()) {
+ const first = history.get(item.item_id)?.firstMerged;
+ if (first && Date.parse(first) > published) landed.push(item.item_id);
+ }
+ if (!landed.length) return null;
+ const since = new Date(published).toISOString();
+ const listed = landed.slice(0, 5).map((id) => `#${id}`).join(', ') + (landed.length > 5 ? ` and ${landed.length - 5} more` : '');
+ return finding('RELEASE_OVERDUE', null, {
+ subject: `release ${tag}`, key: `RELEASE_OVERDUE:release:${tag}`, since, now,
+ title: 'overdue',
+ why: `${landed.length} landed ${landed.length === 1 ? 'item waits' : 'items wait'} for a release since ${tag}: ${listed}`,
+ next: `publish the release after ${tag}`, command: null,
+ owner: { role: 'coordinator', who: COORDINATOR }, detail: { release: tag, landed },
+ });
+}
+
+/** Each item's latest event of every kind, its latest lifecycle move and its first merge record. */
+function itemHistory(db) {
+ const history = new Map();
+ for (const event of db.prepare('SELECT event_id, event_at, event_by, event_kind, item_id, event_detail FROM event WHERE item_id IS NOT NULL ORDER BY event_id').iterate()) {
+ let entry = history.get(event.item_id);
+ if (!entry) history.set(event.item_id, entry = { last: new Map(), lifecycle: null, firstMerged: null });
+ entry.last.set(event.event_kind, event);
+ if (LIFECYCLE.has(event.event_kind)) entry.lifecycle = event;
+ if (event.event_kind === 'merged' && !entry.firstMerged) entry.firstMerged = event.event_at;
+ }
+ return history;
+}
+
+/** Decisions to the coordinator or the person, and the person's requests, that nobody has closed. */
+function unansweredAsks(db) {
+ return db.prepare(`SELECT * FROM shout ask WHERE (
+ (ask.shout_decision = 1 AND ask.shout_to IN (?, ?) AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id))
+ OR (ask.shout_request = 1 AND NOT EXISTS (SELECT 1 FROM shout reply WHERE reply.shout_answers = ask.shout_id AND reply.shout_request_outcome IN ('done', 'declined'))))
+ ORDER BY ask.shout_id`).all(COORDINATOR, PERSON);
+}
+
+/** The primary checkout's branch and commit, or the retained trunk's, or null when neither reads. */
+function trunkTip(root) {
+ let ref;
+ try { ref = mainCheckout(root)?.branch ?? trunkRef(root); } catch { return null; /* A repo with no readable trunk skips merge checks. */ }
+ if (!ref?.startsWith('refs/heads/')) return null;
+ const tip = tryGit(root, ['rev-parse', '--verify', '--quiet', `${ref}^{commit}`]);
+ return tip.status === 0 ? { name: ref.replace(/^refs\/heads\//u, ''), commit: tip.stdout } : null;
+}
+
+/**
+ * The files a commit conflicts in when merged onto the trunk, [] when it merges cleanly, or null
+ * when git cannot tell. merge-tree computes the merge in the object store alone.
+ */
+export function conflictFiles(root, trunk, commit) {
+ if (!/^[0-9a-f]{40,64}$/u.test(commit ?? '')) return null;
+ const merge = tryGit(root, ['-c', 'core.quotepath=false', 'merge-tree', '--write-tree', '--name-only', '-z', trunk, commit]);
+ if (merge.status === 0) return [];
+ if (merge.status !== 1) return null;
+ const parts = merge.stdout.split('\0').slice(1);
+ const end = parts.indexOf('');
+ return parts.slice(0, end < 0 ? parts.length : end);
+}
+
+/** The index of the current release, as localReleaseRank counts it: the first with unverified local work. */
+function currentRelease(releases) {
+ const first = releases.findIndex((release) => release.items.some((entry) => typeof entry.id === 'number' && entry.status !== 'verified'));
+ return first < 0 ? 0 : first;
+}
+
+/** A reject's reason code in brackets, when it recorded one. */
+function rejectReason(event) {
+ try {
+ const reason = JSON.parse(event.event_detail)?.reason;
+ return reason ? ` (${reason})` : '';
+ } catch { return ''; /* Legacy details without JSON carry no reason. */ }
+}
+
+/** The first line of a text, for one-line output. */
+const firstLine = (text) => String(text ?? '').split('\n', 1)[0].trim();
+
+/** A long question cut to one readable line. */
+const clip = (text) => (text.length > 120 ? `${text.slice(0, 119).trimEnd()}…` : text);
+
+/** A commit's twelve-character short form. */
+const short = (commit) => String(commit ?? '').slice(0, 12);
+
+/** Format a finding's age the way resume does: 45m, 3h, 2d. */
+function ageText(minutes) {
+ if (minutes < 60) return `${minutes}m`;
+ if (minutes < 48 * 60) return `${Math.floor(minutes / 60)}h`;
+ return `${Math.floor(minutes / 1440)}d`;
+}
+
+/**
+ * The report as text: one line per stuck finding with its cause, since when, why, the next step
+ * and who takes it; then what waits for a later release. A clear board says nothing is stuck.
+ *
+ * @param {ReturnType<typeof healthReport>} report
+ * @returns {string[]}
+ */
+export function healthLines(report) {
+ const lines = [];
+ const line = (entry) => `${entry.subject} ${entry.title}, since ${entry.since.slice(0, 16).replace('T', ' ')} (${ageText(entry.ageMinutes)}): ${sentence(entry.why)} Next, ${ownerText(entry.owner)}: ${entry.next}.`;
+ if (!report.stuck.length) lines.push('nothing is stuck');
+ else lines.push(`${report.stuck.length} stuck:`, ...report.stuck.map((entry) => ` ${line(entry)}`));
+ if (report.waiting.length) lines.push('waiting for a later release:', ...report.waiting.map((entry) => ` ${line(entry)}`));
+ return lines;
+}
+
+/** End a reason with one full stop, keeping a clipped reason's ellipsis. */
+function sentence(text) {
+ const trimmed = text.replace(/[.\s]+$/u, '');
+ return trimmed.endsWith('…') ? trimmed : `${trimmed}.`;
+}
+
+/** Name who moves a finding next, with their role. */
+function ownerText({ role, who }) {
+ if (role === 'person') return 'the person';
+ if (role === 'coordinator') return who === COORDINATOR ? 'the coordinator' : `${who} (coordinator)`;
+ return who ? `${who} (${role})` : `a ${role}`;
+}
diff --git a/src/help.js b/src/help.js
index f04bad16..d67ad85d 100644
--- a/src/help.js
+++ b/src/help.js
@@ -79,6 +79,9 @@ Work
rename or update a milestone note
pullboard milestone remove <name> remove a milestone without changing its items
pullboard doctor check board integrity without changing it
+ pullboard health every stuck item: why, since when, the next step and who takes it
+ reads the board and changes nothing; exits 1 when something is stuck
+ pullboard.json health.stuck (default 1h), health.holds (1d), health.release (1d)
pullboard skills --update refresh unchanged Claude Code skills from shipped versions
pullboard show <id> [--history] an item, the criterion frozen at claim, its verdicts: the latest in full,
earlier ones as one line; --history prints every note in full
@@ -199,7 +202,7 @@ Reject reasons: TEST_FAILURE, BEHAVIOR_MISMATCH, INSUFFICIENT_EVIDENCE, STALE_HE
const HELP_NAMES = [
'tour', 'init', 'worktree', 'join', 'takeover', 'whoami', 'lanes', 'lane', 'lane add', 'status', 'resources', 'settings', 'view', 'view export',
- 'serve', 'mcp', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'skills', 'show', 'next', 'land',
+ 'serve', 'mcp', 'relay', 'relay recover', 'resume', 'hooks', 'add', 'edit', 'escalate', 'run', 'list', 'doctor', 'health', 'skills', 'show', 'next', 'land',
'check', 'claim', 'release', 'submit', 'done', 'verify', 'fact', 'why', 'shout', 'answer', 'pass', 'decisions', 'inbox', 'export', 'import',
'sweep', 'merged', 'withdraw', 'refreeze', 'reopen', 'hold', 'stats', 'ledger', 'log', 'spec', 'spec check', 'spec view',
'spec show', 'spec unmet', 'spec signoff', 'spec draft', 'spec signers', 'spec signers add', 'doctrine', 'doctrine check', 'forget', 'prompt', 'gate', 'hook',
@@ -229,6 +232,7 @@ const HELP_EXAMPLES = {
runner: 'pullboard runner add studio --slots 2 --browser 1', 'runner add': 'pullboard runner add studio --slots 2 --browser 1',
edit: 'pullboard edit 12 --brief "Add the upload page"', release: 'pullboard release 12',
land: 'pullboard land --max 4',
+ health: 'pullboard health',
reopen: 'pullboard reopen 12 --note "correct the frozen criterion"',
escalate: 'pullboard escalate 12 --note "needs a manual step"', next: 'pullboard next',
run: 'pullboard run --agent "node agent.js"', 'view export': 'pullboard view --export ./site',
diff --git a/src/json.js b/src/json.js
index 8397aaf0..0e7e4c36 100644
--- a/src/json.js
+++ b/src/json.js
@@ -36,6 +36,7 @@ export const JSON_SHAPES = {
stats: shape({ stats: 'object' }),
status: shape({ me: 'object', mine: 'array', stats: 'object', reviewQueue: 'object', unread: 'number', relay: 'object' }),
doctor: shape({ problems: 'array' }),
+ health: shape({ asOf: 'string', thresholds: 'object', stuck: 'array', waiting: 'array' }),
skills: shape({ updated: 'array', current: 'array', customized: 'array' }),
inbox: shape({ shouts: 'array' }),
decisions: shape({ decisions: 'array' }),
diff --git a/src/templates.js b/src/templates.js
index 86f78deb..6a904497 100644
--- a/src/templates.js
+++ b/src/templates.js
@@ -126,7 +126,7 @@ It prints the folder to work in and what to run there first. Every join needs th
6. A reject reopens the item. Fix it, commit, claim, submit again; the same head is refused. If you cannot get an item green, do not force it: \`pullboard escalate <id> --note "what you tried and how it failed"\` hands it one tier up.
7. Your lane is done when its items are verified, not when they are submitted. After your last submit, keep running \`pullboard next --wait 9\`: a rejected item comes back to your lane.
-The coordinator merges verified items into the main line; builders never merge.
+The coordinator merges verified items into the main line; builders never merge. \`pullboard health\` lists every stuck item: a lapsed claim, a review nobody took, accepted work that never landed, an old hold, an unanswered decision. Each line says why, since when, the next step and who takes it; run it at the start of a session and take the steps that name you.
For spare test capacity, use \`pullboard runner add <ssh-host> --slots <n> --browser <n>\`. It registers SSH capacity on this machine; \`pullboard resources\` shows runners and their usage. Only committed source goes to a runner, and board moves stay here.
diff --git a/test/api.test.js b/test/api.test.js
index 008edff9..71aa7cc6 100644
--- a/test/api.test.js
+++ b/test/api.test.js
@@ -604,6 +604,7 @@ test('[A1] command results match the catalog across roots and subcommands', () =
json(box, repo, 'status');
json(box, repo, 'stats');
json(box, repo, 'doctor');
+ assert.deepEqual(json(box, repo, 'health').stuck, [], 'a new board has nothing stuck [A6]');
json(box, repo, 'skills', ['--update']);
const plainStatus = box.run(repo, 'status');
assert.equal(plainStatus.status, 0, plainStatus.stderr);
diff --git a/test/health.test.js b/test/health.test.js
new file mode 100644
index 00000000..6145e7bf
--- /dev/null
+++ b/test/health.test.js
@@ -0,0 +1,278 @@
+/**
+ * pullboard health names every stuck item, why, since when, the next step and who takes it, on a
+ * real SQLite board in a real git repo with an injected clock, and never changes either [A6].
+ */
+import assert from 'node:assert/strict';
+import { createHash } from 'node:crypto';
+import { mkdirSync, mkdtempSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join } from 'node:path';
+import { test } from 'node:test';
+import { DatabaseSync } from 'node:sqlite';
+import * as store from '../src/board.js';
+import { main } from '../src/cli.js';
+import { boardHealth } from '../src/health.js';
+import { JSON_SHAPES } from '../src/json.js';
+import { runFixtureGit } from './fixture-child.js';
+
+const HOUR = 3_600_000;
+const NOW = Date.parse('2026-10-17T12:00:00.000Z');
+const ago = (ms) => new Date(NOW - ms).toISOString();
+const freeze = (item) => ({ text: item.item_title, digest: `digest:${item.item_title}` });
+
+/** A private repo, git identity and Pullboard home, so neither git nor the CLI reads this machine. */
+function repo(t) {
+ const dir = realpathSync(mkdtempSync(join(tmpdir(), 'pullboard-health-')));
+ t.after(() => rmSync(dir, { recursive: true, force: true }));
+ const root = join(dir, 'repo');
+ mkdirSync(root);
+ const env = Object.fromEntries(Object.entries(process.env).filter(([name]) => !name.startsWith('GIT_')));
+ Object.assign(env, {
+ GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Health Test', GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Health Test', GIT_COMMITTER_EMAIL: '[email protected]',
+ });
+ for (const name of Object.keys(process.env)) if (name.startsWith('GIT_')) delete process.env[name];
+ Object.assign(process.env, { PULLBOARD_HOME: join(dir, 'home'), PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'), GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1' });
+ delete process.env.PULLBOARD_RELAY_TOKEN;
+ /** Run git in the fixture repo, optionally at a fixed commit date. */
+ const git = (args, date) => runFixtureGit(args, { cwd: root, env: date ? { ...env, GIT_COMMITTER_DATE: date, GIT_AUTHOR_DATE: date } : env });
+ git(['init', '-q', '-b', 'main']);
+ writeFileSync(join(root, 'pullboard.json'), `${JSON.stringify({ gate: 'true', lanes: { core: { owns: ['src/'] }, docs: { owns: ['docs/'] }, review: { owns: [] } } }, null, 2)}\n`);
+ writeFileSync(join(root, 'a.txt'), 'base\n');
+ git(['add', '-A']);
+ git(['commit', '-q', '-m', 'chore: base'], ago(72 * HOUR));
+ return { dir, root, git, file: join(root, '.git', 'pullboard', 'board.sqlite') };
+}
+
+/** Commit one file on a new branch from `from`, then return to main; returns the commit. */
+function branchCommit(box, branch, from, path, text) {
+ box.git(['checkout', '-q', '-b', branch, from]);
+ writeFileSync(join(box.root, path), text);
+ box.git(['add', path]);
+ box.git(['commit', '-q', '-m', `feat: ${branch}`]);
+ const commit = box.git(['rev-parse', 'HEAD']);
+ box.git(['checkout', '-q', 'main']);
+ return commit;
+}
+
+/** Open the fixture board with a clock the test turns by hand. */
+function boardAt(box) {
+ const clock = { at: NOW - 40 * HOUR, now() { return new Date(this.at); } };
+ const board = store.openBoard(box.file, clock);
+ /** Move the board's clock to a moment before NOW. */
+ const at = (ms) => { clock.at = NOW - ms; };
+ return { board, at };
+}
+
+/** Run the real CLI in this process with the injected clock; returns its exit code and output. */
+async function cli(cwd, argv) {
+ let stdout = '';
+ let stderr = '';
+ const code = await main(argv, {
+ cwd, clock: { now: () => new Date(NOW) },
+ stdout: { isTTY: false, write: (text) => { stdout += text; } },
+ stderr: { write: (text) => { stderr += text; } },
+ });
+ return { code, stdout, stderr };
+}
+
+/** Every board row and the event count, so a read can be proved to change nothing. */
+function boardDigest(file) {
+ const db = new DatabaseSync(file, { readOnly: true });
+ try {
+ const tables = ['item', 'verdict', 'shout', 'event', 'hold', 'agent', 'board_meta'];
+ const rows = tables.map((table) => JSON.stringify(db.prepare(`SELECT * FROM ${table}`).all()));
+ return { events: db.prepare('SELECT COUNT(*) AS n FROM event').get().n, hash: createHash('sha256').update(rows.join('\n')).digest('hex') };
+ } finally { db.close(); }
+}
+
+/** The checkout's HEAD, index and working tree as git reports them. */
+function checkout(box) {
+ return { head: box.git(['rev-parse', 'HEAD']), status: box.git(['status', '--porcelain', '--untracked-files=all']),
+ index: createHash('sha256').update(readFileSync(join(box.root, '.git', 'index'))).digest('hex') };
+}
+
+test('health names each stuck cause with its next step and owner [A6]', async (t) => {
+ const box = repo(t);
+ const base = box.git(['rev-parse', 'HEAD']);
+ box.git(['tag', 'v0.1.0']);
+ const conflicting = branchCommit(box, 'core/conflict', base, 'a.txt', 'branch\n');
+ const clean = branchCommit(box, 'core/clean', base, 'clean.txt', 'clean\n');
+ const cleared = branchCommit(box, 'core/cleared', base, 'other.txt', 'other\n');
+ const parent = branchCommit(box, 'core/parent', base, 'parent.txt', 'parent\n');
+ const child = branchCommit(box, 'core/child', parent, 'child.txt', 'child\n');
+ const landed = branchCommit(box, 'core/landed', base, 'landed.txt', 'landed\n');
+ const own = Object.fromEntries(['lapsedReview', 'unreviewed', 'rejected', 'later', 'reopened', 'held'].map((name) => [name, branchCommit(box, `core/${name}`, base, `${name}.txt`, `${name}\n`)]));
+ writeFileSync(join(box.root, 'a.txt'), 'main\n');
+ box.git(['commit', '-q', '-am', 'feat: main moves on'], ago(48 * HOUR));
+
+ const { board, at } = boardAt(box);
+ store.register(board, { lane: 'coordinator', path: box.root });
+ const builders = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12].map((n) => store.register(board, { lane: 'core', path: join(box.dir, `core-${n}`) }));
+ const reviewer = store.register(board, { lane: 'review', path: join(box.dir, 'review-1') });
+ const otherReviewer = store.register(board, { lane: 'review', path: join(box.dir, 'review-2') });
+ const add = (title, extra = {}) => store.addItem(board, { by: 'coordinator', lane: 'core', title, ...extra });
+ const claim = (id, agentId, leaseMs = 2 * HOUR) => store.claim(board, id, { agentId, lane: 'core', leaseMs, freeze });
+ const submit = (id, agentId, commit) => store.submit(board, id, { agentId, commit, tree: `tree-${id}` });
+ const decide = (id, decision, commit, title, by = reviewer) => store.verify(board, id, { agentId: by, decision,
+ reason: decision === 'ACCEPT' ? 'CRITERION_MET' : 'TEST_FAILURE', note: 'checked the fixture', head: commit, digest: `digest:${title}`, policy: 'any' });
+ /** Build an item through claim and submit, optionally to an accept or a reject. */
+ const built = (title, agentId, commit, verdict, extra) => {
+ const id = add(title, extra);
+ claim(id, agentId);
+ submit(id, agentId, commit);
+ if (verdict) decide(id, verdict, commit, title);
+ return id;
+ };
+
+ at(30 * HOUR);
+ store.holdLane(board, 'docs', { agentId: 'coordinator', reason: 'docs wait for the release notes' });
+ const staleHold = add('Stale hold');
+ store.holdItem(board, staleHold, { agentId: 'coordinator', reason: 'waiting for the design' });
+ at(3 * HOUR);
+ const lapsed = add('Lapsed claim');
+ claim(lapsed, builders[0], HOUR);
+ const reviewLapsed = add('Lapsed review');
+ claim(reviewLapsed, builders[1]);
+ submit(reviewLapsed, builders[1], own.lapsedReview);
+ at(2.5 * HOUR);
+ store.reserveReview(board, reviewLapsed, { agentId: reviewer, leaseMs: HOUR / 2, policy: 'any' });
+ at(2 * HOUR);
+ const unreviewed = built('Waiting review', builders[2], own.unreviewed);
+ const conflict = built('Conflicting accept', builders[3], conflicting, 'ACCEPT');
+ const ready = built('Clean accept', builders[4], clean, 'ACCEPT');
+ const rejected = built('Rejected rework', builders[5], own.rejected, 'REJECT');
+ const later = built('Later rework', builders[6], own.later, 'REJECT');
+ const reopened = built('Reopened rework', builders[7], own.reopened);
+ store.reopen(board, reopened, { agentId: 'coordinator', note: 'the bar named the wrong file' });
+ const stacked = built('Stacked accept', builders[8], child, 'ACCEPT');
+ const shipped = built('Landed work', builders[9], landed, 'ACCEPT');
+ store.merged(board, shipped, { agentId: 'coordinator', commit: landed });
+ const heldAccept = add('Held accept');
+ claim(heldAccept, builders[10]);
+ store.holdItem(board, heldAccept, { agentId: 'coordinator', reason: 'waiting for the person to pick the wording' });
+ submit(heldAccept, builders[10], own.held);
+ decide(heldAccept, 'ACCEPT', own.held, 'Held accept', otherReviewer);
+ const withdrawn = add('Dropped dependency');
+ const orphan = add('Orphaned follow-up', { after: [withdrawn] });
+ store.withdraw(board, withdrawn, { agentId: 'coordinator', reason: 'superseded by the new layout' });
+ const ask = store.shout(board, { from: builders[2], to: 'coordinator', text: 'Which file owns the wording?', lanes: ['core', 'docs', 'review'], decision: true });
+ at(HOUR / 6);
+ const parentItem = built('Parent in review', builders[11], parent);
+ const conflictHold = built('Conflict hold', builders[0], cleared, 'REJECT');
+ store.holdItem(board, conflictHold, { agentId: 'coordinator', reason: 'conflicts with the a.txt batch' });
+ store.addMilestone(board, { agentId: 'coordinator', name: '0.1.1', items: [lapsed, rejected, reopened] });
+ store.addMilestone(board, { agentId: 'coordinator', name: '0.1.2', items: [later] });
+ store.closeBoard(board); // Health opens its own read-only connection.
+
+ const beforeBoard = boardDigest(box.file);
+ const beforeCheckout = checkout(box);
+ const result = await cli(box.root, ['health', '--json']);
+ assert.equal(result.code, 1, `a stuck board exits 1: ${result.stderr}`);
+ const report = JSON.parse(result.stdout);
+ assert.deepEqual(boardDigest(box.file), beforeBoard, 'health changes no board row and appends no event');
+ assert.deepEqual(checkout(box), beforeCheckout, 'the merge check never touches the HEAD, index or working tree');
+ for (const field of Object.keys(JSON_SHAPES.commands.health.required)) assert.ok(field in report, `health JSON has ${field}`);
+ assert.equal(report.asOf, new Date(NOW).toISOString(), 'health reads the injected clock');
+ assert.deepEqual(report.thresholds, { stuck: '1h', holds: '1d', release: '1d' });
+
+ const byKey = new Map(report.stuck.map((entry) => [entry.key, entry]));
+ /** Assert one finding's cause, since, owner and next step, and that its why names `why`. */
+ const expect = (key, { cause, since, role, who, next, why }) => {
+ const entry = byKey.get(key) ?? report.waiting.find((waiting) => waiting.key === key);
+ assert.ok(entry, `health lists ${key}; found ${[...byKey.keys()].join(', ')}`);
+ assert.equal(entry.cause, cause, key);
+ assert.equal(entry.since, since, `${key} since`);
+ assert.deepEqual(entry.owner, { role, who }, `${key} owner`);
+ assert.ok(entry.next.includes(next), `${key} next step: ${entry.next}`);
+ for (const part of [why].flat()) assert.ok(entry.why.includes(part), `${key} why names ${part}: ${entry.why}`);
+ for (const field of ['subject', 'title', 'ageMinutes', 'command', 'detail']) assert.ok(field in entry, `${key} has ${field}`);
+ return entry;
+ };
+ expect(`CLAIM_LAPSED:item:${lapsed}`, { cause: 'CLAIM_LAPSED', since: ago(2 * HOUR), role: 'builder', who: builders[0], next: `pullboard claim ${lapsed}`, why: builders[0] });
+ expect(`REVIEW_LAPSED:item:${reviewLapsed}`, { cause: 'REVIEW_LAPSED', since: ago(2 * HOUR), role: 'reviewer', who: null, next: `pullboard next --verify ${reviewLapsed}`, why: reviewer });
+ expect(`NO_REVIEWER:item:${unreviewed}`, { cause: 'NO_REVIEWER', since: ago(2 * HOUR), role: 'reviewer', who: null, next: `pullboard next --verify ${unreviewed}`, why: builders[2] });
+ const conflictFinding = expect(`UNLANDED_CONFLICT:item:${conflict}`, { cause: 'UNLANDED_CONFLICT', since: ago(2 * HOUR), role: 'builder', who: builders[3], next: 'merge main into its branch', why: ['conflicts with main', 'a.txt'] });
+ assert.deepEqual(conflictFinding.detail.files, ['a.txt'], 'the conflict names its files');
+ expect(`UNLANDED_READY:item:${ready}`, { cause: 'UNLANDED_READY', since: ago(2 * HOUR), role: 'coordinator', who: 'coordinator', next: 'pullboard land', why: 'merges cleanly onto main' });
+ expect(`UNLANDED_HELD:item:${heldAccept}`, { cause: 'UNLANDED_HELD', since: ago(2 * HOUR), role: 'coordinator', who: 'coordinator', next: `pullboard hold ${heldAccept} --off`, why: 'waiting for the person to pick the wording' });
+ expect(`UNLANDED_STACKED:item:${stacked}`, { cause: 'UNLANDED_STACKED', since: ago(2 * HOUR), role: 'reviewer', who: null, next: `pullboard next --verify ${parentItem}`, why: `#${parentItem}` });
+ expect(`HOLD_STALE:item:${staleHold}`, { cause: 'HOLD_STALE', since: ago(30 * HOUR), role: 'coordinator', who: 'coordinator', next: `pullboard hold ${staleHold} --off`, why: 'waiting for the design' });
+ expect('HOLD_STALE:lane:docs', { cause: 'HOLD_STALE', since: ago(30 * HOUR), role: 'coordinator', who: 'coordinator', next: 'pullboard hold docs --off', why: 'docs wait for the release notes' });
+ expect(`CONFLICT_HOLD_CLEARS:item:${conflictHold}`, { cause: 'CONFLICT_HOLD_CLEARS', since: ago(HOUR / 6), role: 'coordinator', who: 'coordinator', next: `pullboard hold ${conflictHold} --off`, why: 'now merges cleanly onto main' });
+ expect(`REWORK_UNCLAIMED:item:${rejected}`, { cause: 'REWORK_UNCLAIMED', since: ago(2 * HOUR), role: 'builder', who: builders[5], next: `pullboard claim ${rejected}`, why: ['rejected by', 'TEST_FAILURE'] });
+ expect(`REWORK_UNCLAIMED:item:${reopened}`, { cause: 'REWORK_UNCLAIMED', since: ago(2 * HOUR), role: 'builder', who: builders[7], next: `pullboard claim ${reopened}`, why: 'reopened by coordinator' });
+ expect(`AFTER_WITHDRAWN:item:${orphan}`, { cause: 'AFTER_WITHDRAWN', since: ago(2 * HOUR), role: 'coordinator', who: 'coordinator', next: `pullboard edit ${orphan} --after none`, why: [`#${withdrawn}`, 'superseded by the new layout'] });
+ expect(`DECISION_UNANSWERED:shout:${ask}`, { cause: 'DECISION_UNANSWERED', since: ago(2 * HOUR), role: 'coordinator', who: 'coordinator', next: `pullboard answer ${ask}`, why: 'Which file owns the wording?' });
+ expect('RELEASE_OVERDUE:release:v0.1.0', { cause: 'RELEASE_OVERDUE', since: ago(72 * HOUR), role: 'coordinator', who: 'coordinator', next: 'publish the release after v0.1.0', why: `#${shipped}` });
+ const waiting = report.waiting.find((entry) => entry.key === `REWORK_LATER:item:${later}`);
+ assert.ok(waiting, 'rework planned for a later release is listed as waiting');
+ assert.ok(!byKey.has(`REWORK_UNCLAIMED:item:${later}`), 'rework in a later release is not stuck');
+ assert.equal(waiting.owner.who, builders[6]);
+ assert.ok(waiting.why.includes('0.1.2'), 'the waiting line names its release');
+ for (const id of [parentItem, conflictHold, shipped]) assert.ok(![...byKey.values()].some((entry) => entry.item === id && !entry.key.startsWith('CONFLICT_HOLD')), `#${id} is moving, not stuck`);
+
+ const patient = boardHealth(box.file, { root: box.root, config: { health: { stuck: '3h', holds: '2d' } }, now: new Date(NOW) });
+ assert.deepEqual(patient.thresholds, { stuck: '3h', holds: '2d', release: '1d' }, 'pullboard.json health thresholds replace the defaults');
+ assert.ok(!patient.stuck.some((entry) => ['NO_REVIEWER', 'HOLD_STALE', 'REWORK_UNCLAIMED'].includes(entry.cause)), 'longer thresholds clear the younger waits');
+ assert.throws(() => boardHealth(box.file, { root: box.root, config: { health: { stuck: 'soon' } }, now: new Date(NOW) }), /BAD_CONFIG|health\.stuck/u);
+
+ const text = await cli(box.root, ['health']);
+ assert.equal(text.code, 1);
+ const lines = text.stdout.trim().split('\n');
+ assert.equal(lines[0], `${report.stuck.length} stuck:`);
+ const lapsedLine = lines.find((line) => line.startsWith(` #${lapsed} `));
+ assert.equal(lapsedLine, ` #${lapsed} claim lapsed, since 2026-10-17 10:00 (2h): ${builders[0]}'s lease ran out and nobody is building it. Next, ${builders[0]} (builder): renew it with pullboard claim ${lapsed}.`);
+ assert.ok(lines.some((line) => line.startsWith(` #${conflict} `) && line.includes('a.txt') && line.includes(`${builders[3]} (builder)`)), 'the text names the conflicting files and the builder');
+ assert.ok(lines.includes('waiting for a later release:'));
+ assert.deepEqual(boardDigest(box.file), beforeBoard, 'text mode changes nothing either');
+ assert.deepEqual(checkout(box), beforeCheckout);
+});
+
+test('health on a healthy board says nothing is stuck [A6]', async (t) => {
+ const box = repo(t);
+ const commit = box.git(['rev-parse', 'HEAD']);
+ const missing = await cli(box.root, ['health']);
+ assert.equal(missing.code, 0, missing.stderr);
+ assert.equal(missing.stdout, 'nothing is stuck\n', 'a repo with no board yet has nothing stuck');
+
+ const { board } = boardAt(box);
+ store.register(board, { lane: 'coordinator', path: box.root });
+ store.closeBoard(board);
+ const empty = await cli(box.root, ['health', '--json']);
+ assert.equal(empty.code, 0, empty.stderr);
+ const emptyReport = JSON.parse(empty.stdout);
+ assert.deepEqual([emptyReport.stuck, emptyReport.waiting], [[], []], 'an empty board has nothing stuck');
+ assert.equal((await cli(box.root, ['health'])).stdout, 'nothing is stuck\n');
+
+ const moving = boardAt(box);
+ t.after(() => store.closeBoard(moving.board));
+ const builder = store.register(moving.board, { lane: 'core', path: join(box.dir, 'core-1') });
+ const second = store.register(moving.board, { lane: 'core', path: join(box.dir, 'core-2') });
+ const reviewer = store.register(moving.board, { lane: 'review', path: join(box.dir, 'review-1') });
+ moving.at(30 * HOUR);
+ const done = store.addItem(moving.board, { by: 'coordinator', lane: 'core', title: 'Done' });
+ store.claim(moving.board, done, { agentId: builder, lane: 'core', leaseMs: 2 * HOUR, freeze });
+ store.submit(moving.board, done, { agentId: builder, commit, tree: 'tree' });
+ store.verify(moving.board, done, { agentId: reviewer, decision: 'ACCEPT', reason: 'CRITERION_MET', note: 'ran it', head: commit, digest: 'digest:Done', policy: 'any' });
+ store.merged(moving.board, done, { agentId: 'coordinator', commit });
+ moving.at(HOUR / 2);
+ const building = store.addItem(moving.board, { by: 'coordinator', lane: 'core', title: 'Building' });
+ store.claim(moving.board, building, { agentId: builder, lane: 'core', leaseMs: 2 * HOUR, freeze });
+ const reviewing = store.addItem(moving.board, { by: 'coordinator', lane: 'core', title: 'Reviewing' });
+ store.claim(moving.board, reviewing, { agentId: second, lane: 'core', leaseMs: 2 * HOUR, freeze });
+ store.submit(moving.board, reviewing, { agentId: second, commit, tree: 'tree' });
+ store.reserveReview(moving.board, reviewing, { agentId: reviewer, leaseMs: HOUR, policy: 'any' });
+ store.addItem(moving.board, { by: 'coordinator', lane: 'core', title: 'Fresh work' });
+ const asked = store.shout(moving.board, { from: builder, to: 'coordinator', text: 'Which wording?', lanes: ['core', 'docs', 'review'], decision: true });
+ store.answerDecision(moving.board, asked, { agentId: 'coordinator', text: 'the short one', lanes: ['core', 'docs', 'review'] });
+ store.holdLane(moving.board, 'docs', { agentId: 'coordinator', reason: 'a short pause' });
+ const before = boardDigest(box.file);
+ const healthy = await cli(box.root, ['health', '--json']);
+ assert.equal(healthy.code, 0, healthy.stdout);
+ const report = JSON.parse(healthy.stdout);
+ assert.deepEqual(report.stuck, [], `a moving board has nothing stuck: ${report.stuck.map((entry) => entry.key).join(', ')}`);
+ assert.equal((await cli(box.root, ['health'])).stdout, 'nothing is stuck\n');
+ assert.deepEqual(boardDigest(box.file), before, 'health changes nothing on a healthy board');
+});