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
/** Compare live idle seats with compatible free work without counting a seat at multiple routes [A6,N2,B13]. */
import { ROUTES } from './route-escalation.js';
import { canTake } from './route-escalation.js';
import { firstRefusal } from './first-refusal-window.js';
import { takeoverReady } from './line-capacity.js';
/**
* Use the queue's held/dependency/collision-filtered entries and health's existing idle projection.
* A reserved return is free only to its original builder until the canonical takeover rule permits
* others. Read that boundary once per item, rather than once for every possible seat/item pair.
*/
export function routeWorkShortages(board, entries, agents) {
const restrictions = new Map();
/** Retain exactly the same builder reservation and configured takeover condition as next. */
function reservedFor(id) {
if (!restrictions.has(id)) {
const window = firstRefusal(board, id);
restrictions.set(id, window && !takeoverReady(board, id) ? window.builder : null);
}
return restrictions.get(id);
}
return ROUTES.flatMap(route => {
const idle = agents.filter(agent => agent.idle && agent.route === route);
if (!idle.length) return [];
const ids = new Set(idle.map(agent => agent.id));
const free = new Set(entries.filter(entry => canTake(route, entry.route)
&& (reservedFor(entry.id) === null || ids.has(reservedFor(entry.id)))).map(entry => entry.id)).size;
if (free >= idle.length) return [];
const since = idle.reduce((earliest, agent) => agent.idleSince < earliest ? agent.idleSince : earliest, idle[0].idleSince);
return [{ route, free, idle: idle.length, since }];
});
}