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
chore(merge): compose signing with shared native state [E22,H16]
Corey Olson91319ea5f60f
diff --cc docs/formats.mdindex 4b2015bd,d372708c..1260dcbe--- a/docs/formats.md+++ b/docs/formats.md@@@ -115,11 -115,9 +115,11 @@@ The version table is generated from th| `row grammar` | `1` | `SPEC_GRAMMAR_VERSION` in `src/spec.js`; optional `<!-- pullboard-grammar N -->` line in either file (absence means the current grammar) | Both files share the version. A declared version must match; an incompatible grammar change requires a coordinated version bump and compatible files. No automatic conversion occurs. || `board schema` | `3` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | On a write open of a board whose version is behind: create missing tables and indexes (version 3 adds the hot-path indexes), add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. Read opens never migrate; a board at the current version whose shape differs is reported once on stderr and left as it is. || `event log` | `1` | `EVENT_LOG_VERSION` in `src/board.js`, persisted in `board_meta` as `event_log_version` | Older event-log versions upgrade in place; newer versions are refused with `EVENT_LOG_VERSION`. Preserve event rows when the board schema changes. |- | `move engine` | `129` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |+ | `move engine` | `130` | `ENGINE_VERSION` in `src/machine.js`, carried as `engine` in every sealed executable move | Bump when a move's meaning changes, independently of the event log and sealed envelope. A newer engine is refused with `ENGINE_VERSION`, naming both versions and asking you to upgrade Pullboard. |<!-- format-versions:end -->+A signed board uses event-log format 2; older tools refuse it.+A builder never picks an engine number (#1101). An item that adds a board move adds its own `src/<name>-engine.js` leaf as `export const NAME_ENGINE = unassignedEngine();` (importing `unassignedEngine` from `./engine-next.js`); on its branch the leaf reads as one above the highest landed engine. The landing merge writes the next number into the leaf, in landing order, inside that item's merge commit, and sets the `move engine` row above to the highest landed number. A landed number never changes, so recorded moves replay as they were written. Moves are recorded under landed numbers only: code with an unnumbered engine is for its branch's own tests, and a move it records on a real board before landing may later read under another item's number, so the item lands before its moves are used.Relay transport capability `apiVersion: 2` is independent of these versions anddiff --cc src/cli.jsindex a23a8590,baa422ff..e2ea769b--- a/src/cli.js+++ b/src/cli.js@@@ -1,7 -1,6 +1,7 @@@+import * as personIdentity from './person.js';import { dependencyValues } from './item-dependencies.js';import { computedReturnArgs } from './computed-conflict-return.js';- import { AGENT_GRANT_ENGINE } from './agent-grant-engine.js';+ import { ENGINE_VERSION as NATIVE_ENGINE } from './engine-metadata.js';import { requireAgentGrant } from './agent-grant.js';import {focusReviewFirst,diff --cc src/native-board-state.jsindex 00000000,66479185..ae21f79amode 000000,100644..100644--- a/src/native-board-state.js+++ b/src/native-board-state.js@@@ -1,0 -1,163 +1,164 @@@+ /** One complete native state builder for local HTTP and sealed relay projections [A2,H5,H16]. */+ import { createHash } from 'node:crypto';+ import { existsSync } from 'node:fs';+ import { readFileSync } from 'node:fs';+ import { join } from 'node:path';+ import { CONFIG_FILE } from './config.js';+ import { fitFile } from './blueprint-fit.js';+ import { BLOCKS_FILE } from './blocks.js';+ import * as store from './board.js';+ import { displayAgentName } from './agent-names.js';+ import { COORDINATOR } from './config.js';+ import { loadConfig } from './config.js';+ import { repoInfo } from './git.js';+ import { listApiProjects } from './projects.js';+ import { nativeStateClockWindow } from './native-state-clock.js';+ import { milestoneRoadmap } from './roadmap.js';+ import { proofStats } from './stats.js';+ import { ruleProofCounts } from './rule-proof-counts.js';+ import { milestoneNamesByItem } from './item-list.js';+ import { withListFields } from './item-list.js';+ import { projectRowDecisions } from './row-decisions.js';+ import { projectSpecApprovals } from './spec-approval.js';+ import { specApprovalState } from './spec-approval.js';+ import { pendingFit } from './blueprint-fit.js';+ import { projectFit } from './blueprint-fit.js';+ import { personBlockWords } from './blocks.js';+ import { verdictProjector } from './verdict-freshness.js';+ import { trunkRevisionReader } from './trunk-revision.js';+ import { projectState } from './serve.js';+ import { personRequestStatuses } from './relay-requests.js';++import { personSigningPresentation } from './person-signing-presentation.js';+ import {+ dependencyValues,+ hasForeignDependencies,+ } from './item-dependencies.js';++ /** Build the complete local API state, including fields that the shared project snapshot omits. */+ export function buildLocalBoardState(root, boardId, board, codeIsMain, { previous = null, fullItemRebuild = true, afterSequence = 0, changedLeases = new Set(), onItemBuild, projects = listApiProjects, scopeCommonDir = null, observedAt = Date.now(), freshnessReader = null, localRelayHealth = null } = {}) {+ if (!Number.isSafeInteger(observedAt) || observedAt < 0) throw new TypeError('native projection needs an observation timestamp');+ board = Object.assign(Object.create(board), { clock: { ...board.clock, now: () => new Date(observedAt) } });+ board.db.exec('BEGIN');+ try {+ const sequence = board.db.prepare('SELECT COALESCE(MAX(event_id), 0) AS id FROM event').get().id;+ let rebuildAll = fullItemRebuild || (previous && previous.sequence > sequence);+ const eventRows = rebuildAll || !previous ? [] : board.db.prepare('SELECT event_id, item_id, event_kind FROM event WHERE event_id > ? ORDER BY event_id').all(afterSequence);+ if (!rebuildAll && previous && eventRows.length !== sequence - previous.sequence) rebuildAll = true;+ const dirtyIds = new Set(rebuildAll ? [] : [...changedLeases]);+ for (const event of eventRows) if (event.item_id !== null) dirtyIds.add(event.item_id);++ const foreignChanged = eventRows.some(event => event.event_kind === 'board_link_state' || event.event_kind === 'board_link');+ const currentItems = store.listItems(board, { all: true });+ const currentById = new Map(currentItems.map((item) => [item.item_id, item]));+ const currentDependencies = new Map(currentItems.map((item) => [item.item_id, dependencyIds(item)]));+ const milestoneNames = milestoneNamesByItem(store.milestones(board));+ for (const prior of previous?.itemMeta.values() ?? []) {+ if (!currentById.has(prior.id)) dirtyIds.add(prior.id);+ }+ for (const item of currentItems) {+ const prior = previous?.itemMeta.get(item.item_id);+ // E32 announcements and consent changes carry no local item_id, but change foreign blockers.+ if (foreignChanged && hasForeignDependencies(item)) dirtyIds.add(item.item_id);+ if (rebuildAll || !previous?.items.has(item.item_id) || !prior || prior.raw !== JSON.stringify(item)) dirtyIds.add(item.item_id);+ if (prior && prior.milestone !== (milestoneNames.get(item.item_id) ?? null)) dirtyIds.add(item.item_id);+ }+ // A dirty item's status affects the blockedBy list of every direct old or new dependent.+ const changedIds = [...dirtyIds];+ for (const dependent of previous?.itemMeta.values() ?? []) {+ if (changedIds.some((id) => dependent.dependencies.includes(id))) dirtyIds.add(dependent.id);+ }+ for (const [id, dependencies] of currentDependencies) {+ if (changedIds.some((changed) => dependencies.includes(changed))) dirtyIds.add(id);+ }++ const config = loadConfig(root);+ const freshness = freshnessReader ?? verdictProjector(root, board, { main: trunkRevisionReader(repoInfo(root))() }).state;+ const state = projectState(root, { seen: null, board, itemProjector: (item, context) => {+ if (dirtyIds.has(item.item_id)) {+ const projected = context.project();+ const verdictState = freshness(item);+ return verdictState ? { ...projected, verdictState } : projected;+ }+ return previous.items.get(item.item_id);+ } });+ state.agents = state.agents.map((agent) => ({ ...agent, model: agent.agent_model ?? 'unknown', displayName: displayAgentName(agent, config.agents.names) }));+ state.board = boardId;+ state.observedAt = new Date(observedAt).toISOString();+ state.decisionQueue = store.openDecisions(board, COORDINATOR);+ const projectData = {+ requests: store.openRequests(board),+ personRequests: personRequestStatuses(board),+ milestones: scopeCommonDir === null+ ? milestoneRoadmap(root, board)+ : milestoneRoadmap(root, board, { projects, hideOutOfScope: true }),+ rowDecisions: store.rowDecisions(board),+ proofStats: proofStats(board, { now: observedAt }),+ };+ state.proofStats = projectData.proofStats;+ state.requests = projectData.requests;+ state.personRequests = projectData.personRequests;++ Object.assign(state, personSigningPresentation(root, board, config));+ state.milestones = projectData.milestones;+ state.blocks = personBlockWords(repoInfo(root).commonDir, board.clock.now()); // Needs you below is recomputed with them [C6].+ // Only the local HTTP host supplies its private telemetry; sealed projections omit it entirely.+ if (localRelayHealth !== null) state.relayHealthAlerts = localRelayHealth;+ const decorated = projectSpecApprovals(projectFit(pendingFit(repoInfo(root).commonDir), projectRowDecisions(projectData.rowDecisions, state)), specApprovalState(root, { board, config }));+ decorated.ruleCounts = ruleProofCounts(root, board, decorated.spec);+ const bases = new Map(decorated.items.map((item) => [item.id, item]));+ for (const id of dirtyIds) {+ if (!currentById.has(id)) continue;+ const item = store.getItem(board, id);+ const base = bases.get(id);+ const full = {+ ...base,+ check: item.item_check,+ ...(item.item_check_baseline ? { checkBaseline: item.item_check_baseline } : {}),+ thread: store.itemThread(board, id),+ };+ bases.set(id, full);+ onItemBuild?.({ board: boardId, itemId: id });+ }+ decorated.items = decorated.items.map((item) => bases.get(item.id) ?? item);+ const leases = new Map(currentItems.map((item) => [item.item_id, item.item_lease_until ?? null]));+ const listFields = withListFields(decorated, leases, { previous, dirtyIds });+ const itemMeta = new Map(currentItems.map((item) => [item.item_id, {+ id: item.item_id,+ raw: JSON.stringify(item),+ dependencies: currentDependencies.get(item.item_id) ?? [],+ milestone: milestoneNames.get(item.item_id) ?? null,+ }]));+ const history = store.events(board);+ const clockWindow = nativeStateClockWindow(listFields.state, history, currentItems, observedAt);+ board.db.exec('COMMIT');+ return { state: listFields.state, itemMeta, itemMoveCounts: listFields.itemMoveCounts, sequence, history, clockWindow };+ } catch (error) {+ try { board.db.exec('ROLLBACK'); } catch { /* Preserve the projection failure. */ }+ throw error;+ }+ }++ /** Parse an item's ordered prerequisite IDs from its persisted row. */+ export function dependencyIds(item) {+ return dependencyValues(item);+ }+++ /** Name project and built-in files separately, even when their basenames collide. */+ export function stateFileInputs(root, config) {+ return [+ { name: `config:${CONFIG_FILE}`, path: join(root, CONFIG_FILE) },+ { name: `spec:${config.spec}`, path: join(root, config.spec) },+ { name: `practice:${config.practice}`, path: join(root, config.practice) },+ { name: 'builtin:standard-doctrine.md', path: new URL('./standard-doctrine.md', import.meta.url) },+ ...['signoffs.jsonl', 'signers', 'first-commit', 'signers.initial'].map(name => ({ name: `approval:${name}`, path: join(root, '.pullboard', name) })),+ { name: 'fit:blueprint-fit.json', path: fitFile(repoInfo(root).commonDir) },+ // A new block changes Needs you without a board move, so the ledger is a state input [C6].+ { name: 'blocks:blocks.jsonl', path: join(repoInfo(root).commonDir, BLOCKS_FILE) },+ ];+ }++ /** Hash the exact bytes of one named input, preserving a missing-file marker. */+ export function fileRevision(file) {+ if (!existsSync(file.path)) return [file.name, null];+ return [file.name, createHash('sha256').update(readFileSync(file.path)).digest('hex')];+ }-diff --cc src/person-signing-presentation.jsindex 00000000,00000000..d7eb19e4new file mode 100644--- /dev/null+++ b/src/person-signing-presentation.js@@@ -1,0 -1,0 +1,31 @@@++/** Preserve the signing item's device-facing fields in the shared native/relay projection [E22,H16]. */++import * as store from './board.js';++import { loadSpec } from './spec.js';++import { loadDoctrine } from './doctrine.js';++import { shownDecisionRows } from './row-decisions.js';++import { personRequestRecords } from './relay-requests.js';++import { barDigest, barReadiness } from './bar-readiness.js';++import { mainPolicy } from './trusted-policy.js';++import { previewBarCoverage } from './bar-coverage.js';++import { Refused } from './refused.js';++++/** Read the exact rows and pending proposals the registered signing device can present. */++export function personSigningPresentation(root, board, config) {++ // The passkey device reads whether person moves are signed and which terminal-started moves wait for it [E22].++ const requested = new Set(personRequestRecords(board).map((record) => record.id));++ const personProposals = store.personProposals(board).filter((proposal) => !requested.has(proposal.id));++ const signed = store.personSigning(board).signed;++ const ids = signed ? [...loadSpec(root, config).rows.map(row => row.id), ...loadDoctrine(root, config).repo.rows.map(row => `doctrine:${row.id}`)] : [];++ const personRows = signed ? shownDecisionRows(root, config, ids) : [];++ let personBars = [];++ if (signed) {++ const entries = store.listItems(board, { all: true }).map(item => ({ item, status: barReadiness(board, item, { signature: false }) }));++ // A board with no committed policy yet still shows its bars, only without their coverage preview.++ let policy = null;++ try { policy = mainPolicy(root); } catch (error) { if (!(error instanceof Refused)) throw error; }++ const plans = policy ? previewBarCoverage(root, entries.map(({ item, status }) => ({ item, coverage: status.signed?.coverage })), policy) : [];++ personBars = entries.map(({ item, status }, index) => ({ id: item.item_id,++ before: { revision: status.revision?.revision ?? 0, digest: barDigest(item) }, ...(plans[index] ? { coverage: plans[index] } : {}) }));++ }++ return { personSigning: { signed }, personProposals, personRows, personBars };++}