{"record":{"id":"2c8a101546aea48c","repo":"ruvnet/ruflo","slug":"batchprocess-requires-wasm-kernel","errorCode":null,"errorMessage":"batchProcess requires WASM kernel","messagePattern":"batchProcess requires WASM kernel","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/guidance/src/wasm-kernel.ts","lineNumber":183,"sourceCode":"      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}\n\n/**\n * Check if the WASM kernel is available without initializing it.\n */\nexport function isWasmAvailable(): boolean {\n  return getKernel().available;\n}\n\n/**\n * Reset the kernel instance (for testing).\n */\nexport function resetKernel(): void {","sourceCodeStart":165,"sourceCodeEnd":201,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/guidance/src/wasm-kernel.ts#L165-L201","documentation":"batchProcess() is the only kernel operation with no pure-JS equivalent: the fallback stub throws unconditionally because batched envelope processing is only worth implementing in the accelerated WASM path. Unlike verifyChain/scanSecrets/detectDestructive, there is no redirected implementation — you must either have WASM or do the operations sequentially yourself.","triggerScenarios":"Calling getKernel().batchProcess(ops) when the WASM kernel is unavailable — the JS fallback's batchProcess stub throws on invocation regardless of arguments.","commonSituations":"Environments where the .wasm asset fails to load (bundler misconfiguration, runtime without WebAssembly, CSP); code that assumed batch acceleration is universal; perf-sensitive paths accidentally run on the fallback.","solutions":["Check isWasmAvailable() before batching; if false, execute each operation individually via the JS primitives (sha256, hmacSha256, contentHash are available on the fallback)","Fix WASM loading so the batch path exists: verify the .wasm file is emitted and resolvable at runtime","Expose batchProcess only in deployments you have verified can instantiate the WASM kernel"],"exampleFix":"// before\nconst results = getKernel().batchProcess(ops); // throws without WASM\n\n// after\nconst kernel = getKernel();\nconst results = kernel.available\n  ? kernel.batchProcess(ops)\n  : ops.map((op) => runOpWithJsPrimitives(op, kernel)); // sha256/contentHash still work","handlingStrategy":"type-guard","validationCode":"const kernel = getKernel();\nconst results = kernel.available\n  ? kernel.batchProcess(ops)\n  : ops.map((op) => runWithJsPrimitives(op, kernel)); // sha256/hmac/contentHash still work on fallback","typeGuard":"function canBatch(k: WasmKernel): k is WasmKernel & { available: true } {\n  return k.available === true; // batchProcess has NO JS fallback implementation\n}","tryCatchPattern":"try {\n  results = kernel.batchProcess(ops);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('requires WASM kernel')) {\n    results = ops.map((op) => runWithJsPrimitives(op, kernel)); // graceful degradation\n  } else {\n    throw e;\n  }\n}","preventionTips":["Gate batching behind a startup capability check; benchmark the sequential path as baseline","Alert when production runs on kernel.version === 'js-fallback' if throughput matters","Ensure the .wasm asset ships with deployment artifacts and the runtime allows WebAssembly"],"tags":["wasm","fallback","batch-processing","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-14T00:17:10.932Z"}