@intutic/mcp-governance-proxy 2.0.0 → 2.1.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.
- package/dist/wasm/fuel.d.ts +35 -0
- package/dist/wasm/fuel.d.ts.map +1 -0
- package/dist/wasm/fuel.js +299 -0
- package/dist/wasm/fuel.js.map +1 -0
- package/dist/wasm/memoryCap.d.ts +21 -0
- package/dist/wasm/memoryCap.d.ts.map +1 -0
- package/dist/wasm/memoryCap.js +54 -0
- package/dist/wasm/memoryCap.js.map +1 -0
- package/dist/wasm/runner.d.ts +16 -15
- package/dist/wasm/runner.d.ts.map +1 -1
- package/dist/wasm/runner.js +36 -22
- package/dist/wasm/runner.js.map +1 -1
- package/dist/wasm/wasmBinary.d.ts +25 -0
- package/dist/wasm/wasmBinary.d.ts.map +1 -0
- package/dist/wasm/wasmBinary.js +100 -0
- package/dist/wasm/wasmBinary.js.map +1 -0
- package/dist/wasm/worker.d.ts +5 -8
- package/dist/wasm/worker.d.ts.map +1 -1
- package/dist/wasm/worker.js +23 -16
- package/dist/wasm/worker.js.map +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instruction budget for WASM rules (TD-440): the MCP proxy's stand-in for
|
|
3
|
+
* Wasmtime fuel, which `runner.rs` sets to 1,000,000 per evaluation.
|
|
4
|
+
*
|
|
5
|
+
* V8 has no metering hook, so the rule's own code is rewritten at load to
|
|
6
|
+
* count. A new mutable i32 global starts at the budget, and a charge is
|
|
7
|
+
* inserted at every function entry and every loop header: subtract the number
|
|
8
|
+
* of instructions that can run before the next charge point, and trap
|
|
9
|
+
* (`unreachable`) once the counter goes negative. Code between two charge
|
|
10
|
+
* points is straight-line apart from forward branches, so each charge is an
|
|
11
|
+
* upper bound on what it pays for, and the budget bounds the instructions the
|
|
12
|
+
* rule actually executes. Structural instructions (`block`, `loop`, `end`,
|
|
13
|
+
* `else`, `nop`, `drop`, `return`, `unreachable`) cost nothing, roughly as
|
|
14
|
+
* Wasmtime prices them.
|
|
15
|
+
*
|
|
16
|
+
* The global is exported as `FUEL_EXPORT` so the worker can tell a trap caused
|
|
17
|
+
* by the budget from any other trap. Each evaluation instantiates the module
|
|
18
|
+
* afresh, so the budget is per evaluation, like a Wasmtime `Store`.
|
|
19
|
+
*
|
|
20
|
+
* The decoder knows the MVP instruction set plus the extensions compilers
|
|
21
|
+
* emit by default (sign extension, saturating truncation, bulk memory,
|
|
22
|
+
* reference types, multi-value, tail calls, SIMD). A module using anything
|
|
23
|
+
* else (exceptions, GC, threads) is refused at load rather than run unmetered.
|
|
24
|
+
*/
|
|
25
|
+
/** `runner.rs`: `store.set_fuel(1_000_000)`. */
|
|
26
|
+
export declare const DEFAULT_FUEL_BUDGET = 1000000;
|
|
27
|
+
/** The export the worker reads to tell budget exhaustion from other traps. */
|
|
28
|
+
export declare const FUEL_EXPORT = "__intutic_fuel";
|
|
29
|
+
/**
|
|
30
|
+
* The module with every function metered against `budget` instructions per
|
|
31
|
+
* instantiation, and the counter exported as `FUEL_EXPORT`. Throws for a
|
|
32
|
+
* module the decoder cannot meter.
|
|
33
|
+
*/
|
|
34
|
+
export declare function meterFuel(bytes: Uint8Array<ArrayBuffer>, budget: number): Uint8Array<ArrayBuffer>;
|
|
35
|
+
//# sourceMappingURL=fuel.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuel.d.ts","sourceRoot":"","sources":["../../src/wasm/fuel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAeH,gDAAgD;AAChD,eAAO,MAAM,mBAAmB,UAAY,CAAA;AAE5C,8EAA8E;AAC9E,eAAO,MAAM,WAAW,mBAAmB,CAAA;AAoM3C;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,MAAM,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA+BjG"}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Instruction budget for WASM rules (TD-440): the MCP proxy's stand-in for
|
|
3
|
+
* Wasmtime fuel, which `runner.rs` sets to 1,000,000 per evaluation.
|
|
4
|
+
*
|
|
5
|
+
* V8 has no metering hook, so the rule's own code is rewritten at load to
|
|
6
|
+
* count. A new mutable i32 global starts at the budget, and a charge is
|
|
7
|
+
* inserted at every function entry and every loop header: subtract the number
|
|
8
|
+
* of instructions that can run before the next charge point, and trap
|
|
9
|
+
* (`unreachable`) once the counter goes negative. Code between two charge
|
|
10
|
+
* points is straight-line apart from forward branches, so each charge is an
|
|
11
|
+
* upper bound on what it pays for, and the budget bounds the instructions the
|
|
12
|
+
* rule actually executes. Structural instructions (`block`, `loop`, `end`,
|
|
13
|
+
* `else`, `nop`, `drop`, `return`, `unreachable`) cost nothing, roughly as
|
|
14
|
+
* Wasmtime prices them.
|
|
15
|
+
*
|
|
16
|
+
* The global is exported as `FUEL_EXPORT` so the worker can tell a trap caused
|
|
17
|
+
* by the budget from any other trap. Each evaluation instantiates the module
|
|
18
|
+
* afresh, so the budget is per evaluation, like a Wasmtime `Store`.
|
|
19
|
+
*
|
|
20
|
+
* The decoder knows the MVP instruction set plus the extensions compilers
|
|
21
|
+
* emit by default (sign extension, saturating truncation, bulk memory,
|
|
22
|
+
* reference types, multi-value, tail calls, SIMD). A module using anything
|
|
23
|
+
* else (exceptions, GC, threads) is refused at load rather than run unmetered.
|
|
24
|
+
*/
|
|
25
|
+
import { assembleModule, concat, malformed, putSection, readSections, readU32, skipLeb, writeS32, writeU32, } from './wasmBinary.js';
|
|
26
|
+
/** `runner.rs`: `store.set_fuel(1_000_000)`. */
|
|
27
|
+
export const DEFAULT_FUEL_BUDGET = 1_000_000;
|
|
28
|
+
/** The export the worker reads to tell budget exhaustion from other traps. */
|
|
29
|
+
export const FUEL_EXPORT = '__intutic_fuel';
|
|
30
|
+
const SECTION = { import: 2, global: 6, export: 7, code: 10 };
|
|
31
|
+
const EXPORT_KIND_GLOBAL = 0x03;
|
|
32
|
+
const VALTYPES = new Set([0x7f, 0x7e, 0x7d, 0x7c, 0x7b, 0x70, 0x6f]);
|
|
33
|
+
const ZERO_COST = new Set([0x00, 0x01, 0x02, 0x03, 0x05, 0x0b, 0x0f, 0x1a]);
|
|
34
|
+
const OP = { block: 0x02, loop: 0x03, if: 0x04, end: 0x0b };
|
|
35
|
+
function unsupported(op) {
|
|
36
|
+
return new Error(`WASM rule uses instruction ${op}, which the instruction budget cannot meter; rebuild it without exceptions, GC or threads`);
|
|
37
|
+
}
|
|
38
|
+
function skipBlockType(b, p) {
|
|
39
|
+
const t = b[p];
|
|
40
|
+
if (t === 0x40 || VALTYPES.has(t))
|
|
41
|
+
return p + 1;
|
|
42
|
+
// A type index, as a non-negative s33: a first byte below 0x40, or one
|
|
43
|
+
// with the continuation bit set.
|
|
44
|
+
if (t < 0x40 || (t & 0x80) !== 0)
|
|
45
|
+
return skipLeb(b, p);
|
|
46
|
+
throw unsupported(`with block type 0x${t.toString(16)}`);
|
|
47
|
+
}
|
|
48
|
+
function skipMemarg(b, p) {
|
|
49
|
+
const align = readU32(b, p);
|
|
50
|
+
p = align.next;
|
|
51
|
+
if (align.value & 0x40)
|
|
52
|
+
p = skipLeb(b, p); // multi-memory index
|
|
53
|
+
return skipLeb(b, p);
|
|
54
|
+
}
|
|
55
|
+
function skipN(b, p, n) {
|
|
56
|
+
for (let i = 0; i < n; i++)
|
|
57
|
+
p = skipLeb(b, p);
|
|
58
|
+
return p;
|
|
59
|
+
}
|
|
60
|
+
/** Offset just past the instruction at `p`, immediates included. */
|
|
61
|
+
function nextInstruction(b, p) {
|
|
62
|
+
const op = b[p];
|
|
63
|
+
const q = p + 1;
|
|
64
|
+
if (op <= 0x01 || op === 0x05 || op === 0x0b || op === 0x0f || op === 0x1a || op === 0x1b || op === 0xd1)
|
|
65
|
+
return q;
|
|
66
|
+
if (op >= 0x45 && op <= 0xc4)
|
|
67
|
+
return q; // numeric, sign extension
|
|
68
|
+
switch (op) {
|
|
69
|
+
case 0x02:
|
|
70
|
+
case 0x03:
|
|
71
|
+
case 0x04: return skipBlockType(b, q);
|
|
72
|
+
case 0x0c:
|
|
73
|
+
case 0x0d:
|
|
74
|
+
case 0x10:
|
|
75
|
+
case 0x12:
|
|
76
|
+
case 0xd2: return skipLeb(b, q);
|
|
77
|
+
case 0x0e: {
|
|
78
|
+
const n = readU32(b, q);
|
|
79
|
+
return skipN(b, n.next, n.value + 1);
|
|
80
|
+
}
|
|
81
|
+
case 0x11:
|
|
82
|
+
case 0x13: return skipN(b, q, 2);
|
|
83
|
+
case 0x1c: {
|
|
84
|
+
const n = readU32(b, q);
|
|
85
|
+
for (let i = 0; i < n.value; i++)
|
|
86
|
+
if (!VALTYPES.has(b[n.next + i]))
|
|
87
|
+
throw unsupported('select with a non-numeric type');
|
|
88
|
+
return n.next + n.value;
|
|
89
|
+
}
|
|
90
|
+
case 0x3f:
|
|
91
|
+
case 0x40:
|
|
92
|
+
case 0x41:
|
|
93
|
+
case 0x42: return skipLeb(b, q);
|
|
94
|
+
case 0x43: return q + 4;
|
|
95
|
+
case 0x44: return q + 8;
|
|
96
|
+
case 0xd0: {
|
|
97
|
+
if (b[q] !== 0x70 && b[q] !== 0x6f)
|
|
98
|
+
throw unsupported('ref.null with a GC heap type');
|
|
99
|
+
return q + 1;
|
|
100
|
+
}
|
|
101
|
+
case 0xfc: return nextPrefixedFc(b, q);
|
|
102
|
+
case 0xfd: return nextSimd(b, q);
|
|
103
|
+
}
|
|
104
|
+
if (op >= 0x20 && op <= 0x26)
|
|
105
|
+
return skipLeb(b, q); // locals, globals, table.get/set
|
|
106
|
+
if (op >= 0x28 && op <= 0x3e)
|
|
107
|
+
return skipMemarg(b, q); // loads and stores
|
|
108
|
+
throw unsupported(`0x${op.toString(16)}`);
|
|
109
|
+
}
|
|
110
|
+
function nextPrefixedFc(b, q) {
|
|
111
|
+
const sub = readU32(b, q);
|
|
112
|
+
const p = sub.next;
|
|
113
|
+
if (sub.value <= 7)
|
|
114
|
+
return p; // saturating truncation
|
|
115
|
+
switch (sub.value) {
|
|
116
|
+
case 8:
|
|
117
|
+
case 10:
|
|
118
|
+
case 12:
|
|
119
|
+
case 14: return skipN(b, p, 2); // memory.init, memory.copy, table.init, table.copy
|
|
120
|
+
case 9:
|
|
121
|
+
case 11:
|
|
122
|
+
case 13:
|
|
123
|
+
case 15:
|
|
124
|
+
case 16:
|
|
125
|
+
case 17: return skipLeb(b, p);
|
|
126
|
+
}
|
|
127
|
+
throw unsupported(`0xfc ${sub.value}`);
|
|
128
|
+
}
|
|
129
|
+
function nextSimd(b, q) {
|
|
130
|
+
const sub = readU32(b, q);
|
|
131
|
+
const p = sub.next;
|
|
132
|
+
const op = sub.value;
|
|
133
|
+
if (op <= 11 || op === 92 || op === 93)
|
|
134
|
+
return skipMemarg(b, p); // v128 loads/stores, load*_zero
|
|
135
|
+
if (op === 12 || op === 13)
|
|
136
|
+
return p + 16; // v128.const, i8x16.shuffle
|
|
137
|
+
if (op >= 21 && op <= 34)
|
|
138
|
+
return p + 1; // extract/replace lane
|
|
139
|
+
if (op >= 84 && op <= 91)
|
|
140
|
+
return skipMemarg(b, p) + 1; // load/store lane
|
|
141
|
+
if (op <= 0x113)
|
|
142
|
+
return p; // everything else in SIMD and relaxed SIMD has no immediate
|
|
143
|
+
throw unsupported(`0xfd ${op}`);
|
|
144
|
+
}
|
|
145
|
+
function chargeSequence(cost, global) {
|
|
146
|
+
const g = writeU32(global);
|
|
147
|
+
return [
|
|
148
|
+
0x23, ...g, 0x41, ...writeS32(cost), 0x6b, 0x24, ...g, // fuel -= cost
|
|
149
|
+
0x23, ...g, 0x41, 0x00, 0x48, 0x04, 0x40, 0x00, 0x0b, // if (fuel < 0) unreachable
|
|
150
|
+
];
|
|
151
|
+
}
|
|
152
|
+
/** One function body with a charge at its entry and at every loop header. */
|
|
153
|
+
function meterBody(body, global) {
|
|
154
|
+
let p = 0;
|
|
155
|
+
const groups = readU32(body, p);
|
|
156
|
+
p = groups.next;
|
|
157
|
+
for (let i = 0; i < groups.value; i++) {
|
|
158
|
+
p = readU32(body, p).next;
|
|
159
|
+
if (!VALTYPES.has(body[p]))
|
|
160
|
+
throw unsupported('a local of a GC type');
|
|
161
|
+
p += 1;
|
|
162
|
+
}
|
|
163
|
+
const regions = [{ at: p, cost: 0 }];
|
|
164
|
+
const closed = [];
|
|
165
|
+
const blocks = []; // true for a loop
|
|
166
|
+
let ended = false;
|
|
167
|
+
while (p < body.length) {
|
|
168
|
+
if (ended)
|
|
169
|
+
throw malformed('instructions after a function body ends');
|
|
170
|
+
const op = body[p];
|
|
171
|
+
const next = nextInstruction(body, p);
|
|
172
|
+
if (!ZERO_COST.has(op))
|
|
173
|
+
regions[regions.length - 1].cost += 1;
|
|
174
|
+
if (op === OP.block || op === OP.if)
|
|
175
|
+
blocks.push(false);
|
|
176
|
+
else if (op === OP.loop) {
|
|
177
|
+
blocks.push(true);
|
|
178
|
+
regions.push({ at: next, cost: 0 });
|
|
179
|
+
}
|
|
180
|
+
else if (op === OP.end) {
|
|
181
|
+
if (blocks.length === 0) {
|
|
182
|
+
closed.push(regions.pop());
|
|
183
|
+
ended = true;
|
|
184
|
+
}
|
|
185
|
+
else if (blocks.pop()) {
|
|
186
|
+
closed.push(regions.pop());
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
p = next;
|
|
190
|
+
}
|
|
191
|
+
if (!ended || regions.length !== 0)
|
|
192
|
+
throw malformed('unbalanced function body');
|
|
193
|
+
closed.sort((a, b) => a.at - b.at);
|
|
194
|
+
const parts = [];
|
|
195
|
+
let cursor = 0;
|
|
196
|
+
for (const r of closed) {
|
|
197
|
+
parts.push(body.subarray(cursor, r.at), Uint8Array.from(chargeSequence(Math.max(1, r.cost), global)));
|
|
198
|
+
cursor = r.at;
|
|
199
|
+
}
|
|
200
|
+
parts.push(body.subarray(cursor));
|
|
201
|
+
return concat(parts);
|
|
202
|
+
}
|
|
203
|
+
function skipLimits(b, p) {
|
|
204
|
+
const flags = b[p];
|
|
205
|
+
p = skipLeb(b, p + 1);
|
|
206
|
+
return flags & 0x01 ? skipLeb(b, p) : p;
|
|
207
|
+
}
|
|
208
|
+
function countImportedGlobals(s) {
|
|
209
|
+
if (!s)
|
|
210
|
+
return 0;
|
|
211
|
+
const b = s.payload;
|
|
212
|
+
const n = readU32(b, 0);
|
|
213
|
+
let p = n.next;
|
|
214
|
+
let globals = 0;
|
|
215
|
+
for (let i = 0; i < n.value; i++) {
|
|
216
|
+
for (let name = 0; name < 2; name++) {
|
|
217
|
+
const len = readU32(b, p);
|
|
218
|
+
p = len.next + len.value;
|
|
219
|
+
}
|
|
220
|
+
const kind = b[p++];
|
|
221
|
+
if (kind === 0x00 || kind === 0x04)
|
|
222
|
+
p = skipLeb(b, kind === 0x04 ? p + 1 : p);
|
|
223
|
+
else if (kind === 0x01) {
|
|
224
|
+
if (b[p] !== 0x70 && b[p] !== 0x6f)
|
|
225
|
+
throw unsupported('an imported table of a GC type');
|
|
226
|
+
p = skipLimits(b, p + 1);
|
|
227
|
+
}
|
|
228
|
+
else if (kind === 0x02)
|
|
229
|
+
p = skipLimits(b, p);
|
|
230
|
+
else if (kind === 0x03) {
|
|
231
|
+
if (!VALTYPES.has(b[p]))
|
|
232
|
+
throw unsupported('an imported global of a GC type');
|
|
233
|
+
p += 2;
|
|
234
|
+
globals += 1;
|
|
235
|
+
}
|
|
236
|
+
else
|
|
237
|
+
throw malformed(`import kind ${kind}`);
|
|
238
|
+
}
|
|
239
|
+
return globals;
|
|
240
|
+
}
|
|
241
|
+
function exportNames(s) {
|
|
242
|
+
if (!s)
|
|
243
|
+
return [];
|
|
244
|
+
const b = s.payload;
|
|
245
|
+
const n = readU32(b, 0);
|
|
246
|
+
let p = n.next;
|
|
247
|
+
const names = [];
|
|
248
|
+
for (let i = 0; i < n.value; i++) {
|
|
249
|
+
const len = readU32(b, p);
|
|
250
|
+
names.push(new TextDecoder().decode(b.subarray(len.next, len.next + len.value)));
|
|
251
|
+
p = readU32(b, len.next + len.value + 1).next;
|
|
252
|
+
}
|
|
253
|
+
return names;
|
|
254
|
+
}
|
|
255
|
+
/** Prepend-count helper: a vector section with `extra` appended. */
|
|
256
|
+
function appendToVector(s, extra) {
|
|
257
|
+
if (!s)
|
|
258
|
+
return Uint8Array.from([0x01, ...extra]);
|
|
259
|
+
const n = readU32(s.payload, 0);
|
|
260
|
+
return concat([Uint8Array.from(writeU32(n.value + 1)), s.payload.subarray(n.next), Uint8Array.from(extra)]);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* The module with every function metered against `budget` instructions per
|
|
264
|
+
* instantiation, and the counter exported as `FUEL_EXPORT`. Throws for a
|
|
265
|
+
* module the decoder cannot meter.
|
|
266
|
+
*/
|
|
267
|
+
export function meterFuel(bytes, budget) {
|
|
268
|
+
const sections = readSections(bytes);
|
|
269
|
+
const find = (id) => sections.find((s) => s.id === id);
|
|
270
|
+
const code = find(SECTION.code);
|
|
271
|
+
if (!code)
|
|
272
|
+
return bytes;
|
|
273
|
+
const exports = find(SECTION.export);
|
|
274
|
+
if (exportNames(exports).includes(FUEL_EXPORT)) {
|
|
275
|
+
throw new Error(`WASM rule already exports "${FUEL_EXPORT}", which the instruction budget reserves`);
|
|
276
|
+
}
|
|
277
|
+
const globals = find(SECTION.global);
|
|
278
|
+
const fuelGlobal = countImportedGlobals(find(SECTION.import)) + (globals ? readU32(globals.payload, 0).value : 0);
|
|
279
|
+
const count = readU32(code.payload, 0);
|
|
280
|
+
const bodies = [Uint8Array.from(writeU32(count.value))];
|
|
281
|
+
let p = count.next;
|
|
282
|
+
for (let i = 0; i < count.value; i++) {
|
|
283
|
+
const size = readU32(code.payload, p);
|
|
284
|
+
const end = size.next + size.value;
|
|
285
|
+
if (end > code.payload.length)
|
|
286
|
+
throw malformed('function body runs past the code section');
|
|
287
|
+
const metered = meterBody(code.payload.subarray(size.next, end), fuelGlobal);
|
|
288
|
+
bodies.push(Uint8Array.from(writeU32(metered.length)), metered);
|
|
289
|
+
p = end;
|
|
290
|
+
}
|
|
291
|
+
if (p !== code.payload.length)
|
|
292
|
+
throw malformed('code section length mismatch');
|
|
293
|
+
putSection(sections, SECTION.global, appendToVector(globals, [0x7f, 0x01, 0x41, ...writeS32(budget), 0x0b]));
|
|
294
|
+
const name = [...new TextEncoder().encode(FUEL_EXPORT)];
|
|
295
|
+
putSection(sections, SECTION.export, appendToVector(exports, [...writeU32(name.length), ...name, EXPORT_KIND_GLOBAL, ...writeU32(fuelGlobal)]));
|
|
296
|
+
putSection(sections, SECTION.code, concat(bodies));
|
|
297
|
+
return assembleModule(bytes, sections);
|
|
298
|
+
}
|
|
299
|
+
//# sourceMappingURL=fuel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fuel.js","sourceRoot":"","sources":["../../src/wasm/fuel.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EACL,cAAc,EACd,MAAM,EACN,SAAS,EACT,UAAU,EACV,YAAY,EACZ,OAAO,EACP,OAAO,EACP,QAAQ,EACR,QAAQ,GAET,MAAM,iBAAiB,CAAA;AAExB,gDAAgD;AAChD,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAE5C,8EAA8E;AAC9E,MAAM,CAAC,MAAM,WAAW,GAAG,gBAAgB,CAAA;AAE3C,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,EAAW,CAAA;AACtE,MAAM,kBAAkB,GAAG,IAAI,CAAA;AAC/B,MAAM,QAAQ,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,CAAC,CAAA;AACpE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A8B,CAAC,CAAA;IAE9E,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,CAAC,CAAC,CAAA;IAC5G,MAAM,IAAI,GAAG,CAAC,GAAG,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAA;IACvD,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,MAAM,EAAE,cAAc,CAAC,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,GAAG,IAAI,EAAE,kBAAkB,EAAE,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAA;IAC/I,UAAU,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAA;IAClD,OAAO,cAAc,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAA;AACxC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bound a rule's linear memory before V8 ever compiles it (TD-440).
|
|
3
|
+
*
|
|
4
|
+
* V8 has no grow hook, but it enforces the maximum a module DECLARES for its
|
|
5
|
+
* own memory: past it, `memory.grow` returns -1 instead of growing. So the
|
|
6
|
+
* memory section is rewritten to declare a maximum no larger than the ceiling,
|
|
7
|
+
* and the engine does the rest, the same guarantee `runner.rs` gets from
|
|
8
|
+
* Wasmtime's `StoreLimits`. A rule that asks for more is refused at load.
|
|
9
|
+
*
|
|
10
|
+
* Only the memory section (id 5) is touched; every other byte is copied
|
|
11
|
+
* through. Shared and 64-bit memories are refused rather than rewritten: the
|
|
12
|
+
* runner never supplies either, and their limits encode differently.
|
|
13
|
+
*/
|
|
14
|
+
/** One WebAssembly page. */
|
|
15
|
+
export declare const WASM_PAGE_BYTES: number;
|
|
16
|
+
/**
|
|
17
|
+
* The module with every memory declaring `max <= maxPages`. Throws when a
|
|
18
|
+
* memory's initial size is already over the ceiling, or it is shared/64-bit.
|
|
19
|
+
*/
|
|
20
|
+
export declare function capDeclaredMemory(bytes: Uint8Array<ArrayBuffer>, maxPages: number): Uint8Array<ArrayBuffer>;
|
|
21
|
+
//# sourceMappingURL=memoryCap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memoryCap.d.ts","sourceRoot":"","sources":["../../src/wasm/memoryCap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,4BAA4B;AAC5B,eAAO,MAAM,eAAe,QAAY,CAAA;AAIxC;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,GAAG,UAAU,CAAC,WAAW,CAAC,CA+B3G"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bound a rule's linear memory before V8 ever compiles it (TD-440).
|
|
3
|
+
*
|
|
4
|
+
* V8 has no grow hook, but it enforces the maximum a module DECLARES for its
|
|
5
|
+
* own memory: past it, `memory.grow` returns -1 instead of growing. So the
|
|
6
|
+
* memory section is rewritten to declare a maximum no larger than the ceiling,
|
|
7
|
+
* and the engine does the rest, the same guarantee `runner.rs` gets from
|
|
8
|
+
* Wasmtime's `StoreLimits`. A rule that asks for more is refused at load.
|
|
9
|
+
*
|
|
10
|
+
* Only the memory section (id 5) is touched; every other byte is copied
|
|
11
|
+
* through. Shared and 64-bit memories are refused rather than rewritten: the
|
|
12
|
+
* runner never supplies either, and their limits encode differently.
|
|
13
|
+
*/
|
|
14
|
+
import { assembleModule, malformed, putSection, readSections, readU32, writeU32 } from './wasmBinary.js';
|
|
15
|
+
/** One WebAssembly page. */
|
|
16
|
+
export const WASM_PAGE_BYTES = 64 * 1024;
|
|
17
|
+
const MEMORY_SECTION_ID = 5;
|
|
18
|
+
/**
|
|
19
|
+
* The module with every memory declaring `max <= maxPages`. Throws when a
|
|
20
|
+
* memory's initial size is already over the ceiling, or it is shared/64-bit.
|
|
21
|
+
*/
|
|
22
|
+
export function capDeclaredMemory(bytes, maxPages) {
|
|
23
|
+
const sections = readSections(bytes);
|
|
24
|
+
const memory = sections.find((s) => s.id === MEMORY_SECTION_ID);
|
|
25
|
+
if (!memory)
|
|
26
|
+
return bytes;
|
|
27
|
+
const b = memory.payload;
|
|
28
|
+
const count = readU32(b, 0);
|
|
29
|
+
let p = count.next;
|
|
30
|
+
const payload = writeU32(count.value);
|
|
31
|
+
for (let i = 0; i < count.value; i++) {
|
|
32
|
+
const flags = b[p];
|
|
33
|
+
if (flags !== 0x00 && flags !== 0x01) {
|
|
34
|
+
throw new Error(`WASM rule declares a shared or 64-bit memory (limits flag 0x${(flags ?? 0).toString(16)}), which the runner does not support`);
|
|
35
|
+
}
|
|
36
|
+
const min = readU32(b, p + 1);
|
|
37
|
+
p = min.next;
|
|
38
|
+
let max = maxPages;
|
|
39
|
+
if (flags === 0x01) {
|
|
40
|
+
const declared = readU32(b, p);
|
|
41
|
+
p = declared.next;
|
|
42
|
+
max = Math.min(declared.value, maxPages);
|
|
43
|
+
}
|
|
44
|
+
if (min.value > maxPages) {
|
|
45
|
+
throw new Error(`WASM rule declares ${min.value * WASM_PAGE_BYTES} bytes of initial memory, over the ${maxPages * WASM_PAGE_BYTES}-byte ceiling`);
|
|
46
|
+
}
|
|
47
|
+
payload.push(0x01, ...writeU32(min.value), ...writeU32(max));
|
|
48
|
+
}
|
|
49
|
+
if (p !== b.length)
|
|
50
|
+
throw malformed('memory section length mismatch');
|
|
51
|
+
putSection(sections, MEMORY_SECTION_ID, Uint8Array.from(payload));
|
|
52
|
+
return assembleModule(bytes, sections);
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=memoryCap.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":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
20
|
-
* V8
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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.
|
|
19
|
+
* - **Guest memory ceiling: the same 16MB, enforced a different way.**
|
|
20
|
+
* `runner.rs` sets a `StoreLimits` cap; V8 has no such hook, but it does
|
|
21
|
+
* enforce the maximum a module declares, so `worker.ts` rewrites the
|
|
22
|
+
* 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.
|
|
25
25
|
* - **`read_referenced_file` is served from a pre-read table**
|
|
26
26
|
* (`referencedFiles.ts`, the port of `referenced_files.rs`), prefetched
|
|
27
27
|
* once per `evaluate()` only when a loaded rule imports the function and
|
|
@@ -84,6 +84,7 @@ export declare class WasmRunner implements CompileBridge {
|
|
|
84
84
|
private prefetchReferencedFiles;
|
|
85
85
|
/** One rule's evaluation, raced against `EVALUATE_TIMEOUT_MS`. `null` means fail-open (timeout, worker error, or guest trap). */
|
|
86
86
|
private evaluateOne;
|
|
87
|
+
private countRunaway;
|
|
87
88
|
/** Terminates the worker. Safe to call even if one was never spawned. */
|
|
88
89
|
shutdown(): Promise<void>;
|
|
89
90
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/wasm/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA;
|
|
1
|
+
{"version":3,"file":"runner.d.ts","sourceRoot":"","sources":["../../src/wasm/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAMH,OAAO,EAA8B,KAAK,aAAa,EAAE,KAAK,cAAc,EAAE,MAAM,aAAa,CAAA;AACjG,OAAO,EAAoB,KAAK,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAqBtE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,GACjB;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACjD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAA;AAyCrD,qBAAa,UAAW,YAAW,aAAa;IAC9C,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAY;IACnC,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,aAAa,CAAI;IACzB,OAAO,CAAC,OAAO,CAAkC;IACjD,OAAO,CAAC,mBAAmB,CAA4B;IACvD,OAAO,CAAC,eAAe,CAAoB;gBAE/B,WAAW,CAAC,EAAE,MAAM;IAIhC,uDAAuD;IACvD,MAAM,IAAI,MAAM;IAIhB,yGAAyG;IACzG,gBAAgB,IAAI,MAAM,EAAE;IAI5B,OAAO,CAAC,YAAY;IAmBpB,gFAAgF;IAChF,OAAO,CAAC,IAAI;IAYZ,OAAO,CAAC,OAAO;IAQT,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,OAAO,CAAC,cAAc,CAAC;IAmBzE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQ5B;;;;OAIG;IACG,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAM7B,oIAAoI;YACtH,aAAa;IAqB3B;;;;;;OAMG;IACG,QAAQ,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAAC,WAAW,CAAC;IAuD7D;;;OAGG;YACW,uBAAuB;IAUrC,iIAAiI;YACnH,WAAW;IA+CzB,OAAO,CAAC,YAAY;IAYpB,yEAAyE;IACnE,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAUhC;AAWD,YAAY,EAAE,gBAAgB,EAAE,CAAA"}
|
package/dist/wasm/runner.js
CHANGED
|
@@ -7,21 +7,21 @@
|
|
|
7
7
|
*
|
|
8
8
|
* ## Divergences from the Rust runner (all recorded as TD entries)
|
|
9
9
|
*
|
|
10
|
-
* - **
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* the
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* V8
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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.
|
|
19
|
+
* - **Guest memory ceiling: the same 16MB, enforced a different way.**
|
|
20
|
+
* `runner.rs` sets a `StoreLimits` cap; V8 has no such hook, but it does
|
|
21
|
+
* enforce the maximum a module declares, so `worker.ts` rewrites the
|
|
22
|
+
* 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.
|
|
25
25
|
* - **`read_referenced_file` is served from a pre-read table**
|
|
26
26
|
* (`referencedFiles.ts`, the port of `referenced_files.rs`), prefetched
|
|
27
27
|
* once per `evaluate()` only when a loaded rule imports the function and
|
|
@@ -46,7 +46,10 @@ const EVALUATE_TIMEOUT_MS = 50;
|
|
|
46
46
|
/** Generous — compilation is not guest-controlled per evaluation, but a
|
|
47
47
|
* pathological file must not hang a rescan forever. */
|
|
48
48
|
const COMPILE_TIMEOUT_MS = 3_000;
|
|
49
|
-
/**
|
|
49
|
+
/**
|
|
50
|
+
* Consecutive per-rule runaways (a timeout, or the instruction budget running
|
|
51
|
+
* out) before that rule is disabled until the next rescan.
|
|
52
|
+
*/
|
|
50
53
|
const MAX_CONSECUTIVE_TIMEOUTS = 3;
|
|
51
54
|
/**
|
|
52
55
|
* Resolves the worker script to spawn.
|
|
@@ -262,17 +265,20 @@ export class WasmRunner {
|
|
|
262
265
|
// fails open — plus the MCP-specific per-rule consecutive-timeout
|
|
263
266
|
// disable ladder the task calls for.
|
|
264
267
|
log.warn({ action: 'wasm_evaluate_timeout', ruleId, timeoutMs: EVALUATE_TIMEOUT_MS }, 'WASM rule evaluation timed out — failing open');
|
|
265
|
-
const attempts = (this.consecutiveTimeouts.get(ruleId) ?? 0) + 1;
|
|
266
|
-
this.consecutiveTimeouts.set(ruleId, attempts);
|
|
267
268
|
// terminate + lazily respawn: the NEXT evaluate() call pays the
|
|
268
269
|
// respawn cost via ensureWorker()/rescan(force); triggered here so a
|
|
269
270
|
// wedged worker does not keep timing out every rule behind it in this
|
|
270
271
|
// same evaluate() loop.
|
|
271
272
|
await this.respawnWorker();
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
273
|
+
this.countRunaway(ruleId);
|
|
274
|
+
return null;
|
|
275
|
+
}
|
|
276
|
+
if (!reply.ok && reply.fuelExhausted) {
|
|
277
|
+
// 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
|
|
279
|
+
// runaway rule caught sooner.
|
|
280
|
+
log.warn({ action: 'wasm_evaluate_fuel_exhausted', ruleId }, 'WASM rule ran out of its instruction budget — failing open');
|
|
281
|
+
this.countRunaway(ruleId);
|
|
276
282
|
return null;
|
|
277
283
|
}
|
|
278
284
|
if (!reply.ok) {
|
|
@@ -286,6 +292,14 @@ export class WasmRunner {
|
|
|
286
292
|
this.consecutiveTimeouts.delete(ruleId);
|
|
287
293
|
return { code: reply.code ?? -1, reason: reply.reason };
|
|
288
294
|
}
|
|
295
|
+
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');
|
|
301
|
+
}
|
|
302
|
+
}
|
|
289
303
|
/** Terminates the worker. Safe to call even if one was never spawned. */
|
|
290
304
|
async shutdown() {
|
|
291
305
|
const worker = this.worker;
|
package/dist/wasm/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","sourceRoot":"","sources":["../../src/wasm/runner.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;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`, `fuel.ts`) share: LEB128 integers, the section list, and
|
|
4
|
+
* reassembly. Not a general decoder; each rewrite parses only what it changes.
|
|
5
|
+
*/
|
|
6
|
+
export interface Section {
|
|
7
|
+
id: number;
|
|
8
|
+
payload: Uint8Array<ArrayBuffer>;
|
|
9
|
+
}
|
|
10
|
+
export declare function malformed(what: string): Error;
|
|
11
|
+
export declare function readU32(bytes: Uint8Array, at: number): {
|
|
12
|
+
value: number;
|
|
13
|
+
next: number;
|
|
14
|
+
};
|
|
15
|
+
/** Skip any LEB128 integer, signed or unsigned, up to 64 bits. */
|
|
16
|
+
export declare function skipLeb(bytes: Uint8Array, at: number): number;
|
|
17
|
+
export declare function writeU32(value: number): number[];
|
|
18
|
+
/** Signed LEB128, for `i32.const` immediates. */
|
|
19
|
+
export declare function writeS32(value: number): number[];
|
|
20
|
+
export declare function readSections(bytes: Uint8Array<ArrayBuffer>): Section[];
|
|
21
|
+
/** Replace the section with `id`, or insert it where the spec's order puts it. */
|
|
22
|
+
export declare function putSection(sections: Section[], id: number, payload: Uint8Array<ArrayBuffer>): void;
|
|
23
|
+
export declare function assembleModule(header: Uint8Array, sections: Section[]): Uint8Array<ArrayBuffer>;
|
|
24
|
+
export declare function concat(parts: Uint8Array[]): Uint8Array<ArrayBuffer>;
|
|
25
|
+
//# sourceMappingURL=wasmBinary.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasmBinary.d.ts","sourceRoot":"","sources":["../../src/wasm/wasmBinary.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAIH,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,MAAM,CAAA;IACV,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,CAAA;CACjC;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAE7C;AAED,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAUtF;AAED,kEAAkE;AAClE,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,EAAE,MAAM,GAAG,MAAM,CAK7D;AAED,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAShD;AAED,iDAAiD;AACjD,wBAAgB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,EAAE,CAShD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,OAAO,EAAE,CAYtE;AAKD,kFAAkF;AAClF,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,CAAC,WAAW,CAAC,GAAG,IAAI,CAYlG;AAED,wBAAgB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAM/F;AAED,wBAAgB,MAAM,CAAC,KAAK,EAAE,UAAU,EAAE,GAAG,UAAU,CAAC,WAAW,CAAC,CAQnE"}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The few pieces of the WebAssembly binary format the load-time rewrites
|
|
3
|
+
* (`memoryCap.ts`, `fuel.ts`) share: LEB128 integers, the section list, and
|
|
4
|
+
* reassembly. Not a general decoder; each rewrite parses only what it changes.
|
|
5
|
+
*/
|
|
6
|
+
const HEADER_BYTES = 8; // `\0asm` + version
|
|
7
|
+
export function malformed(what) {
|
|
8
|
+
return new Error(`malformed WASM module: ${what}`);
|
|
9
|
+
}
|
|
10
|
+
export function readU32(bytes, at) {
|
|
11
|
+
let value = 0;
|
|
12
|
+
let shift = 0;
|
|
13
|
+
for (let i = at; i < bytes.length && i < at + 5; i++) {
|
|
14
|
+
const byte = bytes[i];
|
|
15
|
+
value += (byte & 0x7f) * 2 ** shift;
|
|
16
|
+
if ((byte & 0x80) === 0)
|
|
17
|
+
return { value, next: i + 1 };
|
|
18
|
+
shift += 7;
|
|
19
|
+
}
|
|
20
|
+
throw malformed('truncated or oversized LEB128 integer');
|
|
21
|
+
}
|
|
22
|
+
/** Skip any LEB128 integer, signed or unsigned, up to 64 bits. */
|
|
23
|
+
export function skipLeb(bytes, at) {
|
|
24
|
+
for (let i = at; i < bytes.length && i < at + 10; i++) {
|
|
25
|
+
if ((bytes[i] & 0x80) === 0)
|
|
26
|
+
return i + 1;
|
|
27
|
+
}
|
|
28
|
+
throw malformed('truncated or oversized LEB128 integer');
|
|
29
|
+
}
|
|
30
|
+
export function writeU32(value) {
|
|
31
|
+
const out = [];
|
|
32
|
+
do {
|
|
33
|
+
let byte = value & 0x7f;
|
|
34
|
+
value = Math.floor(value / 128);
|
|
35
|
+
if (value !== 0)
|
|
36
|
+
byte |= 0x80;
|
|
37
|
+
out.push(byte);
|
|
38
|
+
} while (value !== 0);
|
|
39
|
+
return out;
|
|
40
|
+
}
|
|
41
|
+
/** Signed LEB128, for `i32.const` immediates. */
|
|
42
|
+
export function writeS32(value) {
|
|
43
|
+
const out = [];
|
|
44
|
+
for (;;) {
|
|
45
|
+
const byte = value & 0x7f;
|
|
46
|
+
value >>= 7;
|
|
47
|
+
const done = (value === 0 && (byte & 0x40) === 0) || (value === -1 && (byte & 0x40) !== 0);
|
|
48
|
+
out.push(done ? byte : byte | 0x80);
|
|
49
|
+
if (done)
|
|
50
|
+
return out;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
export function readSections(bytes) {
|
|
54
|
+
const sections = [];
|
|
55
|
+
let at = HEADER_BYTES;
|
|
56
|
+
while (at < bytes.length) {
|
|
57
|
+
const id = bytes[at];
|
|
58
|
+
const size = readU32(bytes, at + 1);
|
|
59
|
+
const end = size.next + size.value;
|
|
60
|
+
if (end > bytes.length)
|
|
61
|
+
throw malformed('section runs past the end');
|
|
62
|
+
sections.push({ id, payload: bytes.subarray(size.next, end) });
|
|
63
|
+
at = end;
|
|
64
|
+
}
|
|
65
|
+
return sections;
|
|
66
|
+
}
|
|
67
|
+
/** Section order the spec requires; custom sections (id 0) may sit anywhere. */
|
|
68
|
+
const SECTION_RANK = { 1: 1, 2: 2, 3: 3, 4: 4, 5: 5, 13: 6, 6: 7, 7: 8, 8: 9, 9: 10, 12: 11, 10: 12, 11: 13 };
|
|
69
|
+
/** Replace the section with `id`, or insert it where the spec's order puts it. */
|
|
70
|
+
export function putSection(sections, id, payload) {
|
|
71
|
+
const existing = sections.findIndex((s) => s.id === id);
|
|
72
|
+
if (existing >= 0) {
|
|
73
|
+
sections[existing] = { id, payload };
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const rank = SECTION_RANK[id];
|
|
77
|
+
let insertAt = 0;
|
|
78
|
+
sections.forEach((s, i) => {
|
|
79
|
+
if (s.id !== 0 && SECTION_RANK[s.id] < rank)
|
|
80
|
+
insertAt = i + 1;
|
|
81
|
+
});
|
|
82
|
+
sections.splice(insertAt, 0, { id, payload });
|
|
83
|
+
}
|
|
84
|
+
export function assembleModule(header, sections) {
|
|
85
|
+
const parts = [header.subarray(0, HEADER_BYTES)];
|
|
86
|
+
for (const s of sections) {
|
|
87
|
+
parts.push(Uint8Array.from([s.id, ...writeU32(s.payload.length)]), s.payload);
|
|
88
|
+
}
|
|
89
|
+
return concat(parts);
|
|
90
|
+
}
|
|
91
|
+
export function concat(parts) {
|
|
92
|
+
const out = new Uint8Array(parts.reduce((n, p) => n + p.length, 0));
|
|
93
|
+
let at = 0;
|
|
94
|
+
for (const p of parts) {
|
|
95
|
+
out.set(p, at);
|
|
96
|
+
at += p.length;
|
|
97
|
+
}
|
|
98
|
+
return out;
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=wasmBinary.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wasmBinary.js","sourceRoot":"","sources":["../../src/wasm/wasmBinary.ts"],"names":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
/**
|
|
29
|
-
* Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440).
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* What it cannot do is bound the growth itself; that remainder stays in
|
|
35
|
-
* TD-440. Checked before the call too, so a module that declares more than
|
|
36
|
-
* the ceiling as its initial size never runs.
|
|
29
|
+
* Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440). Enforced at
|
|
30
|
+
* load by `capDeclaredMemory`: the module's own memory is rewritten to declare
|
|
31
|
+
* this as its maximum, so V8 refuses any `memory.grow` past it (the call
|
|
32
|
+
* returns -1) instead of growing. A module whose initial size is already over
|
|
33
|
+
* it is refused, and so is an imported memory, which would sit outside the cap.
|
|
37
34
|
*/
|
|
38
35
|
export declare const MAX_GUEST_MEMORY_BYTES: number;
|
|
39
36
|
//# sourceMappingURL=worker.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.d.ts","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;
|
|
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"}
|
package/dist/wasm/worker.js
CHANGED
|
@@ -29,15 +29,14 @@ import { parentPort } from 'node:worker_threads';
|
|
|
29
29
|
import { unsupportedWasmImports, WASM_HOST_IMPORTS } from '@intutic/shared-types';
|
|
30
30
|
import { createHostImports, newHostImportState } from './hostImports.js';
|
|
31
31
|
import { ReferencedFiles } from './referencedFiles.js';
|
|
32
|
+
import { capDeclaredMemory, WASM_PAGE_BYTES } from './memoryCap.js';
|
|
33
|
+
import { DEFAULT_FUEL_BUDGET, FUEL_EXPORT, meterFuel } from './fuel.js';
|
|
32
34
|
/**
|
|
33
|
-
* Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440).
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
*
|
|
38
|
-
* What it cannot do is bound the growth itself; that remainder stays in
|
|
39
|
-
* TD-440. Checked before the call too, so a module that declares more than
|
|
40
|
-
* the ceiling as its initial size never runs.
|
|
35
|
+
* Guest memory ceiling, `runner.rs`'s 16MB `StoreLimits` (TD-440). Enforced at
|
|
36
|
+
* load by `capDeclaredMemory`: the module's own memory is rewritten to declare
|
|
37
|
+
* this as its maximum, so V8 refuses any `memory.grow` past it (the call
|
|
38
|
+
* returns -1) instead of growing. A module whose initial size is already over
|
|
39
|
+
* it is refused, and so is an imported memory, which would sit outside the cap.
|
|
41
40
|
*/
|
|
42
41
|
export const MAX_GUEST_MEMORY_BYTES = 16 * 1024 * 1024;
|
|
43
42
|
/**
|
|
@@ -72,7 +71,11 @@ function importsUsingReadReferencedFile(module) {
|
|
|
72
71
|
}
|
|
73
72
|
function handleCompile(msg) {
|
|
74
73
|
try {
|
|
75
|
-
const
|
|
74
|
+
const capped = capDeclaredMemory(new Uint8Array(msg.bytes), MAX_GUEST_MEMORY_BYTES / WASM_PAGE_BYTES);
|
|
75
|
+
const module = new WebAssembly.Module(meterFuel(capped, DEFAULT_FUEL_BUDGET));
|
|
76
|
+
if (WebAssembly.Module.imports(module).some((i) => i.kind === 'memory')) {
|
|
77
|
+
throw new Error('WASM rule imports its memory; a rule must define and export its own');
|
|
78
|
+
}
|
|
76
79
|
const unsupported = unsupportedWasmImports(module);
|
|
77
80
|
if (unsupported.length > 0) {
|
|
78
81
|
parentPort?.postMessage({
|
|
@@ -159,6 +162,9 @@ function handleEvaluate(msg) {
|
|
|
159
162
|
parentPort?.postMessage({ type: 'evaluate-result', id: msg.id, ruleId: msg.ruleId, ok: false, error: 'rule not loaded' });
|
|
160
163
|
return;
|
|
161
164
|
}
|
|
165
|
+
// Read in the catch below: a trap with the counter below zero is the
|
|
166
|
+
// instruction budget running out, not the rule's own `unreachable`.
|
|
167
|
+
let fuel;
|
|
162
168
|
try {
|
|
163
169
|
// A holder object, not a reassigned `let`: the import object (needed by
|
|
164
170
|
// `WebAssembly.Instance` below) has to exist BEFORE the instance's own
|
|
@@ -169,15 +175,15 @@ function handleEvaluate(msg) {
|
|
|
169
175
|
const env = createHostImports(() => memoryHolder.current, hostState);
|
|
170
176
|
const instance = new WebAssembly.Instance(module, { env });
|
|
171
177
|
const exportsObj = instance.exports;
|
|
178
|
+
const fuelExport = exportsObj[FUEL_EXPORT];
|
|
179
|
+
if (fuelExport instanceof WebAssembly.Global)
|
|
180
|
+
fuel = fuelExport;
|
|
172
181
|
const memExport = exportsObj['memory'];
|
|
173
182
|
if (!(memExport instanceof WebAssembly.Memory)) {
|
|
174
183
|
throw new Error("WASM module missing 'memory' export");
|
|
175
184
|
}
|
|
176
185
|
memoryHolder.current = memExport;
|
|
177
186
|
const memory = memExport;
|
|
178
|
-
if (memory.buffer.byteLength > MAX_GUEST_MEMORY_BYTES) {
|
|
179
|
-
throw new Error(`WASM module declares ${memory.buffer.byteLength} bytes of initial memory, over the ${MAX_GUEST_MEMORY_BYTES}-byte ceiling`);
|
|
180
|
-
}
|
|
181
187
|
const contextBytes = new Uint8Array(msg.bytes);
|
|
182
188
|
// allocate() primary, __new(size, id) AssemblyScript fallback — same
|
|
183
189
|
// fallback order as runner.rs.
|
|
@@ -205,21 +211,22 @@ function handleEvaluate(msg) {
|
|
|
205
211
|
// hostile length must not be able to buy extra time by doing so after
|
|
206
212
|
// the verdict — same reasoning runner.rs states for its own placement.
|
|
207
213
|
const reason = readGuestReason(exportsObj, memory);
|
|
208
|
-
if (memory.buffer.byteLength > MAX_GUEST_MEMORY_BYTES) {
|
|
209
|
-
throw new Error(`WASM rule grew guest memory to ${memory.buffer.byteLength} bytes, over the ${MAX_GUEST_MEMORY_BYTES}-byte ceiling; verdict discarded`);
|
|
210
|
-
}
|
|
211
214
|
parentPort?.postMessage({ type: 'evaluate-result', id: msg.id, ruleId: msg.ruleId, ok: true, code, reason });
|
|
212
215
|
}
|
|
213
216
|
catch (err) {
|
|
214
217
|
// A guest trap (including one following an `abort` call) lands here.
|
|
215
218
|
// Reported as a failure, never re-thrown — the worker process must
|
|
216
219
|
// survive one hostile or buggy rule to keep evaluating every other one.
|
|
220
|
+
const fuelExhausted = fuel !== undefined && fuel.value < 0;
|
|
217
221
|
parentPort?.postMessage({
|
|
218
222
|
type: 'evaluate-result',
|
|
219
223
|
id: msg.id,
|
|
220
224
|
ruleId: msg.ruleId,
|
|
221
225
|
ok: false,
|
|
222
|
-
|
|
226
|
+
fuelExhausted,
|
|
227
|
+
error: fuelExhausted
|
|
228
|
+
? `WASM rule ran out of its ${DEFAULT_FUEL_BUDGET}-instruction budget`
|
|
229
|
+
: err instanceof Error ? err.message : String(err),
|
|
223
230
|
});
|
|
224
231
|
}
|
|
225
232
|
}
|
package/dist/wasm/worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAA;AACjF,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAA;AACxE,OAAO,EAAE,eAAe,EAA6B,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"worker.js","sourceRoot":"","sources":["../../src/wasm/worker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAA;AAChD,OAAO,EAAE,sBAAsB,EAAE,iBAAiB,EAAE,MAA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,EAAE;IAC3C,QAAQ,GAAG,CAAC,IAAI,EAAE,CAAC;QACjB,KAAK,SAAS;YACZ,aAAa,CAAC,GAAG,CAAC,CAAA;YAClB,MAAK;QACP,KAAK,QAAQ;YACX,YAAY,CAAC,GAAG,CAAC,CAAA;YACjB,MAAK;QACP,KAAK,UAAU;YACb,cAAc,CAAC,GAAG,CAAC,CAAA;YACnB,MAAK;IACT,CAAC;AACH,CAAC,CAAC,CAAA;AAEF,4EAA4E;AAC5E,yEAAyE;AACzE,qEAAqE;AACrE,gEAAgE;AAChE,yDAAyD;AACzD,KAAK,iBAAiB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intutic/mcp-governance-proxy",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Intutic MCP Governance Proxy — transparent stdio proxy that intercepts all tools/call JSON-RPC messages and applies workspace SOP policy before forwarding to real MCP servers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"LICENSE"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@modelcontextprotocol/sdk": "^1.
|
|
25
|
+
"@modelcontextprotocol/sdk": "^1.31.0",
|
|
26
26
|
"@opentelemetry/api": "^1.9.1",
|
|
27
27
|
"@opentelemetry/auto-instrumentations-node": "^0.79.0",
|
|
28
28
|
"@opentelemetry/exporter-metrics-otlp-http": "^0.221.0",
|
|
@@ -33,9 +33,9 @@
|
|
|
33
33
|
"@opentelemetry/semantic-conventions": "^1.43.0",
|
|
34
34
|
"ioredis": "^5",
|
|
35
35
|
"zod": "^3",
|
|
36
|
-
"@intutic/id": "2.
|
|
37
|
-
"@intutic/
|
|
38
|
-
"@intutic/
|
|
36
|
+
"@intutic/id": "2.1.0",
|
|
37
|
+
"@intutic/logger": "2.1.0",
|
|
38
|
+
"@intutic/shared-types": "2.1.0"
|
|
39
39
|
},
|
|
40
40
|
"devDependencies": {
|
|
41
41
|
"@types/node": "^22",
|