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.

perf(cli): finish the shared read graph [C7]

Corey Olson0e168ddd8b91
diff --git a/src/board-query.js b/src/board-query.js
index 5eca18f9..b45811ce 100644
--- a/src/board-query.js
+++ b/src/board-query.js
@@ -1,5 +1,6 @@
/** Canonical board queries shared by reads and the synchronous write store [C7]. */
import { COORDINATOR } from './config.js';
+import { itemFiles } from './item-files.js';
import { parseSpec } from './spec.js';
import { BOARD_SENTINEL_ENGINE } from './sentinel-engine.js';
import { Refused } from './refused.js';
@@ -390,3 +391,25 @@ export function ensureCoordinator(board, path) {
if (!existing || existing.agent_path !== path) throw new ReadNeedsWrite('coordinator registration or path update requires the write store');
return COORDINATOR;
}
+
+/**
+ * Finished items that touched the same files as this one, most shared first (N21). A builder
+ * starting cold reads how its neighbours were done instead of rediscovering it. File overlap, not
+ * word similarity: in one real build, an item shared a source file with one of the three before it
+ * in its lane 56% of the time.
+ *
+ * @param {any} board
+ * @param {any} item
+ * @param {number} [limit]
+ * @returns {{ item: any, shared: string[] }[]}
+ */
+export function relatedItems(board, item, limit = 3) {
+ const mine = new Set(itemFiles(item));
+ if (!mine.size) return [];
+ return listItems(board, { all: true })
+ .filter((other) => other.item_id !== item.item_id && other.item_status === 'verified')
+ .map((other) => ({ item: other, shared: itemFiles(other).filter((path) => mine.has(path)) }))
+ .filter((entry) => entry.shared.length)
+ .sort((first, second) => second.shared.length - first.shared.length || second.item.item_id - first.item.item_id)
+ .slice(0, limit);
+}
diff --git a/src/board.js b/src/board.js
index eb3aeb37..903aadd6 100644
--- a/src/board.js
+++ b/src/board.js
@@ -2131,27 +2131,7 @@ function idleReason(items, lane, routed) {
return `${reason}; ${awaiting.join(', ')} still await${awaiting.length === 1 ? 's' : ''} a verdict, and a rejected item comes back to this lane. A lane is done when its items are verified`;
}
-/**
- * Finished items that touched the same files as this one, most shared first (N21). A builder
- * starting cold reads how its neighbours were done instead of rediscovering it. File overlap, not
- * word similarity: in one real build, an item shared a source file with one of the three before it
- * in its lane 56% of the time.
- *
- * @param {any} board
- * @param {any} item
- * @param {number} [limit]
- * @returns {{ item: any, shared: string[] }[]}
- */
-export function relatedItems(board, item, limit = 3) {
- const mine = new Set(itemFiles(item));
- if (!mine.size) return [];
- return listItems(board, { all: true })
- .filter((other) => other.item_id !== item.item_id && other.item_status === 'verified')
- .map((other) => ({ item: other, shared: itemFiles(other).filter((path) => mine.has(path)) }))
- .filter((entry) => entry.shared.length)
- .sort((first, second) => second.shared.length - first.shared.length || second.item.item_id - first.item.item_id)
- .slice(0, limit);
-}
+export { relatedItems } from './board-query.js';
/**
* Hold a lane (N22): `next` there claims nothing and names the reason, so a pause lives on the board
diff --git a/src/commands/show.js b/src/commands/show.js
index 441d6d3d..bfb6f4b6 100644
--- a/src/commands/show.js
+++ b/src/commands/show.js
@@ -1,5 +1,3 @@
-// Pending the legally landed #1114 item-files leaf, keep the existing related-items implementation.
-import { relatedItems } from '../board.js';
import { withBoardRead } from '../cli-board-read.js';
/** The pullboard show command, in its own module so an item adding another command never edits these lines. */
import {
@@ -49,7 +47,7 @@ export async function run(io, { first, values }) {
if (values.json) return result;
const history = store.events(board, { itemId: id });
return { ...result, moves: history.filter((event) => ['attempt', 'escalate'].includes(event.event_kind)),
- related: relatedItems(board, item), reviewer: store.reviewHolder(board, item),
+ related: store.relatedItems(board, item), reviewer: store.reviewHolder(board, item),
agents: store.listAgents(board), mainMerge: mainMergeFor(board, id), infra: infraNotes.infraNoteOf(history) };
});
const agentApproved = itemAgentApprovals(item, approval);