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

Function verifyContract

src/extraction/kernel/loader.ts:128–141  ·  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

126 * NodeKind/EdgeKind tables (kinds cross the boundary as indexes into these).
127 */
128function verifyContract(mod: KernelModule, from: string): boolean {
129 const info = mod.contractInfo();
130 if (info.abiVersion !== KERNEL_ABI_VERSION) {
131 debug(`${from}: ABI ${info.abiVersion} != expected ${KERNEL_ABI_VERSION} — ignoring kernel`);
132 return false;
133 }
134 const sameTable = (a: readonly string[], b: readonly string[]) =>
135 a.length === b.length && a.every((v, i) => v === b[i]);
136 if (!sameTable(info.nodeKinds, NODE_KINDS) || !sameTable(info.edgeKinds, EDGE_KINDS)) {
137 debug(`${from}: NodeKind/EdgeKind tables differ from src/types.ts — ignoring kernel`);
138 return false;
139 }
140 return true;
141}
142
143/**
144 * 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