MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / verifyContract

Function verifyContract

src/extraction/kernel/loader.ts:124–137  ·  view source on GitHub ↗

* Verify the binary speaks our wire contract: same ABI version and byte-equal * NodeKind/EdgeKind tables (kinds cross the boundary as indexes into these).

(mod: KernelModule, from: string)

Source from the content-addressed store, hash-verified

122 * NodeKind/EdgeKind tables (kinds cross the boundary as indexes into these).
123 */
124function verifyContract(mod: KernelModule, from: string): boolean {
125 const info = mod.contractInfo();
126 if (info.abiVersion !== KERNEL_ABI_VERSION) {
127 debug(`${from}: ABI ${info.abiVersion} != expected ${KERNEL_ABI_VERSION} — ignoring kernel`);
128 return false;
129 }
130 const sameTable = (a: readonly string[], b: readonly string[]) =>
131 a.length === b.length && a.every((v, i) => v === b[i]);
132 if (!sameTable(info.nodeKinds, NODE_KINDS) || !sameTable(info.edgeKinds, EDGE_KINDS)) {
133 debug(`${from}: NodeKind/EdgeKind tables differ from src/types.ts — ignoring kernel`);
134 return false;
135 }
136 return true;
137}
138
139/**
140 * Load (once per process) and return the kernel module, or null when

Callers 1

getKernelFunction · 0.85

Calls 3

sameTableFunction · 0.85
contractInfoMethod · 0.80
debugFunction · 0.70

Tested by

no test coverage detected