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
Merge remote-tracking branch 'origin/main' into core/695-merge
Corey Olsone08a998d4b51
diff --cc src/cli.jsindex f272a725,a4040e01..39a24779--- a/src/cli.js+++ b/src/cli.js@@@ -2,108 -2,25 +2,106 @@@* The pullboard command line: every command, bound to who is asking (B3, R3). The main checkout is the* coordinator; every other worktree is the agent that joined from it.*/-import { createHash, randomUUID } from 'node:crypto';-import { spawn, spawnSync } from 'node:child_process';-import { appendFileSync, existsSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, writeFileSync } from 'node:fs';-import { hostname, loadavg } from 'node:os';-import { basename, dirname, isAbsolute, join, relative, resolve } from 'node:path';+import {+ createHash,+ randomUUID,+} from 'node:crypto';+import {+ spawn,+ spawnSync,+} from 'node:child_process';+import {+ appendFileSync,+ existsSync,+ mkdirSync,+ readFileSync,+ realpathSync,+ writeFileSync,+} from 'node:fs';- import {- hostname,- loadavg,- } from 'node:os';++import { loadavg } from 'node:os';+import {+ basename,+ dirname,+ isAbsolute,+ join,+ relative,+ resolve,+} from 'node:path';import { performance } from 'node:perf_hooks';-import { fileURLToPath, pathToFileURL } from 'node:url';+import {+ fileURLToPath,+ pathToFileURL,+} from 'node:url';import { parseArgs } from 'node:util';import * as store from './board.js';-import { CONFIG_FILE, COORDINATOR, DOCTRINE_FILE, LEGACY_DOCTRINE_FILE, loadConfig } from './config.js';+import {+ CONFIG_FILE,+ COORDINATOR,+ DOCTRINE_FILE,+ LEGACY_DOCTRINE_FILE,+ loadConfig,+} from './config.js';import { displayAgentName } from './agent-names.js';-import { doctrineHistory, loadDoctrine } from './doctrine.js';-import { checkRulesAt, doctrineReport, hasSubmitRules, holdDoctrine, ruleLine } from './doctrine-checks.js';-import { agentSessionDigest, requirePersonChannel } from './person.js';-import { bindLocalSession, localSessionMatches } from './agent-session.js';-import { decisionAnswer, decisionProjection, handAnsweredQuestions, pendingAnswers, planRowApply, prepareRowDecisions, restoreRowApply, writeRowApply } from './row-decisions.js';-import { digestOf, gateReport, refuseSandboxBlocked, runGate, runProfiledShell, runSubmitGate, submitGateReport, timingDigest, withGateSlot } from './gate.js';+import {+ doctrineHistory,+ loadDoctrine,+} from './doctrine.js';+import {+ checkRulesAt,+ doctrineReport,+ hasSubmitRules,+ holdDoctrine,+ ruleLine,+} from './doctrine-checks.js';+import {+ agentSessionDigest,+ requirePersonChannel,+} from './person.js';+import {+ bindLocalSession,+ localSessionMatches,+} from './agent-session.js';+import {+ decisionAnswer,+ decisionProjection,+ handAnsweredQuestions,++ pendingAnswers,+ planRowApply,+ prepareRowDecisions,+ restoreRowApply,+ writeRowApply,+} from './row-decisions.js';+import {+ digestOf,+ gateReport,+ refuseSandboxBlocked,+ runGate,+ runProfiledShell,+ runSubmitGate,+ submitGateReport,+ timingDigest,+ withGateSlot,+} from './gate.js';import { checkNeedsBrowser } from './browser-admission.js';-import { bareWorktreeFinding, codeIsFromMain, contains, differFromHead, git, gitChildEnv, headCommit, headTree, invalidateGitFacts, isClean, mainCheckout, patchId, repoInfo, resolveCommit, tryGit, untracked, withGitFacts } from './git.js';+import {+ bareWorktreeFinding,+ codeIsFromMain,+ contains,+ differFromHead,+ git,+ gitChildEnv,+ headCommit,+ headTree,+ invalidateGitFacts,+ isClean,+ mainCheckout,+ patchId,+ repoInfo,+ resolveCommit,+ tryGit,+ untracked,+ withGitFacts,+} from './git.js';import {FIX_NOTE,applyFixers,@@@ -180,173 -61,42 +178,178 @@@ importstandings,unmetRows,} from './spec.js';-import { answerQuestion, bundledBlueprints, landBlueprint, planBlueprint, readBlueprint, repoAnswers, saveBlueprint } from './blueprints.js';+import {+ answerQuestion,+ bundledBlueprints,+ landBlueprint,+ planBlueprint,+ readBlueprint,+ repoAnswers,+ saveBlueprint,+} from './blueprints.js';import { briefFiles } from './brief.js';-import { commitFirst, commitOwnerLines, commitOwners, coordinatorInbox, coordinatorInboxLines, inboxFirst } from './resume.js';-import { checkBaseline, prepareCheckBaseline, sayCheckBaseline, refuseCheckSyntax } from './check-baseline.js';-import { retryCheckBaselines, startCheckBaseline } from './check-baseline-worker.js';-import { compareMainFailures, mainRedMessage, mainRedReworkItems } from './main-red.js';+import {+ commitFirst,+ commitOwnerLines,+ commitOwners,+ coordinatorInbox,+ coordinatorInboxLines,+ inboxFirst,+} from './resume.js';+import {+ checkBaseline,+ prepareCheckBaseline,+ sayCheckBaseline,+ refuseCheckSyntax,+} from './check-baseline.js';+import {+ retryCheckBaselines,+ startCheckBaseline,+} from './check-baseline-worker.js';+import {+ compareMainFailures,+ mainRedMessage,+ mainRedReworkItems,+} from './main-red.js';import { runItems } from './run.js';-import { parseProblems, sweepItems } from './sweep.js';+import {+ parseProblems,+ sweepItems,+} from './sweep.js';import { renderSpecView } from './view.js';import { tour } from './tour.js';-import { commandOutput, refusalDocument } from './json.js';-import { forgetProject, listApiProjects, registerProjectAndLink, registeredProjectRootsSnapshot } from './projects.js';+import {+ commandOutput,+ refusalDocument,+} from './json.js';+import {+ forgetProject,+ listApiProjects,+ registerProjectAndLink,+ registeredProjectRootsSnapshot,+} from './projects.js';import { milestoneRoadmap } from './roadmap.js';-import { listResources, memoryVerdict, readMachineMemory, runnerResourceStatus } from './resources.js';-import { citedTestFiles, rowEvidence, rowStage } from './evidence.js';-import { exportView, serveView } from './serve.js';-import { forgetView, portHolder, rememberView, runningView } from './view-session.js';+import {+ listResources,+ memoryVerdict,+ readMachineMemory,+ runnerResourceStatus,+} from './resources.js';+import {+ citedTestFiles,+ rowEvidence,+ rowStage,+} from './evidence.js';+import {+ exportView,+ serveView,+} from './serve.js';+import {+ forgetView,+ portHolder,+ rememberView,+ runningView,+} from './view-session.js';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 {+ 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';-import { flowLines, flowAlertLine } from './stats-flow.js';+import {+ flowLines,+ flowAlertLine,+} from './stats-flow.js';import { releaseHeadlinesBetween } from './changelog.js';-import { exportBoard, importBoard } from './exchange.js';-import { addSigner, assertRequiredSigners, defaultPrincipal, hasSignerFile } from './signature.js';-import { addRunner, browserFreeChecksEnabled, gateQueueSettings, loadMachineSettings, memoryFloorMB, setBrowserSlots, setGateSlots } from './settings.js';-import { formatSnapshotLimit, pendingSnapshotSize, pendingCheckpointProblem, relayCommandReceipt, relayCommandReceiptReported, relayLinked, relayOff, relayOn, relayOperation, relayRecover, relayRecovered, relayRevoke, relayStatus, relayTokens, syncRelay } from './relay.js';-import { autoLinkProject, relayOnAll, revokeRelayDevice, unlinkedRelayProjects } from './relay-setup.js';+import {+ exportBoard,+ importBoard,+} from './exchange.js';+import {+ addSigner,+ assertRequiredSigners,+ defaultPrincipal,+ hasSignerFile,+} from './signature.js';+import {+ browserFreeChecksEnabled,+ gateQueueSettings,+ loadMachineSettings,+ memoryFloorMB,+} from './settings.js';+import {+ pendingSnapshotSize,+ pendingCheckpointProblem,+ relayCommandReceipt,+ relayCommandReceiptReported,+ relayLinked,+ relayOff,+ relayOn,+ relayOperation,+ relayRecover,+ relayRecovered,+ relayRevoke,+ relayStatus,+ relayTokens,+ syncRelay,+} from './relay.js';+import {+ autoLinkProject,+ relayOnAll,+ revokeRelayDevice,+ unlinkedRelayProjects,+} from './relay-setup.js';import { readRelayMachine } from './relay-machine.js';-import { relayJoin, relayPair } from './relay-pairing-client.js';+import {+ relayJoin,+ relayPair,+} from './relay-pairing-client.js';import { executePersonRequests } from './relay-request-execution.js';-import { engineReceipt } from './engine.js';-import { land, landingRemote, landingSubject } from './land.js';+import {+ boardSetup,+ recordSetupState,+ recordViewBind,+ recordViewReuse,+ setupIdentity,+ viewSetupComplete,+} from './setup-card.js';+import { formatSnapshotLimit } from './relay-messages.js';++import { privateNames } from './private-names.js';+import {+ runnerCommand,+ settingsCommand,+} from './machine-commands.js';+import {+ filesSince,+ recordedRecovery,+ refuseUnverifiedStack,+ reportSubmission,+} from './submission.js';+import {+ land,+ landingRemote,+ landingSubject,+} from './land.js';import { installStep } from './worktree.js';const CHECKOUT_LEASES = new WeakMap();@@@ -3948,37 -3953,37 +3970,6 @@@ async function runCommand(argv, io)}}--/**-- * Every private name a saved blueprint must never carry: each agent's id, display name, model-- * and family, the person's Git name and email, everyone who signed off or signs rows, and this-- * machine's host name, whole, plus the parts of each (a first name, an email's user) to match-- * only as written. Missing sources add nothing; they never stop the save [S1].-- */--function privateNames(root, board, spec) {-- const names = new Set();-- const parts = new Set();-- const add = (value) => {-- const text = typeof value === 'string' ? value.trim() : '';-- // "unknown" is the label for an undeclared model, not anyone's name.-- if (!text || text === 'unknown') return;-- names.add(text);-- for (const part of text.split(/[\s@.<>()]+/u)) if (part.length >= 3 && part !== 'unknown' && part !== text) parts.add(part);-- };-- for (const agent of store.listAgents(board)) {-- add(agent.agent_id); add(agent.agent_model); add(agent.agent_family); add(displayAgentName(agent)); add(displayAgentName(agent, 'prefix'));-- }-- for (const key of ['user.name', 'user.email']) add(tryGit(root, ['config', '--get', key]).stdout);-- for (const ident of ['GIT_AUTHOR_IDENT', 'GIT_COMMITTER_IDENT']) {-- const found = /^(.*?)\s*<([^>]*)>/u.exec(tryGit(root, ['var', ident]).stdout ?? '');-- if (found) { add(found[1]); add(found[2]); }-- }-- try { for (const record of readSignoffs(root)) add(record.by); } catch { /* An unreadable sign-off file adds no names. */ }-- for (const row of spec.rows) for (const signer of row.signers ?? []) add(signer);-- add(hostname());-- add(hostname().split('.')[0]);-- return { names: [...names], parts: [...parts] };--}--/** Retain the primary branch on every command without creating a board for global help. */function rememberTrunk(io) {let info;diff --cc src/health.jsindex 00000000,6ed86963..c55c1440mode 000000,100644..100644--- a/src/health.js+++ b/src/health.js@@@ -1,0 -1,435 +1,447 @@@+ /**+ * `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 {++ 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 --cc src/private-names.jsindex 00000000,00000000..79d645ddnew file mode 100644--- /dev/null+++ b/src/private-names.js@@@ -1,0 -1,0 +1,40 @@@++/**++ * The names a saved blueprint must never carry (S1): who works on this board and this machine's++ * name, read from the board, Git, the sign-offs and the spec.++ */++import { hostname } from 'node:os';++import { displayAgentName } from './agent-names.js';++import * as store from './board.js';++import { tryGit } from './git.js';++import { readSignoffs } from './spec.js';++++/**++ * Every private name a saved blueprint must never carry: each agent's id, display name, model++ * and family, the person's Git name and email, everyone who signed off or signs rows, and this++ * machine's host name, whole, plus the parts of each (a first name, an email's user) to match++ * only as written. Missing sources add nothing; they never stop the save [S1].++ */++export function privateNames(root, board, spec) {++ const names = new Set();++ const parts = new Set();++ const add = (value) => {++ const text = typeof value === 'string' ? value.trim() : '';++ // "unknown" is the label for an undeclared model, not anyone's name.++ if (!text || text === 'unknown') return;++ names.add(text);++ for (const part of text.split(/[\s@.<>()]+/u)) if (part.length >= 3 && part !== 'unknown' && part !== text) parts.add(part);++ };++ for (const agent of store.listAgents(board)) {++ add(agent.agent_id); add(agent.agent_model); add(agent.agent_family); add(displayAgentName(agent)); add(displayAgentName(agent, 'prefix'));++ }++ for (const key of ['user.name', 'user.email']) add(tryGit(root, ['config', '--get', key]).stdout);++ for (const ident of ['GIT_AUTHOR_IDENT', 'GIT_COMMITTER_IDENT']) {++ const found = /^(.*?)\s*<([^>]*)>/u.exec(tryGit(root, ['var', ident]).stdout ?? '');++ if (found) { add(found[1]); add(found[2]); }++ }++ try { for (const record of readSignoffs(root)) add(record.by); } catch { /* An unreadable sign-off file adds no names. */ }++ for (const row of spec.rows) for (const signer of row.signers ?? []) add(signer);++ add(hostname());++ add(hostname().split('.')[0]);++ return { names: [...names], parts: [...parts] };++}diff --cc src/relay-phone.jsindex b5322cf2,6b1bff73..23c99233--- a/src/relay-phone.js+++ b/src/relay-phone.js@@@ -1,12 -1,8 +1,14 @@@/** Native approval requests never retain a person grant or its reply key [H5,H16,H17,B26]. */import { randomUUID } from 'node:crypto';+ import { hostname } from 'node:os';+ import { basename } from 'node:path';-import { approvalContext, createApprovalReply, openApproval, sealApproval, signApprovalIntent } from './relay-approval.js';+import {+ approvalContext,+ createApprovalReply,+ openApproval,+ sealApproval,+ signApprovalIntent,+} from './relay-approval.js';import { readBoardKey } from './relay-key.js';import { readRelayMachine } from './relay-machine.js';import { requirePersonChannel } from './person.js';diff --cc src/relay.jsindex 1fb59672,f8900245..de864334--- a/src/relay.js+++ b/src/relay.js@@@ -1,102 -1,26 +1,103 @@@/** Opt-in, sealed relay ordering, with crash-safe migration from the older mirror [H1,H3,H5,H16,H17,P5]. */-import { createHash, randomUUID } from 'node:crypto';-import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';+import {+ createHash,+ randomUUID,+} from 'node:crypto';+import {+ existsSync,+ lstatSync,+ mkdirSync,+ readFileSync,+ readdirSync,+ renameSync,+ rmSync,+ writeFileSync,+} from 'node:fs';import { hostname } from 'node:os';-import { basename, dirname, join } from 'node:path';-import { gunzipSync, gzipSync } from 'node:zlib';+import {+ basename,+ dirname,+ join,+} from 'node:path';+import {+ gunzipSync,+ gzipSync,+} from 'node:zlib';import * as store from './board.js';-import { exportBoard, importBoard, restoreRelaySnapshot, semanticBoardDigest } from './exchange.js';-import { appliedSequence, applyEngineMove, applyRelayMove, checkpointSequence, engineReceipt, prepareEngineMove, refuseRelayMove, requireSupportedEngine, startRelayEpoch } from './engine.js';+import {+ exportBoard,+ importBoard,+ restoreRelaySnapshot,+ semanticBoardDigest,+} from './exchange.js';+import {+ appliedSequence,++ applyEngineMove,+ applyRelayMove,+ checkpointSequence,+ engineReceipt,+ prepareEngineMove,+ refuseRelayMove,+ requireSupportedEngine,+ startRelayEpoch,+} from './engine.js';import { relayMoveActor } from './relay-sender.js';import { ENGINE_VERSION } from './machine.js';-import { presentationDigest, relayPresentation, relaySnapshot } from './relay-presentation.js';-import { codeIsFromMain, repoInfo, tryGit } from './git.js';-import { forgetBoardKey, readBoardKey, storeBoardKey } from './relay-key.js';-import { encodeBoardKey, generateBoardKey, seal, unseal } from './seal.js';+import {+ presentationDigest,+ relayPresentation,+ relaySnapshot,+} from './relay-presentation.js';+import {+ codeIsFromMain,+ repoInfo,+ tryGit,+} from './git.js';+import {+ forgetBoardKey,+ readBoardKey,+ storeBoardKey,+} from './relay-key.js';+import {+ encodeBoardKey,+ generateBoardKey,+ seal,+ unseal,+} from './seal.js';import { terminalQr } from './qr.js';import { Refused } from './refused.js';+import {+ baselinePauseLine,+ expiredSignInMoveRefusal,+ formatSnapshotLimit,+ permanentBaselineRefusal,+ safePauseCode,+ safePauseMessage,+ transportFailure,+} from './relay-messages.js';import { refusalFromReceipt } from './recorded-refusal.js';import { relaySenderProblem } from './relay-sender.js';-import { readRelayMachine, removeRecordedDevice, updateRelayMachine, wrapForRecordedDevice } from './relay-machine.js';-import { receivePersonRequest, requestMoveProblem } from './relay-requests.js';-import { nativePhoneAction, phoneProposal, publishPhoneApproval, warnPhoneApproval } from './relay-phone.js';-import { remoteShell as isRemoteShell, requirePersonChannel, requireRelayOnChannel } from './person.js';+import {+ readRelayMachine,+ removeRecordedDevice,+ updateRelayMachine,+ wrapForRecordedDevice,+} from './relay-machine.js';+import {+ receivePersonRequest,+ requestMoveProblem,+} from './relay-requests.js';+import {+ nativePhoneAction,+ phoneProposal,+ publishPhoneApproval,+ warnPhoneApproval,+} from './relay-phone.js';+import {+ remoteShell as isRemoteShell,+ requirePersonChannel,+ requireRelayOnChannel,+} from './person.js';import { listApiProjects } from './projects.js';export const DEFAULT_RELAY = 'https://app.pullboard.dev';