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
fix(core): remove withdrawn local milestone aliases [N26]
Corey Olson7cfa34dd3e21
diff --git a/src/cli.js b/src/cli.jsindex f5346677..9d38b1a2 100644--- a/src/cli.js+++ b/src/cli.js@@ -272,8 +272,13 @@ import {registerProjectAndLink,registeredProjectRootsSnapshot,} from './projects.js';-import { milestoneRoadmap } from './roadmap.js';-import { milestonesListing } from './milestones.js';+import {+ milestoneRoadmap,+ resolveMilestoneProjectReference,+} from './roadmap.js';+import {+ milestoneReferencesToRemove,+} from './milestones.js';import {rigorLines,rigorReport,@@ -3715,9 +3720,24 @@ function workCommands(io, args) {return 0;}),withdraw: () => act(async (ctx, board, me) => {- await ordered(ctx, board, 'withdraw', [idArg(first), { agentId: me.id, reason: [second, ...rest].filter(Boolean).join(' ') }]);- const left = milestonesListing(board, idArg(first));- for (const name of left) await ordered(ctx, board, 'editMilestoneItems', [name, { agentId: me.id, remove: [idArg(first)] }]);+ const id = idArg(first);+ await ordered(ctx, board, 'withdraw', [id, { agentId: me.id, reason: [second, ...rest].filter(Boolean).join(' ') }]);+ const projects = listApiProjects();+ const localRoot = resolve(ctx.info.root);+ const aliases = new Set();+ for (const milestone of store.milestones(board)) {+ for (const reference of milestone.items) {+ if (typeof reference !== 'string') continue;+ const parsed = resolveMilestoneProjectReference(reference, projects);+ if (!parsed?.project || !Number.isSafeInteger(Number(parsed.number)) || Number(parsed.number) !== id) continue;+ if (resolve(parsed.project.root) === localRoot) aliases.add(reference);+ }+ }+ const removals = milestoneReferencesToRemove(board, [id, ...aliases]);+ const left = removals.map(({ name }) => name);+ for (const { name, remove } of removals) {+ await ordered(ctx, board, 'editMilestoneItems', [name, { agentId: me.id, remove }]);+ }io.result?.({ id: idArg(first), reason: [second, ...rest].filter(Boolean).join(' '), milestones: left });io.say(`withdrew #${first}${left.length ? `; removed it from milestone ${left.join(', ')}` : ''}`);return 0;diff --git a/src/milestones.js b/src/milestones.jsindex 42d19b55..0b7f6194 100644--- a/src/milestones.js+++ b/src/milestones.js@@ -57,6 +57,15 @@ export function milestonesListing(board, id) {return milestones(board).filter((milestone) => milestone.items.includes(id)).map((milestone) => milestone.name);}+/** Return each milestone and its matching references, preserving milestone and item order. */+export function milestoneReferencesToRemove(board, references) {+ const wanted = new Set(references);+ return milestones(board).flatMap((milestone) => {+ const remove = milestone.items.filter((reference) => wanted.has(reference));+ return remove.length ? [{ name: milestone.name, remove }] : [];+ });+}+/*** 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.diff --git a/src/roadmap.js b/src/roadmap.jsindex 07c22a52..b894b9c9 100644--- a/src/roadmap.js+++ b/src/roadmap.js@@ -21,6 +21,15 @@ import {} from './git.js';import { listApiProjects } from './projects.js';+/** Parse a registered-project reference and resolve only an unambiguous project name or basename. */+export function resolveMilestoneProjectReference(reference, projects) {+ const match = /^(.+)#([1-9]\d*)$/.exec(reference);+ if (!match) return null;+ const [, repo, number] = match;+ const candidates = projects.filter((project) => project.name === repo || basename(project.root) === repo);+ return { repo, number, project: candidates.length === 1 ? candidates[0] : null };+}+/** Resolve a repo-qualified milestone item against registered boards, optionally within an API scope.* @param {string} root* @param {any} board@@ -33,14 +42,13 @@ export function milestoneRoadmap(root, board, options = {}) {const externalItems = new Map();const hidden = () => ({ id: `external-${++hiddenExternal}`, title: 'External item', status: 'unavailable' });const resolveExternal = (reference) => {- const match = /^(.+)#([1-9]\d*)$/.exec(reference);- if (!match) return options.hideOutOfScope ? hidden() : { id: reference, title: reference, status: 'unavailable' };- const [, repo, number] = match;- const candidates = projects.filter((project) => project.name === repo || basename(project.root) === repo);- if (candidates.length !== 1) return options.hideOutOfScope ? hidden() : { id: reference, title: `#${number} (${repo})`, status: 'unavailable' };+ const parsed = resolveMilestoneProjectReference(reference, projects);+ if (!parsed) return options.hideOutOfScope ? hidden() : { id: reference, title: reference, status: 'unavailable' };+ const { repo, number, project } = parsed;+ if (!project) return options.hideOutOfScope ? hidden() : { id: reference, title: `#${number} (${repo})`, status: 'unavailable' };try {- const info = repoInfo(candidates[0].root);- const other = resolve(candidates[0].root) === resolve(root)+ const info = repoInfo(project.root);+ const other = resolve(project.root) === resolve(root)? board: openBoard(join(info.commonDir, 'pullboard', 'board.sqlite'), undefined, { isMain: codeIsFromMain() });try {diff --git a/test/roadmap.test.js b/test/roadmap.test.jsindex 4ca23de9..bf1a52a9 100644--- a/test/roadmap.test.js+++ b/test/roadmap.test.js@@ -1,7 +1,7 @@/** Roadmap progress and withdrawn work preserve their recorded meaning [N26]. */import assert from 'node:assert/strict';import { execFileSync, spawnSync } from 'node:child_process';-import { chmodSync, mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';+import { chmodSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';import { tmpdir } from 'node:os';import { join, resolve } from 'node:path';import { after, test } from 'node:test';@@ -10,10 +10,10 @@ import { main } from '../src/cli.js';import { milestoneRoadmap } from '../src/roadmap.js';import { submitFixture } from './board-submit-fixture.js';import {- ENGINE_VERSION,MILESTONE_SHIP_ENGINE,WITHDRAW_MILESTONE_ENGINE,} from '../src/milestones.js';+import { ENGINE_VERSION } from '../src/machine.js';import { prepareEngineMove } from '../src/engine.js';const BIN = resolve(import.meta.dirname, '../bin/pullboard.js');@@ -47,19 +47,21 @@ function withdrawFixture(t) {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 Git inside a fixture repo with its private identity. */+ const gitAt = (cwd, ...args) => execFileSync('git', args, { cwd, env, encoding: 'utf8', stdio: 'pipe' }).trim();+ const git = (...args) => gitAt(repo, ...args);/** 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' });+ const runAt = (cwd, ...args) => {+ const result = spawnSync(process.execPath, [BIN, ...args], { cwd, env, encoding: 'utf8' });assert.equal(result.status, 0, `${args.join(' ')}: ${result.stdout}${result.stderr}`);return result.stdout;};+ const run = (...args) => runAt(repo, ...args);/** 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: [] }));+ writeFileSync(join(repo, 'pullboard.json'), JSON.stringify({ name: 'Local Alias', 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'));@@ -79,7 +81,7 @@ function withdrawFixture(t) {if (state === 'landed') store.merged(board, id, { agentId: 'coordinator', commit: git('rev-parse', 'HEAD') });return id;};- return { run, json, board, item };+ return { run, runAt, gitAt, dir, json, board, item };}/** A real Git repository and SQLite board with a shared, controlled command clock. */@@ -142,15 +144,45 @@ function fixture(t) {}test('withdraw leaves every milestone and the roadmap lists work to ship first [N26]', (t) => {- const { run, json, board, item } = withdrawFixture(t);+ const { run, runAt, gitAt, dir, 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');+ const foreignRepo = join(dir, 'foreign');+ mkdirSync(foreignRepo);+ gitAt(dir, 'init', '-q', '-b', 'main', foreignRepo);+ runAt(foreignRepo, 'init');+ const foreignBoard = store.openBoard(join(foreignRepo, '.git', 'pullboard', 'board.sqlite'));+ let foreignItem;+ try {+ store.ensureCoordinator(foreignBoard, foreignRepo);+ for (let index = 1; index < dropped; index++) {+ store.addItem(foreignBoard, { by: 'coordinator', lane: 'web', title: `Foreign filler ${index}` });+ }+ foreignItem = store.addItem(foreignBoard, { by: 'coordinator', lane: 'web', title: 'Foreign same-id item' });+ } finally {+ store.closeBoard(foreignBoard);+ }+ assert.equal(foreignItem, dropped, 'the registered foreign board has a real item with the same numeric ID');+ for (const name of ['ambiguous-one', 'ambiguous-two']) {+ const root = join(dir, name);+ mkdirSync(root);+ gitAt(dir, 'init', '-q', '-b', 'main', root);+ runAt(root, 'init');+ const configPath = join(root, 'pullboard.json');+ const config = JSON.parse(readFileSync(configPath, 'utf8'));+ writeFileSync(configPath, JSON.stringify({ ...config, name: 'Shared Alias' }));+ }+ const namedAlias = `Local Alias#${dropped}`;+ const basenameAlias = `repo#${dropped}`;+ const foreignAlias = `foreign#${dropped}`;+ const ambiguousAlias = `Shared Alias#${dropped}`;run('milestone', 'add', 'Now', '--items', [landed, dropped, first, accepted, second].join(','));run('milestone', 'add', 'Later', '--items', [second, dropped].join(','));+ run('milestone', 'add', 'Aliases', '--items', [namedAlias, basenameAlias, foreignAlias, ambiguousAlias].join(','));run('milestone', 'add', 'Elsewhere', '--items', String(unrelated));// Probe both sealed writers without consuming fixture IDs or changing board state.@@ -162,11 +194,11 @@ test('withdraw leaves every milestone and the roadmap lists work to ship first [// 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');+ assert.match(said, new RegExp(`withdrew #${dropped}; removed it from milestone Now, Later, Aliases`), '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');+ assert.deepEqual(lists, { Now: [landed, first, accepted, second], Later: [second], Aliases: [foreignAlias, ambiguousAlias], Elsewhere: [unrelated] }, 'numeric membership and both local aliases leave their milestones, while foreign and ambiguous aliases remain');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');+ assert.deepEqual(removals.map(({ name, remove }) => [name, remove]), [['Now', [dropped]], ['Later', [dropped]], ['Aliases', [namedAlias, basenameAlias]]], 'each milestone records exactly its local references in stored order');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');@@ -181,13 +213,16 @@ test('withdraw leaves every milestone and the roadmap lists work to ship first [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.Aliases.items.map(({ id, status }) => [id, status]),+ [[foreignAlias, 'open'], [ambiguousAlias, 'unavailable']], 'the foreign same-ID board resolves independently and duplicate project names remain ambiguous');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');+ const itemText = text.replace(/^ {2}\d+ left of \d+: [^\n]*\n/gm, '');+ assert.match(itemText, /^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(itemText, /^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');});@@ -219,10 +254,12 @@ test('[N26] each milestone sums its items by state with an estimate', async t =>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.total, 6, 'withdrawn work is excluded from milestone membership');+ assert.equal(direct.withdrawn, 1, 'the omitted withdrawn member remains reported separately');+ assert.ok(direct.items.every(entry => entry.status !== 'withdrawn'));assert.equal(direct.done, 1);- assert.deepEqual(direct.items.map(entry => entry.id), ids, 'existing roadmap fields stay intact');+ assert.deepEqual(direct.items.map(entry => entry.id),+ [review, building, held, waiting, landings.at(-1), landing], 'the roadmap keeps work to ship first and omits withdrawn work');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');