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
feat(core): withdraw items from roadmap milestones [N26]
Corey Olsondf2b9e7b64af
diff --cc docs/formats.mdindex f59c9789,cbc0ebe8..0e50627b--- a/docs/formats.md+++ b/docs/formats.md@@@ -138,8 -142,6 +140,10 @@@ Engine 38 records submission test selecEngine 45 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-45 move, and an older engine refuses it with `RELAY_MOVE` before changing its board or cursor. The coordinator assigned engine 45 to this milestone feature; each other feature retains its separately allocated engine minimum. Engine 30 carries the cause-key behavior above; engine 33 retains the checked-review behavior described above.++Engine 50 automatically advances a rejected item one route after two REJECT verdicts on the current route. A release is not a rejection; a manual escalation or an actual route edit starts a new count. The existing escalation event records both rejection receipts. The strong route remains the ceiling. Moves below engine 50 retain their earlier behavior and do not automatically escalate. Upgrade linked boards before using automatic rejection escalation.+++Engine 51 writes #649's withdraw-and-remove milestone behavior. A withdraw move is followed by one ordered `editMilestoneItems` removal for each local milestone that lists the item; previous withdraw records retain their original replay, and an older client refuses the new engine before applying any move. `WITHDRAW_MILESTONE_ENGINE` is 51; `MILESTONE_SHIP_ENGINE` remains 45, so milestone targets and shipment keep their engine-45 meaning. The roadmap projects remaining-to-ship work before verified items and omits withdrawn items from its list and total while reporting them separately.+Engine 42 adds ordered `recordHealthFindings` observations. A scan retains its board event revision, emits new and resolved sentinel notices once, and records `health-failure` receipts under their refusal cause keys. Rigor counts repeated health episodes without inventing a changed code commit. Older engines refuse this operation before replay; earlier move meanings and feature minima stay unchanged.The CLI declares its engine in every relay request's `X-Pullboard-Engine` header.diff --cc src/machine.jsindex 83a29e4c,bf39c8c1..96bc9886--- a/src/machine.js+++ b/src/machine.js@@@ -9,11 -9,21 +9,28 @@@* broken copy, and checks the declaration against the refusals board.js and cli.js raise today.*/- /** Executable move semantics, carried by every sealed move and retained during replay [H16]. */import { RIGOR_NOTICE_ENGINE } from './rigor-source.js';- export const ENGINE_VERSION = 51;- /** The engine at which a reject, reopen or person fact can carry a cause key (#713); older moves replay unchanged [D1,H16]. */++/** First writer for withdraw-and-remove milestone behavior; shipment remains engine 45. */++export const WITHDRAW_MILESTONE_ENGINE = 51;+++ /** First engine that automatically escalates an item's second rejection at its current route [B15]. */+ export const AUTO_ESCALATE_ENGINE = 50;++ /** Executable move semantics, carried by every sealed move and retained during replay [H16]. */-export const ENGINE_VERSION = Math.max(AUTO_ESCALATE_ENGINE, RIGOR_NOTICE_ENGINE);++export const ENGINE_VERSION = Math.max(++ AUTO_ESCALATE_ENGINE,++ RIGOR_NOTICE_ENGINE,++ WITHDRAW_MILESTONE_ENGINE,++);++ /**+ * The engine whose relay moves carry seat provenance and verifier standing (#579). It is its own+ * constant because engine slots are allotted per item: whoever lands second renumbers this line.+ */+ export const VERIFIER_STANDING_ENGINE = 48;++ /** The engine at which reject, reopen and person facts may carry cause keys [D1,H16]. */export const CAUSE_ENGINE = 30;/** First released engine binding the checked composition, review trunk and paths [E8,H16]. */diff --cc src/milestones.jsindex 17b1db0b,e291c02a..42d19b55--- a/src/milestones.js+++ b/src/milestones.js@@@ -10,7 -10,7 +10,9 @@@ import { COORDINATOR } from './config.jimport {ENGINE_VERSION,MILESTONE_RANK_ENGINE,++ WITHDRAW_MILESTONE_ENGINE,} from './machine.js';++export { WITHDRAW_MILESTONE_ENGINE };import { Refused } from './refused.js';import {atomic,@@@ -24,9 -24,6 +26,7 @@@/** The engine at which a milestone carries a target and ships; older moves replay as they did. */export const MILESTONE_SHIP_ENGINE = 45;- /** First writer for withdraw-and-remove milestone behavior; shipment remains engine 45. */- export const WITHDRAW_MILESTONE_ENGINE = 51;+/** The engine a move runs under: its recorded one during replay, else this client's. */function engineOf(board) {return board.executionEngineVersion ?? ENGINE_VERSION;diff --cc test/agent-model-engine.test.jsindex 71061e17,82cfcf04..bee61d90--- a/test/agent-model-engine.test.js+++ b/test/agent-model-engine.test.js@@@ -4,8 -5,9 +4,15 @@@ import { test } from 'node:test'import * as store from '../src/board.js';import { applyEngineMove, prepareEngineMove } from '../src/engine.js';import { exportBoard, importBoard } from '../src/exchange.js';-import { AUTO_ESCALATE_ENGINE } from '../src/machine.js';--import { ENGINE_VERSION } from '../src/machine.js';- import { MILESTONE_SHIP_ENGINE, WITHDRAW_MILESTONE_ENGINE } from '../src/milestones.js';-import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';++import {++ AUTO_ESCALATE_ENGINE,++ ENGINE_VERSION,++ VERIFIER_STANDING_ENGINE,++} from '../src/machine.js';++import {++ MILESTONE_SHIP_ENGINE,++ WITHDRAW_MILESTONE_ENGINE,++} from '../src/milestones.js';import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';import { HEALTH_SENTINEL_ENGINE } from '../src/health-receipts.js';import { configProblems, defaults, loadConfig } from '../src/config.js';@@@ -13,12 -15,14 +20,16 @@@ import { mkdtempSync, rmSync, writeFileimport { tmpdir } from 'node:os';import { join } from 'node:path';- test('model declarations and event snapshots retain engines 1 through 51 semantics [O8,O3,H16]', (t) => {- assert.equal(WITHDRAW_MILESTONE_ENGINE, ENGINE_VERSION, 'withdraw writes use the allocated feature engine');+ test('model declarations and event snapshots retain all supported engine semantics [O8,O3,H16]', (t) => {- assert.equal(ENGINE_VERSION, AUTO_ESCALATE_ENGINE, 'the current writer is the automatic-escalation engine');- assert.ok(ENGINE_VERSION >= 45, 'the current writer retains engine-45 milestone semantics');++ assert.equal(AUTO_ESCALATE_ENGINE, 50, 'automatic escalation retains its allocated engine');++ assert.equal(WITHDRAW_MILESTONE_ENGINE, 51, 'withdraw retains its allocated feature engine');++ assert.equal(ENGINE_VERSION, WITHDRAW_MILESTONE_ENGINE, 'the current writer includes the withdraw feature');++ assert.ok(ENGINE_VERSION >= AUTO_ESCALATE_ENGINE, 'the current writer retains automatic escalation');+ assert.equal(MILESTONE_SHIP_ENGINE, 45, 'shipment retains its engine-45 meaning');+ assert.ok(ENGINE_VERSION >= MILESTONE_SHIP_ENGINE, 'the current writer retains all milestone shipment behavior');++ assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer preserves every historical model snapshot through main engine 33');assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');- assert.equal(AUTO_ESCALATE_ENGINE, ENGINE_VERSION, 'the current writer includes automatic escalation and preserves historical model snapshots');- assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');- assert.ok(ENGINE_VERSION >= MILESTONE_SHIP_ENGINE, 'the current writer retains milestone shipping');for (const version of Array.from({ length: ENGINE_VERSION }, (_, index) => index + 1)) {const board = store.openBoard(':memory:');t.after(() => store.closeBoard(board));diff --cc test/pending-refreeze.test.jsindex ac0df3ae,0e91dc6b..7b33d3ef--- a/test/pending-refreeze.test.js+++ b/test/pending-refreeze.test.js@@@ -8,8 -8,9 +8,15 @@@ import { test } from 'node:test'import * as store from '../src/board.js';import { appliedSequence, applyRelayMove, engineReceipt, prepareEngineMove } from '../src/engine.js';import { exportBoard, importBoard } from '../src/exchange.js';-import { AUTO_ESCALATE_ENGINE } from '../src/machine.js';--import { ENGINE_VERSION } from '../src/machine.js';- import { MILESTONE_SHIP_ENGINE, WITHDRAW_MILESTONE_ENGINE } from '../src/milestones.js';-import { VERIFIER_STANDING_ENGINE } from '../src/machine.js';++import {++ AUTO_ESCALATE_ENGINE,++ ENGINE_VERSION,++ VERIFIER_STANDING_ENGINE,++} from '../src/machine.js';++import {++ MILESTONE_SHIP_ENGINE,++ WITHDRAW_MILESTONE_ENGINE,++} from '../src/milestones.js';import { RIGOR_NOTICE_ENGINE } from '../src/rigor-source.js';import { HEALTH_SENTINEL_ENGINE } from '../src/health-receipts.js';import { createE2eHelpers } from './e2e-helpers.js';@@@ -264,11 -265,12 +271,15 @@@ async function checkDependencyLegacyCli}test('dependency edits replay the same on every engine [B3,V2,H16]', async (t) => {- assert.equal(WITHDRAW_MILESTONE_ENGINE, ENGINE_VERSION, 'withdraw writes use the allocated feature engine');- assert.equal(ENGINE_VERSION, AUTO_ESCALATE_ENGINE, 'the current writer is the automatic-escalation engine');- assert.ok(ENGINE_VERSION >= 45, 'the current writer retains engine-45 milestone semantics');++ assert.equal(AUTO_ESCALATE_ENGINE, 50, 'automatic escalation retains its allocated engine');++ assert.equal(WITHDRAW_MILESTONE_ENGINE, 51, 'withdraw retains its allocated feature engine');++ assert.equal(ENGINE_VERSION, WITHDRAW_MILESTONE_ENGINE, 'the current writer includes the withdraw feature');++ assert.ok(ENGINE_VERSION >= AUTO_ESCALATE_ENGINE, 'the current writer retains automatic escalation');+ assert.equal(MILESTONE_SHIP_ENGINE, 45, 'shipment retains its engine-45 meaning');+ assert.ok(ENGINE_VERSION >= MILESTONE_SHIP_ENGINE, 'the current writer retains all milestone shipment behavior');++ assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');assert.ok(ENGINE_VERSION >= RIGOR_NOTICE_ENGINE, 'the next writer retains all recorded dependency-edit behavior');assert.ok(ENGINE_VERSION >= HEALTH_SENTINEL_ENGINE, 'the current writer retains the sentinel minimum and historical behavior');- assert.equal(AUTO_ESCALATE_ENGINE, ENGINE_VERSION, 'the current writer retains recorded dependency-edit behavior and automatic escalation');- assert.ok(ENGINE_VERSION >= VERIFIER_STANDING_ENGINE, 'the current writer retains verifier standing');const directory = mkdtempSync(join(tmpdir(), 'pullboard-dependency-engines-'));const cleanup = [];t.after(() => {diff --cc test/roadmap.test.jsindex 58d42d1c,cd33bb10..9ab54008--- a/test/roadmap.test.js+++ b/test/roadmap.test.js@@@ -1,128 -1,146 +1,266 @@@- /** Withdrawn work leaves the roadmap, and each milestone lists its work to ship first [N26]. */-/** The roadmap summarizes recorded progress without treating acceptance as landing [N26]. */++/** Roadmap progress and withdrawn work preserve their recorded meaning [N26]. */import assert from 'node:assert/strict';-import { execFileSync } from 'node:child_process';-import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { execFileSync, spawnSync } from 'node:child_process';+import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';-import { join } from 'node:path';-import { test } from 'node:test';+import { join, resolve } from 'node:path';+import { after, test } from 'node:test';import * as store from '../src/board.js';+ import { main } from '../src/cli.js';+ import { milestoneRoadmap } from '../src/roadmap.js';import { submitFixture } from './board-submit-fixture.js';- import { ENGINE_VERSION } from '../src/machine.js';- import { WITHDRAW_MILESTONE_ENGINE } from '../src/milestones.js';++import {++ ENGINE_VERSION,++ MILESTONE_SHIP_ENGINE,++ WITHDRAW_MILESTONE_ENGINE,++} from '../src/milestones.js';+import { prepareEngineMove } from '../src/engine.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, a builder agent, and a helper that files an item+ * in the state the roadmap tells apart: open, accepted (verified only) or landed (verified with a+ * merge commit). Git runs with every GIT_* variable stripped, so a hook's repository never leaks in.+ */- function fixture(t) {++function withdrawFixture(t) {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-roadmap-'));+ 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.+ /** Quote a value for the fixture's private shell launcher. */+ 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: 'Roadmap fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Roadmap 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, and require success. */+ const run = (...args) => {+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd: repo, env, encoding: 'utf8' });+ assert.equal(result.status, 0, `${args.join(' ')}: ${result.stdout}${result.stderr}`);+ return result.stdout;+ };+ /** Run a command that must succeed and return its JSON document. */+ const json = (...args) => JSON.parse(run(...args, '--json'));+ run('init');+ 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' });+ /** Supply the stable criterion snapshot used by these synthetic board transitions. */+ 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 });+ submitFixture(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 { run, json, board, item };+}+ /** A real Git repository and SQLite board with a shared, controlled command clock. */+ function fixture(t) {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-roadmap-'));+ const repo = join(dir, 'repo');+ mkdirSync(repo);+ const saved = { ...process.env };+ for (const key of Object.keys(process.env)) if (key.startsWith('GIT_')) delete process.env[key];+ Object.assign(process.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: 'Roadmap fixture', GIT_AUTHOR_EMAIL: '[email protected]',+ GIT_COMMITTER_NAME: 'Roadmap fixture', GIT_COMMITTER_EMAIL: '[email protected]' });+ t.after(() => {+ for (const key of Object.keys(process.env)) if (!(key in saved)) delete process.env[key];+ Object.assign(process.env, saved);+ rmSync(dir, { recursive: true, force: true });+ });+ execFileSync('git', ['init', '-q', '-b', 'main', repo]);+ 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'] }, paused: { owns: ['paused/'], specs: ['G1'] } }, shared: [] }));+ execFileSync('git', ['-C', repo, 'add', '-A']);+ execFileSync('git', ['-C', repo, 'commit', '-qm', 'chore: initialize fixture']);+ const commit = execFileSync('git', ['-C', repo, 'rev-parse', 'HEAD'], { encoding: 'utf8' }).trim();+ let instant = Date.parse('2026-10-17T12:00:00Z');+ const clock = { now: () => new Date(instant) };+ const board = store.openBoard(join(repo, '.git', 'pullboard', 'board.sqlite'), clock);+ t.after(() => store.closeBoard(board));+ store.ensureCoordinator(board, repo);+ const builder = store.register(board, { lane: 'web', path: join(dir, 'builder'), model: 'Fixture Model' });+ /** Advance the board clock without editing its stored records. */+ const at = value => { instant = value; };+ /** File work and advance it through ordinary board operations to the requested state. */+ const item = (state, lane = 'web') => {+ const id = store.addItem(board, { by: 'coordinator', lane, title: state + ' work', criterion: 'Tracked work', specIds: ['G1'] });+ if (['waiting', 'held'].includes(state)) {+ if (state === 'held') store.holdItem(board, id, { agentId: 'coordinator', reason: 'Waiting for a judgment' });+ return id;+ }+ store.claim(board, id, { agentId: builder, lane: 'web', leaseMs: HOUR,+ freeze: () => ({ text: 'Tracked work', digest: 'digest:tracked' }) });+ if (state === 'building') return id;+ submitFixture(board, id, { agentId: builder, commit, tree: 'tree' });+ if (state === 'review') return id;+ 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 });+ return id;+ };+ /** Read the public command with the same clock as the board's projections. */+ const run = async (json = true) => {+ let stdout = ''; let stderr = '';+ const code = await main(['roadmap', ...(json ? ['--json'] : [])], { cwd: repo, clock,+ stdout: { write: value => { stdout += value; } }, stderr: { write: value => { stderr += value; } } });+ assert.equal(code, 0, stdout + stderr);+ return json ? JSON.parse(stdout) : stdout;+ };+ return { repo, board, clock, commit, at, item, run };+ }++test('withdraw leaves every milestone and the roadmap lists work to ship first [N26]', (t) => {- const { run, json, board, item } = fixture(t);++ const { run, json, board, item } = withdrawFixture(t);+ const landed = item('Landed page', 'landed');+ const dropped = item('Dropped idea', 'open');+ const first = item('First open page', 'open');+ const accepted = item('Accepted page', 'accepted');+ const second = item('Second open page', 'open');+ const unrelated = item('Unrelated page', 'open');+ run('milestone', 'add', 'Now', '--items', [landed, dropped, first, accepted, second].join(','));+ run('milestone', 'add', 'Later', '--items', [second, dropped].join(','));+ run('milestone', 'add', 'Elsewhere', '--items', String(unrelated));++ // Probe both sealed writers without consuming fixture IDs or changing board state.+ const withdrawMove = prepareEngineMove(board, 'withdraw', [dropped, { agentId: 'coordinator', reason: 'writer version' }], { id: 'withdraw-writer', actor: 'coordinator' });+ const cleanupMove = prepareEngineMove(board, 'editMilestoneItems', ['Now', { agentId: 'coordinator', remove: [dropped] }], { id: 'milestone-writer', actor: 'coordinator' });+ assert.equal(WITHDRAW_MILESTONE_ENGINE, ENGINE_VERSION, 'the feature writer is the current engine');+ assert.equal(withdrawMove.engine, ENGINE_VERSION, 'withdraw writes use the current engine');+ assert.equal(cleanupMove.engine, ENGINE_VERSION, 'milestone cleanup writes use the current engine');++ // Withdraw removes the item from every milestone that lists it and says which, in roadmap order.+ const said = run('withdraw', String(dropped), 'not recurring');+ assert.match(said, new RegExp(`withdrew #${dropped}; removed it from milestone Now, Later`), 'withdraw names each milestone it left');+ const lists = Object.fromEntries(store.milestones(board).map((entry) => [entry.name, entry.items]));+ assert.deepEqual(lists, { Now: [landed, first, accepted, second], Later: [second], Elsewhere: [unrelated] }, 'the item left Now and Later, and Elsewhere is untouched');+ const removals = store.events(board).filter((event) => event.event_kind === 'milestone_items').map((event) => JSON.parse(event.event_detail));+ assert.deepEqual(removals.map(({ name, remove }) => [name, remove]), [['Now', [dropped]], ['Later', [dropped]]], 'each removal is an ordered milestone move, so a replay does the same');+ const quiet = json('withdraw', String(unrelated), 'folded into another item');+ assert.deepEqual(quiet.milestones, ['Elsewhere'], 'the JSON result names the milestones too');+ assert.equal(json('withdraw', String(item('Never planned', 'open')), 'not needed').milestones.length, 0, 'an item no milestone lists leaves none');++ // A board from before this change still names a withdrawn item: the roadmap neither shows nor counts it.+ const stale = item('Stale withdrawn page', 'open');+ run('milestone', 'add', 'Old', '--items', [stale, landed].join(','));+ store.withdraw(board, stale, { agentId: 'coordinator', reason: 'withdrawn before withdraw left milestones' });+ assert.deepEqual(store.milestones(board).find((entry) => entry.name === 'Old').items, [stale, landed], 'the old board still names it');++ const roadmap = Object.fromEntries(json('roadmap').milestones.map((entry) => [entry.name, entry]));+ assert.deepEqual(roadmap.Now.items.map((entry) => [entry.id, entry.state]),+ [[first, 'open'], [second, 'open'], [landed, 'landed'], [accepted, 'accepted']], 'work to ship first, verified after, each in milestone order');+ assert.deepEqual([roadmap.Now.landed, roadmap.Now.done, roadmap.Now.total], [1, 1, 4], 'Now counts 1/4 landed');+ assert.deepEqual(roadmap.Old.items.map((entry) => entry.id), [landed], 'a withdrawn item is never shown');+ assert.deepEqual([roadmap.Old.done, roadmap.Old.total, roadmap.Old.withdrawn], [1, 1, 1], 'nor counted: Old is finished, 1/1, with one withdrawn item set aside');+ assert.deepEqual([roadmap.Elsewhere.total, roadmap.Elsewhere.items], [0, []], 'a milestone whose only item was withdrawn is empty');++ const text = run('roadmap');+ assert.match(text, /^Now: 1\/4 landed\n {2}#3 First open page — open\n {2}#5 Second open page — open\n {2}#1 Landed page — landed\n {2}#4 Accepted page — accepted$/m, 'the text roadmap lists the same order and count');+ assert.match(text, /^Old: 1\/1 landed\n {2}#1 Landed page — landed$/m, 'and leaves the withdrawn item out of the text');+ assert.doesNotMatch(text, /Stale withdrawn page|Dropped idea/, 'no withdrawn item appears anywhere in the text roadmap');+});+++ test('[N26] each milestone sums its items by state with an estimate', async t => {+ const box = fixture(t);+ const now = box.clock.now().getTime();+ const landings = [];+ for (const hours of [7, 6, 4, 3, 1.5, 1, 0.5]) {+ box.at(now - hours * HOUR);+ landings.push(box.item('landed'));+ }+ box.at(now);+ // Recording an old landing again must not turn it into new progress.+ store.merged(box.board, landings[0], { agentId: 'coordinator', commit: box.commit });+ const landing = box.item('landing');+ const review = box.item('review');+ const building = box.item('building');+ const held = box.item('held');+ const waiting = box.item('waiting');+ const withdrawn = box.item('waiting');+ store.withdraw(box.board, withdrawn, { agentId: 'coordinator', reason: 'No longer planned' });+ const ids = [landings.at(-1), landing, review, building, held, waiting, withdrawn];+ store.addMilestone(box.board, { agentId: 'coordinator', name: 'A', items: ids });+ const ask = store.shout(box.board, { from: 'coordinator', to: store.PERSON, lanes: ['web'], decision: true,+ text: `Choose for #${waiting}, #${waiting}, #${withdrawn}; foreign#${review} and https://example.invalid/#${landing} are outside`,+ evidence: { kind: 'attempt', outcome: 'Needs judgment', item: held, commit: box.commit } });+ const expected = { total: 6, left: 5, landed: 1, landing: 1, review: 1, building: 1, held: 1, waiting: 1,+ needsYou: [held, waiting], pace: { last6h: 5, last2h: 3 }, estimate: { low: 3.5, high: 6 } };+ assert.deepEqual((await box.run()).milestones[0].summary, expected);+ assert.match(await box.run(false), /^ 5 left of 6: 1 landed, 1 landing, 1 in review, 1 building, 1 waiting, 1 held; about 3.5 to 6 h at today's pace\.$/m);+ const direct = milestoneRoadmap(box.repo, box.board, { projects: () => [] })[0];+ assert.equal(direct.total, 7, 'legacy milestone membership still includes withdrawn work');+ assert.equal(direct.items.at(-1).status, 'withdrawn');+ assert.equal(direct.done, 1);+ assert.deepEqual(direct.items.map(entry => entry.id), ids, 'existing roadmap fields stay intact');+ assert.equal(['landed', 'landing', 'review', 'building', 'held', 'waiting'].reduce((sum, key) => sum + direct.summary[key], 0), direct.summary.total);+ store.shout(box.board, { from: store.PERSON, to: 'coordinator', lanes: ['web'], answers: ask, text: 'Choose it' });+ assert.deepEqual((await box.run()).milestones[0].summary.needsYou, [], 'answered questions no longer need the person');+ box.at(now + 2 * HOUR);+ const later = (await box.run()).milestones[0].summary;+ assert.equal(later.building, 0, 'an expired claim becomes waiting');+ assert.equal(later.waiting, 2);+ assert.deepEqual(later.pace, { last6h: 4, last2h: 0 });+ assert.deepEqual(later.estimate, { low: 7.5, high: 7.5 }, 'a zero short window uses the positive six-hour rate');+ box.at(now + 6 * HOUR);+ assert.equal((await box.run()).milestones[0].summary.estimate, null, 'fewer than three recent landings has no estimate');+ box.at(now);+ store.addMilestone(box.board, { agentId: 'coordinator', name: 'B', items: [] });+ store.shipMilestone(box.board, 'A', { agentId: 'coordinator', commit: box.commit });+ const shipped = (await box.run()).milestones[0];+ assert.equal(shipped.summary.estimate, null, 'a shipped milestone has no estimate even at a known pace');+ assert.doesNotMatch((await box.run(false)).split('B:')[0], /left of/, 'the shipped milestone has no summary line');+ });+++ test('[N26] roadmap holds and unavailable scoped references partition without leaking names', async t => {+ const box = fixture(t);+ const now = box.clock.now().getTime();+ const building = box.item('building');+ store.holdItem(box.board, building, { agentId: 'coordinator', reason: 'Next stage waits' });+ const paused = box.item('waiting', 'paused');+ store.holdLane(box.board, 'paused', { agentId: 'coordinator', reason: 'Paused lane' });+ store.addMilestone(box.board, { agentId: 'coordinator', name: 'Scoped', items: [building, paused, 'unregistered-private#7'] });+ const scoped = milestoneRoadmap(box.repo, box.board, { projects: () => [], hideOutOfScope: true })[0];+ assert.equal(scoped.summary.building, 1, 'a live builder takes precedence over a hold');+ assert.equal(scoped.summary.held, 1, 'a held lane counts its open work');+ assert.equal(scoped.summary.waiting, 1, 'an unresolved foreign item remains in the total');+ assert.equal(scoped.summary.total, 3);+ assert.equal(scoped.summary.estimate, null);+ assert.doesNotMatch(JSON.stringify(scoped), /unregistered-private/, 'the summary preserves scoped reference redaction');+ box.at(now + 2 * HOUR);+ const expired = milestoneRoadmap(box.repo, box.board, { projects: () => [], hideOutOfScope: true })[0].summary;+ assert.equal(expired.building, 0);+ assert.equal(expired.held, 2, 'the expired builder is held instead of waiting');+ assert.equal(expired.waiting, 1);+ });