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(roadmap): a milestone target is one instant on every replica [N26]
Corey Olson749f47ec0d63
diff --git a/src/board.js b/src/board.jsindex 6e9f0eab..8ed7c5d7 100644--- a/src/board.js+++ b/src/board.js@@ -2408,7 +2408,7 @@ export function milestones(board) {}// The roadmap's moves live in milestones.js; the board keeps exporting them so the engine replays them.-export { addMilestone, editMilestone, editMilestoneItems, moveMilestone, removeMilestone, roadmap, shipMilestone } from './milestones.js';+export { addMilestone, canonicalMilestoneTarget, editMilestone, editMilestoneItems, moveMilestone, removeMilestone, roadmap, shipMilestone } from './milestones.js';/** Current person decisions, including applied receipts, stored without checkout-dependent state. */export function rowDecisions(board) {diff --git a/src/cli.js b/src/cli.jsindex 210ac81d..6f4674de 100644--- a/src/cli.js+++ b/src/cli.js@@ -2863,7 +2863,7 @@ function workCommands(io, args) {throw new Refused('USAGE', 'pullboard milestone edit <name> [--name <new name>] [--note <text>] [--target <date and time>|none]');}name = second;- entry = await ordered(ctx, board, 'editMilestone', [name, { agentId: me.id, newName: values.name, note: values.note, ...(values.target === undefined ? {} : { target: values.target }) }]);+ entry = await ordered(ctx, board, 'editMilestone', [name, { agentId: me.id, newName: values.name, note: values.note, ...(values.target === undefined ? {} : { target: store.canonicalMilestoneTarget(values.target) }) }]);name = entry.name;} else if (first === 'ship') {if (!second || rest.length || ['items', 'note', 'before', 'name', 'add', 'remove', 'target'].some((key) => values[key] !== undefined)) {diff --git a/src/engine.js b/src/engine.jsindex a3f906e7..8f8fcd68 100644--- a/src/engine.js+++ b/src/engine.js@@ -3,7 +3,7 @@ import { createHash, randomUUID } from 'node:crypto';import * as store from './board.js';import { recordedRefusal } from './recorded-refusal.js';import { ENGINE_VERSION } from './machine.js';-import { MILESTONE_SHIP_ENGINE } from './milestones.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';@@ -95,6 +95,8 @@ export function prepareEngineMove(board, operation, args, { id = randomUUID(), aoptions.freezeError = error ?? null;}}+ // A target is fixed to one instant here, so replicas in other time zones read the same one.+ if (operation === 'editMilestone' && values[1] && 'target' in values[1]) values[1].target = canonicalMilestoneTarget(values[1].target);const move = { version: 1, engine: ENGINE_VERSION, id, operation, args: values, ...(actor === undefined ? {} : { actor }) };// JSON is the wire format: optional undefined fields become absent on every replica alike.return JSON.parse(JSON.stringify(move));diff --git a/src/milestones.js b/src/milestones.jsindex a63b9748..81c5eb78 100644--- a/src/milestones.js+++ b/src/milestones.js@@ -106,16 +106,33 @@ function normalizeMilestoneText(name, note = null) {}/**- * A target as ISO text, or null for `none`, which clears it. Stored normalized so every replica- * compares the same instant whatever form the coordinator typed.+ * 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 at = typeof target === 'string' && /\d/.test(target) ? Date.parse(target.trim()) : NaN;- if (!Number.isFinite(at)) throw new Refused('MILESTONE_TARGET', 'a target needs a date and time, like 2026-10-20T18:00Z; use --target <date and time>, or --target none to clear it');+ 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();}diff --git a/test/milestones.test.js b/test/milestones.test.jsindex 52e16d11..b98f80d9 100644--- a/test/milestones.test.js+++ b/test/milestones.test.js@@ -85,7 +85,7 @@ function moves(box, id) {return box.json('show', String(id)).thread.filter((entry) => entry.kind === 'milestone_moved');}-test('[N26] a milestone ships what landed and moves the rest', (t) => {+test('[N26] a milestone ships what landed and moves the rest', async (t) => {const box = fixture(t);const landed = box.item('Landed work', 'landed');const accepted = box.item('Accepted work', 'accepted');@@ -146,6 +146,37 @@ test('[N26] a milestone ships what landed and moves the rest', (t) => {assert.notEqual(refused.status, 0, refused.stdout + refused.stderr);assert.equal(JSON.parse(refused.stdout).error.code, 'MILESTONE_SHIPPED', 'adding to a shipped milestone is refused');assert.deepEqual(milestone(box.json('roadmap'), 'A').items.map(({ id }) => id), [landed], 'the refusal changes nothing');++ // A target means one instant on every replica: the move carries UTC, and a bare local time+ // in an ordered envelope is refused alike in every zone instead of read in each one's own.+ const { prepareEngineMove, applyEngineMove } = await import('../src/engine.js');+ const { exportBoard, importBoard } = await import('../src/exchange.js');+ store.addMilestone(box.board, { agentId: 'coordinator', name: 'Z' });+ const snapshot = exportBoard(box.board);+ const prepared = prepareEngineMove(box.board, 'editMilestone', ['Z', { agentId: 'coordinator', target: '2026-10-20T18:00' }], { id: 'zone-target', actor: 'coordinator' });+ assert.match(prepared.args[1].target, /Z$/u, 'the prepared move carries the instant in UTC');+ const bare = { ...prepared, id: 'bare-target', args: ['Z', { agentId: 'coordinator', target: '2026-10-20T18:00' }] };+ const zone = process.env.TZ;+ const replicas = [];+ try {+ for (const name of ['UTC', 'America/Chicago']) {+ const dir = mkdtempSync(join(tmpdir(), 'pullboard-target-zone-'));+ TEMP_DIRS.push(dir);+ const replica = store.openBoard(join(dir, 'board.sqlite'));+ t.after(() => store.closeBoard(replica));+ importBoard(replica, snapshot);+ process.env.TZ = name;+ const refused = applyEngineMove(replica, bare, { sequence: 1, at: '2026-10-17T04:00:00.000Z' });+ assert.equal(refused.error?.code, 'MILESTONE_TARGET', `a bare local time is refused in ${name}: ${JSON.stringify(refused)}`);+ const applied = applyEngineMove(replica, prepared, { sequence: 2, at: '2026-10-17T04:00:01.000Z' });+ assert.equal(applied.error, undefined, JSON.stringify(applied));+ replicas.push(store.milestones(replica).find((row) => row.name === 'Z').target);+ }+ } finally {+ if (zone === undefined) delete process.env.TZ;+ else process.env.TZ = zone;+ }+ assert.equal(replicas[0], replicas[1], `every replica stores the same target: ${JSON.stringify(replicas)}`);});test('[N26] milestone ship --next names where the unlanded items go', (t) => {