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
feat: prefer remaining paths and soften overlaps [N2,N20,H16]
Corey Olsonbce4d26d92dd
diff --git a/docs/api.md b/docs/api.mdindex 65ec82d6..1614940d 100644--- a/docs/api.md+++ b/docs/api.md@@ -618,7 +618,7 @@ Unavailable Git-object verdict projections are retried on the next read, so fetcWhen the runner's own resource pool refuses the run's setup, the run fails at once with `RUNNER_SETUP_REFUSED`, naming the runner host and the pool's refusal code. It is not retried, and it leaves no holder or waiter on either machine.-Agents and the coordinator can set explicit item ranks with `milestone order <name> <ids>` (comma-separated ids from that milestone). It replaces that milestone’s `order` list in board metadata; other items stay unranked. `next` compares milestone, explicit rank, then its existing route/recent-file/age tie-breaks. A never-ranked board keeps its existing order. Removing an item drops its rank; adding it again leaves it unranked. This does not change newcomer help or person flows.+Agents and the coordinator can set explicit item ranks with `milestone order <name> <ids>` (comma-separated ids from that milestone). It replaces that milestone’s `order` list in board metadata; other items stay unranked. For current-engine build offers, `next` compares focus/release group, longest remaining unit-item dependency path, soft file overlap, then explicit rank and existing route/recent-file/age ties. File overlaps remain warnings and never hard-block ready work. Historical engines preserve their earlier order; review ordering keeps its existing policy. Removing an item drops its rank; adding it again leaves it unranked. This does not change newcomer help or person flows.`resume` on the coordinator seat includes `rigor: {undrafted: [...]}`, naming each repeated cause that has no live or approved proved draft. Each entry retains the ordinary Rigor cause key, item evidence and commits. The text resume names the proof-bearing `pullboard rigor draft` command. Declined repeats stay quiet until a new item repeats them. `needsYou` may contain an individual `kind: "rigor-draft"` call with `cause`, `evidence`, `proof`, a qualified spec or doctrine `target`, and `what: "Approve or Decline"`. An ordinary draft remains in the existing aggregate count; a Rigor draft is not counted twice. These fields add no person permission: the existing person-only approval and decline channels still apply.diff --git a/docs/formats.md b/docs/formats.mdindex 3ff92a4c..7ff0183b 100644--- a/docs/formats.md+++ b/docs/formats.md@@ -577,6 +577,8 @@ The engine-68 `recordSpecApprovalBaseline` move carries `{agentId, baseline: {ve`order` opts into next ordering: a builder’s own send-back, scarce review eligibility, release, downstream demand, signed-bar readiness, then coordinator rank. The readiness tier stays inert until the signed-readiness predicate is available (#1110); it never guesses a sign-off from prose. The other inputs retain their separate meanings; `reviewsFirst` selects review versus build and does not turn ordering on. Takeover and landing behavior are separate changes. The move carries `{agentId,key,value,reason,window}`; its native `line_setting` event carries `{key,value,reason,window}` with the board's actor and time outside that detail. Latest values live under `board_meta` keys `line_setting:<name>`, and ordered engine replay updates them and appends the same evidence. The unassigned `LINE_SETTINGS_ENGINE` leaf receives its permanent number at landing. Older engine records cannot request this new operation. Range, unknown-key, missing-reason and invalid-window refusals have named codes. The existing settings API reports each input as `scope: "board"`, key `line.<name>`, with off as its default and the board SQLite file as its source; it does not expose reason text or evidence payloads through that inventory.+The critical-path engine, numbered at landing, orders ready build offers within each focus/release group by the longest remaining dependency path. Each unfinished item counts as one unit; verified and withdrawn work contributes none. This is the unit-duration Hu ordering, not a claim of measured completion-time estimates. Equal paths prefer fewer overlaps with live claimed, submitted or accepted-not-landed files, then retain existing rank, route, recent-file and age ties. An overlap never makes ready work unavailable. Queue display and next share this rule; dependency, hold, route and reviewer-authority guards remain in force. Earlier engine records retain their original ordering and hard file-collision policy.+With `collisionFreeBatch` on, landing selection previews each reviewed commit against the immutable trunk and reads the resulting Git changed paths, including both rename paths. Overlapping later verdicts wait without reopening; disjoint items still join the current batch. Deferred items keep their recorded place ahead of newer acceptances, even after merge-only re-acceptance. This priority applies only while the setting is on and the item remains accepted and unlanded with the identical submitted commit and frozen digest; new source or a new bar loses that old priority. Once the first batch lands, each deferred item receives one item-addressed reviewer notice in the same atomic landed transition. Existing verdict freshness is unchanged: if main touched the deferred review, its reviewer merges the new trunk and records a merge-only re-accept without a builder cycle or reopening. The default off path keeps existing composition. The control has its own replay-engine boundary; it does not infer paths from briefs.Landing queue grants, first queue entries and releases are shared ordered transitions. New landing-local-heartbeat engine moves leave renewal and repeated-poll events out of history; old engine receipts keep their recorded meaning. `local:landing-lease:<token>` board metadata binds a physical board id, token/generation, process, branch and coordinator lineage to its local deadline. It is excluded from exports, imports and semantic digests and is retained only on the receiving physical board during a same-board relay snapshot restore. A linked foreign holder has no clock-based expiry: release or coordinator takeover fences it; local heartbeat deadlines never authorize another machine to merge.diff --git a/src/board.js b/src/board.jsindex 38819a37..76f76add 100644--- a/src/board.js+++ b/src/board.js@@ -1,4 +1,8 @@import { requireFactKind } from './item-notes.js';+import {+ criticalPathEnabled,+ criticalPathOrder,+} from './critical-path-order.js';import { activityNewsFlag } from './activity-news.js';import { migrateEventLogVersion } from './board-event-log-migrate.js';import {@@ -8,6 +12,7 @@ import {import {focusOrder,focusReasons,+ milestoneFocus,} from './focus-milestone.js';import { answerProvenance } from './decision-origin.js';import { ensureProofCounters } from './proof-counters.js';@@ -1898,6 +1903,7 @@ function milestoneRanks(board, priority) {/** Make the shared build-queue comparator once: milestone, explicit rank, route, recent files, then oldest. */export function buildOrder(board, { warm = [], agentId, readiness = barReadyForOrder } = {}) {const milestonePriority = milestonePriorities(board);+ const items = listItems(board, { all: true });const rank = milestoneRanks(board, milestonePriority);const recent = new Set(warm);const shared = (entry) => itemFiles(entry).filter((path) => recent.has(path)).length;@@ -1905,7 +1911,10 @@ export function buildOrder(board, { warm = [], agentId, readiness = barReadyForO|| rank(first) - rank(second)|| ROUTES.indexOf(second.item_route) - ROUTES.indexOf(first.item_route)|| shared(second) - shared(first) || first.item_id - second.item_id;- return focusOrder(board, lineOrderEnabled(board) ? lineBuildOrder({ agentId, release: milestonePriority, rank, items: listItems(board, { all: true }), ready: item => readiness(board, item), fallback }) : fallback);+ const previous = lineOrderEnabled(board) ? lineBuildOrder({ agentId, release: milestonePriority, rank, items, ready: item => readiness(board, item), fallback }) : fallback;+ const focus = milestoneFocus(board);+ const group = item => focus?.ids.has(item.item_id) ? -1 : milestonePriority(item);+ return focusOrder(board, criticalPathEnabled(board) ? criticalPathOrder({ items, group, fallback: previous }) : previous);}/**@@ -1989,7 +1998,7 @@ export function nextFor(board, { agentId, lane, verify = false, policy = 'any',.map((entry, order) => ({ entry, order, shared: itemFiles(entry).filter((path) => recent.has(path)) })).sort((first, second) => compare(first.entry, second.entry));// Move only evidenced reworks ahead of their own tier; with no evidence, normal order is exact.- for (const route of lineOrderEnabled(board) ? [] : ROUTES) {+ for (const route of lineOrderEnabled(board) || criticalPathEnabled(board) ? [] : ROUTES) {const routeTier = ROUTES.indexOf(route);const selected = mine.findIndex(({ entry }) => tier(entry) === routeTier && mainRed.has(entry.item_id));const firstTierItem = mine.findIndex(({ entry }) => tier(entry) === routeTier);@@ -2014,8 +2023,9 @@ export function nextFor(board, { agentId, lane, verify = false, policy = 'any',const reserved = firstRefusalReason(board, entry.item_id, agentId);if (reserved) { reasons.push(reserved); continue; }const collisions = itemFileCollisions(entry, inFlight);- if (collisions.length) { reasons.push(...collisions); continue; }- if (!waiting.length) return { item: entry, reasons: focusReasons(board, entry, reasons), shared };+ if (collisions.length && !criticalPathEnabled(board)) { reasons.push(...collisions); continue; }+ if (!waiting.length) return { item: entry, reasons: focusReasons(board, entry,+ [...reasons, ...collisions.map(reason => reason.replace(' waits for ', ' overlaps with '))]), shared };reasons.push(`#${entry.item_id} waits on ${waiting.map(waitingOn).join(', ')}`);}if (!mine.length && !reasons.length) reasons.push(idleReason(items, lane, routed));diff --git a/src/critical-path-engine.js b/src/critical-path-engine.jsnew file mode 100644index 00000000..02138290--- /dev/null+++ b/src/critical-path-engine.js@@ -0,0 +1,3 @@+/** Critical-chain ordering and soft overlaps acquire their replay boundary at landing [N2,H16]. */+import { unassignedEngine } from './engine-next.js';+export const CRITICAL_PATH_ENGINE = unassignedEngine();diff --git a/src/critical-path-order.js b/src/critical-path-order.jsnew file mode 100644index 00000000..97bf5fc0--- /dev/null+++ b/src/critical-path-order.js@@ -0,0 +1,67 @@+/** Unit-item Hu priorities use only the recorded dependency graph, never invented duration estimates [N2,H16]. */+import { ENGINE_VERSION } from './machine.js';+import { CRITICAL_PATH_ENGINE } from './critical-path-engine.js';+import { briefFiles } from './brief.js';+import { itemFiles } from './item-files.js';++/** Historical next moves retain their original collision and ordering policy. */+export function criticalPathEnabled(board) {+ return (board.executionEngineVersion ?? ENGINE_VERSION) >= CRITICAL_PATH_ENGINE;+}++/** Count unfinished nodes on the longest successor path within each milestone group, in linear graph time. */+export function remainingPaths(items, group) {+ const active = new Map(items.filter(item => !['verified', 'withdrawn'].includes(item.item_status))+ .map(item => [item.item_id, item]));+ const predecessors = new Map([...active.keys()].map(id => [id, []]));+ const outstanding = new Map([...active.keys()].map(id => [id, 0]));+ for (const item of active.values()) {+ for (const id of new Set((item.item_after ?? '').split(',').filter(Boolean).map(Number))) {+ const before = active.get(id);+ if (!before || group(before) !== group(item)) continue;+ predecessors.get(item.item_id).push(id);+ outstanding.set(id, outstanding.get(id) + 1);+ }+ }+ const paths = new Map([...active.keys()].map(id => [id, 1]));+ const queue = [...outstanding].filter(([, count]) => count === 0).map(([id]) => id);+ for (let cursor = 0; cursor < queue.length; cursor++) {+ const id = queue[cursor];+ for (const before of predecessors.get(id)) {+ paths.set(before, Math.max(paths.get(before), paths.get(id) + 1));+ outstanding.set(before, outstanding.get(before) - 1);+ if (!outstanding.get(before)) queue.push(before);+ }+ }+ // Normal moves refuse dependency cycles. A damaged historical graph must still give a bounded order.+ for (const [id, count] of outstanding) if (count) paths.set(id, 1);+ return paths;+}++/** Index live declared/changed paths once; an overlap lowers preference but never eligibility. */+function overlapCounts(items) {+ const holders = new Map();+ for (const item of items) {+ if (!['claimed', 'submitted'].includes(item.item_status)+ && !(item.item_status === 'verified' && !item.item_merged_commit)) continue;+ for (const path of itemFiles(item)) {+ if (!holders.has(path)) holders.set(path, new Set());+ holders.get(path).add(item.item_id);+ }+ }+ return new Map(items.map(item => {+ const overlaps = new Set(briefFiles(item.item_brief ?? '').flatMap(path => [...(holders.get(path) ?? [])]));+ overlaps.delete(item.item_id);+ return [item.item_id, overlaps.size];+ }));+}++/** Release/focus membership precedes longest path, then soft overlap and the established deterministic ties. */+export function criticalPathOrder({ items, group, fallback }) {+ const paths = remainingPaths(items, group);+ const overlaps = overlapCounts(items);+ return (first, second) => group(first) - group(second)+ || (paths.get(second.item_id) ?? 0) - (paths.get(first.item_id) ?? 0)+ || (overlaps.get(first.item_id) ?? 0) - (overlaps.get(second.item_id) ?? 0)+ || fallback(first, second);+}diff --git a/src/queue.js b/src/queue.jsindex 3da07237..38df1962 100644--- a/src/queue.js+++ b/src/queue.js@@ -6,6 +6,7 @@* next cannot disagree. It is for agents and coordinators; the person reads the Roadmap instead.*/import { itemAuthorProblem } from './item-authors.js';+import { criticalPathEnabled } from './critical-path-order.js';import { Refused } from './refused.js';import { itemFileCollisions } from './item-files.js';import {@@ -46,7 +47,8 @@ function waitsOf(board, item, inFlight) {.filter((before) => before && before.item_status !== 'verified').map((before) => `#${before.item_id} (${before.item_status})`);const lane = laneHold(board, item.item_lane);- return [...after, ...itemFileCollisions(item, inFlight), ...(item.item_hold_reason ? [`held: ${item.item_hold_reason}`] : []), ...(lane ? [`${item.item_lane} lane held: ${lane.hold_reason}`] : [])];+ const collisions = criticalPathEnabled(board) ? [] : itemFileCollisions(item, inFlight);+ return [...after, ...collisions, ...(item.item_hold_reason ? [`held: ${item.item_hold_reason}`] : []), ...(lane ? [`${item.item_lane} lane held: ${lane.hold_reason}`] : [])];}/**diff --git a/test/next-order.test.js b/test/next-order.test.jsindex a1cc4bf5..a628efee 100644--- a/test/next-order.test.js+++ b/test/next-order.test.js@@ -9,6 +9,7 @@ import { ENGINE_VERSION, MILESTONE_RANK_ENGINE } from '../src/machine.js';import { LINE_ORDER_ENGINE } from '../src/line-order-engine.js';import { setLineSetting } from '../src/line-settings.js';import { FOCUS_MILESTONE_ENGINE } from '../src/focus-milestone-engine.js';+import { CRITICAL_PATH_ENGINE } from '../src/critical-path-engine.js';import { exportBoard, importBoard } from '../src/exchange.js';import { createE2eHelpers } from './e2e-helpers.js';import { existsSync, mkdirSync, readFileSync } from 'node:fs';@@ -577,9 +578,10 @@ test('a reserve-next move with skipIds needs engine 69 and older engines replay});/** The native lifecycle is seeded here; these are board-state records, not claimed gate executions. */-test('next never hands out work that collides with work in flight [N2,B13,N20]', (t) => {+test('historical next never hands out work that collides with work in flight [N2,B13,N20,H16]', (t) => {const { board, builder, reviewer } = boardFixture();t.after(() => store.closeBoard(board));+ board.executionEngineVersion = CRITICAL_PATH_ENGINE - 1;const other = store.register(board, { lane: 'core', path: '/busy-builder', route: 'strong' });/** Name the actual files as a coordinator's ordinary brief does. */const add = (title, file) => store.addItem(board, { by: 'coordinator', lane: 'core', title,@@ -661,9 +663,10 @@ test('next leaves a brief without named files in its original order [N2,N20]', ('missing file declarations do not invent a reservation or change selection');});-test('the queue names the same noncolliding work next can serve [N2,N20]', (t) => {+test('the historical queue names the same noncolliding work next can serve [N2,N20,H16]', (t) => {const { board, builder } = boardFixture();t.after(() => store.closeBoard(board));+ board.executionEngineVersion = CRITICAL_PATH_ENGINE - 1;const busy = store.register(board, { lane: 'core', path: '/queue-busy', route: 'strong' });const a = store.addItem(board, { by: 'coordinator', lane: 'core', title: 'Already changing a file',brief: 'Files: src/shared.js' });