refactor(graph): the missing-dependency note is a string, not a callback

topoSort, finalizeGraph, assertNeedsSatisfiable and finalize all threaded a
`(key: string) => string`, and no caller ever read `key` — the one producer,
in prepareGraph, is `() => ...`. The note names which teapots did not connect,
which does not vary by token, so the parameter was machinery for a
customization nothing asked for.

Signed-off-by: Diego Resendez <diego.resendez@zero-oneit.com>
This commit is contained in:
chrnx committed 2026-09-12 15:40:25 -05:00
1 parent bff8778112
commit 727987286b
2 files changed
+7 -7

No files matched your search

+2 -2
View File
@@ -43,7 +43,7 @@ export interface GraphNode {
}
/** Orders nodes so every dependency precedes its dependents; throws on missing keys or cycles. */
export function topoSort(nodes: GraphNode[], seedKeys: string[], note?: (key: string) => string): GraphNode[] {
export function topoSort(nodes: GraphNode[], seedKeys: string[], note = ''): GraphNode[] {
const producedBy = new Map<string, GraphNode>();
for (const node of nodes) for (const key of node.provides) producedBy.set(key, node);
@@ -51,7 +51,7 @@ export function topoSort(nodes: GraphNode[], seedKeys: string[], note?: (key: st
for (const node of nodes) {
for (const key of node.needs) {
if (!seedKeys.includes(key) && !producedBy.has(key)) {
throw new Error(`missing dependency: ${key} needed by ${node.name}${note?.(key) ?? ''}`);
throw new Error(`missing dependency: ${key} needed by ${node.name}${note}`);
}
}
}