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
/** Validate retained item dependencies independently of board write orchestration. */
import { itemById } from './board-query.js';
import { Refused } from './refused.js';
import * as itemDependencies from './item-dependencies.js';
/** Validate that dependencies exist, remain usable, and cannot lead back to the edited item. */
export function validateItemDependencies(board, itemId, after) {
itemDependencies.dependencyValues(after);
const direct = itemDependencies.localDependencyIds(after).map((dependency) => itemById(board, dependency));
const withdrawn = direct.find((dependency) => dependency.item_status === 'withdrawn');
if (withdrawn) {
throw new Refused('WITHDRAWN', `item #${withdrawn.item_id} is withdrawn; nothing can wait on it`);
}
if (itemId === null) return;
const visited = new Set();
const pending = itemDependencies.localDependencyIds(after);
while (pending.length) {
const dependency = pending.pop();
if (dependency === itemId) {
throw new Refused('DEPENDENCY_CYCLE', `item #${itemId} cannot wait on itself through its dependencies; change --after to remove the cycle`);
}
if (visited.has(dependency)) continue;
const item = itemById(board, dependency);
visited.add(dependency);
pending.push(...itemDependencies.localDependencyIds(item));
}
}