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.

fix(api): defer local roadmap hydration [A2, N26]

Corey Olson37d8d7305f83
diff --git a/src/api.js b/src/api.js
index 3b901d77..5f97ec57 100644
--- a/src/api.js
+++ b/src/api.js
@@ -56,14 +56,15 @@ function boardStateRevision(root, id, isMain) {
agents,
leases,
requestReceipts: board.db.prepare('SELECT meta_value FROM board_meta WHERE meta_key = ?').get('relay_person_requests')?.meta_value ?? null,
- milestones: hasExternalMilestones ? milestoneRoadmap(info.root, board) : store.roadmap(board),
+ milestones,
+ externalMilestones: hasExternalMilestones ? milestoneRoadmap(info.root, board) : null,
};
}, isMain);
const revision = JSON.stringify([
info.commonDir, id, resolveCommit(info.root, 'HEAD'), files,
- local.event, local.agents, local.leases, local.requestReceipts, local.milestones, store.EVENT_LOG_VERSION,
+ local.event, local.agents, local.leases, local.requestReceipts, local.milestones, local.externalMilestones, store.EVENT_LOG_VERSION,
]);
- return { cacheId: info.commonDir + '\0' + id, revision, milestones: local.milestones, cacheable: true };
+ return { cacheId: info.commonDir + '\0' + id, revision, milestones: local.externalMilestones, cacheable: true };
}
/** Build the complete local API state, including fields that the shared project snapshot omits. */
@@ -79,7 +80,7 @@ function buildLocalBoardState(board, codeIsMain, milestones) {
const projectData = withBoard(board.root, (db) => ({
requests: store.openRequests(db),
personRequests: personRequestStatuses(db),
- milestones,
+ milestones: milestones ?? store.roadmap(db),
rowDecisions: store.rowDecisions(db),
checks: new Map(store.listItems(db, { all: true }).map((item) => store.getItem(db, item.item_id)).map((item) => [item.item_id, {
check: item.item_check,
diff --git a/test/api-http.test.js b/test/api-http.test.js
index dcb4d94e..ee9df79f 100644
--- a/test/api-http.test.js
+++ b/test/api-http.test.js
@@ -212,6 +212,36 @@ async function cachedHttpStateTest(t) {
test('[A2, N26] an unchanged board state is reused and a move rebuilds it', cachedHttpStateTest);
+test('[A2, N26] local milestone item status refreshes after an item event', async (t) => {
+ let builds = 0;
+ const box = await httpBox(t, { onStateBuild: () => { builds += 1; } });
+ const agent = box.cli(box.root, 'worktree', 'app', '--model', 'fixture-agent');
+ const added = await box.call(box.path + '/moves', {
+ verb: 'add', args: { lane: 'app', title: 'Roadmap item', criterion: 'refresh local status', specs: 'G1' },
+ });
+ assert.equal(added.status, 200);
+ const itemId = added.document.result.item.item_id;
+ box.cli(box.root, 'milestone', 'add', 'Delivery', '--items', String(itemId));
+
+ const before = await box.call(box.path + '/state');
+ assert.equal(builds, 1);
+ assert.deepEqual(before.document.state.milestones[0].items[0], {
+ id: itemId, title: 'Roadmap item', status: 'open',
+ });
+
+ const unchanged = await box.call(box.path + '/state');
+ assert.equal(builds, 1, 'an unchanged local roadmap state reuses its cached snapshot');
+ assert.deepEqual(unchanged.document.state.milestones, before.document.state.milestones);
+
+ const claimed = await box.call(box.path + '/moves', { verb: 'claim', item: itemId, agent: agent.agent });
+ assert.equal(claimed.status, 200);
+ const after = await box.call(box.path + '/state');
+ assert.equal(builds, 2, 'a real item event rebuilds the cached local roadmap');
+ assert.deepEqual(after.document.state.milestones[0].items[0], {
+ id: itemId, title: 'Roadmap item', status: 'claimed',
+ });
+});
+
test('[A2, N26] a person request receipt refreshes cached state without an event', async (t) => {
let builds = 0;
const box = await httpBox(t, { onStateBuild: () => { builds += 1; } });