@intutic/mcp-governance-proxy 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (148) hide show
  1. package/README.md +34 -18
  2. package/dist/agentTools.d.ts +68 -0
  3. package/dist/agentTools.d.ts.map +1 -0
  4. package/dist/agentTools.js +150 -0
  5. package/dist/agentTools.js.map +1 -0
  6. package/dist/anomaly/detectors.js +1 -1
  7. package/dist/anomaly/detectors.js.map +1 -1
  8. package/dist/anomaly/index.d.ts +2 -1
  9. package/dist/anomaly/index.d.ts.map +1 -1
  10. package/dist/anomaly/index.js.map +1 -1
  11. package/dist/approvalHold.d.ts +66 -0
  12. package/dist/approvalHold.d.ts.map +1 -0
  13. package/dist/approvalHold.js +143 -0
  14. package/dist/approvalHold.js.map +1 -0
  15. package/dist/budget.d.ts +133 -0
  16. package/dist/budget.d.ts.map +1 -0
  17. package/dist/budget.js +191 -0
  18. package/dist/budget.js.map +1 -0
  19. package/dist/config.d.ts +7 -2
  20. package/dist/config.d.ts.map +1 -1
  21. package/dist/config.js +2 -2
  22. package/dist/config.js.map +1 -1
  23. package/dist/daemon/healthMonitor.d.ts +2 -0
  24. package/dist/daemon/healthMonitor.d.ts.map +1 -1
  25. package/dist/daemon/healthMonitor.js +60 -27
  26. package/dist/daemon/healthMonitor.js.map +1 -1
  27. package/dist/daemon/index.d.ts +0 -2
  28. package/dist/daemon/index.d.ts.map +1 -1
  29. package/dist/daemon/index.js +0 -2
  30. package/dist/daemon/index.js.map +1 -1
  31. package/dist/daemon/instrumentation.d.ts +2 -2
  32. package/dist/daemon/instrumentation.js +2 -2
  33. package/dist/daemon/policyCache.d.ts +38 -3
  34. package/dist/daemon/policyCache.d.ts.map +1 -1
  35. package/dist/daemon/policyCache.js +64 -22
  36. package/dist/daemon/policyCache.js.map +1 -1
  37. package/dist/daemon/socketServer.d.ts +0 -1
  38. package/dist/daemon/socketServer.d.ts.map +1 -1
  39. package/dist/daemon/socketServer.js +0 -1
  40. package/dist/daemon/socketServer.js.map +1 -1
  41. package/dist/daemon/statusReporter.d.ts.map +1 -1
  42. package/dist/daemon/statusReporter.js +0 -1
  43. package/dist/daemon/statusReporter.js.map +1 -1
  44. package/dist/daemon/telemetryBatcher.d.ts.map +1 -1
  45. package/dist/daemon/telemetryBatcher.js +0 -1
  46. package/dist/daemon/telemetryBatcher.js.map +1 -1
  47. package/dist/daemonClient.d.ts.map +1 -1
  48. package/dist/daemonClient.js +0 -1
  49. package/dist/daemonClient.js.map +1 -1
  50. package/dist/dlp.d.ts +32 -3
  51. package/dist/dlp.d.ts.map +1 -1
  52. package/dist/dlp.js +116 -18
  53. package/dist/dlp.js.map +1 -1
  54. package/dist/dlpPii.d.ts +66 -0
  55. package/dist/dlpPii.d.ts.map +1 -0
  56. package/dist/dlpPii.js +235 -0
  57. package/dist/dlpPii.js.map +1 -0
  58. package/dist/emitter.d.ts +68 -10
  59. package/dist/emitter.d.ts.map +1 -1
  60. package/dist/emitter.js +29 -43
  61. package/dist/emitter.js.map +1 -1
  62. package/dist/guardedValkey.d.ts +40 -0
  63. package/dist/guardedValkey.d.ts.map +1 -0
  64. package/dist/guardedValkey.js +84 -0
  65. package/dist/guardedValkey.js.map +1 -0
  66. package/dist/httpJson.d.ts +19 -0
  67. package/dist/httpJson.d.ts.map +1 -0
  68. package/dist/httpJson.js +62 -0
  69. package/dist/httpJson.js.map +1 -0
  70. package/dist/identity.d.ts +27 -0
  71. package/dist/identity.d.ts.map +1 -0
  72. package/dist/identity.js +36 -0
  73. package/dist/identity.js.map +1 -0
  74. package/dist/injection.js +1 -1
  75. package/dist/interceptor.d.ts +135 -8
  76. package/dist/interceptor.d.ts.map +1 -1
  77. package/dist/interceptor.js +284 -45
  78. package/dist/interceptor.js.map +1 -1
  79. package/dist/policy.d.ts +105 -2
  80. package/dist/policy.d.ts.map +1 -1
  81. package/dist/policy.js +188 -40
  82. package/dist/policy.js.map +1 -1
  83. package/dist/proxy.d.ts +35 -11
  84. package/dist/proxy.d.ts.map +1 -1
  85. package/dist/proxy.js +183 -66
  86. package/dist/proxy.js.map +1 -1
  87. package/dist/refusals.d.ts +26 -0
  88. package/dist/refusals.d.ts.map +1 -0
  89. package/dist/refusals.js +43 -0
  90. package/dist/refusals.js.map +1 -0
  91. package/dist/registryObserver.d.ts +37 -0
  92. package/dist/registryObserver.d.ts.map +1 -0
  93. package/dist/registryObserver.js +70 -0
  94. package/dist/registryObserver.js.map +1 -0
  95. package/dist/session.d.ts +1 -1
  96. package/dist/session.js +1 -1
  97. package/dist/sessionScope.d.ts +1 -1
  98. package/dist/sessionScope.js +1 -1
  99. package/dist/sessionStore.d.ts +10 -23
  100. package/dist/sessionStore.d.ts.map +1 -1
  101. package/dist/sessionStore.js +17 -76
  102. package/dist/sessionStore.js.map +1 -1
  103. package/dist/version.d.ts +12 -0
  104. package/dist/version.d.ts.map +1 -0
  105. package/dist/version.js +13 -0
  106. package/dist/version.js.map +1 -0
  107. package/dist/wasm/context.d.ts +10 -0
  108. package/dist/wasm/context.d.ts.map +1 -1
  109. package/dist/wasm/context.js +27 -0
  110. package/dist/wasm/context.js.map +1 -1
  111. package/dist/wasm/hostImports.d.ts +3 -3
  112. package/dist/wasm/hostImports.d.ts.map +1 -1
  113. package/dist/wasm/hostImports.js +8 -7
  114. package/dist/wasm/hostImports.js.map +1 -1
  115. package/dist/wasm/loader.d.ts +8 -1
  116. package/dist/wasm/loader.d.ts.map +1 -1
  117. package/dist/wasm/loader.js +2 -0
  118. package/dist/wasm/loader.js.map +1 -1
  119. package/dist/wasm/referencedFiles.d.ts +29 -4
  120. package/dist/wasm/referencedFiles.d.ts.map +1 -1
  121. package/dist/wasm/referencedFiles.js +48 -21
  122. package/dist/wasm/referencedFiles.js.map +1 -1
  123. package/dist/wasm/runner.d.ts +106 -22
  124. package/dist/wasm/runner.d.ts.map +1 -1
  125. package/dist/wasm/runner.js +194 -74
  126. package/dist/wasm/runner.js.map +1 -1
  127. package/dist/wasm/watch.js +1 -1
  128. package/dist/wasm/worker.d.ts +10 -6
  129. package/dist/wasm/worker.d.ts.map +1 -1
  130. package/dist/wasm/worker.js +93 -9
  131. package/dist/wasm/worker.js.map +1 -1
  132. package/package.json +5 -4
  133. package/dist/toolPoison.d.ts +0 -32
  134. package/dist/toolPoison.d.ts.map +0 -1
  135. package/dist/toolPoison.js +0 -81
  136. package/dist/toolPoison.js.map +0 -1
  137. package/dist/wasm/fuel.d.ts +0 -35
  138. package/dist/wasm/fuel.d.ts.map +0 -1
  139. package/dist/wasm/fuel.js +0 -299
  140. package/dist/wasm/fuel.js.map +0 -1
  141. package/dist/wasm/memoryCap.d.ts +0 -21
  142. package/dist/wasm/memoryCap.d.ts.map +0 -1
  143. package/dist/wasm/memoryCap.js +0 -54
  144. package/dist/wasm/memoryCap.js.map +0 -1
  145. package/dist/wasm/wasmBinary.d.ts +0 -25
  146. package/dist/wasm/wasmBinary.d.ts.map +0 -1
  147. package/dist/wasm/wasmBinary.js +0 -100
  148. package/dist/wasm/wasmBinary.js.map +0 -1
@@ -8,20 +8,25 @@
8
8
  * ## Divergences from the Rust runner (all recorded as TD entries)
9
9
  *
10
10
  * - **Fuel: the same 1,000,000-instruction budget, metered a different
11
- * way.** V8 has no fuel hook, so `fuel.ts` rewrites each rule at load to
12
- * count its own instructions and trap when the budget runs out (TD-440).
13
- * A rule that exhausts it fails open for that call, as under Wasmtime.
14
- * - **50ms per-rule deadline, not 5ms.** Fuel bounds the guest's own work;
15
- * the deadline is the backstop for everything else, and it races a
16
- * `postMessage` round trip that pays IPC overhead the in-process Wasmtime
17
- * call never did. 50ms, not 5ms, keeps that overhead from
18
- * false-positiving a legitimate rule under normal load.
11
+ * way.** V8 has no fuel hook, so `wasmFuel.ts` (shared-types) rewrites each rule at load to
12
+ * count its own instructions and trap when the budget runs out.
13
+ * A rule that exhausts it reaches no verdict, as under Wasmtime.
14
+ * - **The deadline is a backstop, not the limit.** Fuel is the limit: it is
15
+ * deterministic, so a rule within budget is never refused because the
16
+ * machine is busy. The deadline catches what fuel cannot see — a bulk
17
+ * `memory.fill` costs one instruction whatever its length, a host call
18
+ * costs none — and it races a `postMessage` round trip that the
19
+ * in-process Wasmtime call never pays. See {@link EVALUATE_TIMEOUT_MS}.
19
20
  * - **Guest memory ceiling: the same 16MB, enforced a different way.**
20
21
  * `runner.rs` sets a `StoreLimits` cap; V8 has no such hook, but it does
21
22
  * enforce the maximum a module declares, so `worker.ts` rewrites the
22
23
  * module's memory section to declare 16MB as its maximum before compiling
23
- * (`memoryCap.ts`). A `memory.grow` past it returns -1 as it would under
24
- * Wasmtime. Not a divergence any more; TD-440 records how it got here.
24
+ * (`wasmMemoryCap.ts`). A `memory.grow` past it returns -1 as it would under
25
+ * Wasmtime. Not a divergence any more.
26
+ * - **Rego rules (OPA builds) run through `@intutic/shared-types`' Rego
27
+ * host**, with their own instruction budget (`wasmFuel.ts`'s
28
+ * `REGO_FUEL_BUDGET`) and deadline (`REGO_EVALUATE_TIMEOUT_MS`), and
29
+ * reply with a decision instead of a verdict code — a hold has none.
25
30
  * - **`read_referenced_file` is served from a pre-read table**
26
31
  * (`referencedFiles.ts`, the port of `referenced_files.rs`), prefetched
27
32
  * once per `evaluate()` only when a loaded rule imports the function and
@@ -35,22 +40,39 @@ import { existsSync } from 'node:fs';
35
40
  import { fileURLToPath } from 'node:url';
36
41
  import { createStderrLogger as createLogger } from '../stderrLog.js';
37
42
  import { WasmLoader, resolveWasmDir } from './loader.js';
38
- import { buildWasmContext } from './context.js';
43
+ import { buildRegoInput, buildWasmContext } from './context.js';
39
44
  import { prefetch, resolveRoot, ReferencedFiles } from './referencedFiles.js';
40
45
  const log = createLogger('mcp-proxy-wasm-runner');
41
46
  /**
42
- * Per-rule evaluation deadline. See this module's doc comment for why this
43
- * is 50ms rather than `runner.rs`'s 5ms.
47
+ * A native rule's deadline: a backstop for stalls the instruction budget
48
+ * cannot see, set well above the time any rule within budget takes on a busy
49
+ * machine, because a rule that reaches no verdict refuses the call.
50
+ *
51
+ * Measured on a 14-core machine, idle and with 100 busy threads (about the
52
+ * oversubscription of a 4-vCPU CI runner running every package's suite): the
53
+ * 1,000,000-instruction budget runs out in at most 2 ms either way, and a
54
+ * worker round trip for a 60 KB context takes at most 0.5 ms idle and 3.9 ms
55
+ * loaded. The Rego round trip below shows the loaded machine also stalls a
56
+ * thread for hundreds of milliseconds, which is what one second covers.
57
+ */
58
+ export const EVALUATE_TIMEOUT_MS = 1_000;
59
+ /**
60
+ * A Rego rule's deadline, on the same reasoning with the Rego budget
61
+ * (`REGO_FUEL_BUDGET`): the destructive-shell example on the largest input
62
+ * (64 KB) takes at most 6 ms idle and 430 ms loaded, round trip included, and
63
+ * a loop using up the whole budget takes up to 350 ms idle and 4.4 s loaded.
64
+ * Ten seconds is over twice that, so on a loaded machine the budget still
65
+ * stops a runaway rule first, and only a stall fuel cannot see waits this long.
44
66
  */
45
- const EVALUATE_TIMEOUT_MS = 50;
67
+ export const REGO_EVALUATE_TIMEOUT_MS = 10_000;
46
68
  /** Generous — compilation is not guest-controlled per evaluation, but a
47
69
  * pathological file must not hang a rescan forever. */
48
70
  const COMPILE_TIMEOUT_MS = 3_000;
49
71
  /**
50
72
  * Consecutive per-rule runaways (a timeout, or the instruction budget running
51
- * out) before that rule is disabled until the next rescan.
73
+ * out) before that rule is quarantined until the next rescan.
52
74
  */
53
- const MAX_CONSECUTIVE_TIMEOUTS = 3;
75
+ export const MAX_CONSECUTIVE_RUNAWAYS = 3;
54
76
  /**
55
77
  * Resolves the worker script to spawn.
56
78
  *
@@ -89,8 +111,10 @@ export class WasmRunner {
89
111
  worker = null;
90
112
  nextRequestId = 1;
91
113
  pending = new Map();
92
- consecutiveTimeouts = new Map();
93
- disabledRuleIds = new Set();
114
+ consecutiveRunaways = new Map();
115
+ /** The worker replacing one that missed a deadline, while its rules recompile. */
116
+ respawning = null;
117
+ quarantined = new Set();
94
118
  constructor(dirOverride) {
95
119
  this.loader = new WasmLoader(resolveWasmDir(dirOverride));
96
120
  }
@@ -145,33 +169,49 @@ export class WasmRunner {
145
169
  const id = this.allocId();
146
170
  const reply = await this.send({ type: 'compile', id, ruleId, bytes: toArrayBuffer(bytes) }, COMPILE_TIMEOUT_MS);
147
171
  if (!reply)
148
- return { ok: false, error: `compile timed out after ${COMPILE_TIMEOUT_MS}ms` };
172
+ return { ok: false, reason: 'load_error', error: `compile timed out after ${COMPILE_TIMEOUT_MS}ms` };
149
173
  if (!reply.ok) {
150
174
  const fallback = reply.unsupportedImports && reply.unsupportedImports.length > 0
151
175
  ? `imports ${reply.unsupportedImports.join(', ')}, which this proxy does not provide`
152
176
  : 'unknown compile error';
153
- return { ok: false, error: reply.error ?? fallback, unsupportedImports: reply.unsupportedImports };
177
+ return {
178
+ ok: false,
179
+ reason: reply.reason ?? 'load_error',
180
+ error: reply.error ?? fallback,
181
+ unsupportedImports: reply.unsupportedImports,
182
+ };
154
183
  }
155
- return { ok: true, readsReferencedFiles: reply.readsReferencedFiles ?? false };
184
+ return { ok: true, readsReferencedFiles: reply.readsReferencedFiles ?? false, rego: reply.rego ?? false };
156
185
  }
157
186
  remove(ruleId) {
158
187
  this.ensureWorker().postMessage({ type: 'remove', ruleId });
159
- this.consecutiveTimeouts.delete(ruleId);
160
- this.disabledRuleIds.delete(ruleId);
188
+ this.consecutiveRunaways.delete(ruleId);
189
+ this.quarantined.delete(ruleId);
161
190
  }
162
191
  // ── Rescan (driven by the existing policy-tick timer — see policy.ts) ──
163
192
  /**
164
193
  * Rescans `~/.intutic/wasm/` and (re)compiles anything changed. Also
165
- * clears every rule's disabled-by-timeout status — "disable that rule
166
- * until the next policy-driven rescan" is this call.
194
+ * releases every quarantined rule — "quarantined until the next
195
+ * policy-driven rescan" is this call.
167
196
  */
168
197
  async rescan() {
198
+ await this.respawning;
169
199
  await this.loader.rescan(this);
170
- this.disabledRuleIds.clear();
171
- this.consecutiveTimeouts.clear();
200
+ this.quarantined.clear();
201
+ this.consecutiveRunaways.clear();
172
202
  }
173
- /** Terminates the worker and respawns a fresh one, resending every currently-loaded rule's bytes so its module cache is rebuilt. */
174
- async respawnWorker() {
203
+ /**
204
+ * Replaces the worker, resending every currently-loaded rule's bytes so the
205
+ * new one's module cache is rebuilt, without waiting for the old one to stop.
206
+ *
207
+ * `Worker.terminate()` can take seconds: V8 stops a guest only at an
208
+ * interrupt check, and a loop around a bulk `memory.fill` reaches one
209
+ * rarely — measured, 1.5 s on an idle machine and 16 s on a loaded one. The
210
+ * call that missed its deadline is refused at the deadline; the old worker
211
+ * stops whenever V8 gets to it, and the next evaluation waits only for the
212
+ * new worker's recompile (`respawning`, about 50 ms for three Rego rules).
213
+ */
214
+ respawnWorker() {
175
215
  const old = this.worker;
176
216
  this.worker = null;
177
217
  if (old) {
@@ -182,34 +222,97 @@ export class WasmRunner {
182
222
  entry.resolve({ ok: false, error: 'worker terminated' });
183
223
  this.pending.delete(id);
184
224
  }
185
- await old.terminate();
225
+ old.terminate().catch((err) => {
226
+ log.warn({ action: 'wasm_worker_terminate_error', err: err.message }, 'WASM worker did not terminate cleanly');
227
+ });
186
228
  }
187
229
  // Force-reload every currently-known file into the new worker — its
188
230
  // module cache started empty. `force: true` mirrors this loader's own
189
231
  // "worker cache was lost, nothing on disk moved" case.
190
- await this.loader.rescan(this, true);
232
+ const respawning = this.loader.rescan(this, true).finally(() => {
233
+ if (this.respawning === respawning)
234
+ this.respawning = null;
235
+ });
236
+ this.respawning = respawning;
191
237
  }
192
238
  // ── Evaluation ───────────────────────────────────────────────────────
193
239
  /**
194
- * Evaluates every currently loaded, non-disabled rule (priority order)
195
- * against one context, mirroring `registry.rs`'s `evaluate_inner`:
196
- * short-circuit on the first block, carry the first reask through in case
197
- * a later, higher-priority rule still blocks, `allow` when nothing fired
198
- * or every loaded rule was fail-open (timeout/trap/unmapped code).
240
+ * Evaluates every currently loaded rule (priority order) against one
241
+ * context, as `registry.rs`'s `evaluate_inner` does: short-circuit on the
242
+ * first block, carry the first hold and reask through in case a later rule
243
+ * still blocks, `allow` when nothing fired.
244
+ *
245
+ * A rule that reaches no verdict — its deadline, its instruction budget, a
246
+ * trap or other error, or a result that is not a verdict — refuses the call
247
+ * (`unavailable`), whatever `mcpProxyFailBehavior` or
248
+ * `INTUTIC_MCP_FAIL_OPEN` say. That setting exists for control-plane
249
+ * outages, which an agent cannot cause; a rule's timeout an agent can cause
250
+ * by padding its input, so it must never become an allow. The refusal
251
+ * outranks a hold and a reask, since neither an approval nor a retry can
252
+ * clear a call a rule never judged; a later rule's block still wins,
253
+ * because it says what is wrong with the call.
254
+ *
255
+ * A quarantined rule (see {@link countRunaway}) refuses at once, without
256
+ * anything being evaluated, until the next rescan.
199
257
  */
200
258
  async evaluate(input) {
201
- const rules = this.loader.getRules().filter((r) => !this.disabledRuleIds.has(r.ruleId));
259
+ const rules = this.loader.getRules();
260
+ const held = rules.find((r) => this.quarantined.has(r.ruleId));
261
+ if (held) {
262
+ return {
263
+ code: 'unavailable',
264
+ stop: 'quarantined',
265
+ ruleId: held.ruleId,
266
+ reason: noVerdictReason(held.ruleId, 'quarantined', `it is quarantined after ${MAX_CONSECUTIVE_RUNAWAYS} runaway evaluations in a row (deadline or budget), until the next rescan`),
267
+ };
268
+ }
202
269
  if (rules.length === 0)
203
270
  return { code: 'allow' };
204
- const contextBytes = Buffer.from(JSON.stringify(buildWasmContext(input)));
271
+ // Each built once, and only if a rule of that kind is loaded.
272
+ let contextBytes;
273
+ let regoBytes;
274
+ const bytesFor = (rego) => rego
275
+ ? (regoBytes ??= Buffer.from(buildRegoInput(input)))
276
+ : (contextBytes ??= Buffer.from(JSON.stringify(buildWasmContext(input))));
205
277
  let pendingReask = null;
278
+ let pendingHold = null;
279
+ let unavailable = null;
206
280
  // Read once per evaluation, before any rule runs, so the per-rule
207
281
  // deadline covers guest execution only — and only when a rule will ask.
208
282
  const files = rules.some((r) => r.readsReferencedFiles) ? await this.prefetchReferencedFiles(input) : undefined;
209
283
  for (const rule of rules) {
210
- const result = await this.evaluateOne(rule.ruleId, contextBytes, rule.readsReferencedFiles ? files : undefined);
211
- if (result === null)
212
- continue; // fail-open ALLOW for this rule (timeout, trap, or worker error)
284
+ const outcome = await this.evaluateOne(rule.ruleId, bytesFor(rule.rego), rule.rego ? REGO_EVALUATE_TIMEOUT_MS : EVALUATE_TIMEOUT_MS, rule.readsReferencedFiles ? files : undefined);
285
+ const failure = 'stop' in outcome ? outcome : undefinedVerdict(outcome);
286
+ if (failure) {
287
+ const quarantinedNow = this.quarantined.has(rule.ruleId);
288
+ const detail = quarantinedNow
289
+ ? `${failure.detail}; it is now quarantined until the next rescan, after ${MAX_CONSECUTIVE_RUNAWAYS} runaway evaluations in a row`
290
+ : failure.detail;
291
+ log.warn({ action: 'wasm_rule_no_verdict', ruleId: rule.ruleId, stop: failure.stop }, `WASM rule reached no verdict: ${detail} — refusing`);
292
+ if (!unavailable) {
293
+ unavailable = {
294
+ code: 'unavailable',
295
+ stop: failure.stop,
296
+ ruleId: rule.ruleId,
297
+ reason: noVerdictReason(rule.ruleId, failure.stop, detail),
298
+ };
299
+ }
300
+ continue;
301
+ }
302
+ const result = outcome;
303
+ if ('decision' in result) {
304
+ // A Rego rule. Same ordering as the native codes below: a block ends
305
+ // it, and a hold waits for a person, so it outranks a reask.
306
+ const reason = result.reason ?? 'Refused by Rego policy';
307
+ if (result.decision === 'deny')
308
+ return { code: 'block', reason, ruleId: rule.ruleId };
309
+ if (result.decision === 'hold' && !pendingHold) {
310
+ pendingHold = { code: 'hold', reason, ruleId: rule.ruleId, ...(result.riskTier ? { riskTier: result.riskTier } : {}) };
311
+ }
312
+ if (result.decision === 'reask' && !pendingReask)
313
+ pendingReask = { code: 'reask', reason, ruleId: rule.ruleId };
314
+ continue;
315
+ }
213
316
  switch (result.code) {
214
317
  case 0:
215
318
  break; // Bypass — try the next rule
@@ -235,15 +338,12 @@ export class WasmRunner {
235
338
  };
236
339
  }
237
340
  break;
238
- default:
239
- log.warn({ action: 'wasm_unmapped_verdict', ruleId: rule.ruleId, code: result.code }, 'WASM rule returned an unmapped verdict code; allowing. Valid codes are 0 (allow), 1 (block), 3 (reask).');
240
- break;
241
341
  }
242
342
  }
243
- return pendingReask ?? { code: 'allow' };
343
+ return unavailable ?? pendingHold ?? pendingReask ?? { code: 'allow' };
244
344
  }
245
345
  /**
246
- * The referenced-files table for this evaluation (TD-441). With no
346
+ * The referenced-files table for this evaluation. With no
247
347
  * `INTUTIC_WASM_MANIFEST_ROOT` the table is empty and every read refuses.
248
348
  */
249
349
  async prefetchReferencedFiles(input) {
@@ -256,48 +356,57 @@ export class WasmRunner {
256
356
  }
257
357
  return files.toTable();
258
358
  }
259
- /** One rule's evaluation, raced against `EVALUATE_TIMEOUT_MS`. `null` means fail-open (timeout, worker error, or guest trap). */
260
- async evaluateOne(ruleId, contextBytes, files) {
359
+ /** One rule's evaluation, raced against its deadline: its answer, or why it reached none. */
360
+ async evaluateOne(ruleId, contextBytes, timeoutMs, files) {
361
+ // A worker replaced after a missed deadline has its rules only once they
362
+ // recompile; an evaluation sent before then would find none.
363
+ await this.respawning;
261
364
  const id = this.allocId();
262
- const reply = await this.send({ type: 'evaluate', id, ruleId, bytes: toArrayBuffer(contextBytes), ...(files ? { files } : {}) }, EVALUATE_TIMEOUT_MS);
365
+ const reply = await this.send({ type: 'evaluate', id, ruleId, bytes: toArrayBuffer(contextBytes), ...(files ? { files } : {}) }, timeoutMs);
263
366
  if (reply === null) {
264
- // Timed out. Mirrors `runner.rs`'s `Err(_) => Bypass` — this call
265
- // fails open — plus the MCP-specific per-rule consecutive-timeout
266
- // disable ladder the task calls for.
267
- log.warn({ action: 'wasm_evaluate_timeout', ruleId, timeoutMs: EVALUATE_TIMEOUT_MS }, 'WASM rule evaluation timed out — failing open');
268
- // terminate + lazily respawn: the NEXT evaluate() call pays the
269
- // respawn cost via ensureWorker()/rescan(force); triggered here so a
270
- // wedged worker does not keep timing out every rule behind it in this
271
- // same evaluate() loop.
272
- await this.respawnWorker();
367
+ // Timed out: `runner.rs`'s deadline, plus this proxy's quarantine. The
368
+ // worker is replaced so a wedged one does not time out every rule
369
+ // behind it; this call does not wait for that (see respawnWorker).
370
+ this.respawnWorker();
273
371
  this.countRunaway(ruleId);
274
- return null;
372
+ return { stop: 'deadline', detail: `it ran past its ${timeoutMs} ms deadline` };
275
373
  }
276
374
  if (!reply.ok && reply.fuelExhausted) {
277
375
  // The budget trapped the guest, so the worker is healthy: no respawn,
278
- // but the same disable ladder as a timeout, since it is the same
376
+ // but the same quarantine count as a timeout, since it is the same
279
377
  // runaway rule caught sooner.
280
- log.warn({ action: 'wasm_evaluate_fuel_exhausted', ruleId }, 'WASM rule ran out of its instruction budget — failing open');
281
378
  this.countRunaway(ruleId);
282
- return null;
379
+ return { stop: 'budget', detail: 'it used up its instruction budget' };
283
380
  }
284
381
  if (!reply.ok) {
285
- // Worker-reported failure: a guest trap (including one following an
286
- // `abort` call) or an internal error. Fail-open ALLOW for this call,
287
- // never a crash — matches the task's explicit instruction.
288
- log.warn({ action: 'wasm_evaluate_error', ruleId, err: reply.error }, 'WASM rule evaluation failed — failing open');
289
- return null;
382
+ // A guest trap (including one following an `abort` call), a result
383
+ // that is not a decision, or an internal error — never a crash.
384
+ return reply.notADecision
385
+ ? { stop: 'result', detail: reply.error ?? 'it returned a result that is not a decision' }
386
+ : { stop: 'error', detail: `it failed while running: ${reply.error ?? 'unknown error'}` };
387
+ }
388
+ // A clean reply resets this rule's runaway streak.
389
+ this.consecutiveRunaways.delete(ruleId);
390
+ if (reply.decision) {
391
+ return {
392
+ decision: reply.decision,
393
+ ...(reply.reason ? { reason: reply.reason } : {}),
394
+ ...(reply.riskTier ? { riskTier: reply.riskTier } : {}),
395
+ };
290
396
  }
291
- // A clean reply resets this rule's timeout streak.
292
- this.consecutiveTimeouts.delete(ruleId);
293
397
  return { code: reply.code ?? -1, reason: reply.reason };
294
398
  }
399
+ /**
400
+ * Counts one runaway (deadline or budget) against `ruleId`, quarantining
401
+ * the rule at {@link MAX_CONSECUTIVE_RUNAWAYS} in a row. Logged once, at the
402
+ * transition; what a quarantined rule means for a call is `evaluate`'s.
403
+ */
295
404
  countRunaway(ruleId) {
296
- const attempts = (this.consecutiveTimeouts.get(ruleId) ?? 0) + 1;
297
- this.consecutiveTimeouts.set(ruleId, attempts);
298
- if (attempts >= MAX_CONSECUTIVE_TIMEOUTS) {
299
- this.disabledRuleIds.add(ruleId);
300
- log.warn({ action: 'wasm_rule_disabled', ruleId, consecutiveRunaways: attempts }, 'WASM rule disabled after consecutive timeouts or budget exhaustion — will retry on the next policy-driven rescan');
405
+ const runaways = (this.consecutiveRunaways.get(ruleId) ?? 0) + 1;
406
+ this.consecutiveRunaways.set(ruleId, runaways);
407
+ if (runaways >= MAX_CONSECUTIVE_RUNAWAYS && !this.quarantined.has(ruleId)) {
408
+ this.quarantined.add(ruleId);
409
+ log.warn({ action: 'wasm_rule_quarantined', ruleId, consecutiveRunaways: runaways }, 'WASM rule quarantined after consecutive timeouts or budget exhaustion — retried on the next policy-driven rescan');
301
410
  }
302
411
  }
303
412
  /** Terminates the worker. Safe to call even if one was never spawned. */
@@ -313,6 +422,17 @@ export class WasmRunner {
313
422
  await worker.terminate();
314
423
  }
315
424
  }
425
+ /** A native code that is not a verdict: the rule reached none. */
426
+ function undefinedVerdict(result) {
427
+ if ('decision' in result || [0, 1, 2, 3].includes(result.code))
428
+ return null;
429
+ return { stop: 'result', detail: `it returned ${result.code}, which is not a verdict code (0 allow, 1 block, 3 reask)` };
430
+ }
431
+ /** The refusal an agent reads when a rule reached no verdict: which rule, and why. */
432
+ function noVerdictReason(ruleId, stop, detail) {
433
+ return (`Custom rule ${ruleId} reached no verdict (${stop}): ${detail}. Tool call blocked: a ` +
434
+ `rule that cannot decide never allows.`);
435
+ }
316
436
  function toArrayBuffer(bytes) {
317
437
  // Structured-clone (postMessage) needs an ArrayBuffer, not a Node Buffer
318
438
  // view that may share a larger underlying pool — slice guarantees the
@@ -1 +1 @@
1
- {"version":3,"file":"runner.js","sourceRoot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MAAM,GAAG,IAAI,CAAA;QAClB,KAAK,MAAM,CAAC,EAAE,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACvC,YAAY,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YACzB,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,kBAAkB,EAAE,CAAC,CAAA;YACvD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAA;QACzB,CAAC;QACD,IAAI,MAAM;YAAE,MAAM,MAAM,CAAC,SAAS,EAAE,CAAA;IACtC,CAAC;CACF;AAED,kEAAkE;AAClE,SAAS,gBAAgB,CAAC,MAAkB;IAC1C,IAAI,UAAU,IAAI,MAAM,IAAI,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAA;IAC3E,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,eAAe,MAAM,CAAC,IAAI,2DAA2D,EAAE,CAAA;AAC1H,CAAC;AAED,sFAAsF;AACtF,SAAS,eAAe,CAAC,MAAc,EAAE,IAAc,EAAE,MAAc;IACrE,OAAO,CACL,eAAe,MAAM,wBAAwB,IAAI,MAAM,MAAM,yBAAyB;QACtF,uCAAuC,CACxC,CAAA;AACH,CAAC;AAED,SAAS,aAAa,CAAC,KAAiB;IACtC,yEAAyE;IACzE,sEAAsE;IACtE,+DAA+D;IAC/D,OAAO,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,UAAU,EAAE,KAAK,CAAC,UAAU,GAAG,KAAK,CAAC,UAAU,CAAgB,CAAA;AACjG,CAAC"}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Watch the local rules directory and call back, debounced, when a `.wasm`
3
- * file appears, changes or goes away (TD-442).
3
+ * file appears, changes or goes away.
4
4
  *
5
5
  * The rescan rides the 60-second policy tick (`policy.ts` `start(onTick)`)
6
6
  * and no second timer was wanted. A filesystem watcher is not a timer: it
@@ -10,23 +10,27 @@
10
10
  * happen to share a rule.
11
11
  *
12
12
  * Protocol (see `runner.ts` for the main-thread side):
13
- * compile { type:'compile', id, ruleId, bytes } -> { type:'compile-result', id, ruleId, ok, unsupportedImports?, readsReferencedFiles?, error? }
13
+ * compile { type:'compile', id, ruleId, bytes } -> { type:'compile-result', id, ruleId, ok, reason?, unsupportedImports?, readsReferencedFiles?, rego?, error? }
14
14
  * remove { type:'remove', ruleId } (no reply)
15
- * evaluate { type:'evaluate', id, ruleId, bytes, files? } -> { type:'evaluate-result', id, ruleId, ok, code?, reason?, error? }
15
+ * evaluate { type:'evaluate', id, ruleId, bytes, files? } -> { type:'evaluate-result', id, ruleId, ok, code?, decision?, reason?, riskTier?, error?, fuelExhausted?, notADecision? }
16
16
  *
17
- * `files` is the per-evaluation referenced-files table (TD-441), posted only
17
+ * A Rego rule (an OPA build, `@intutic/shared-types`' Rego host) is compiled
18
+ * and evaluated here too; its `evaluate` bytes are the Rego input document and
19
+ * its reply carries `decision` instead of `code`.
20
+ *
21
+ * `files` is the per-evaluation referenced-files table, posted only
18
22
  * to a rule that imports `read_referenced_file`; it is rebuilt here into the
19
23
  * host-import state, so the main thread never shares memory with the guest.
20
24
  *
21
25
  * A guest `abort` call is inert (hostImports.ts logs and returns); an
22
26
  * uncaught exception or trap during instantiation/evaluation is caught here
23
- * and reported as `ok:false` — the caller (runner.ts) treats that as
24
- * fail-open ALLOW, exactly like a timeout, never a crash.
27
+ * and reported as `ok:false` — the caller (runner.ts) treats that as a rule
28
+ * that reached no verdict, exactly like a timeout, never a crash.
25
29
  *
26
30
  * @module
27
31
  */
28
32
  /**
29
- * Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440). Enforced at
33
+ * Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits`. Enforced at
30
34
  * load by `capDeclaredMemory`: the module's own memory is rewritten to declare
31
35
  * this as its maximum, so V8 refuses any `memory.grow` past it (the call
32
36
  * returns -1) instead of growing. A module whose initial size is already over
@@ -1 +1 @@
1
- {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AASH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QAAmB,CAAA"}
1
+ {"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAyBH;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,QAAmB,CAAA"}