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.

chore(core): integrate reviewed trunk for milestones [N26,H16]

Corey Olson52bc950d1f73
diff --cc docs/formats.md
index 355daab1,e6137d4b..45daf0d5
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -113,7 -113,7 +113,7 @@@ The board file is in the repository's G
| `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` | `2` | `SCHEMA_VERSION` in `src/board.js`, persisted as `PRAGMA user_version` | Create missing tables and indexes, add missing columns in place with declared defaults, restore missing or changed triggers, and remove stale machine triggers without replacing rows. |
| `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` | `31` | `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` | `33` | `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` | `39` | `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 -->
Pullboard 0.6.1 released engine 1. Engine 2 records a fresh explicit-build claim's skipped-review snapshot. Pullboard 0.8.1 released engine 3, including lane-sensitive graft refusals and authenticated relay senders. Engine 4 adds captured background-baseline completions through `completeCheckBaseline`; released engine-3 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Engine 5 requires a one-line reason when releasing a review and gives that reviewer a one-hour cooldown for the current submission. Each sealed move replays under its recorded engine version: engines 1 through 4 retain the original release event and review-reservation behavior. Engine 5 retains support for older moves, including engine-4 baseline completions. Pullboard 0.8.3 released engine 6, adding board-scoped machine credentials and permitting machine execution only for one exact, earlier authenticated phone request, including its payload digest. Engine 7 adds ordered item holds through `holdItem` and `releaseItemHold`; engine-6 clients stop with `ENGINE_VERSION` before interpreting either operation or advancing their replay cursor. Engine 8, shared by the 0.8.5 move changes, retains merged-item exception notes, selects the next review in roadmap order, and adds coordinator-only `reopen` for a submission returned without a verdict; engine-7 clients stop with `ENGINE_VERSION` before interpreting this new operation or advancing their replay cursor. Recorded engines 1 through 7 retain their original tier-first review selection. Engine 8 also adds durable refusal recovery for blocked relay positions; each explicit skip publishes the readable prefix even when another unsupported record follows. Engine 8 also permits coordinator criterion/check edits on a live claim as pending corrections; the holder cannot renew or submit until a refreeze adopts the correction while preserving the claim. Older request receipts retain their recorded engine semantics. Upgrade every linked device before using the new moves. Each release shares one engine bump across its changed moves. Engine 8 also retains declared model labels on registration and records each registered agent move's model snapshot; engines 1 through 7 retain their original registration and event details without these model fields. Pullboard 0.8.8 released engine 9, which allows resubmitting the same rejected commit after a corrected criterion is refrozen, but only when the rejection names a different frozen digest. Engine 8 retains its HEAD_NOT_NEW refusal and prior submit-event detail. Engine-9 submit events add `criterionDigest`, and engine-8 boards replay with the original refusal and event history.
@@@ -132,9 -134,6 +134,9 @@@ Engine 24 adds the person's `acceptChec
Engine 30 lets a reject and a reopen carry a cause key (`cause`: `test:<file>::<title>`, `refusal:<CODE>`, `row:<id>` or `doctrine:<id>`) and lets the person record a never-again fact with `cause` and `neverAgain: true`, for `pullboard rigor`. Only a move that carries one of these needs engine 30; engine-29 and older moves replay unchanged, and clients on an older engine refuse an engine-30 move with `RELAY_MOVE` before changing their board or cursor. Engine 20 is the implied-items engine above; engine numbers 21 through 29 are allocated to other changes.
- Engine 31 gives a milestone a target and a shipment. An `editMilestone` move may carry `target`, an ISO date or date-time with an explicit zone (the CLI and `prepareEngineMove` turn a typed local time into UTC before the move is sealed, so every replica stores the same instant; a bare local time in an envelope is refused with `MILESTONE_TARGET`), or `none` to clear it. A `shipMilestone` move records the milestone as shipped at main's commit and moves every local item that has not landed and is not withdrawn into the next unshipped milestone, or `--next`, writing a `milestone_moved` event on each moved item; repo-qualified references stay in place and are listed as not moved across boards. A shipped milestone refuses new items with `MILESTONE_SHIPPED`. Either makes the move an engine-31 move, and an older engine refuses it with `RELAY_MOVE` before changing its board or cursor. Engine numbers 13 to 18 and 21 to 29 are allocated to other changes; engine 30 carries the cause-key behavior above.
++Engine 39 gives a milestone a target and a shipment. An `editMilestone` move may carry `target`, an ISO date or date-time with an explicit zone (the CLI and `prepareEngineMove` turn a typed local time into UTC before the move is sealed, so every replica stores the same instant; a bare local time in an envelope is refused with `MILESTONE_TARGET`), or `none` to clear it. A `shipMilestone` move records the milestone as shipped at main's commit and moves every local item that has not landed and is not withdrawn into the next unshipped milestone, or `--next`, writing a `milestone_moved` event on each moved item; repo-qualified references stay in place and are listed as not moved across boards. A shipped milestone refuses new items with `MILESTONE_SHIPPED`. Either makes the move an engine-39 move, and an older engine refuses it with `RELAY_MOVE` before changing its board or cursor. The coordinator assigned engines 34, 35, 36, 37 and 38 to #794, #579, #777, #408 and #696 respectively; engine 39 is assigned to this milestone feature. Engine 30 carries the cause-key behavior above; engine 33 retains the checked-review behavior described above.
+
+
The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.
A linked board requires at least engine 3 after issuing any agent token, including
revoked or expired tokens. Issuing any machine credential raises that board’s minimum to engine 6, including after revocation or expiry. The minimum survives reopening the auth database;
diff --cc src/engine.js
index 78618e45,a88943bd..b4f6bad1
--- a/src/engine.js
+++ b/src/engine.js
@@@ -5,8 -5,7 +5,8 @@@ import { recordedRefusal } from './reco
import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';
import { carriesImplies, IMPLIES_ENGINE } from './implies.js';
import { CHECK_ACCEPT_ENGINE } from './check-accept.js';
- import { CAUSE_ENGINE, ENGINE_VERSION } from './machine.js';
+ import { CAUSE_ENGINE, ENGINE_VERSION, VERDICT_REVIEW_ENGINE } from './machine.js';
+import { MILESTONE_SHIP_ENGINE, canonicalMilestoneTarget } from './milestones.js';
import { Refused } from './refused.js';
import { requestMoveProblem, recordRequestMove } from './relay-requests.js';
import { relayMoveActor, relaySenderProblem, validRelaySender } from './relay-sender.js';
@@@ -24,13 -23,20 +24,21 @@@ export const ENGINE_OPERATIONS = Object
]);
/** Engine version at which each ordered operation first has stable replay semantics. */
-const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8, acceptCheck: CHECK_ACCEPT_ENGINE });
+const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8, acceptCheck: CHECK_ACCEPT_ENGINE,
+ shipMilestone: MILESTONE_SHIP_ENGINE });
- /** Dependency edits add engine-10 meaning, edit reasons engine-19, implied items engine-20, a cause key on a reject, reopen or person fact engine-30 (#713), and milestone targets engine-31, without changing ordinary historical envelopes. */
- function minimumOperationEngine(operation, args) {
-/** Dependency edits, bar reasons and sealed review metadata retain their distinct recorded engine meanings. */
++/** Dependency edits, bar reasons, cause keys, checked reviews, and milestone targets retain their distinct recorded engine meanings. */
+ function minimumOperationEngine(operation, args, board) {
const options = args[1];
const given = (name) => Boolean(options && typeof options === 'object' && Object.hasOwn(options, name) && options[name] !== undefined && options[name] !== null && options[name] !== false);
+ if (board && ['recordLandingBatch', 'finishLandingBatch'].includes(operation)) {
+ const id = operation === 'recordLandingBatch' ? args[0]?.batch?.id : args[0]?.id;
+ const prior = id && store.landingBatches(board).find(batch => batch.id === id);
+ if (prior && ['items', 'candidates'].some(key => Array.isArray(prior[key]) && prior[key].some(entry => entry && Object.hasOwn(entry, 'reviewedCommit')))) return VERDICT_REVIEW_ENGINE;
+ }
+ if (operation === 'verify' && options && Object.hasOwn(options, 'review')) return VERDICT_REVIEW_ENGINE;
+ if (operation === 'recordLandingBatch' && args[0]?.batch
+ && ['items', 'candidates'].some(key => Array.isArray(args[0].batch[key]) && args[0].batch[key].some(entry => entry && typeof entry === 'object' && Object.hasOwn(entry, 'reviewedCommit')))) return VERDICT_REVIEW_ENGINE;
if (['verify', 'reopen', 'appendFact'].includes(operation) && (given('cause') || given('neverAgain') || given('asPerson'))) return CAUSE_ENGINE;
if (carriesImplies(operation, args)) return IMPLIES_ENGINE;
if (carriesBarReason(operation, args)) return BAR_ENGINE;
diff --cc src/machine.js
index 95527ca0,d569abe7..f6e8fb38
--- a/src/machine.js
+++ b/src/machine.js
@@@ -10,7 -10,7 +10,7 @@@
*/
/** Executable move semantics, carried by every sealed move and retained during replay [H16]. */
- export const ENGINE_VERSION = 31;
-export const ENGINE_VERSION = 33;
++export const ENGINE_VERSION = 39;
/** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */
export const CAUSE_ENGINE = 30;
diff --cc src/milestones.js
index 4f16fdff,00000000..adcaf401
mode 100644,000000..100644
--- a/src/milestones.js
+++ b/src/milestones.js
@@@ -1,308 -1,0 +1,308 @@@
+/**
+ * The roadmap's milestones: ordered names, notes, targets and item references kept in one
+ * board_meta value, and the moves that change them (N26). Only the coordinator changes them.
+ *
+ * An item counts toward a milestone only once it has landed on main: it is verified and its merge
+ * commit is recorded. Shipping a milestone records main's commit and carries every unlanded item
+ * into the next milestone, so the roadmap stays the one place that says what is planned.
+ */
+import { COORDINATOR } from './config.js';
+import { ENGINE_VERSION } from './machine.js';
+import { Refused } from './refused.js';
+import { atomic, itemById, listItems, logEvent, milestones } from './board.js';
+
+/** The engine at which a milestone carries a target and ships; older moves replay as they did. */
- export const MILESTONE_SHIP_ENGINE = 31;
++export const MILESTONE_SHIP_ENGINE = 39;
+
+/** The engine a move runs under: its recorded one during replay, else this client's. */
+function engineOf(board) {
+ return board.executionEngineVersion ?? ENGINE_VERSION;
+}
+
+/**
+ * An item's roadmap state: landed once its merge onto main is recorded, accepted while verified
+ * but not yet landed, and otherwise its board status.
+ *
+ * @param {string} status
+ * @param {boolean} landed
+ * @returns {string}
+ */
+export function roadmapState(status, landed) {
+ if (status === 'verified' && landed) return 'landed';
+ return status === 'verified' ? 'accepted' : status;
+}
+
+/**
+ * Return milestones with each item's current status and state, a landed count, and the
+ * milestone's target and shipment. `done` is the landed count: accepted work has not shipped yet.
+ *
+ * @param {any} board
+ * @param {((reference: string) => any) | null} [resolveExternal]
+ * @returns {any[]}
+ */
+export function roadmap(board, resolveExternal = null) {
+ const items = new Map(listItems(board, { all: true }).map((item) => [item.item_id, item]));
+ const at = board.clock.now().getTime();
+ return milestones(board).map((milestone) => {
+ const entries = milestone.items.map((id) => {
+ if (typeof id === 'number') {
+ const item = items.get(id);
+ return item
+ ? { id, title: item.item_title, status: item.item_status, state: roadmapState(item.item_status, Boolean(item.item_merged_commit)) }
+ : { id, title: `#${id}`, status: 'missing', state: 'missing' };
+ }
+ const external = resolveExternal?.(id) ?? { id, title: id, status: 'unavailable' };
+ return { id: external.id, title: external.title, status: external.status, state: roadmapState(external.status, Boolean(external.landed)) };
+ });
+ const landed = entries.filter((item) => item.state === 'landed').length;
+ const target = milestone.target ?? null;
+ return {
+ name: milestone.name,
+ note: milestone.note,
+ target,
+ pastTarget: !milestone.shipped && target !== null && Date.parse(target) <= at,
+ shipped: milestone.shipped ?? null,
+ items: entries,
+ landed,
+ done: landed,
+ total: entries.length,
+ };
+ });
+}
+
+/** Validate a coordinator identity before changing roadmap metadata. */
+function requireCoordinator(agentId) {
+ if (agentId !== COORDINATOR) throw new Refused('COORDINATOR_ONLY', 'only the coordinator changes milestones; ask your coordinator to update the roadmap');
+}
+
+/** Parse an ordered list of local item ids and repo-qualified ids. */
+function normalizeMilestoneItems(items) {
+ if (!Array.isArray(items)) throw new Refused('MILESTONE_ITEMS', 'milestone items need comma-separated item ids; use pullboard milestone add --items 1,2');
+ const result = items.map((value) => {
+ if (Number.isSafeInteger(value) && value > 0) return value;
+ if (typeof value === 'string') {
+ const text = value.trim();
+ if (/^[1-9]\d*$/.test(text) && Number.isSafeInteger(Number(text))) return Number(text);
+ if (/^[^#,\s][^#,]*#[1-9]\d*$/.test(text)) return text;
+ }
+ throw new Refused('MILESTONE_ITEMS', `invalid item id ${String(value)}; use a positive id or repo#id`);
+ });
+ if (new Set(result.map((value) => JSON.stringify(value))).size !== result.length) {
+ throw new Refused('MILESTONE_ITEMS', 'a milestone cannot list the same item twice; remove duplicate ids and retry');
+ }
+ return result;
+}
+
+/** Refuse local item ids that do not exist while leaving repo-qualified ids for board lookup. */
+function validateLocalMilestoneItems(board, items) {
+ for (const id of items) if (typeof id === 'number') itemById(board, id);
+}
+
+/** Validate a milestone name and note before storing them. */
+function normalizeMilestoneText(name, note = null) {
+ if (typeof name !== 'string' || !name.trim()) throw new Refused('MILESTONE_NAME', 'a milestone needs a name; use pullboard milestone add <name>');
+ if (typeof note !== 'string' && note !== null) throw new Refused('MILESTONE_NOTE', 'a milestone note needs text; use --note <text>');
+ return { name: name.trim(), note: note?.trim() || null };
+}
+
+/**
+ * The instant a target the coordinator typed names, read in this machine's time zone, as UTC ISO
+ * text, or `none` unchanged. The move is prepared with this value, so the ordered envelope never
+ * carries a local time that another replica would read in its own zone.
+ *
+ * @param {unknown} target
+ * @returns {unknown}
+ */
+export function canonicalMilestoneTarget(target) {
+ if (target === 'none' || typeof target !== 'string' || !/\d/.test(target)) return target;
+ const at = Date.parse(target.trim());
+ return Number.isFinite(at) ? new Date(at).toISOString() : target;
+}
+
+/**
+ * A target as ISO text, or null for `none`, which clears it. Applying a move accepts only a date or
+ * a date and time with an explicit zone, so every replica reads the same instant: a bare local
+ * time would mean a different moment on a machine in another zone.
+ *
+ * @param {unknown} target
+ * @returns {string | null}
+ */
+function normalizeMilestoneTarget(target) {
+ if (target === 'none') return null;
+ const text = typeof target === 'string' ? target.trim() : '';
+ const zoned = /^\d{4}-\d{2}-\d{2}$/.test(text) || /T.*(?:Z|[+-]\d{2}:?\d{2})$/i.test(text);
+ const at = zoned ? Date.parse(text) : NaN;
+ if (!Number.isFinite(at)) throw new Refused('MILESTONE_TARGET', 'a target needs a date, or a date and time with its zone, like 2026-10-20T18:00Z; use --target <date and time>, or --target none to clear it');
+ return new Date(at).toISOString();
+}
+
+/** Save the whole milestone list in one board_meta value. */
+function saveMilestones(board, entries) {
+ board.db.prepare('INSERT INTO board_meta (meta_key, meta_value) VALUES (?, ?) ON CONFLICT(meta_key) DO UPDATE SET meta_value = excluded.meta_value')
+ .run('milestones', JSON.stringify(entries));
+}
+
+/** The refusal for adding work to a milestone that already shipped. */
+function shippedRefusal(entry) {
+ return new Refused('MILESTONE_SHIPPED', `milestone ${entry.name} shipped at ${entry.shipped.commit}; add the item to the next milestone instead`);
+}
+
+/** Add an ordered milestone without changing any referenced board items. */
+export function addMilestone(board, { agentId, name, note = null, items = [] }) {
+ requireCoordinator(agentId);
+ const text = normalizeMilestoneText(name, note);
+ const normalized = normalizeMilestoneItems(items);
+ validateLocalMilestoneItems(board, normalized);
+ return atomic(board, () => {
+ const entries = milestones(board);
+ if (entries.some((entry) => entry.name === text.name)) throw new Refused('MILESTONE_EXISTS', `milestone ${text.name} already exists; edit it or choose another name`);
+ saveMilestones(board, [...entries, { ...text, items: normalized }]);
+ logEvent(board, agentId, 'milestone_add', null, { name: text.name, items: normalized });
+ return text.name;
+ });
+}
+
+/**
- * Add or remove item references while preserving the remaining order. From engine 31 a shipped
++ * Add or remove item references while preserving the remaining order. From engine 39 a shipped
+ * milestone takes no new items; removing one is still allowed.
+ */
+export function editMilestoneItems(board, name, { agentId, add = [], remove = [] }) {
+ requireCoordinator(agentId);
+ const additions = normalizeMilestoneItems(add);
+ const removals = normalizeMilestoneItems(remove);
+ validateLocalMilestoneItems(board, additions);
+ if (additions.length && removals.length) throw new Refused('MILESTONE_ITEMS', 'add or remove milestone items in separate commands');
+ if (!additions.length && !removals.length) throw new Refused('MILESTONE_ITEMS', 'name ids with --add or --remove');
+ return atomic(board, () => {
+ const entries = milestones(board);
+ const index = entries.findIndex((entry) => entry.name === name);
+ if (index < 0) throw new Refused('NO_MILESTONE', `no milestone named ${name}; list them with pullboard roadmap`);
+ const current = entries[index];
+ if (additions.length && current.shipped && engineOf(board) >= MILESTONE_SHIP_ENGINE) throw shippedRefusal(current);
+ const nextItems = additions.length
+ ? [...current.items, ...additions]
+ : current.items.filter((id) => !removals.some((removeId) => JSON.stringify(removeId) === JSON.stringify(id)));
+ if (additions.length && new Set(nextItems.map((value) => JSON.stringify(value))).size !== nextItems.length) {
+ throw new Refused('MILESTONE_ITEMS', 'a milestone cannot list the same item twice; remove duplicate ids and retry');
+ }
+ if (removals.some((id) => current.items.every((present) => JSON.stringify(id) !== JSON.stringify(present)))) {
+ throw new Refused('MILESTONE_ITEMS', 'one or more ids are not in this milestone; read pullboard roadmap and retry');
+ }
+ entries[index] = { ...current, items: nextItems };
+ saveMilestones(board, entries);
+ logEvent(board, agentId, 'milestone_items', null, { name, add: additions, remove: removals });
+ return nextItems;
+ });
+}
+
+/** Move a milestone before another while retaining all item and note data. */
+export function moveMilestone(board, name, { agentId, before }) {
+ requireCoordinator(agentId);
+ return atomic(board, () => {
+ const entries = milestones(board);
+ const index = entries.findIndex((entry) => entry.name === name);
+ const target = entries.findIndex((entry) => entry.name === before);
+ if (index < 0 || target < 0) throw new Refused('NO_MILESTONE', `name both milestones in pullboard milestone move ${name} --before <other>`);
+ if (name === before) throw new Refused('MILESTONE_ORDER', 'choose a different milestone to move before');
+ const [entry] = entries.splice(index, 1);
+ entries.splice(entries.findIndex((value) => value.name === before), 0, entry);
+ saveMilestones(board, entries);
+ logEvent(board, agentId, 'milestone_move', null, { name, before });
+ return entries;
+ });
+}
+
+/**
+ * Rename a milestone, update its note, or set its target without touching its items. A target is
- * an engine-31 meaning, so an older engine's edit replays exactly as it did.
++ * an engine-39 meaning, so an older engine's edit replays exactly as it did.
+ */
+export function editMilestone(board, name, { agentId, newName, note, target }) {
+ requireCoordinator(agentId);
+ const engine = engineOf(board);
+ if (target !== undefined && engine < MILESTONE_SHIP_ENGINE) {
+ throw new Refused('ENGINE_VERSION', `a milestone target requires engine ${MILESTONE_SHIP_ENGINE}; this board uses engine ${engine}; upgrade Pullboard before using --target`);
+ }
+ if (newName === undefined && note === undefined && target === undefined) {
+ throw new Refused('MILESTONE_EDIT', engine < MILESTONE_SHIP_ENGINE ? 'supply --name or --note to edit a milestone' : 'supply --name, --note or --target to edit a milestone');
+ }
+ const targetValue = target === undefined ? undefined : normalizeMilestoneTarget(target);
+ return atomic(board, () => {
+ const entries = milestones(board);
+ const index = entries.findIndex((entry) => entry.name === name);
+ if (index < 0) throw new Refused('NO_MILESTONE', `no milestone named ${name}; list them with pullboard roadmap`);
+ const renamed = newName === undefined ? name : normalizeMilestoneText(newName).name;
+ if (renamed !== name && entries.some((entry) => entry.name === renamed)) throw new Refused('MILESTONE_EXISTS', `milestone ${renamed} already exists; choose another name`);
+ entries[index] = { ...entries[index], name: renamed, ...(note === undefined ? {} : { note: normalizeMilestoneText(renamed, note).note }) };
+ if (targetValue !== undefined) entries[index].target = targetValue;
+ saveMilestones(board, entries);
+ logEvent(board, agentId, 'milestone_edit', null, { before: name, after: renamed, noteChanged: note !== undefined,
+ ...(targetValue === undefined ? {} : { target: targetValue }) });
+ return entries[index];
+ });
+}
+
+/** Remove one milestone only; its referenced work items remain on their boards. */
+export function removeMilestone(board, name, { agentId }) {
+ requireCoordinator(agentId);
+ return atomic(board, () => {
+ const entries = milestones(board);
+ const remaining = entries.filter((entry) => entry.name !== name);
+ if (remaining.length === entries.length) throw new Refused('NO_MILESTONE', `no milestone named ${name}; list them with pullboard roadmap`);
+ saveMilestones(board, remaining);
+ logEvent(board, agentId, 'milestone_remove', null, { name });
+ return name;
+ });
+}
+
+/**
+ * Ship a milestone: record main's commit on it, keep the items that landed, and move every other
+ * local item into the next milestone (the first unshipped one after it, or `next`), recording the
+ * move on each item's thread. A withdrawn item stays, since it will never land; a repo#id
+ * reference stays too, since its board, not this one, says whether it landed.
+ *
+ * @param {any} board
+ * @param {string} name
+ * @param {{ agentId: string, commit: string | null, next?: string }} options
+ * @returns {{ milestone: any, into: string | null, moved: number[], notMoved: string[] }}
+ */
+export function shipMilestone(board, name, { agentId, commit, next }) {
+ requireCoordinator(agentId);
+ if (typeof commit !== 'string' || !/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(commit)) {
+ throw new Refused('MILESTONE_COMMIT', "shipping records main's commit and main has none here; commit to main, then ship from the main checkout");
+ }
+ return atomic(board, () => {
+ const entries = milestones(board);
+ const index = entries.findIndex((entry) => entry.name === name);
+ if (index < 0) throw new Refused('NO_MILESTONE', `no milestone named ${name}; list them with pullboard roadmap`);
+ const current = entries[index];
+ if (current.shipped) throw shippedRefusal(current);
+ const items = new Map(listItems(board, { all: true }).map((item) => [item.item_id, item]));
+ const notMoved = current.items.filter((id) => typeof id === 'string');
+ const stays = (id) => {
+ const item = typeof id === 'number' ? items.get(id) : null;
+ return !item || item.item_status === 'withdrawn' || roadmapState(item.item_status, Boolean(item.item_merged_commit)) === 'landed';
+ };
+ const moved = current.items.filter((id) => !stays(id));
+ let into = null;
+ if (next !== undefined) {
+ into = entries.findIndex((entry) => entry.name === next);
+ if (into < 0) throw new Refused('NO_MILESTONE', `no milestone named ${next}; list them with pullboard roadmap`);
+ if (into === index) throw new Refused('MILESTONE_ORDER', 'choose a different milestone for --next than the one shipping');
+ if (entries[into].shipped) throw shippedRefusal(entries[into]);
+ } else if (moved.length) {
+ into = entries.findIndex((entry, position) => position > index && !entry.shipped);
+ if (into < 0) throw new Refused('NO_NEXT_MILESTONE', `no unshipped milestone follows ${name} to take its unlanded items; add one with pullboard milestone add, or name one with --next`);
+ }
+ const intoName = into === null ? null : entries[into].name;
+ const at = board.clock.now().toISOString();
+ if (into !== null) entries[into] = { ...entries[into], items: [...entries[into].items, ...moved.filter((id) => !entries[into].items.includes(id))] };
+ entries[index] = { ...current, items: current.items.filter(stays), shipped: { commit, at, by: agentId } };
+ saveMilestones(board, entries);
+ logEvent(board, agentId, 'milestone_ship', null, { name, commit, into: intoName, moved, notMoved });
+ for (const id of moved) {
+ logEvent(board, agentId, 'milestone_moved', id, { from: name, to: intoName, commit,
+ note: `moved from ${name} to ${intoName}: ${name} shipped at ${commit.slice(0, 12)} before this item landed` });
+ }
+ return { milestone: entries[index], into: intoName, moved, notMoved };
+ });
+}
diff --cc test/agent-model-engine.test.js
index 19c8fb04,d0bca12b..f050bf22
--- a/test/agent-model-engine.test.js
+++ b/test/agent-model-engine.test.js
@@@ -10,9 -10,9 +10,9 @@@ import { mkdtempSync, rmSync, writeFile
import { tmpdir } from 'node:os';
import { join } from 'node:path';
- test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 31, 'engine 31 preserves the released engine-8 through engine-11 model behavior');
- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, ENGINE_VERSION]) {
-test('model declarations and event snapshots retain engines 1 through 33 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 33, 'the next writer preserves every historical model snapshot through main engine 30');
++test('model declarations and event snapshots retain engines 1 through 39 semantics [O8,O3,H16]', (t) => {
++ assert.equal(ENGINE_VERSION, 39, 'the next writer preserves every historical model snapshot through engine 38');
+ for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {
const board = store.openBoard(':memory:');
t.after(() => store.closeBoard(board));
const registration = prepareEngineMove(board, 'register', [{ lane: 'web', path: '/web', model: 'First Model' }]);
diff --cc test/milestones.test.js
index f0ecf793,00000000..d6a590b0
mode 100644,000000..100644
--- a/test/milestones.test.js
+++ b/test/milestones.test.js
@@@ -1,237 -1,0 +1,237 @@@
+/** The roadmap counts what landed on main, and shipping a milestone carries the rest forward [N26]. */
+import assert from 'node:assert/strict';
+import { execFileSync, spawnSync } from 'node:child_process';
+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
+import { tmpdir } from 'node:os';
+import { join, resolve } from 'node:path';
+import { after, test } from 'node:test';
+import * as store from '../src/board.js';
+
+const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');
+const HOUR = 3_600_000;
+const TEMP_DIRS = [];
+
+after(() => {
+ for (const dir of TEMP_DIRS) rmSync(dir, { recursive: true, force: true });
+});
+
+/**
+ * A real repo on main with an initialized board and a builder agent, and items in each state
+ * the roadmap tells apart: landed (verified with a merge commit), accepted (verified only) and open.
+ * Git runs with every GIT_* variable stripped, so a hook's repository never leaks into the fixture.
+ */
+function fixture(t) {
+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-milestones-'));
+ TEMP_DIRS.push(dir);
+ const repo = join(dir, 'repo');
+ const bin = join(dir, 'bin');
+ mkdirSync(bin);
+ // The repo's hooks call pullboard by name, so the fixture puts this checkout's CLI on PATH.
+ const word = (value) => `'${String(value).replaceAll("'", "'\\''")}'`;
+ writeFileSync(join(bin, 'pullboard'), `#!/bin/sh\nexec ${word(process.execPath)} ${word(BIN)} "$@"\n`);
+ chmodSync(join(bin, 'pullboard'), 0o755);
+ const env = { ...process.env };
+ for (const key of Object.keys(env)) if (key.startsWith('GIT_')) delete env[key];
+ Object.assign(env, { HOME: join(dir, 'home'), PULLBOARD_HOME: join(dir, 'pullboard-home'),
+ PULLBOARD_MACHINE_HOME: join(dir, 'machine-home'), GIT_CONFIG_GLOBAL: '/dev/null', GIT_CONFIG_NOSYSTEM: '1',
+ GIT_AUTHOR_NAME: 'Milestone fixture', GIT_AUTHOR_EMAIL: '[email protected]',
+ GIT_COMMITTER_NAME: 'Milestone fixture', GIT_COMMITTER_EMAIL: '[email protected]', PATH: `${bin}:${process.env.PATH}` });
+ execFileSync('git', ['init', '-q', '-b', 'main', repo], { env });
+ /** Run Git inside the fixture repo with its private identity. */
+ const git = (...args) => execFileSync('git', args, { cwd: repo, env, encoding: 'utf8', stdio: 'pipe' }).trim();
+ /** Run pullboard from the main checkout, where it acts as the coordinator. */
+ const run = (...args) => {
+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });
+ return { status: result.status, stdout: result.stdout ?? '', stderr: result.stderr ?? '' };
+ };
+ /** Run a command that must succeed and return its JSON document. */
+ const json = (...args) => {
+ const result = run(...args, '--json');
+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.stdout}${result.stderr}`);
+ return JSON.parse(result.stdout);
+ };
+ const initialized = run('init');
+ assert.equal(initialized.status, 0, initialized.stdout + initialized.stderr);
+ writeFileSync(join(repo, 'SPEC.md'), '# Fixture\n\n## G · Goals\n- G1 [approved, must] Work is tracked. | gate: true\n');
+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ gate: 'true', verify: 'any', lanes: { web: { owns: ['web/'], specs: ['G1'] } }, shared: [] }));
+ git('add', '-A');
+ git('commit', '-q', '-m', 'chore: initialize fixture');
+ const board = store.openBoard(join(repo, '.git', 'pullboard', 'board.sqlite'));
+ t.after(() => store.closeBoard(board));
+ store.ensureCoordinator(board, repo);
+ const builder = store.register(board, { lane: 'web', path: join(dir, 'builder'), model: 'Fixture Model' });
+ const freeze = () => ({ text: 'Tracked work', digest: 'digest:tracked' });
+ /** File an item and take it to the named state: open, accepted or landed. */
+ const item = (title, state) => {
+ const id = store.addItem(board, { by: 'coordinator', lane: 'web', title, criterion: 'Tracked work', specIds: ['G1'] });
+ if (state === 'open') return id;
+ const commit = String(id).repeat(40).slice(0, 40);
+ store.claim(board, id, { agentId: builder, lane: 'web', leaseMs: HOUR, freeze });
+ store.submit(board, id, { agentId: builder, commit, tree: 'tree' });
+ store.verify(board, id, { agentId: 'coordinator', decision: 'ACCEPT', note: 'checked it', head: commit, digest: 'digest:tracked', policy: 'any' });
+ if (state === 'landed') store.merged(board, id, { agentId: 'coordinator', commit: git('rev-parse', 'HEAD') });
+ return id;
+ };
+ return { repo, git, run, json, board, builder, item };
+}
+
+/** The milestone named `name` in a roadmap document. */
+function milestone(document, name) {
+ return document.milestones.find((entry) => entry.name === name);
+}
+
+/** The milestone moves recorded on an item's thread. */
+function moves(box, id) {
+ return box.json('show', String(id)).thread.filter((entry) => entry.kind === 'milestone_moved');
+}
+
+test('[N26] a milestone ships what landed and moves the rest', async (t) => {
+ const box = fixture(t);
+ const landed = box.item('Landed work', 'landed');
+ const accepted = box.item('Accepted work', 'accepted');
+ const open = box.item('Open work', 'open');
+ const later = box.item('Later work', 'open');
+ box.json('milestone', 'add', 'A', '--items', `${landed},${accepted},${open}`);
+ box.json('milestone', 'add', 'B', '--items', String(later));
+
+ // The target: set on A and shown in the roadmap and its JSON; a passed one is marked.
+ const edited = box.json('milestone', 'edit', 'A', '--target', '2026-01-02T03:04Z');
+ assert.equal(edited.milestone.target, '2026-01-02T03:04:00.000Z', 'the edit stores the target');
+ const before = box.json('roadmap');
+ assert.equal(milestone(before, 'A').target, '2026-01-02T03:04:00.000Z', 'the roadmap JSON shows the target');
+ assert.equal(milestone(before, 'A').pastTarget, true, 'an unshipped milestone past its target is marked');
+ assert.equal(milestone(before, 'B').pastTarget, false, 'a milestone with no target is never past it');
+
+ // Landed counting: only the merged item counts; each item shows landed, accepted or its status.
+ assert.equal(milestone(before, 'A').landed, 1, 'only the item merged onto main counts as landed');
+ assert.equal(milestone(before, 'A').done, 1, 'done means landed, so accepted work is not done');
+ assert.equal(milestone(before, 'A').total, 3);
+ assert.deepEqual(milestone(before, 'A').items.map(({ id, state }) => [id, state]),
+ [[landed, 'landed'], [accepted, 'accepted'], [open, 'open']], 'each item shows its roadmap state');
+ const text = box.run('roadmap');
+ assert.equal(text.status, 0, text.stdout + text.stderr);
+ assert.match(text.stdout, /^A: 1\/3 landed · target 2026-01-02T03:04:00\.000Z, past target$/m, 'the text shows N/M landed, the target and past target');
+ assert.match(text.stdout, /^ {2}#\d+ Landed work — landed$/m);
+ assert.match(text.stdout, /^ {2}#\d+ Accepted work — accepted$/m);
+ assert.match(text.stdout, /^ {2}#\d+ Open work — open$/m);
+
+ // Shipping is the coordinator's move, not a builder's.
+ assert.throws(() => store.shipMilestone(box.board, 'A', { agentId: box.builder, commit: box.git('rev-parse', 'main') }),
+ (error) => error.code === 'COORDINATOR_ONLY');
+
+ // Ship: A records main's commit, and the two unlanded items move into B.
+ const main = box.git('rev-parse', 'main');
+ const shipped = box.json('milestone', 'ship', 'A');
+ assert.equal(shipped.milestone.shipped.commit, main, "the milestone is shipped at main's commit");
+ assert.equal(shipped.into, 'B', 'the next milestone is the one after it');
+ assert.deepEqual(shipped.moved, [accepted, open]);
+ assert.deepEqual(shipped.notMoved, [], 'no external references were left behind');
+ const after = box.json('roadmap');
+ assert.equal(milestone(after, 'A').shipped.commit, main, "the roadmap shows main's commit on the shipped milestone");
+ assert.deepEqual(milestone(after, 'A').items.map(({ id }) => id), [landed], 'only the landed item stays in the shipped milestone');
+ assert.equal(milestone(after, 'A').pastTarget, false, 'a shipped milestone is no longer past its target');
+ assert.deepEqual(milestone(after, 'B').items.map(({ id }) => id), [later, accepted, open], 'the unlanded items are now in B');
+
+ // The threads: each moved item records the move; the landed one records none.
+ for (const id of [accepted, open]) {
+ const recorded = moves(box, id);
+ assert.equal(recorded.length, 1, `#${id}'s thread records its move`);
+ assert.equal(recorded[0].detail.from, 'A');
+ assert.equal(recorded[0].detail.to, 'B');
+ assert.equal(recorded[0].detail.commit, main);
+ }
+ assert.deepEqual(moves(box, landed), [], 'a landed item does not move');
+
+ // The refusal: a shipped milestone takes no new items.
+ const refused = box.run('milestone', 'items', 'A', '--add', String(later), '--json');
+ assert.notEqual(refused.status, 0, refused.stdout + refused.stderr);
+ assert.equal(JSON.parse(refused.stdout).error.code, 'MILESTONE_SHIPPED', 'adding to a shipped milestone is refused');
+ assert.deepEqual(milestone(box.json('roadmap'), 'A').items.map(({ id }) => id), [landed], 'the refusal changes nothing');
+
+ // A target means one instant on every replica: the move carries UTC, and a bare local time
+ // in an ordered envelope is refused alike in every zone instead of read in each one's own.
+ const { prepareEngineMove, applyEngineMove } = await import('../src/engine.js');
+ const { exportBoard, importBoard } = await import('../src/exchange.js');
+ store.addMilestone(box.board, { agentId: 'coordinator', name: 'Z' });
+ const snapshot = exportBoard(box.board);
+ const prepared = prepareEngineMove(box.board, 'editMilestone', ['Z', { agentId: 'coordinator', target: '2026-10-20T18:00' }], { id: 'zone-target', actor: 'coordinator' });
+ assert.match(prepared.args[1].target, /Z$/u, 'the prepared move carries the instant in UTC');
+ const bare = { ...prepared, id: 'bare-target', args: ['Z', { agentId: 'coordinator', target: '2026-10-20T18:00' }] };
+ const zone = process.env.TZ;
+ const replicas = [];
+ try {
+ for (const name of ['UTC', 'America/Chicago']) {
+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-target-zone-'));
+ TEMP_DIRS.push(dir);
+ const replica = store.openBoard(join(dir, 'board.sqlite'));
+ t.after(() => store.closeBoard(replica));
+ importBoard(replica, snapshot);
+ process.env.TZ = name;
+ const refused = applyEngineMove(replica, bare, { sequence: 1, at: '2026-10-17T04:00:00.000Z' });
+ assert.equal(refused.error?.code, 'MILESTONE_TARGET', `a bare local time is refused in ${name}: ${JSON.stringify(refused)}`);
+ const applied = applyEngineMove(replica, prepared, { sequence: 2, at: '2026-10-17T04:00:01.000Z' });
+ assert.equal(applied.error, undefined, JSON.stringify(applied));
+ replicas.push(store.milestones(replica).find((row) => row.name === 'Z').target);
+ }
+ } finally {
+ if (zone === undefined) delete process.env.TZ;
+ else process.env.TZ = zone;
+ }
+ assert.equal(replicas[0], replicas[1], `every replica stores the same target: ${JSON.stringify(replicas)}`);
+});
+
+test('[N26] milestone ship --next names where the unlanded items go', (t) => {
+ const box = fixture(t);
+ const open = box.item('Open work', 'open');
+ box.json('milestone', 'add', 'A', '--items', String(open));
+ box.json('milestone', 'add', 'B');
+ box.json('milestone', 'add', 'C');
+ const shipped = box.json('milestone', 'ship', 'A', '--next', 'C');
+ assert.equal(shipped.into, 'C', '--next overrides the milestone after it');
+ const document = box.json('roadmap');
+ assert.deepEqual(milestone(document, 'B').items, [], 'the milestone after it gets nothing');
+ assert.deepEqual(milestone(document, 'C').items.map(({ id }) => id), [open], 'the --next milestone gets the unlanded item');
+ assert.equal(moves(box, open)[0].detail.to, 'C', 'the thread names the --next milestone');
+});
+
+test('[N26] milestone ship leaves external references in place and names them as not moved', (t) => {
+ const box = fixture(t);
+ box.json('milestone', 'add', 'JSON release', '--items', 'other-repo#17,third-repo#29');
+ const shipped = box.json('milestone', 'ship', 'JSON release');
+ assert.deepEqual(shipped.notMoved, ['other-repo#17', 'third-repo#29'], 'JSON lists each reference that remains on another board');
+ assert.deepEqual(shipped.moved, [], 'shipping does not move foreign items');
+ assert.deepEqual(milestone(box.json('roadmap'), 'JSON release').items.map(({ id }) => id),
+ ['other-repo#17', 'third-repo#29'], 'the foreign references remain on the shipped milestone');
+
+ box.json('milestone', 'add', 'Text release', '--items', 'other-repo#31,third-repo#33');
+ const text = box.run('milestone', 'ship', 'Text release');
+ assert.equal(text.status, 0, text.stdout + text.stderr);
+ assert.match(text.stdout, /not moved across boards: other-repo#31, third-repo#33/,
+ 'human output names every foreign reference that stayed in place');
+});
+
- test('[N26,H16] engine 30 cannot ship a milestone or set its target', async (t) => {
++test('[N26,H16] engine 38 cannot ship a milestone or set its target', async (t) => {
+ const box = fixture(t);
+ box.json('milestone', 'add', 'A');
+ box.json('milestone', 'add', 'B');
+ const { applyEngineMove, appliedSequence, engineReceipt, prepareEngineMove } = await import('../src/engine.js');
+ const { exportBoard } = await import('../src/exchange.js');
+ const main = box.git('rev-parse', 'main');
+ const moves = [
+ prepareEngineMove(box.board, 'shipMilestone', ['A', { agentId: 'coordinator', commit: main, next: 'B' }],
- { id: 'engine30-milestone-ship', actor: 'coordinator' }),
++ { id: 'engine38-milestone-ship', actor: 'coordinator' }),
+ prepareEngineMove(box.board, 'editMilestone', ['A', { agentId: 'coordinator', target: '2026-10-20T18:00:00Z' }],
- { id: 'engine30-milestone-target', actor: 'coordinator' }),
++ { id: 'engine38-milestone-target', actor: 'coordinator' }),
+ ];
+ const before = exportBoard(box.board);
+
+ for (const move of moves) {
- const oldEnvelope = { ...move, engine: 30 };
++ const oldEnvelope = { ...move, engine: 38 };
+ assert.throws(() => applyEngineMove(box.board, oldEnvelope, { sequence: 1, at: '2026-10-17T12:00:00.000Z' }),
- (error) => error.code === 'RELAY_MOVE' && /introduced in engine 31/u.test(error.message),
- `${move.operation} was introduced in engine 31 and must not run as engine 30`);
- assert.deepEqual(exportBoard(box.board), before, 'an unsupported engine-30 meaning changes no rows or event history');
++ (error) => error.code === 'RELAY_MOVE' && /introduced in engine 39/u.test(error.message),
++ `${move.operation} was introduced in engine 39 and must not run as engine 38`);
++ assert.deepEqual(exportBoard(box.board), before, 'an unsupported engine-38 meaning changes no rows or event history');
+ assert.equal(appliedSequence(box.board), 0, 'pre-validation refusal does not advance the relay cursor');
+ assert.equal(engineReceipt(box.board, move.id), null, 'pre-validation refusal creates no move receipt');
+ }
+});
diff --cc test/pending-refreeze.test.js
index f537ca6b,03fb0767..c649eda7
--- a/test/pending-refreeze.test.js
+++ b/test/pending-refreeze.test.js
@@@ -261,7 -261,7 +261,7 @@@ async function checkDependencyLegacyCli
}
test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {
- assert.equal(ENGINE_VERSION, 31);
- assert.equal(ENGINE_VERSION, 33, 'the next writer retains all recorded dependency-edit behavior');
++ assert.equal(ENGINE_VERSION, 39, 'the next writer retains all recorded dependency-edit behavior');
const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));
const cleanup = [];
t.after(() => {