{"record":{"id":"548df9ceb5ed7275","repo":"ruvnet/ruflo","slug":"detectdestructive-not-available-in-js-fallback-us","errorCode":null,"errorMessage":"detectDestructive not available in JS fallback; use EnforcementGates","messagePattern":"detectDestructive not available in JS fallback; use EnforcementGates","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"v3/@claude-flow/guidance/src/wasm-kernel.ts","lineNumber":179,"sourceCode":"      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}\n\n/**\n * Check if the WASM kernel is available without initializing it.\n */\nexport function isWasmAvailable(): boolean {\n  return getKernel().available;\n}\n","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/ruvnet/ruflo/blob/fa13ee4ad60ac2090b1480656eb233521790d640/v3/@claude-flow/guidance/src/wasm-kernel.ts#L161-L197","documentation":"The JS fallback kernel's detectDestructive() stub throws because destructive-command detection is delegated to the EnforcementGates class in pure-JS environments instead of being duplicated in the fallback. The message tells you the supported alternative; you hit the stub only when the WASM kernel could not be loaded.","triggerScenarios":"Calling getKernel().detectDestructive(command) while running on the JS fallback — i.e. tryLoadWasm() failed (asset missing, runtime without WebAssembly, CSP blocking instantiation).","commonSituations":"CI environments or edge runtimes that lack WASM; bundling pipelines that omit the .wasm file; hardened environments where WebAssembly is disabled by policy.","solutions":["Use EnforcementGates' destructive-command detection for the pure-JS path","Gate the call behind isWasmAvailable() so the code picks the right implementation per environment","Fix WASM availability (bundle the .wasm asset, relax CSP/runtime restrictions) to keep the accelerated path"],"exampleFix":"// before\nconst finding = getKernel().detectDestructive(cmd); // throws in JS fallback\n\n// after\nconst finding = isWasmAvailable()\n  ? getKernel().detectDestructive(cmd)\n  : enforcementGates.detectDestructive(cmd); // JS implementation","handlingStrategy":"type-guard","validationCode":"function detectDestructiveAnywhere(cmd: string, gates: EnforcementGates): string | null {\n  return isWasmAvailable()\n    ? getKernel().detectDestructive(cmd)\n    : gates.detectDestructive(cmd); // JS path\n}","typeGuard":"function hasWasmKernel(k: WasmKernel): k is WasmKernel & { available: true } {\n  return k.available === true;\n}","tryCatchPattern":"try {\n  finding = kernel.detectDestructive(cmd);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('JS fallback')) {\n    finding = gates.detectDestructive(cmd);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Route destructive-command checks through one helper that picks kernel vs gates","Treat isWasmAvailable() === false as a supported environment, not an error","Test both branches so the gates path stays correct"],"tags":["wasm","fallback","destructive-command","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"}