{"record":{"id":"61dd6cdb8ce75502","repo":"ruvnet/ruflo","slug":"verifychain-not-available-in-js-fallback-use-proo","errorCode":null,"errorMessage":"verifyChain not available in JS fallback; use ProofChain.verifyChain()","messagePattern":"verifyChain not available in JS fallback; use ProofChain\\.verifyChain\\(\\)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/guidance/src/wasm-kernel.ts","lineNumber":171,"sourceCode":"      batchProcess: (ops: BatchOp[]): BatchResult[] => {\n        const json = (wasm.batch_process as (s: string) => string)(JSON.stringify(ops));\n        try { return JSON.parse(json); } catch { return []; }\n      },\n    };\n  } else {\n    // JS fallback — identical outputs, just slower\n    kernelInstance = {\n      available: false,\n      version: 'js-fallback',\n\n      sha256: jsSha256,\n      hmacSha256: jsHmacSha256,\n      contentHash: jsContentHash,\n      signEnvelope: jsHmacSha256,\n      verifyChain: () => {\n        // Chain verification requires full envelope parsing — not implemented\n        // in JS fallback because the ProofChain class already does it.\n        throw new Error('verifyChain not available in JS fallback; use ProofChain.verifyChain()');\n      },\n\n      scanSecrets: (): string[] => {\n        // Gate scanning in JS fallback defers to EnforcementGates class\n        throw new Error('scanSecrets not available in JS fallback; use EnforcementGates');\n      },\n      detectDestructive: (): string | null => {\n        throw new Error('detectDestructive not available in JS fallback; use EnforcementGates');\n      },\n\n      batchProcess: (): BatchResult[] => {\n        throw new Error('batchProcess requires WASM kernel');\n      },\n    };\n  }\n\n  return kernelInstance;\n}","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/guidance/src/wasm-kernel.ts#L153-L189","documentation":"getKernel() silently falls back to a pure-JS kernel when the WASM binary fails to load, and the fallback implements only the hashing primitives. verifyChain() deliberately throws because chain verification requires full envelope parsing, which is already implemented by the ProofChain class — the fallback refuses to duplicate it. Hitting this means you are on the JS fallback path and called a WASM-only method.","triggerScenarios":"Calling kernel.verifyChain(chainJson, key) on the object returned by getKernel() when tryLoadWasm() returned null — e.g. the .wasm asset is missing from the bundle, the runtime lacks WebAssembly support, or a CSP blocks wasm-unsafeeval.","commonSituations":"Bundlers (webpack/esbuild config) that fail to emit or resolve the .wasm sidecar asset; edge/serverless runtimes without WebAssembly; strict Content-Security-Policy headers; code written against the WASM feature set then deployed where WASM is unavailable.","solutions":["Use ProofChain.verifyChain() instead — it is the canonical pure-JS implementation and works everywhere","Feature-detect first with isWasmAvailable() and branch to the pure-JS path when it returns false","If you need the WASM speedup, fix asset loading: ensure the .wasm file ships with the bundle and the runtime permits WebAssembly"],"exampleFix":"// before\nconst ok = getKernel().verifyChain(chainJson, key); // throws in JS fallback\n\n// after\nimport { ProofChain } from './proof.js';\nconst ok = isWasmAvailable()\n  ? getKernel().verifyChain(chainJson, key)\n  : ProofChain.verifyChain(chainJson, key); // canonical JS implementation","handlingStrategy":"type-guard","validationCode":"import { getKernel, isWasmAvailable } from './wasm-kernel.js';\nimport { ProofChain } from './proof.js';\n\nfunction verifyAnywhere(chainJson: string, key: string): boolean {\n  return isWasmAvailable()\n    ? getKernel().verifyChain(chainJson, key)\n    : ProofChain.verifyChain(chainJson, key); // canonical pure-JS path\n}","typeGuard":"type FullKernel = WasmKernel & { available: true };\nfunction hasFullKernel(k: WasmKernel): k is FullKernel {\n  return k.available === true; // false => 'js-fallback', WASM-only ops throw\n}","tryCatchPattern":"try {\n  ok = kernel.verifyChain(chainJson, key);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('JS fallback')) {\n    ok = ProofChain.verifyChain(chainJson, key); // intentional fallback, not a failure\n  } else {\n    throw e;\n  }\n}","preventionTips":["Feature-detect once at startup with isWasmAvailable() and store the capability decision","Prefer ProofChain.verifyChain() unconditionally when performance is not critical","Verify the .wasm asset is emitted in production build artifacts"],"tags":["wasm","fallback","proof-chain","guidance","feature-detection"],"backgroundTag":"wasm-unavailable","analyzedSha":"fa13ee4ad60ac2090b1480656eb233521790d640","analyzedAt":"2026-08-18T21:34:22.708Z","contentChangedAt":"2026-08-18T21:34:22.708Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}