@variance-authority/core 0.5.9 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- {"version":3,"file":"merkle.js","sourceRoot":"","sources":["../../src/relate/merkle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,GAIN,MAAM,YAAY,CAAC;AA+BpB;;;;;;GAMG;AACH,MAAM,UAAU,SAAS,CAAC,KAAmB;IAC3C,MAAM,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;IACrC,MAAM,OAAO,GAAG,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC;IAErC,MAAM,EAAE,SAAS,EAAE,KAAK,EAAE,GAAG,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,GAAG,EAAkB,CAAC;IAC1C,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IAEnC,6EAA6E;IAC7E,MAAM,WAAW,GAAa,EAAE,CAAC;IACjC,MAAM,cAAc,GAAc,EAAE,CAAC;IAErC,+EAA+E;IAC/E,iEAAiE;IACjE,KAAK,MAAM,CAAC,EAAE,EAAE,OAAO,CAAC,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,KAAK,GAAa,EAAE,CAAC;QAC3B,MAAM,OAAO,GAAG,IAAI,GAAG,EAAU,CAAC;QAClC,IAAI,KAAK,GAAG,KAAK,CAAC;QAElB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,IAAI,GAA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AC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * The graph, hashed the way a build system hashes an action's inputs.\n *\n * Reachability answers *what could this diff have moved*. It needs a diff, which\n * means it needs `git`, a ref that exists, a checkout deep enough to contain it,\n * and the assumption that the ref is where this branch actually diverged. Every\n * one of those is a thing CI gets wrong, and each failure narrows a run.\n *\n * A Merkle digest asks a different question and needs none of them: **is this\n * subject's entire input closure byte-identical to the one that produced the\n * baseline?** One digest per node, over the node's own content and the digests of\n * everything it rests on — the same construction `bazel` uses to key an action,\n * and the same idea as this project's own content addressing, applied one level\n * out from the document to the source that produced it.\n *\n * What the difference buys:\n *\n * | situation | reachability | closure digest |\n * |---|---|---|\n * | a change, then a revert | both commits are in the diff, so it widens | identical digest, nothing runs |\n * | rebase, squash, branch switch | the merge base moves and the diff with it | unaffected — no ref is consulted |\n * | a shallow clone with no merge base | cannot answer; runs everything | unaffected |\n * | a dependency changed two hops away | reached, and observed | different digest, and observed |\n * | *why* a subject is being observed | a chain of files | a digest that differs |\n *\n * Neither replaces the other. The trail is the explanation, and the digest is the\n * proof; a run wants the digest to decide and the trail to justify.\n *\n * ## Cycles\n *\n * A dependency graph has them and a Merkle tree cannot. Strongly connected\n * components are condensed and hashed as a unit, so every file in a cycle carries\n * the same digest — which is exactly the truth about a cycle: no member of one can\n * be called unchanged while another moved.\n *\n * ## The digest that must never lie\n *\n * A digest says *these inputs are the same*. A file whose content was not supplied,\n * or whose own imports could not be read, breaks that claim — its closure may have\n * moved with no digest in this structure changing. Those nodes are marked\n * **volatile**, the mark propagates to everything that rests on them, and a\n * volatile node is treated as changed however its digest compares. A cache that\n * cannot be trusted must not be silently trusted.\n */\n\nimport { digestCombine, digestString, type Digest } from '../format/hash.js';\nimport {\n EDGE_KINDS,\n NODE_KINDS,\n keyOf,\n type EdgeKind,\n type NodeId,\n type Relations,\n} from './graph.js';\n\nexport interface ClosureInput {\n readonly relations: Relations;\n\n /**\n * Content digest per file, keyed by the file's path.\n *\n * A file with no entry is volatile: nothing here can tell whether it moved.\n * Component nodes take no entry — a component has no bytes of its own, and its\n * content is the file that declares it, which it already depends on.\n */\n readonly content: ReadonlyMap<string, Digest>;\n\n /** Restrict the closure to these edge kinds. Every kind by default. */\n readonly through?: Iterable<EdgeKind>;\n}\n\nexport interface Closure {\n /** `keyOf(kind, name)` → the digest of everything that node rests on. */\n readonly digests: ReadonlyMap<string, Digest>;\n\n /**\n * Nodes whose digest cannot prove sameness, and everything resting on them.\n *\n * Not an error. It is the honest half of the answer, and a caller that ignores\n * it converts a missing input into a subject nobody observed.\n */\n readonly volatile: ReadonlySet<string>;\n}\n\n/**\n * Hash every node over its own content and its whole dependency closure.\n *\n * One pass of Tarjan's algorithm and one pass over the components it emits, which\n * is `O(n + m)` — the same cost as the traversal next door, for an answer that\n * survives a rebase.\n */\nexport function closureOf(input: ClosureInput): Closure {\n const { relations, content } = input;\n const allowed = allowedKinds(input.through);\n const count = relations.names.length;\n\n const { component, order } = condense(relations, allowed);\n const digests = new Map<string, Digest>();\n const unstable = new Set<string>();\n\n // One digest per component, so every member of a cycle carries the same one.\n const byComponent: Digest[] = [];\n const shakyComponent: boolean[] = [];\n\n // Tarjan emits a component only after everything it can reach, so a dependency\n // digest is always already computed by the time it is read here.\n for (const [id, members] of order.entries()) {\n const terms: string[] = [];\n const outward = new Set<string>();\n let shaky = false;\n\n for (const node of members) {\n const kind = NODE_KINDS[relations.kinds[node]!]!;\n const name = relations.names[node]!;\n const own = kind === 'file' ? content.get(name) : SETTLED;\n\n if (own === undefined || relations.unknown[node] === 1) shaky = true;\n terms.push(`${kind}\\u0000${name}\\u0000${own ?? UNREAD}`);\n\n const { offset, target, kind: edgeKind } = relations.depends;\n for (let at = offset[node]!; at < offset[node + 1]!; at += 1) {\n if (allowed[edgeKind[at]!] !== 1) continue;\n\n const other = target[at]!;\n if (component[other] === id) continue;\n\n outward.add(`${EDGE_KINDS[edgeKind[at]!]!}\\u0000${byComponent[component[other]!]!}`);\n if (shakyComponent[component[other]!] === true) shaky = true;\n }\n }\n\n byComponent.push(\n digestCombine('relate.closure', [\n digestString([...terms].sort(byCodeUnit).join('\u0001')),\n digestString([...outward].sort(byCodeUnit).join('\u0001')),\n ]),\n );\n shakyComponent.push(shaky);\n }\n\n for (let node = 0; node < count; node += 1) {\n const key = keyOf(NODE_KINDS[relations.kinds[node]!]!, relations.names[node]!);\n digests.set(key, byComponent[component[node]!]!);\n if (shakyComponent[component[node]!] === true) unstable.add(key);\n }\n\n return { digests, volatile: unstable };\n}\n\n/** The term a node with content contributes when the content is not known. */\nconst UNREAD = '(unread)';\n\n/** The term a node that has no content of its own contributes. */\nconst SETTLED = '(declared)';\n\nexport interface Drift {\n /** Node keys whose closure is not provably the one it was. */\n readonly changed: readonly string[];\n /** The file paths among them. */\n readonly files: readonly string[];\n /** The component names among them. */\n readonly components: readonly string[];\n /** Node keys the earlier closure held and this one does not. */\n readonly gone: readonly string[];\n}\n\n/**\n * What moved between two closures, without consulting a repository.\n *\n * Three ways a node lands in `changed`, and only the first is a difference: its\n * digest differs, it is **new**, or it is **volatile** — the last because a node\n * whose inputs were not fully read has a digest that can match by accident, and a\n * selector that believed it would skip a subject on the strength of a hash over\n * bytes nobody hashed.\n */\nexport function driftedBetween(before: Closure, after: Closure): Drift {\n const changed: string[] = [];\n\n for (const [key, digest] of after.digests) {\n const was = before.digests.get(key);\n if (was === digest && !after.volatile.has(key) && !before.volatile.has(key)) continue;\n changed.push(key);\n }\n\n const gone = [...before.digests.keys()].filter((key) => !after.digests.has(key));\n\n return {\n changed: changed.sort(byCodeUnit),\n files: named(changed, 'file'),\n components: named(changed, 'component'),\n gone: gone.sort(byCodeUnit),\n };\n}\n\nfunction named(keys: readonly string[], kind: 'file' | 'component'): readonly string[] {\n const prefix = `${kind}:`;\n\n return keys\n .filter((key) => key.startsWith(prefix))\n .map((key) => key.slice(prefix.length))\n .sort(byCodeUnit);\n}\n\ninterface Condensation {\n /** Component index per node. */\n readonly component: Int32Array;\n /** Components in emission order — every one after everything it reaches. */\n readonly order: readonly (readonly NodeId[])[];\n}\n\n/**\n * Tarjan's strongly connected components, iteratively.\n *\n * Iterative because the recursion depth is the longest dependency chain in the\n * repository, and a deep monorepo would overflow a call stack on a structure whose\n * whole point is to be cheap. The emission order is the useful half: a component\n * appears only once everything it can reach has, which is the order a Merkle fold\n * needs and costs nothing extra to get.\n */\nfunction condense(relations: Relations, allowed: Uint8Array): Condensation {\n const count = relations.names.length;\n const { offset, target, kind } = relations.depends;\n\n const index = new Int32Array(count).fill(-1);\n const low = new Int32Array(count);\n const onStack = new Uint8Array(count);\n const component = new Int32Array(count).fill(-1);\n\n const pending: NodeId[] = [];\n const order: NodeId[][] = [];\n\n // Frames as two parallel arrays: the node, and how far through its edges it is.\n const frameNode: number[] = [];\n const frameEdge: number[] = [];\n let counter = 0;\n\n for (let root = 0; root < count; root += 1) {\n if (index[root] !== -1) continue;\n\n index[root] = counter;\n low[root] = counter;\n counter += 1;\n pending.push(root);\n onStack[root] = 1;\n frameNode.push(root);\n frameEdge.push(offset[root]!);\n\n while (frameNode.length > 0) {\n const node = frameNode[frameNode.length - 1]!;\n const at = frameEdge[frameEdge.length - 1]!;\n\n if (at < offset[node + 1]!) {\n frameEdge[frameEdge.length - 1] = at + 1;\n if (allowed[kind[at]!] !== 1) continue;\n\n const next = target[at]!;\n if (index[next] === -1) {\n index[next] = counter;\n low[next] = counter;\n counter += 1;\n pending.push(next);\n onStack[next] = 1;\n frameNode.push(next);\n frameEdge.push(offset[next]!);\n } else if (onStack[next] === 1) {\n if (index[next]! < low[node]!) low[node] = index[next]!;\n }\n continue;\n }\n\n frameNode.pop();\n frameEdge.pop();\n\n const parent = frameNode[frameNode.length - 1];\n if (parent !== undefined && low[node]! < low[parent]!) low[parent] = low[node]!;\n\n if (low[node] !== index[node]) continue;\n\n const members: NodeId[] = [];\n for (;;) {\n const member = pending.pop()!;\n onStack[member] = 0;\n component[member] = order.length;\n members.push(member);\n if (member === node) break;\n }\n order.push(members.sort((a, b) => a - b));\n }\n }\n\n return { component, order };\n}\n\n/**\n * The edge kinds a closure walks when the caller does not say.\n *\n * Listed rather than derived from `EDGE_KINDS`, and the difference is the whole\n * point. A digest is a claim about *which inputs* were folded, so changing the\n * fold silently changes every digest that exists — one edge kind added or\n * removed, and the next run finds nothing it can prove unchanged and re-observes\n * the entire suite while reporting a successful narrowing. Changing this list is\n * a decision with a cost, and it should read like one.\n *\n * `type` is not in it: a type-only import is erased before a render, so a change\n * behind one is not an input the render folded.\n *\n * `depends-on` is not in it either, for the opposite reason. It runs between two\n * packages, and a package node is a name rather than a content digest — an\n * install that moved is a fact the diff carries, never one a hash of names could\n * reveal. Folding it would add a term that cannot change and a walk that cannot\n * answer.\n */\nexport const CLOSURE_EDGES: readonly EdgeKind[] = [\n 'imports',\n 'reexports',\n 'dynamic',\n 'asset',\n 'declared-in',\n];\n\n/** Edge kinds as a lookup, so the inner loop tests a byte. */\nfunction allowedKinds(through: Iterable<EdgeKind> | undefined): Uint8Array {\n const allowed = new Uint8Array(EDGE_KINDS.length);\n\n for (const kind of through ?? CLOSURE_EDGES) {\n const at = EDGE_KINDS.indexOf(kind);\n if (at !== -1) allowed[at] = 1;\n }\n\n return allowed;\n}\n\nfunction byCodeUnit(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n"]}
1
+ {"version":3,"file":"merkle.js","sourceRoot":"","sources":["../../src/relate/merkle.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8CG;AAEH,OAAO,EAAE,aAAa,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EACL,UAAU,EACV,UAAU,EACV,KAAK,GAIN,MAAM,YAAY,CAAC;AA+BpB;;;;;;GAMG;AACH,MAAM,UAA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C,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC;AAC9B,CAAC;AAED;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,CAAC,MAAM,aAAa,GAAwB;IAChD,SAAS;IACT,WAAW;IACX,SAAS;IACT,OAAO;IACP,aAAa;CACd,CAAC;AAEF,8DAA8D;AAC9D,SAAS,YAAY,CAAC,OAAuC;IAC3D,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAElD,KAAK,MAAM,IAAI,IAAI,OAAO,IAAI,aAAa,EAAE,CAAC;QAC5C,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IAED,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,UAAU,CAAC,CAAS,EAAE,CAAS;IACtC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACpC,CAAC","sourcesContent":["/**\n * The graph, hashed the way a build system hashes an action's inputs.\n *\n * Reachability answers *what could this diff affect*. It needs a diff, which\n * means it needs `git`, a ref that exists, a checkout deep enough to contain it,\n * and the assumption that the ref is where this branch actually diverged. Every\n * one of those is a thing CI gets wrong, and each failure narrows a run.\n *\n * A Merkle digest asks a different question and needs none of them: **is this\n * subject's entire input closure byte-identical to the one that produced the\n * baseline?** One digest per node, over the node's own content and the digests of\n * everything it rests on — the same construction `bazel` uses to key an action,\n * and the same idea as this project's own content addressing, applied one level\n * out from the document to the source that produced it.\n *\n * What the difference buys:\n *\n * | situation | reachability | closure digest |\n * |---|---|---|\n * | a change, then a revert | both commits are in the diff, so it widens | identical digest, nothing runs |\n * | rebase, squash, branch switch | the merge base moves and the diff with it | unaffected — no ref is consulted |\n * | a shallow clone with no merge base | cannot answer; runs everything | unaffected |\n * | a dependency changed two hops away | affected, and observed | different digest, and observed |\n * | *why* a subject is being observed | a chain of files | a digest that differs |\n *\n * Neither replaces the other. The trail is the explanation, and the digest is the\n * proof; a run wants the digest to decide and the trail to justify.\n *\n * ## Cycles\n *\n * A dependency graph has them and a Merkle tree cannot. Strongly connected\n * components are condensed and hashed as a unit, so every file in a cycle carries\n * the same digest — which is exactly the truth about a cycle: no member of one can\n * be called unchanged while another changed.\n *\n * ## The digest that must never lie\n *\n * A digest says *these inputs are the same*. A file whose content was not supplied\n * breaks that claim — its bytes may have changed with no digest in this structure\n * changing. Those nodes are marked **volatile**, the mark propagates to everything\n * that rests on them, and a volatile node is treated as changed however its digest\n * compares. A cache that cannot be trusted must not be silently trusted.\n *\n * A file whose imports could not all be read is not volatile. Its bytes are\n * hashed, and the edges that were read are folded; the one nobody could read is\n * left to a recorded run, which sees the module load whatever named it.\n */\n\nimport { digestCombine, digestString, type Digest } from '../format/hash.js';\nimport {\n EDGE_KINDS,\n NODE_KINDS,\n keyOf,\n type EdgeKind,\n type NodeId,\n type Relations,\n} from './graph.js';\n\nexport interface ClosureInput {\n readonly relations: Relations;\n\n /**\n * Content digest per file, keyed by the file's path.\n *\n * A file with no entry is volatile: nothing here can tell whether it changed.\n * Component nodes take no entry — a component has no bytes of its own, and its\n * content is the file that declares it, which it already depends on.\n */\n readonly content: ReadonlyMap<string, Digest>;\n\n /** Restrict the closure to these edge kinds. Every kind by default. */\n readonly through?: Iterable<EdgeKind>;\n}\n\nexport interface Closure {\n /** `keyOf(kind, name)` → the digest of everything that node rests on. */\n readonly digests: ReadonlyMap<string, Digest>;\n\n /**\n * Nodes whose content was not supplied, and everything resting on them.\n *\n * Not an error. It is the honest half of the answer, and a caller that ignores\n * it converts a missing input into a subject nobody observed.\n */\n readonly volatile: ReadonlySet<string>;\n}\n\n/**\n * Hash every node over its own content and its whole dependency closure.\n *\n * One pass of Tarjan's algorithm and one pass over the components it emits, which\n * is `O(n + m)` — the same cost as the traversal next door, for an answer that\n * survives a rebase.\n */\nexport function closureOf(input: ClosureInput): Closure {\n const { relations, content } = input;\n const allowed = allowedKinds(input.through);\n const count = relations.names.length;\n\n const { component, order } = condense(relations, allowed);\n const digests = new Map<string, Digest>();\n const unstable = new Set<string>();\n\n // One digest per component, so every member of a cycle carries the same one.\n const byComponent: Digest[] = [];\n const shakyComponent: boolean[] = [];\n\n // Tarjan emits a component only after everything it can reach, so a dependency\n // digest is always already computed by the time it is read here.\n for (const [id, members] of order.entries()) {\n const terms: string[] = [];\n const outward = new Set<string>();\n let shaky = false;\n\n for (const node of members) {\n const kind = NODE_KINDS[relations.kinds[node]!]!;\n const name = relations.names[node]!;\n const own = kind === 'file' ? content.get(name) : SETTLED;\n\n if (own === undefined) shaky = true;\n terms.push(`${kind}\\u0000${name}\\u0000${own ?? UNREAD}`);\n\n const { offset, target, kind: edgeKind } = relations.depends;\n for (let at = offset[node]!; at < offset[node + 1]!; at += 1) {\n if (allowed[edgeKind[at]!] !== 1) continue;\n\n const other = target[at]!;\n if (component[other] === id) continue;\n\n outward.add(`${EDGE_KINDS[edgeKind[at]!]!}\\u0000${byComponent[component[other]!]!}`);\n if (shakyComponent[component[other]!] === true) shaky = true;\n }\n }\n\n byComponent.push(\n digestCombine('relate.closure', [\n digestString([...terms].sort(byCodeUnit).join('\u0001')),\n digestString([...outward].sort(byCodeUnit).join('\u0001')),\n ]),\n );\n shakyComponent.push(shaky);\n }\n\n for (let node = 0; node < count; node += 1) {\n const key = keyOf(NODE_KINDS[relations.kinds[node]!]!, relations.names[node]!);\n digests.set(key, byComponent[component[node]!]!);\n if (shakyComponent[component[node]!] === true) unstable.add(key);\n }\n\n return { digests, volatile: unstable };\n}\n\n/** The term a node with content contributes when the content is not known. */\nconst UNREAD = '(unread)';\n\n/** The term a node that has no content of its own contributes. */\nconst SETTLED = '(declared)';\n\nexport interface Drift {\n /** Node keys whose closure is not provably the one it was. */\n readonly changed: readonly string[];\n /** The file paths among them. */\n readonly files: readonly string[];\n /** The component names among them. */\n readonly components: readonly string[];\n /** Node keys the earlier closure held and this one does not. */\n readonly gone: readonly string[];\n}\n\n/**\n * What changed between two closures, without consulting a repository.\n *\n * Three ways a node lands in `changed`, and only the first is a difference: its\n * digest differs, it is **new**, or it is **volatile** — the last because a node\n * whose inputs were not fully read has a digest that can match by accident, and a\n * selector that believed it would skip a subject on the strength of a hash over\n * bytes nobody hashed.\n */\nexport function driftedBetween(before: Closure, after: Closure): Drift {\n const changed: string[] = [];\n\n for (const [key, digest] of after.digests) {\n const was = before.digests.get(key);\n if (was === digest && !after.volatile.has(key) && !before.volatile.has(key)) continue;\n changed.push(key);\n }\n\n const gone = [...before.digests.keys()].filter((key) => !after.digests.has(key));\n\n return {\n changed: changed.sort(byCodeUnit),\n files: named(changed, 'file'),\n components: named(changed, 'component'),\n gone: gone.sort(byCodeUnit),\n };\n}\n\nfunction named(keys: readonly string[], kind: 'file' | 'component'): readonly string[] {\n const prefix = `${kind}:`;\n\n return keys\n .filter((key) => key.startsWith(prefix))\n .map((key) => key.slice(prefix.length))\n .sort(byCodeUnit);\n}\n\ninterface Condensation {\n /** Component index per node. */\n readonly component: Int32Array;\n /** Components in emission order — every one after everything it reaches. */\n readonly order: readonly (readonly NodeId[])[];\n}\n\n/**\n * Tarjan's strongly connected components, iteratively.\n *\n * Iterative because the recursion depth is the longest dependency chain in the\n * repository, and a deep monorepo would overflow a call stack on a structure whose\n * whole point is to be cheap. The emission order is the useful half: a component\n * appears only once everything it can reach has, which is the order a Merkle fold\n * needs and costs nothing extra to get.\n */\nfunction condense(relations: Relations, allowed: Uint8Array): Condensation {\n const count = relations.names.length;\n const { offset, target, kind } = relations.depends;\n\n const index = new Int32Array(count).fill(-1);\n const low = new Int32Array(count);\n const onStack = new Uint8Array(count);\n const component = new Int32Array(count).fill(-1);\n\n const pending: NodeId[] = [];\n const order: NodeId[][] = [];\n\n // Frames as two parallel arrays: the node, and how far through its edges it is.\n const frameNode: number[] = [];\n const frameEdge: number[] = [];\n let counter = 0;\n\n for (let root = 0; root < count; root += 1) {\n if (index[root] !== -1) continue;\n\n index[root] = counter;\n low[root] = counter;\n counter += 1;\n pending.push(root);\n onStack[root] = 1;\n frameNode.push(root);\n frameEdge.push(offset[root]!);\n\n while (frameNode.length > 0) {\n const node = frameNode[frameNode.length - 1]!;\n const at = frameEdge[frameEdge.length - 1]!;\n\n if (at < offset[node + 1]!) {\n frameEdge[frameEdge.length - 1] = at + 1;\n if (allowed[kind[at]!] !== 1) continue;\n\n const next = target[at]!;\n if (index[next] === -1) {\n index[next] = counter;\n low[next] = counter;\n counter += 1;\n pending.push(next);\n onStack[next] = 1;\n frameNode.push(next);\n frameEdge.push(offset[next]!);\n } else if (onStack[next] === 1) {\n if (index[next]! < low[node]!) low[node] = index[next]!;\n }\n continue;\n }\n\n frameNode.pop();\n frameEdge.pop();\n\n const parent = frameNode[frameNode.length - 1];\n if (parent !== undefined && low[node]! < low[parent]!) low[parent] = low[node]!;\n\n if (low[node] !== index[node]) continue;\n\n const members: NodeId[] = [];\n for (;;) {\n const member = pending.pop()!;\n onStack[member] = 0;\n component[member] = order.length;\n members.push(member);\n if (member === node) break;\n }\n order.push(members.sort((a, b) => a - b));\n }\n }\n\n return { component, order };\n}\n\n/**\n * The edge kinds a closure walks when the caller does not say.\n *\n * Listed rather than derived from `EDGE_KINDS`, and the difference is the whole\n * point. A digest is a claim about *which inputs* were folded, so changing the\n * fold silently changes every digest that exists — one edge kind added or\n * removed, and the next run finds nothing it can prove unchanged and re-observes\n * the entire suite while reporting a successful narrowing. Changing this list is\n * a decision with a cost, and it should read like one.\n *\n * `type` is not in it: a type-only import is erased before a render, so a change\n * behind one is not an input the render folded.\n *\n * `depends-on` is not in it either, for the opposite reason. It runs between two\n * packages, and a package node is a name rather than a content digest — an\n * install that changed is a fact the diff carries, never one a hash of names could\n * reveal. Folding it would add a term that cannot change and a walk that cannot\n * answer.\n */\nexport const CLOSURE_EDGES: readonly EdgeKind[] = [\n 'imports',\n 'reexports',\n 'dynamic',\n 'asset',\n 'declared-in',\n];\n\n/** Edge kinds as a lookup, so the inner loop tests a byte. */\nfunction allowedKinds(through: Iterable<EdgeKind> | undefined): Uint8Array {\n const allowed = new Uint8Array(EDGE_KINDS.length);\n\n for (const kind of through ?? CLOSURE_EDGES) {\n const at = EDGE_KINDS.indexOf(kind);\n if (at !== -1) allowed[at] = 1;\n }\n\n return allowed;\n}\n\nfunction byCodeUnit(a: string, b: string): number {\n return a < b ? -1 : a > b ? 1 : 0;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Two questions, one traversal each way:
5
5
  *
6
- * - **`dependentsOf`** — against the arrows. *What could this change have moved?*
6
+ * - **`dependentsOf`** — against the arrows. *What could this change affect?*
7
7
  * This is the one selection asks, and it is asked once per run over the whole
8
8
  * seed set rather than once per seed, because a breadth-first search from many
9
9
  * sources costs the same as one from a single source.
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * ## The trail is not an extra
14
14
  *
15
- * Both return the path each node was reached by, and that is load-bearing rather
15
+ * Both return the path to each node they visit, and that is load-bearing rather
16
16
  * than a convenience. A selector that says *observe 41 of 300* is asking to be
17
17
  * trusted; a selector that says *`Button` is affected because
18
18
  * `src/tokens.css` → `src/button.css` → `src/Button.tsx`* has shown its work, and
@@ -29,27 +29,27 @@
29
29
  */
30
30
  import { type EdgeKind, type NodeId, type Relations } from './graph.js';
31
31
  /**
32
- * What one walk from a set of seeds reached: a mark over every node, the node
33
- * each one was reached through, and the reached ids in the order they were
34
- * found. `trailOf` reads the chain from any reached node back to its seed.
32
+ * What one walk from a set of seeds visited: a mark over every node, the node
33
+ * each one was entered from, and the visited ids in id order. `trailOf` reads
34
+ * the chain from any visited node back to its seed.
35
35
  */
36
- export interface Reach {
37
- /** `1` where the node was reached, including the seeds themselves. */
36
+ export interface Traversal {
37
+ /** `1` where the node was visited, including the seeds themselves. */
38
38
  readonly mask: Uint8Array;
39
39
  /**
40
- * The node that reached each one, or `-1` for a seed and for anything
41
- * unreached. Following it lands on a seed, which is what `trailOf` walks.
40
+ * The node each one was entered from, or `-1` for a seed and for anything
41
+ * not visited. Walking it back lands on a seed, which is what `trailOf` does.
42
42
  */
43
43
  readonly via: Int32Array;
44
- /** Reached nodes in id order, which is kind-major and then code unit. */
45
- readonly reached: readonly NodeId[];
44
+ /** Visited nodes in id order, which is kind-major and then code unit. */
45
+ readonly nodes: readonly NodeId[];
46
46
  }
47
- export interface ReachOptions {
47
+ export interface TraversalOptions {
48
48
  /**
49
49
  * Edge kinds to walk. `RUNTIME_EDGES` when absent: every kind but `type`.
50
50
  *
51
51
  * A type-only import is erased before anything runs, so a change behind it
52
- * moves no test and no pixel, and walking it selects work nothing can fail.
52
+ * fails no test and changes no pixel, and walking it selects work nothing can fail.
53
53
  * A caller asking a question about source rather than about a runtime passes
54
54
  * `EDGE_KINDS`, or any narrower list, and gets exactly those.
55
55
  */
@@ -65,15 +65,15 @@ export interface ReachOptions {
65
65
  readonly avoid?: Iterable<NodeId>;
66
66
  }
67
67
  /** What depends on these nodes, transitively. Against the arrows. */
68
- export declare function dependentsOf(relations: Relations, seeds: Iterable<NodeId>, options?: ReachOptions): Reach;
68
+ export declare function dependentsOf(relations: Relations, seeds: Iterable<NodeId>, options?: TraversalOptions): Traversal;
69
69
  /** What these nodes depend on, transitively. Along the arrows. */
70
- export declare function dependenciesOf(relations: Relations, seeds: Iterable<NodeId>, options?: ReachOptions): Reach;
70
+ export declare function dependenciesOf(relations: Relations, seeds: Iterable<NodeId>, options?: TraversalOptions): Traversal;
71
71
  /**
72
- * The chain from a reached node back to the seed that reached it.
72
+ * The chain from a visited node back to the seed the walk started it from.
73
73
  *
74
74
  * In arrival order — seed first, `id` last — because that is the direction the
75
75
  * sentence reads: *the token file, then the stylesheet, then the component*.
76
- * Empty when the node was never reached.
76
+ * Empty when the node was never visited.
77
77
  */
78
- export declare function trailOf(reach: Reach, id: NodeId): readonly NodeId[];
78
+ export declare function trailOf(traversal: Traversal, id: NodeId): readonly NodeId[];
79
79
  //# sourceMappingURL=reach.d.ts.map
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * Two questions, one traversal each way:
5
5
  *
6
- * - **`dependentsOf`** — against the arrows. *What could this change have moved?*
6
+ * - **`dependentsOf`** — against the arrows. *What could this change affect?*
7
7
  * This is the one selection asks, and it is asked once per run over the whole
8
8
  * seed set rather than once per seed, because a breadth-first search from many
9
9
  * sources costs the same as one from a single source.
@@ -12,7 +12,7 @@
12
12
  *
13
13
  * ## The trail is not an extra
14
14
  *
15
- * Both return the path each node was reached by, and that is load-bearing rather
15
+ * Both return the path to each node they visit, and that is load-bearing rather
16
16
  * than a convenience. A selector that says *observe 41 of 300* is asking to be
17
17
  * trusted; a selector that says *`Button` is affected because
18
18
  * `src/tokens.css` → `src/button.css` → `src/Button.tsx`* has shown its work, and
@@ -37,17 +37,17 @@ export function dependenciesOf(relations, seeds, options = {}) {
37
37
  return search(relations.depends, relations.names.length, seeds, options);
38
38
  }
39
39
  /**
40
- * The chain from a reached node back to the seed that reached it.
40
+ * The chain from a visited node back to the seed the walk started it from.
41
41
  *
42
42
  * In arrival order — seed first, `id` last — because that is the direction the
43
43
  * sentence reads: *the token file, then the stylesheet, then the component*.
44
- * Empty when the node was never reached.
44
+ * Empty when the node was never visited.
45
45
  */
46
- export function trailOf(reach, id) {
47
- if (reach.mask[id] !== 1)
46
+ export function trailOf(traversal, id) {
47
+ if (traversal.mask[id] !== 1)
48
48
  return [];
49
49
  const trail = [];
50
- for (let at = id; at !== -1; at = reach.via[at])
50
+ for (let at = id; at !== -1; at = traversal.via[at])
51
51
  trail.push(at);
52
52
  return trail.reverse();
53
53
  }
@@ -94,11 +94,11 @@ function search(adjacency, nodes, seeds, options) {
94
94
  // `queue` is in visit order, which depends on seed order. The result is in id
95
95
  // order instead, so a report built from it is byte-stable whatever order the
96
96
  // caller listed its changed files in.
97
- const reached = [];
97
+ const visited = [];
98
98
  for (let id = 0; id < nodes; id += 1)
99
99
  if (mask[id] === 1)
100
- reached.push(id);
101
- return { mask, via, reached };
100
+ visited.push(id);
101
+ return { mask, via, nodes: visited };
102
102
  }
103
103
  /** A kind filter as a byte lookup. */
104
104
  function allowedKinds(through) {
@@ -1 +1 @@
1
- {"version":3,"file":"reach.js","sourceRoot":"","sources":["../../src/relate/reach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAA8D,MAAM,YAAY,CAAC;AAwCnH,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAC1B,SAAoB,EACpB,KAAuB,EACvB,OAAO,GAAiB,EAAE;IAE1B,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,cAAc,CAC5B,SAAoB,EACpB,KAAuB,EACvB,OAAO,GAAiB,EAAE;IAE1B,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC3E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,OAAO,CAAC,KAAY,EAAE,EAAU;IAC9C,IAAI,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,CAAC;IAEpC,MAAM,KAAK,GAAa,EAAE,CAAC;IAC3B,KAAK,IAAI,EAAE,GAAW,EAAE,EAAE,EAAE,KAAK,CAAC,CAAC,EAAE,EAAE,GAAG,KAAK,CAAC,GAAG,CAAC,E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C;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Walking the graph, and being able to say why the walk arrived.\n *\n * Two questions, one traversal each way:\n *\n * - **`dependentsOf`** — against the arrows. *What could this change have moved?*\n * This is the one selection asks, and it is asked once per run over the whole\n * seed set rather than once per seed, because a breadth-first search from many\n * sources costs the same as one from a single source.\n * - **`dependenciesOf`** — along them. *What does this rest on?* The cache-key\n * question, and the one a reviewer asks about a file they have not read.\n *\n * ## The trail is not an extra\n *\n * Both return the path each node was reached by, and that is load-bearing rather\n * than a convenience. A selector that says *observe 41 of 300* is asking to be\n * trusted; a selector that says *`Button` is affected because\n * `src/tokens.css` → `src/button.css` → `src/Button.tsx`* has shown its work, and\n * the operator can see the edge that is wrong when one is.\n *\n * Recording it costs one `Int32Array` and nothing in the inner loop — the parent\n * is written exactly where the visited mark already is.\n *\n * ## Cycles\n *\n * Import graphs have them, routinely and legitimately. Nothing here treats a\n * cycle as an error: the visited mask means every node is expanded once, so a\n * cycle terminates the same way any revisit does.\n */\n\nimport { EDGE_KINDS, RUNTIME_EDGES, type Adjacency, type EdgeKind, type NodeId, type Relations } from './graph.js';\n\n/**\n * What one walk from a set of seeds reached: a mark over every node, the node\n * each one was reached through, and the reached ids in the order they were\n * found. `trailOf` reads the chain from any reached node back to its seed.\n */\nexport interface Reach {\n /** `1` where the node was reached, including the seeds themselves. */\n readonly mask: Uint8Array;\n /**\n * The node that reached each one, or `-1` for a seed and for anything\n * unreached. Following it lands on a seed, which is what `trailOf` walks.\n */\n readonly via: Int32Array;\n /** Reached nodes in id order, which is kind-major and then code unit. */\n readonly reached: readonly NodeId[];\n}\n\nexport interface ReachOptions {\n /**\n * Edge kinds to walk. `RUNTIME_EDGES` when absent: every kind but `type`.\n *\n * A type-only import is erased before anything runs, so a change behind it\n * moves no test and no pixel, and walking it selects work nothing can fail.\n * A caller asking a question about source rather than about a runtime passes\n * `EDGE_KINDS`, or any narrower list, and gets exactly those.\n */\n readonly through?: Iterable<EdgeKind>;\n /**\n * Nodes the walk never enters, seeds included.\n *\n * A module a test file mocks is replaced for that file's whole run, so a\n * question asked from the file's point of view is asked of a graph with the\n * module taken out — not one edge, the node. Marking it visited before the\n * walk starts is exactly that removal, at no cost in the inner loop.\n */\n readonly avoid?: Iterable<NodeId>;\n}\n\n/** What depends on these nodes, transitively. Against the arrows. */\nexport function dependentsOf(\n relations: Relations,\n seeds: Iterable<NodeId>,\n options: ReachOptions = {},\n): Reach {\n return search(relations.dependents, relations.names.length, seeds, options);\n}\n\n/** What these nodes depend on, transitively. Along the arrows. */\nexport function dependenciesOf(\n relations: Relations,\n seeds: Iterable<NodeId>,\n options: ReachOptions = {},\n): Reach {\n return search(relations.depends, relations.names.length, seeds, options);\n}\n\n/**\n * The chain from a reached node back to the seed that reached it.\n *\n * In arrival order — seed first, `id` last — because that is the direction the\n * sentence reads: *the token file, then the stylesheet, then the component*.\n * Empty when the node was never reached.\n */\nexport function trailOf(reach: Reach, id: NodeId): readonly NodeId[] {\n if (reach.mask[id] !== 1) return [];\n\n const trail: NodeId[] = [];\n for (let at: number = id; at !== -1; at = reach.via[at]!) trail.push(at);\n return trail.reverse();\n}\n\n/**\n * Breadth-first over one direction, from every seed at once.\n *\n * A plain array as the queue with a moving head rather than `shift()`, which is\n * `O(n)` per call in every engine that does not special-case it and turns a\n * linear traversal quadratic on the graphs this exists for.\n *\n * Breadth-first rather than depth-first for the trail's sake: the parent\n * recorded is then the one on a *shortest* path, so the explanation a run prints\n * is the shortest true one rather than whichever the stack happened to unwind.\n */\nfunction search(\n adjacency: Adjacency,\n nodes: number,\n seeds: Iterable<NodeId>,\n options: ReachOptions,\n): Reach {\n const mask = new Uint8Array(nodes);\n const via = new Int32Array(nodes).fill(-1);\n const queue: NodeId[] = [];\n\n const avoided = new Uint8Array(nodes);\n for (const id of options.avoid ?? []) if (id >= 0 && id < nodes) avoided[id] = 1;\n\n for (const seed of seeds) {\n if (seed < 0 || seed >= nodes || mask[seed] === 1 || avoided[seed] === 1) continue;\n mask[seed] = 1;\n queue.push(seed);\n }\n\n const allowed = allowedKinds(options.through);\n\n for (let head = 0; head < queue.length; head += 1) {\n const node = queue[head]!;\n const end = adjacency.offset[node + 1]!;\n\n for (let at = adjacency.offset[node]!; at < end; at += 1) {\n if (allowed[adjacency.kind[at]!] !== 1) continue;\n\n const next = adjacency.target[at]!;\n if (mask[next] === 1 || avoided[next] === 1) continue;\n\n mask[next] = 1;\n via[next] = node;\n queue.push(next);\n }\n }\n\n // `queue` is in visit order, which depends on seed order. The result is in id\n // order instead, so a report built from it is byte-stable whatever order the\n // caller listed its changed files in.\n const reached: NodeId[] = [];\n for (let id = 0; id < nodes; id += 1) if (mask[id] === 1) reached.push(id);\n\n return { mask, via, reached };\n}\n\n/** A kind filter as a byte lookup. */\nfunction allowedKinds(through: Iterable<EdgeKind> | undefined): Uint8Array {\n const allowed = new Uint8Array(EDGE_KINDS.length);\n for (const kind of through ?? RUNTIME_EDGES) {\n const at = EDGE_KINDS.indexOf(kind);\n if (at !== -1) allowed[at] = 1;\n }\n return allowed;\n}\n"]}
1
+ {"version":3,"file":"reach.js","sourceRoot":"","sources":["../../src/relate/reach.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,EAAE,UAAU,EAAE,aAAa,EAA8D,MAAM,YAAY,CAAC;AAwCnH,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAC1B,SAAoB,EACpB,KAAuB,EACvB,OAAO,GAAqB,EAAE;IAE9B,OAAO,MAAM,CAAC,SAAS,CAAC,UAAU,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC;AAC9E,CAAC;AAED,kEAAkE;AAClE,MAAM,UAAU,cAAc,CAC5B,SAAoB,EACpB,KAAuB,EACvB,OAAO,GAAqB,EAAE;IAE9B,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,EAAE,SAAS,CAAC,KAAK,CAA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AAO,EAAE,CAAC;AACvC,CAAC;AAED,sCAAsC;AACtC,SAAS,YAAY,CAAC,OAAuC;IAC3D,MAAM,OAAO,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;IAClD,KAAK,MAAM,IAAI,IAAI,OAAO,IAAI,aAAa,EAAE,CAAC;QAC5C,MAAM,EAAE,GAAG,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,EAAE,KAAK,CAAC,CAAC;YAAE,OAAO,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IACjC,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC","sourcesContent":["/**\n * Walking the graph, and being able to say why the walk arrived.\n *\n * Two questions, one traversal each way:\n *\n * - **`dependentsOf`** — against the arrows. *What could this change affect?*\n * This is the one selection asks, and it is asked once per run over the whole\n * seed set rather than once per seed, because a breadth-first search from many\n * sources costs the same as one from a single source.\n * - **`dependenciesOf`** — along them. *What does this rest on?* The cache-key\n * question, and the one a reviewer asks about a file they have not read.\n *\n * ## The trail is not an extra\n *\n * Both return the path to each node they visit, and that is load-bearing rather\n * than a convenience. A selector that says *observe 41 of 300* is asking to be\n * trusted; a selector that says *`Button` is affected because\n * `src/tokens.css` → `src/button.css` → `src/Button.tsx`* has shown its work, and\n * the operator can see the edge that is wrong when one is.\n *\n * Recording it costs one `Int32Array` and nothing in the inner loop — the parent\n * is written exactly where the visited mark already is.\n *\n * ## Cycles\n *\n * Import graphs have them, routinely and legitimately. Nothing here treats a\n * cycle as an error: the visited mask means every node is expanded once, so a\n * cycle terminates the same way any revisit does.\n */\n\nimport { EDGE_KINDS, RUNTIME_EDGES, type Adjacency, type EdgeKind, type NodeId, type Relations } from './graph.js';\n\n/**\n * What one walk from a set of seeds visited: a mark over every node, the node\n * each one was entered from, and the visited ids in id order. `trailOf` reads\n * the chain from any visited node back to its seed.\n */\nexport interface Traversal {\n /** `1` where the node was visited, including the seeds themselves. */\n readonly mask: Uint8Array;\n /**\n * The node each one was entered from, or `-1` for a seed and for anything\n * not visited. Walking it back lands on a seed, which is what `trailOf` does.\n */\n readonly via: Int32Array;\n /** Visited nodes in id order, which is kind-major and then code unit. */\n readonly nodes: readonly NodeId[];\n}\n\nexport interface TraversalOptions {\n /**\n * Edge kinds to walk. `RUNTIME_EDGES` when absent: every kind but `type`.\n *\n * A type-only import is erased before anything runs, so a change behind it\n * fails no test and changes no pixel, and walking it selects work nothing can fail.\n * A caller asking a question about source rather than about a runtime passes\n * `EDGE_KINDS`, or any narrower list, and gets exactly those.\n */\n readonly through?: Iterable<EdgeKind>;\n /**\n * Nodes the walk never enters, seeds included.\n *\n * A module a test file mocks is replaced for that file's whole run, so a\n * question asked from the file's point of view is asked of a graph with the\n * module taken out — not one edge, the node. Marking it visited before the\n * walk starts is exactly that removal, at no cost in the inner loop.\n */\n readonly avoid?: Iterable<NodeId>;\n}\n\n/** What depends on these nodes, transitively. Against the arrows. */\nexport function dependentsOf(\n relations: Relations,\n seeds: Iterable<NodeId>,\n options: TraversalOptions = {},\n): Traversal {\n return search(relations.dependents, relations.names.length, seeds, options);\n}\n\n/** What these nodes depend on, transitively. Along the arrows. */\nexport function dependenciesOf(\n relations: Relations,\n seeds: Iterable<NodeId>,\n options: TraversalOptions = {},\n): Traversal {\n return search(relations.depends, relations.names.length, seeds, options);\n}\n\n/**\n * The chain from a visited node back to the seed the walk started it from.\n *\n * In arrival order — seed first, `id` last — because that is the direction the\n * sentence reads: *the token file, then the stylesheet, then the component*.\n * Empty when the node was never visited.\n */\nexport function trailOf(traversal: Traversal, id: NodeId): readonly NodeId[] {\n if (traversal.mask[id] !== 1) return [];\n\n const trail: NodeId[] = [];\n for (let at: number = id; at !== -1; at = traversal.via[at]!) trail.push(at);\n return trail.reverse();\n}\n\n/**\n * Breadth-first over one direction, from every seed at once.\n *\n * A plain array as the queue with a moving head rather than `shift()`, which is\n * `O(n)` per call in every engine that does not special-case it and turns a\n * linear traversal quadratic on the graphs this exists for.\n *\n * Breadth-first rather than depth-first for the trail's sake: the parent\n * recorded is then the one on a *shortest* path, so the explanation a run prints\n * is the shortest true one rather than whichever the stack happened to unwind.\n */\nfunction search(\n adjacency: Adjacency,\n nodes: number,\n seeds: Iterable<NodeId>,\n options: TraversalOptions,\n): Traversal {\n const mask = new Uint8Array(nodes);\n const via = new Int32Array(nodes).fill(-1);\n const queue: NodeId[] = [];\n\n const avoided = new Uint8Array(nodes);\n for (const id of options.avoid ?? []) if (id >= 0 && id < nodes) avoided[id] = 1;\n\n for (const seed of seeds) {\n if (seed < 0 || seed >= nodes || mask[seed] === 1 || avoided[seed] === 1) continue;\n mask[seed] = 1;\n queue.push(seed);\n }\n\n const allowed = allowedKinds(options.through);\n\n for (let head = 0; head < queue.length; head += 1) {\n const node = queue[head]!;\n const end = adjacency.offset[node + 1]!;\n\n for (let at = adjacency.offset[node]!; at < end; at += 1) {\n if (allowed[adjacency.kind[at]!] !== 1) continue;\n\n const next = adjacency.target[at]!;\n if (mask[next] === 1 || avoided[next] === 1) continue;\n\n mask[next] = 1;\n via[next] = node;\n queue.push(next);\n }\n }\n\n // `queue` is in visit order, which depends on seed order. The result is in id\n // order instead, so a report built from it is byte-stable whatever order the\n // caller listed its changed files in.\n const visited: NodeId[] = [];\n for (let id = 0; id < nodes; id += 1) if (mask[id] === 1) visited.push(id);\n\n return { mask, via, nodes: visited };\n}\n\n/** A kind filter as a byte lookup. */\nfunction allowedKinds(through: Iterable<EdgeKind> | undefined): Uint8Array {\n const allowed = new Uint8Array(EDGE_KINDS.length);\n for (const kind of through ?? RUNTIME_EDGES) {\n const at = EDGE_KINDS.indexOf(kind);\n if (at !== -1) allowed[at] = 1;\n }\n return allowed;\n}\n"]}
@@ -8,18 +8,19 @@
8
8
  * without touching a disk. `core` performs no I/O (ADR-0006); whoever owns the
9
9
  * disk produces these and hands them over.
10
10
  *
11
- * ## An empty record and an unreadable one are different facts
11
+ * ## An unreadable file contributes what was read of it
12
12
  *
13
- * A file with no imports and a file nothing could parse both produce a record
14
- * with no edges, and treating them alike is the one mistake that turns this from
15
- * a saving into a silent hole: the second one may import anything, including
16
- * whatever just changed. So `unknown` carries the *reason* the edges are not
17
- * known, and every consumer seeds its traversal with those files (ADR-0002 —
18
- * absent is not empty, and here absent is not even absent, it is *unread*).
13
+ * A `require(name)` with a variable for a name, an `import('./' + page)`, a
14
+ * parse that did not finish: the edges a reader could see are recorded, and the
15
+ * one it could not is not guessed at. `unknown` carries the sentence saying why,
16
+ * for whoever reports on the scan. It widens no walk. Seeding every such file as
17
+ * though it had changed turns one computed `require` into a whole run on every
18
+ * diff, forever, and the edge it hides is exactly what a recorded run sees: the
19
+ * module loaded, whatever expression named it.
19
20
  */
20
21
  import type { Digest } from '../format/hash.js';
21
22
  import { type EdgeKind, type Node, type Relations } from './graph.js';
22
- import { type Reach, type ReachOptions } from './reach.js';
23
+ import { type Traversal, type TraversalOptions } from './reach.js';
23
24
  export interface FileEdge {
24
25
  /** Repository-relative, already resolved. A specifier is not an edge. */
25
26
  readonly to: string;
@@ -45,7 +46,7 @@ export interface FileRecord {
45
46
  /**
46
47
  * The content digest this record was read from.
47
48
  *
48
- * Two jobs. It lets a second scan skip the parse for a file that has not moved,
49
+ * Two jobs. It lets a second scan skip the parse for a file that has not changed,
49
50
  * which is the difference between a scan that costs a second and one nobody
50
51
  * leaves enabled. And it is the leaf of the Merkle fold in
51
52
  * [`merkle.ts`](./merkle.ts) — a file with no digest is one nothing can prove
@@ -65,8 +66,8 @@ export interface FileRecord {
65
66
  * dependency, and what the install currently has under that name is a question
66
67
  * for the lockfile ([`sense/lock`](../../../sense/src/lock/index.ts)).
67
68
  *
68
- * A file that imports `@mui/material` is moved by `@mui/material` moving; a
69
- * file that does not, is not. That is the whole rule, and it is why this is
69
+ * A file that imports `@mui/material` is affected when `@mui/material`
70
+ * changes; a file that does not, is not. That is the whole rule, and it is why this is
70
71
  * read from the imports rather than from a manifest: a `package.json` says what
71
72
  * a workspace may use, and the imports say what a file does use.
72
73
  */
@@ -81,11 +82,11 @@ export interface FileRecord {
81
82
  */
82
83
  readonly unresolved?: readonly string[];
83
84
  /**
84
- * Why this file's outgoing edges could not be enumerated, when they could not.
85
+ * Why this file's outgoing edges could not all be enumerated, when they could not.
85
86
  *
86
- * Present means *this file may depend on anything*. The sentence is carried
87
- * rather than a flag, because it ends up in the paragraph explaining why a run
88
- * observed more than the operator expected.
87
+ * The edges that were read are in `edges`; this names what was not. A walk
88
+ * treats the file like any other, and the edge nobody could read is left to a
89
+ * recorded run, which sees the module load whatever named it.
89
90
  */
90
91
  readonly unknown?: string;
91
92
  }
@@ -113,32 +114,26 @@ export interface RelationsOptions {
113
114
  * Optional, and a graph without them is not wrong, only shorter-sighted: it
114
115
  * answers a change to a package some file imports directly, and says nothing
115
116
  * about a change three levels down. Supplying them is what turns *`jsdom`
116
- * moved* into *every test whose environment is built on it*.
117
+ * changed* into *every test whose environment is built on it*.
117
118
  */
118
119
  readonly depends?: Iterable<readonly [string, string]>;
119
120
  }
120
- export interface Hole {
121
- /** The file whose outgoing edges could not be enumerated. */
122
- readonly file: string;
123
- /** Why, in the words of whoever read it. Absent when nobody said. */
124
- readonly because?: string;
125
- }
126
121
  /**
127
- * What one backwards walk over the file graph found, and what widened it.
122
+ * What one backwards walk over the file graph found.
128
123
  *
129
124
  * Every field is part of one answer and none of them stands alone: `files` is
130
- * the answer, `missing` and `opaque` are the two ways it is not the whole truth,
131
- * and `reach` is what an explanation is read back out of. A caller that took
125
+ * the answer, `missing` is what it could not say anything about, and
126
+ * `traversal` is what an explanation is read back out of. A caller that took
132
127
  * `files` and dropped the rest would be a caller that cannot say whether the
133
128
  * list is narrow because the diff was small or because the scan never ran.
134
129
  */
135
- export interface Reached {
136
- /** Files the change could have moved, including the changed files themselves. */
130
+ export interface Affected {
131
+ /** Files the change could affect, including the changed files themselves. */
137
132
  readonly files: readonly string[];
138
133
  /** Components declared in any of them. */
139
134
  readonly components: readonly string[];
140
135
  /**
141
- * Packages the change could have moved, including the changed packages
136
+ * Packages the change could affect, including the changed packages
142
137
  * themselves and everything the install resolved beneath them.
143
138
  *
144
139
  * Reported rather than used: the answer a caller acts on is in `files`, and
@@ -151,52 +146,40 @@ export interface Reached {
151
146
  * Changed paths the graph does not hold.
152
147
  *
153
148
  * Never silently ignored. A `README.md` belongs here and means nothing; a
154
- * source file belongs here only because the scan never reached it, and the
149
+ * source file belongs here only because the scan never read it, and the
155
150
  * caller — which knows where it told the scan to look — is the one that can
156
151
  * tell those apart.
157
152
  */
158
153
  readonly missing: readonly string[];
159
154
  /**
160
- * Files seeded because their own edges are unknown, rather than because
161
- * anything reached them, each with the reason it could not be read.
162
- *
163
- * Counted separately so that "we widened" never hides inside "we found", and
164
- * carrying its sentence so the widening is a work item rather than a tax: *four
165
- * files could not be read* is something to live with, and ``src/legacy.js — a
166
- * computed require()`` is something to fix.
167
- */
168
- readonly opaque: readonly Hole[];
169
- /**
170
- * Files the graph reached and their own shadows cut: every trail from a
155
+ * Files the walk visited and their own shadows cut: every trail from a
171
156
  * changed file to each one crossed a module the file replaces for its run.
172
157
  * Listed so the report can say a test was left out and by whose word.
173
158
  */
174
159
  readonly shadowed: readonly string[];
175
- /** The traversal, kept so a caller can ask how any one file was reached. */
176
- readonly reach: Reach;
160
+ /** The walk itself, kept so a caller can ask why any one file is in the answer. */
161
+ readonly traversal: Traversal;
177
162
  }
178
- export interface MovedOptions extends ReachOptions {
163
+ export interface AffectedOptions extends TraversalOptions {
179
164
  /**
180
165
  * Per file, the files it takes out of its own graph: what a test mocks.
181
166
  *
182
167
  * A row is a fact about one file's run and nothing else's, so it is kept
183
168
  * beside the records rather than in them — the records say what the text
184
- * imports, this says what the run never reaches. A file with a row is moved
169
+ * imports, this says what the run never loads. A file with a row is affected
185
170
  * only if some trail from a changed file arrives at it without crossing a
186
- * file in its row, and what is reached only *through* it goes with it: the
171
+ * file in its row, and what depends on the change only *through* it goes with it: the
187
172
  * component a story declares, the test a setup file's mocks hold for. The
188
173
  * graph's own table when absent ({@link Relations.shadows}).
189
174
  */
190
175
  readonly shadows?: ReadonlyMap<string, readonly string[]>;
191
176
  }
192
177
  /**
193
- * What a set of changed files could have moved.
178
+ * What a set of changed files could affect.
194
179
  *
195
- * The seed set is the changed files **and every file whose edges are unknown**,
196
- * which is the rule the whole structure rests on. An unreadable file might import
197
- * the one that changed; seeding it means everything depending on *it* is observed
198
- * too, and the cost is a collection rather than a green run over an unwatched
199
- * surface.
180
+ * The seed set is the changed files and nothing else. A file whose edges could
181
+ * not all be read is walked through the edges that were; the one nobody saw is
182
+ * a recorded run's to answer, not a reason to seed the file on every diff.
200
183
  *
201
184
  * A seed is a path, or a node naming its own kind. The second form is how a
202
185
  * changed *package* enters: a bare string keeps meaning a file, because that is
@@ -209,12 +192,12 @@ export interface MovedOptions extends ReachOptions {
209
192
  * One breadth-first search, whatever the number of changed files, over the
210
193
  * runtime edges unless the caller names others.
211
194
  */
212
- export declare function movedBy(relations: Relations, changed: Iterable<string | Node>, options?: MovedOptions): Reached;
195
+ export declare function affectedBy(relations: Relations, changed: Iterable<string | Node>, options?: AffectedOptions): Affected;
213
196
  /**
214
- * How one file or component was reached, as the chain that reached it.
197
+ * Why one file or component is affected: the chain of imports from a changed file to it.
215
198
  *
216
199
  * The sentence a run prints when somebody asks why a subject was observed. Empty
217
- * when the node was not reached at all.
200
+ * when the node is not affected at all.
218
201
  */
219
- export declare function explain(relations: Relations, moved: Reached, node: Node): readonly string[];
202
+ export declare function explain(relations: Relations, affected: Affected, node: Node): readonly string[];
220
203
  //# sourceMappingURL=records.d.ts.map