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
refactor(core): bound withdraw code and document it [N26,A1]
Corey Olson6af2458b37fd
diff --git a/docs/api.md b/docs/api.mdindex 323061ca..aa2086e5 100644--- a/docs/api.md+++ b/docs/api.md@@ -122,7 +122,7 @@ For example: `flow: review wait average 61 min (1 measured; > 60 min); bottlenec| `verify` | `version:number`, `id:number`, `decision:string`, `reason:string` || `merged` | `version:number`, `id:number`, `commit:string` || `land` | `version:number`, `batch:object\|null`, `landed:array`, `conflicts:array`, `blocked:array`, `culprits:array`, `flakes:array` |-| `withdraw` | `version:number`, `id:number`, `reason:string` |+| `withdraw` | `version:number`, `id:number`, `reason:string`, `milestones:array` || `refreeze` | `version:number`, `id:number`, `after:string` || `reopen` | `version:number`, `id:number`, `commit:string` || `shout` | `version:number`, `id:number`, `decision:boolean` |@@ -372,7 +372,9 @@ The local board state and events responses include `eventLogVersion`, which idenThe 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`. Each milestone also carries `summary: { total, left, landed, landing, review, building, held, waiting, needsYou, pace: { last6h, last2h }, estimate }`. Only non-withdrawn members participate in the summary: its `total`, `left`, six state counts and `needsYou` exclude withdrawn work, while the existing milestone `items`, `total`, `landed` and `done` fields retain their original membership semantics. The six summary state counts are exclusive and sum to summary `total`: landed, accepted but not landed, submitted, live claimed, held, then waiting (including expired claims and unresolved references), in that order of precedence. `left` is total minus landed. Holds include item and lane holds. `needsYou` contains local milestone item ids linked to unanswered person decisions by typed item evidence or explicit local `#N` tokens in the question; repo-qualified and URL references do not link local items. Pace counts this board's distinct currently landed items at the first merged event for their current merge commit, with windows excluding the exact lower boundary. `estimate` is `{ low, high }` hours, from left divided by each window's hourly rate, sorted and rounded to the nearest half hour. A zero two-hour rate uses the positive six-hour rate for both bounds. The estimate is `null` with fewer than three landings in six hours or after shipping. Unshipped milestones print one summary line, including the estimate when available; shipment, targets and item states retain their existing fields.+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, withdrawn }` 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`. Each milestone also carries `summary: { total, left, landed, landing, review, building, held, waiting, needsYou, pace: { last6h, last2h }, estimate }`. Withdrawn members are omitted from milestone `items` and `total` and counted separately in `withdrawn`; remaining work precedes verified items, preserving order within each group. The summary also excludes withdrawn work from its `total`, `left`, six state counts and `needsYou`. The six summary state counts are exclusive and sum to summary `total`: landed, accepted but not landed, submitted, live claimed, held, then waiting (including expired claims and unresolved references), in that order of precedence. `left` is total minus landed. Holds include item and lane holds. `needsYou` contains local milestone item ids linked to unanswered person decisions by typed item evidence or explicit local `#N` tokens in the question; repo-qualified and URL references do not link local items. Pace counts this board's distinct currently landed items at the first merged event for their current merge commit, with windows excluding the exact lower boundary. `estimate` is `{ low, high }` hours, from left divided by each window's hourly rate, sorted and rounded to the nearest half hour. A zero two-hour rate uses the positive six-hour rate for both bounds. The estimate is `null` with fewer than three landings in six hours or after shipping. Unshipped milestones print one summary line, including the estimate when available; shipment, targets and item states retain their existing fields.++`pullboard withdraw` removes the item's numeric reference and unambiguous references through this project's registered name or basename from every milestone. Foreign and ambiguous project references remain. Its `milestones` JSON array lists the affected milestone names in stored order.`milestone ship` is the coordinator's move. It records the milestone as shipped at the main checkout's commit and moves every local 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 local item stays in place. A `repo#id` reference also stays in place because its board belongs to another repository; every such reference is listed in `notMoved` in JSON and named as “not moved across boards” in text output. Its JSON result is `{ milestone, into, moved, notMoved }`. A shipped milestone takes no new items: `milestone items <name> --add` refuses `MILESTONE_SHIPPED`. Shipping refuses `NO_NEXT_MILESTONE` when unlanded local items have nowhere to go, and `MILESTONE_COMMIT` when main has no commit. Targets and shipping are engine 45 moves.diff --git a/src/cli.js b/src/cli.jsindex 9d38b1a2..f1e7b4d5 100644--- a/src/cli.js+++ b/src/cli.js@@ -272,13 +272,8 @@ import {registerProjectAndLink,registeredProjectRootsSnapshot,} from './projects.js';-import {- milestoneRoadmap,- resolveMilestoneProjectReference,-} from './roadmap.js';-import {- milestoneReferencesToRemove,-} from './milestones.js';+import { milestoneRoadmap, localMilestoneAliases } from './roadmap.js';+import { milestoneReferencesToRemove } from './milestones.js';import {rigorLines,rigorReport,@@ -3722,18 +3717,7 @@ function workCommands(io, args) {withdraw: () => act(async (ctx, board, me) => {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 removals = milestoneReferencesToRemove(board, [id, ...localMilestoneAliases(ctx.info.root, board, id)]);const left = removals.map(({ name }) => name);for (const { name, remove } of removals) {await ordered(ctx, board, 'editMilestoneItems', [name, { agentId: me.id, remove }]);diff --git a/src/json.js b/src/json.jsindex 0f2624d4..7e1cb049 100644--- a/src/json.js+++ b/src/json.js@@ -67,7 +67,7 @@ export const JSON_SHAPES = {verify: shape({ id: 'number', decision: 'string', reason: 'string' }),merged: shape({ id: 'number', commit: 'string' }),land: shape({ batch: 'object|null', landed: 'array', conflicts: 'array', blocked: 'array', culprits: 'array', flakes: 'array' }),- withdraw: shape({ id: 'number', reason: 'string' }),+ withdraw: shape({ id: 'number', reason: 'string', milestones: 'array' }),refreeze: shape({ id: 'number', after: 'string' }),reopen: shape({ id: 'number', commit: 'string' }),shout: shape({ id: 'number', decision: 'boolean' }),diff --git a/src/roadmap.js b/src/roadmap.jsindex b894b9c9..49e23073 100644--- a/src/roadmap.js+++ b/src/roadmap.js@@ -10,6 +10,7 @@ import {events,laneHolds,listItems,+ milestones,openDecisions,PERSON,openBoard,@@ -30,6 +31,22 @@ export function resolveMilestoneProjectReference(reference, projects) {return { repo, number, project: candidates.length === 1 ? candidates[0] : null };}+/** Collect unambiguous registered aliases for one local item before milestone cleanup. */+export function localMilestoneAliases(root, board, id) {+ const projects = listApiProjects();+ const localRoot = resolve(root);+ const aliases = new Set();+ for (const milestone of 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);+ }+ }+ return [...aliases];+}+/** Resolve a repo-qualified milestone item against registered boards, optionally within an API scope.* @param {string} root* @param {any} board