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.

Merge remote-tracking branch 'origin/main' into core/692-claude

Corey Olson7b38eae931ba
diff --cc docs/api.md
index 7c41f693,822eacaf..8fe8fcf4
--- a/docs/api.md
+++ b/docs/api.md
@@@ -256,11 -263,7 +264,11 @@@ Core readers can call `allShouts(board)
The local board state and events responses include `eventLogVersion`, which identifies the persisted event-record format separately from the HTTP envelope's `version`. Static view exports keep this field in both state.json and events.json so a reader can refuse a format newer than it understands. Sealed relay events do not use this local board format marker.
-The coordinator maintains the roadmap with `milestone add <name> [--note ...] [--items 1,2,3]`, `milestone items <name> --add|--remove ids`, `milestone move <name> --before <other>`, `milestone edit <name> [--name <new>] [--note <text>]`, and `milestone remove <name>`. A milestone stores only its name, optional note, and ordered item ids in `board_meta`; removing a milestone leaves its items untouched. A `repo#id` reference uses a registered repo's display name (or its folder name) before `#`; its status is read from that board when the repo is registered on this machine. `pullboard roadmap` prints milestones in order with a verified-item done count. Its JSON results and API state use `{ name, note, items: [{ id, title, status }], done, total }` for each milestone.
+The coordinator maintains the roadmap with `milestone add <name> [--note ...] [--items 1,2,3]`, `milestone items <name> --add|--remove ids`, `milestone move <name> --before <other>`, `milestone edit <name> [--name <new>] [--note <text>] [--target <date and time>|none]`, `milestone ship <name> [--next <name>]`, and `milestone remove <name>`. A milestone stores its name, optional note, optional target, its shipment once shipped, and ordered item ids in `board_meta`; removing a milestone leaves its items untouched. A target is stored as ISO time; `--target none` clears it. A `repo#id` reference uses a registered repo's display name (or its folder name) before `#`; its status is read from that board when the repo is registered on this machine.
+
+An item counts as done only once it has landed on main: it is verified and its merge commit is recorded. `pullboard roadmap` prints milestones in order as `N/M landed`, with the target, `past target` for an unshipped milestone whose target has passed, or the commit it shipped at, and each item as `landed`, `accepted` (verified, not landed) or its status. Its JSON results and API state use `{ name, note, target, pastTarget, shipped, items: [{ id, title, status, state }], landed, done, total }` for each milestone: `target` is ISO text or `null`, `shipped` is `{ commit, at, by }` or `null`, `state` is `landed`, `accepted` or the status, and `done` equals `landed`.
+
- `milestone ship` is the coordinator's move. It records the milestone as shipped at the main checkout's commit and moves every item that has not landed into the next unshipped milestone after it, or into `--next`, recording a `milestone_moved` event on each moved item's thread. A withdrawn item and a `repo#id` reference stay where they are. Its JSON result is `{ milestone, into, moved }`. A shipped milestone takes no new items: `milestone items <name> --add` refuses `MILESTONE_SHIPPED`. Shipping refuses `NO_NEXT_MILESTONE` when unlanded items have nowhere to go, and `MILESTONE_COMMIT` when main has no commit. Targets and shipping are engine 14 moves.
++`milestone ship` is the coordinator's move. It records the milestone as shipped at the main checkout's commit and moves every item that has not landed into the next unshipped milestone after it, or into `--next`, recording a `milestone_moved` event on each moved item's thread. A withdrawn item and a `repo#id` reference stay where they are. Its JSON result is `{ milestone, into, moved }`. A shipped milestone takes no new items: `milestone items <name> --add` refuses `MILESTONE_SHIPPED`. Shipping refuses `NO_NEXT_MILESTONE` when unlanded items have nowhere to go, and `MILESTONE_COMMIT` when main has no commit. Targets and shipping are engine 21 moves.
<!-- api-http-shapes:start -->
| Response | Required top-level fields |
diff --cc docs/formats.md
index 08417b90,56cc62a3..e6e4e521
--- a/docs/formats.md
+++ b/docs/formats.md
@@@ -102,7 -102,7 +102,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` | `12` | `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` | `19` | `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` | `21` | `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.
@@@ -113,6 -113,8 +113,10 @@@ Engine 11 permits resubmitting the sam
Engine 12 records declined person row decisions without replacing the exact source text: the row becomes `wont` and the reason stays in the decision record. Engine-11 decline receipts retain their original reason-as-row-text validation and replay outcome. Engine-11 clients refuse engine-12 moves before interpreting them; upgrade linked clients before recording new decline decisions.
+ Engine 19 makes a corrected bar record why the old one was wrong. Once an item has ever been claimed, an `editItem` that changes its criterion or check must carry `reason`, the text of what the old bar got wrong; without one it is refused with `BAR_REASON`, naming `--reason`. The edit event then records `reason` and `barCorrection: {fields, reject}`: `fields` lists `criterion` and/or `check`, and `reject` is `{verdict, by, reason, at}` when the item's newest verdict is a reject no earlier correction already explained, or `null`. That reject is counted as caused by the bar. The board derives `barCorrection` from its own rows; a move supplies only `reason`. An edit before any claim needs no reason and records one only if given. `pullboard stats` JSON adds `bars`, keyed by agent: `{corrections, barRejects, buildRejects}`. Corrections and the rejects they explain count to the agent who corrected the bar; any other reject counts as the build's, to the agent who added the item. An `editItem` move carrying `reason` requires engine 19, and older engines refuse it with `RELAY_MOVE` before changing their board or cursor. Moves recorded under engines 18 and earlier replay without the reason rule. Engine numbers 13 to 18 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
+
++Engine 21 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 into the next unshipped milestone, or `--next`, writing a `milestone_moved` event on each moved item; a shipped milestone refuses new items with `MILESTONE_SHIPPED`. Either makes the move an engine-21 move, and an older engine refuses it with `RELAY_MOVE` before changing its board or cursor. Engine numbers 13 to 18 and 20 are allocated to other changes; whichever lands later renumbers, keeping every earlier engine's replay unchanged.
++
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 8f8fcd68,8f1c9ca0..c0b59ee0
--- a/src/engine.js
+++ b/src/engine.js
@@@ -2,8 -2,8 +2,9 @@@
import { createHash, randomUUID } from 'node:crypto';
import * as store from './board.js';
import { recordedRefusal } from './recorded-refusal.js';
+ import { BAR_ENGINE, carriesBarReason } from './bar-corrections.js';
import { ENGINE_VERSION } 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';
@@@ -21,19 -21,14 +22,16 @@@ 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 });
+const OPERATION_ENGINE = Object.freeze({ reopen: 8, recordLandingBatch: 8, recordLandingWaiver: 8, recordLandingFlake: 8, finishLandingBatch: 8,
+ shipMilestone: MILESTONE_SHIP_ENGINE });
- /**
- * Dependency edits add engine-10 meaning, and a milestone target engine-14 meaning, without
- * changing ordinary historical edit envelopes.
- */
-/** Dependency edits add engine-10 meaning, and edit reasons engine-19 meaning, without changing ordinary historical edit envelopes. */
++/** Dependency edits add engine-10 meaning, edit reasons engine-19 and a milestone target engine-21, without changing ordinary historical edit envelopes. */
function minimumOperationEngine(operation, args) {
const options = args[1];
- const given = (key) => Boolean(options) && Object.hasOwn(options, key) && options[key] !== undefined;
- if (operation === 'editItem' && given('after')) return 10;
- if (operation === 'editMilestone' && given('target')) return MILESTONE_SHIP_ENGINE;
- return OPERATION_ENGINE[operation] ?? 1;
+ if (carriesBarReason(operation, args)) return BAR_ENGINE;
++ if (operation === 'editMilestone' && options && Object.hasOwn(options, 'target') && options.target !== undefined) return MILESTONE_SHIP_ENGINE;
+ return operation === 'editItem' && options && Object.hasOwn(options, 'after') && options.after !== undefined
+ ? 10 : OPERATION_ENGINE[operation] ?? 1;
}
/** Read a replica's committed prefix without trusting an independently saved transport cursor. */
diff --cc src/machine.js
index bf981509,bbd1cfb9..310650ed
--- 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 = 14;
-export const ENGINE_VERSION = 19;
++export const ENGINE_VERSION = 21;
/** @typedef {'agent' | 'coordinator' | 'clock'} Role */
diff --cc src/milestones.js
index 81c5eb78,00000000..56ea8e31
mode 100644,000000..100644
--- a/src/milestones.js
+++ b/src/milestones.js
@@@ -1,307 -1,0 +1,307 @@@
+/**
+ * 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 = 14;
++export const MILESTONE_SHIP_ENGINE = 21;
+
+/** 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 14 a shipped
++ * Add or remove item references while preserving the remaining order. From engine 21 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-14 meaning, so an older engine's edit replays exactly as it did.
++ * an engine-21 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[] }}
+ */
+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 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 });
+ 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 };
+ });
+}
diff --cc test/agent-model-engine.test.js
index a58abce5,ba92a56d..e74da95c
--- 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 12 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 14, 'engine 14 preserves the released engine-8 through engine-12 model behavior');
- for (const version of [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, ENGINE_VERSION]) {
+ test('model declarations and event snapshots retain engines 1 through 11 semantics [O8,O3,H16]', (t) => {
- assert.equal(ENGINE_VERSION, 19, 'engine 19 preserves the released engine-8 through engine-11 model behavior');
++ assert.equal(ENGINE_VERSION, 21, 'engine 21 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]) {
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/pending-refreeze.test.js
index 4840ab92,7191bfc2..b542a37c
--- a/test/pending-refreeze.test.js
+++ b/test/pending-refreeze.test.js
@@@ -243,12 -243,12 +243,12 @@@ async function checkDependencyLegacyCli
const oldFeature = legacyEngine.applyRelayMove(old, engine10Move, engine10Receipt);
const currentFeature = applyRelayMove(current, engine10Move, engine10Receipt);
assert.equal(oldFeature.error, undefined, JSON.stringify(oldFeature));
- assert.deepEqual(currentFeature, oldFeature, 'engine 14 reproduces engine 10 dependency additions and clears');
- assert.deepEqual(currentFeature, oldFeature, 'engine 12 reproduces engine 10 dependency additions and clears');
++ assert.deepEqual(currentFeature, oldFeature, 'engine 21 reproduces engine 10 dependency additions and clears');
assert.deepEqual(store.getItem(current, target), legacyStore.getItem(old, target));
- assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 14 replay identical events');
- assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 12 replay identical events');
++ assert.deepEqual(store.events(current), legacyStore.events(old), 'engine 10 and engine 21 replay identical events');
assert.equal(appliedSequence(current), legacyEngine.appliedSequence(old));
assert.deepEqual(engineReceipt(current, engine10Move.id), legacyEngine.engineReceipt(old, engine10Move.id),
- 'engine 10 and engine 14 retain the same dependency-move receipts');
- 'engine 10 and engine 12 retain the same dependency-move receipts');
++ 'engine 10 and engine 21 retain the same dependency-move receipts');
const oldSnapshot = legacyExchange.exportBoard(old);
const currentSnapshot = exportBoard(current);
assert.equal(oldSnapshot.tables.board_meta.find((row) => row.meta_key === 'relay_engine_version').meta_value, '10');
@@@ -261,7 -261,7 +261,7 @@@
}
test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {
- assert.equal(ENGINE_VERSION, 14);
- assert.equal(ENGINE_VERSION, 19);
++ assert.equal(ENGINE_VERSION, 21);
const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));
const cleanup = [];
t.after(() => {