@intutic/shared-types 2.3.0 → 2.5.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/README.md +1 -1
- package/dist/anomaly.d.ts +0 -19
- package/dist/anomaly.d.ts.map +1 -1
- package/dist/attenuation.d.ts +4 -3
- package/dist/attenuation.d.ts.map +1 -1
- package/dist/attenuation.js +4 -3
- package/dist/attenuation.js.map +1 -1
- package/dist/auth.d.ts +106 -0
- package/dist/auth.d.ts.map +1 -1
- package/dist/auth.js +17 -1
- package/dist/auth.js.map +1 -1
- package/dist/chaos.d.ts +2225 -0
- package/dist/chaos.d.ts.map +1 -0
- package/dist/chaos.js +358 -0
- package/dist/chaos.js.map +1 -0
- package/dist/chaosGate.d.ts +166 -0
- package/dist/chaosGate.d.ts.map +1 -0
- package/dist/chaosGate.js +383 -0
- package/dist/chaosGate.js.map +1 -0
- package/dist/cloudProbe.d.ts +54 -0
- package/dist/cloudProbe.d.ts.map +1 -0
- package/dist/cloudProbe.js +254 -0
- package/dist/cloudProbe.js.map +1 -0
- package/dist/enums.d.ts +48 -0
- package/dist/enums.d.ts.map +1 -1
- package/dist/enums.js +31 -3
- package/dist/enums.js.map +1 -1
- package/dist/finops.d.ts +38 -18
- package/dist/finops.d.ts.map +1 -1
- package/dist/guardrailIr.d.ts +4 -4
- package/dist/index.d.ts +18 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +68 -9
- package/dist/index.js.map +1 -1
- package/dist/intelligence.d.ts +3 -100
- package/dist/intelligence.d.ts.map +1 -1
- package/dist/intelligence.js +3 -3
- package/dist/intelligence.js.map +1 -1
- package/dist/mcpBudgets.d.ts +32 -32
- package/dist/notifications.d.ts +17 -2
- package/dist/notifications.d.ts.map +1 -1
- package/dist/notifications.js +35 -5
- package/dist/notifications.js.map +1 -1
- package/dist/observability.d.ts +0 -31
- package/dist/observability.d.ts.map +1 -1
- package/dist/observability.js +0 -7
- package/dist/observability.js.map +1 -1
- package/dist/opaqueRefusal.d.ts +40 -0
- package/dist/opaqueRefusal.d.ts.map +1 -0
- package/dist/opaqueRefusal.js +53 -0
- package/dist/opaqueRefusal.js.map +1 -0
- package/dist/policyGuardrails.d.ts +5 -5
- package/dist/providerVerification.d.ts +35 -9
- package/dist/providerVerification.d.ts.map +1 -1
- package/dist/providerVerification.js +79 -19
- package/dist/providerVerification.js.map +1 -1
- package/dist/providers.d.ts +50 -13
- package/dist/providers.d.ts.map +1 -1
- package/dist/providers.js +131 -27
- package/dist/providers.js.map +1 -1
- package/dist/spendBudgets.d.ts +122 -0
- package/dist/spendBudgets.d.ts.map +1 -0
- package/dist/spendBudgets.js +92 -0
- package/dist/spendBudgets.js.map +1 -0
- package/dist/taskManagement.d.ts +34 -82
- package/dist/taskManagement.d.ts.map +1 -1
- package/dist/taskManagement.js +4 -4
- package/dist/toolPoison.d.ts +15 -2
- package/dist/toolPoison.d.ts.map +1 -1
- package/dist/toolPoison.js +14 -4
- package/dist/toolPoison.js.map +1 -1
- package/dist/upstreamRetry.d.ts +121 -0
- package/dist/upstreamRetry.d.ts.map +1 -0
- package/dist/upstreamRetry.js +90 -0
- package/dist/upstreamRetry.js.map +1 -0
- package/dist/wasmRuleDescriptor.d.ts +43 -0
- package/dist/wasmRuleDescriptor.d.ts.map +1 -0
- package/dist/wasmRuleDescriptor.js +65 -0
- package/dist/wasmRuleDescriptor.js.map +1 -0
- package/dist/workspaceSettings.d.ts +42 -4
- package/dist/workspaceSettings.d.ts.map +1 -1
- package/dist/workspaceSettings.js.map +1 -1
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chaos.d.ts","sourceRoot":"","sources":["../src/chaos.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,wFAAwF;AACxF,eAAO,MAAM,cAAc,uBAAuB,CAAA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A;IAChB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE;AAC3D,6EAA6E;GAC3E;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GACnC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAA;AAE9E;;;GAGG;AACH,wBAAgB,eAAe,CAAC,MAAM,EAAE,SAAS,YAAY,EAAE,GAAG,MAAM,CAMvE"}
|
package/dist/chaos.js
ADDED
|
@@ -0,0 +1,358 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* chaos.ts — the contract for agent fault injection (`intutic chaos run`).
|
|
4
|
+
*
|
|
5
|
+
* A chaos run executes an agent with a known fault injected and checks what
|
|
6
|
+
* the agent did next. Four components share this contract:
|
|
7
|
+
*
|
|
8
|
+
* - the CLI runner, which reads an experiment file, launches each repetition
|
|
9
|
+
* in a sandbox and scores the result;
|
|
10
|
+
* - the LLM proxy, which injects the `llm.*` and `egress.*` faults;
|
|
11
|
+
* - the MCP proxy, which injects the MCP side of `tool.error` plus
|
|
12
|
+
* `tool.stale_data`, `mcp.toolset_change` and `inject.tool_result`;
|
|
13
|
+
* - the gates — the hook gates and the in-process gate SDKs — which inject
|
|
14
|
+
* `permission.deny_or_delay` and the built-in-tool side of `tool.error`.
|
|
15
|
+
*
|
|
16
|
+
* The runner hands each component a plan through {@link CHAOS_PLAN_ENV} and an
|
|
17
|
+
* events file through {@link CHAOS_EVENTS_ENV}. Both are plain environment
|
|
18
|
+
* variables, so they cross the sandbox boundary the same way the proxy URL
|
|
19
|
+
* does. Each component appends one JSON line per event to the events file;
|
|
20
|
+
* the probes read nothing else.
|
|
21
|
+
*
|
|
22
|
+
* Two rules every injector keeps:
|
|
23
|
+
*
|
|
24
|
+
* 1. **A fault never loosens governance.** Faults are applied only to a call
|
|
25
|
+
* that governance has already allowed. A fault can turn an allow into a
|
|
26
|
+
* failure, a delay or a changed result; it can never turn a block, a hold
|
|
27
|
+
* or a redaction into an allow.
|
|
28
|
+
* 2. **Silence is not success.** A component that loads a plan reports
|
|
29
|
+
* `plan_loaded`, so the runner can tell "the fault fired and the agent
|
|
30
|
+
* coped" from "the component never saw the plan".
|
|
31
|
+
*
|
|
32
|
+
* The Rust proxy decodes the same plan with serde; its tests read the fixture
|
|
33
|
+
* at `src/__tests__/fixtures/chaos-plan.json`, which this module's tests also
|
|
34
|
+
* validate, so the two decoders cannot drift apart.
|
|
35
|
+
*
|
|
36
|
+
* @module
|
|
37
|
+
*/
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.ExperimentSchema = exports.PROBE_IDS = exports.ChaosEventSchema = exports.FaultCounter = exports.ChaosPlanSchema = exports.FaultSchema = exports.FAULT_CATALOG = exports.FAULT_IDS = exports.CHAOS_PLAN_VERSION = exports.CHAOS_EVENTS_ENV = exports.CHAOS_PLAN_ENV = void 0;
|
|
40
|
+
exports.encodeChaosPlan = encodeChaosPlan;
|
|
41
|
+
exports.decodeChaosPlan = decodeChaosPlan;
|
|
42
|
+
exports.matchesPattern = matchesPattern;
|
|
43
|
+
exports.faultMatches = faultMatches;
|
|
44
|
+
exports.faultMessage = faultMessage;
|
|
45
|
+
exports.parseChaosEvents = parseChaosEvents;
|
|
46
|
+
exports.resilienceScore = resilienceScore;
|
|
47
|
+
const zod_1 = require("zod");
|
|
48
|
+
/** Environment variable carrying the plan: base64url-encoded JSON {@link ChaosPlan}. */
|
|
49
|
+
exports.CHAOS_PLAN_ENV = 'INTUTIC_CHAOS_PLAN';
|
|
50
|
+
/** Environment variable carrying the path of the append-only JSONL events file. */
|
|
51
|
+
exports.CHAOS_EVENTS_ENV = 'INTUTIC_CHAOS_EVENTS';
|
|
52
|
+
/** Wire version of {@link ChaosPlan}. A component refuses any other version. */
|
|
53
|
+
exports.CHAOS_PLAN_VERSION = 1;
|
|
54
|
+
/** Every fault the catalog knows, by id. */
|
|
55
|
+
exports.FAULT_IDS = [
|
|
56
|
+
'llm.rate_limit',
|
|
57
|
+
'llm.upstream_5xx',
|
|
58
|
+
'llm.context_trim',
|
|
59
|
+
'llm.model_degrade',
|
|
60
|
+
'tool.error',
|
|
61
|
+
'tool.stale_data',
|
|
62
|
+
'mcp.toolset_change',
|
|
63
|
+
'permission.deny_or_delay',
|
|
64
|
+
'inject.tool_result',
|
|
65
|
+
'egress.dns_fail',
|
|
66
|
+
'egress.credential_401',
|
|
67
|
+
];
|
|
68
|
+
/** Which component injects each fault, and its safety class. */
|
|
69
|
+
exports.FAULT_CATALOG = {
|
|
70
|
+
'llm.rate_limit': { injectedBy: ['proxy'], safety: 'fail_safe' },
|
|
71
|
+
'llm.upstream_5xx': { injectedBy: ['proxy'], safety: 'fail_safe' },
|
|
72
|
+
'llm.context_trim': { injectedBy: ['proxy'], safety: 'mutating' },
|
|
73
|
+
'llm.model_degrade': { injectedBy: ['proxy'], safety: 'mutating' },
|
|
74
|
+
'tool.error': { injectedBy: ['gate', 'mcp-proxy'], safety: 'fail_safe' },
|
|
75
|
+
'tool.stale_data': { injectedBy: ['mcp-proxy'], safety: 'mutating' },
|
|
76
|
+
'mcp.toolset_change': { injectedBy: ['mcp-proxy'], safety: 'mutating' },
|
|
77
|
+
'permission.deny_or_delay': { injectedBy: ['gate'], safety: 'fail_safe' },
|
|
78
|
+
'inject.tool_result': { injectedBy: ['mcp-proxy'], safety: 'mutating' },
|
|
79
|
+
'egress.dns_fail': { injectedBy: ['proxy'], safety: 'fail_safe' },
|
|
80
|
+
'egress.credential_401': { injectedBy: ['proxy'], safety: 'fail_safe' },
|
|
81
|
+
};
|
|
82
|
+
// ── Faults ───────────────────────────────────────────────────────────────────
|
|
83
|
+
/**
|
|
84
|
+
* Which calls a fault applies to. Every field present must match; an absent
|
|
85
|
+
* field matches anything. `tool` and `host` match exactly, or by suffix when
|
|
86
|
+
* they start with `*` (`*.npmjs.org`). `model` matches the requested model id.
|
|
87
|
+
*/
|
|
88
|
+
const MatchSchema = zod_1.z
|
|
89
|
+
.object({
|
|
90
|
+
tool: zod_1.z.string().min(1).optional(),
|
|
91
|
+
host: zod_1.z.string().min(1).optional(),
|
|
92
|
+
model: zod_1.z.string().min(1).optional(),
|
|
93
|
+
})
|
|
94
|
+
.strict();
|
|
95
|
+
/** Fields every fault has: which calls, how many to skip, how many to hit. */
|
|
96
|
+
const common = {
|
|
97
|
+
match: MatchSchema.optional(),
|
|
98
|
+
/** Skip this many matching calls before the first injection. */
|
|
99
|
+
after_calls: zod_1.z.number().int().min(0).max(10_000).default(0),
|
|
100
|
+
/** Inject at most this many times; absent means every matching call. */
|
|
101
|
+
times: zod_1.z.number().int().min(1).max(10_000).optional(),
|
|
102
|
+
};
|
|
103
|
+
const hostRequired = MatchSchema.extend({ host: zod_1.z.string().min(1) });
|
|
104
|
+
exports.FaultSchema = zod_1.z.discriminatedUnion('id', [
|
|
105
|
+
zod_1.z.object({ id: zod_1.z.literal('llm.rate_limit'), ...common, retry_after_s: zod_1.z.number().int().min(0).max(600).default(5) }).strict(),
|
|
106
|
+
zod_1.z
|
|
107
|
+
.object({
|
|
108
|
+
id: zod_1.z.literal('llm.upstream_5xx'),
|
|
109
|
+
...common,
|
|
110
|
+
status: zod_1.z.union([zod_1.z.literal(500), zod_1.z.literal(502), zod_1.z.literal(503), zod_1.z.literal(529)]).default(500),
|
|
111
|
+
/** Cut a streamed response after this many chunks instead of failing the request. */
|
|
112
|
+
stream_cut_after_chunks: zod_1.z.number().int().min(0).max(10_000).optional(),
|
|
113
|
+
})
|
|
114
|
+
.strict(),
|
|
115
|
+
zod_1.z
|
|
116
|
+
.object({
|
|
117
|
+
id: zod_1.z.literal('llm.context_trim'),
|
|
118
|
+
...common,
|
|
119
|
+
drop_oldest: zod_1.z.number().int().min(0).max(1_000).default(0),
|
|
120
|
+
drop_system: zod_1.z.boolean().default(false),
|
|
121
|
+
})
|
|
122
|
+
.strict(),
|
|
123
|
+
zod_1.z.object({ id: zod_1.z.literal('llm.model_degrade'), ...common, to_model: zod_1.z.string().min(1) }).strict(),
|
|
124
|
+
zod_1.z.object({ id: zod_1.z.literal('tool.error'), ...common, message: zod_1.z.string().min(1).max(2_000).default('tool failed') }).strict(),
|
|
125
|
+
zod_1.z.object({ id: zod_1.z.literal('tool.stale_data'), ...common, result: zod_1.z.string().max(100_000) }).strict(),
|
|
126
|
+
zod_1.z
|
|
127
|
+
.object({
|
|
128
|
+
id: zod_1.z.literal('mcp.toolset_change'),
|
|
129
|
+
...common,
|
|
130
|
+
remove: zod_1.z.array(zod_1.z.string().min(1)).max(500).default([]),
|
|
131
|
+
/** Tool name → the description it is redefined with. */
|
|
132
|
+
redefine: zod_1.z.record(zod_1.z.string().min(1), zod_1.z.string().max(10_000)).default({}),
|
|
133
|
+
})
|
|
134
|
+
.strict(),
|
|
135
|
+
zod_1.z
|
|
136
|
+
.object({
|
|
137
|
+
id: zod_1.z.literal('permission.deny_or_delay'),
|
|
138
|
+
...common,
|
|
139
|
+
mode: zod_1.z.enum(['deny', 'delay', 'hold_then_deny']).default('deny'),
|
|
140
|
+
/**
|
|
141
|
+
* `delay` and `hold_then_deny`: how long a held call stays held. The
|
|
142
|
+
* call is refused as held, the way an approval hold refuses it, and so
|
|
143
|
+
* is its identical retry until this many seconds have passed since the
|
|
144
|
+
* first refusal; then the retry is allowed (`delay`) or denied
|
|
145
|
+
* (`hold_then_deny`). Nothing waits: 0 holds the call once and allows
|
|
146
|
+
* (or denies) the first retry.
|
|
147
|
+
*/
|
|
148
|
+
delay_s: zod_1.z.number().int().min(0).max(600).default(0),
|
|
149
|
+
})
|
|
150
|
+
.strict(),
|
|
151
|
+
zod_1.z.object({ id: zod_1.z.literal('inject.tool_result'), ...common, payload: zod_1.z.string().min(1).max(20_000) }).strict(),
|
|
152
|
+
zod_1.z.object({ id: zod_1.z.literal('egress.dns_fail'), ...common, match: hostRequired }).strict(),
|
|
153
|
+
zod_1.z.object({ id: zod_1.z.literal('egress.credential_401'), ...common, match: hostRequired }).strict(),
|
|
154
|
+
]);
|
|
155
|
+
// ── The plan a component receives ────────────────────────────────────────────
|
|
156
|
+
exports.ChaosPlanSchema = zod_1.z
|
|
157
|
+
.object({
|
|
158
|
+
v: zod_1.z.literal(exports.CHAOS_PLAN_VERSION),
|
|
159
|
+
runId: zod_1.z.string().regex(/^[A-Za-z0-9_-]{6,64}$/),
|
|
160
|
+
/** 0-based repetition index; baseline repetitions carry no faults. */
|
|
161
|
+
repetition: zod_1.z.number().int().min(0).max(1_000),
|
|
162
|
+
/** Token every injected error text carries, so `failure_surfaced` needs no model. */
|
|
163
|
+
canary: zod_1.z.string().regex(/^E-INTUTIC-[0-9A-F]{4,16}$/),
|
|
164
|
+
faults: zod_1.z.array(exports.FaultSchema).max(50),
|
|
165
|
+
})
|
|
166
|
+
.strict();
|
|
167
|
+
// base64url without Node's Buffer: the dashboard imports this package in the browser.
|
|
168
|
+
function toBase64Url(text) {
|
|
169
|
+
let binary = '';
|
|
170
|
+
for (const byte of new TextEncoder().encode(text))
|
|
171
|
+
binary += String.fromCharCode(byte);
|
|
172
|
+
return btoa(binary).replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/, '');
|
|
173
|
+
}
|
|
174
|
+
function fromBase64Url(raw) {
|
|
175
|
+
const b64 = raw.replace(/-/g, '+').replace(/_/g, '/');
|
|
176
|
+
const binary = atob(b64 + '='.repeat((4 - (b64.length % 4)) % 4));
|
|
177
|
+
return new TextDecoder().decode(Uint8Array.from(binary, (c) => c.charCodeAt(0)));
|
|
178
|
+
}
|
|
179
|
+
/** Encode a plan for {@link CHAOS_PLAN_ENV}. */
|
|
180
|
+
function encodeChaosPlan(plan) {
|
|
181
|
+
return toBase64Url(JSON.stringify(exports.ChaosPlanSchema.parse(plan)));
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Decode {@link CHAOS_PLAN_ENV}. Returns null when the variable is unset or
|
|
185
|
+
* empty; throws when it is set but not a valid plan, so a component can say
|
|
186
|
+
* so instead of silently injecting nothing.
|
|
187
|
+
*/
|
|
188
|
+
function decodeChaosPlan(raw) {
|
|
189
|
+
if (!raw)
|
|
190
|
+
return null;
|
|
191
|
+
let json;
|
|
192
|
+
try {
|
|
193
|
+
json = JSON.parse(fromBase64Url(raw));
|
|
194
|
+
}
|
|
195
|
+
catch {
|
|
196
|
+
throw new Error(`${exports.CHAOS_PLAN_ENV} is not base64url-encoded JSON`);
|
|
197
|
+
}
|
|
198
|
+
const parsed = exports.ChaosPlanSchema.safeParse(json);
|
|
199
|
+
if (!parsed.success)
|
|
200
|
+
throw new Error(`${exports.CHAOS_PLAN_ENV} is not a valid plan: ${parsed.error.issues[0]?.message ?? 'invalid'}`);
|
|
201
|
+
return parsed.data;
|
|
202
|
+
}
|
|
203
|
+
/** Whether `value` matches a fault's `tool`/`host` pattern (exact, or `*suffix`). */
|
|
204
|
+
function matchesPattern(pattern, value) {
|
|
205
|
+
if (pattern === undefined)
|
|
206
|
+
return true;
|
|
207
|
+
if (value === undefined)
|
|
208
|
+
return false;
|
|
209
|
+
return pattern.startsWith('*') ? value.endsWith(pattern.slice(1)) : value === pattern;
|
|
210
|
+
}
|
|
211
|
+
/** Whether a fault's `match` covers a call. */
|
|
212
|
+
function faultMatches(fault, call) {
|
|
213
|
+
const m = fault.match;
|
|
214
|
+
if (!m)
|
|
215
|
+
return true;
|
|
216
|
+
return matchesPattern(m.tool, call.tool) && matchesPattern(m.host, call.host) && matchesPattern(m.model, call.model);
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* Per-process injection counter: decides whether the nth matching call of a
|
|
220
|
+
* fault is hit, honouring `after_calls` and `times`. One instance per
|
|
221
|
+
* component process; the plan is per run, so per-process state is per run.
|
|
222
|
+
*/
|
|
223
|
+
class FaultCounter {
|
|
224
|
+
seen = new Map();
|
|
225
|
+
hit = new Map();
|
|
226
|
+
/** Call once per matching call; returns true when this call is injected. */
|
|
227
|
+
shouldInject(faultIndex, fault) {
|
|
228
|
+
const seen = (this.seen.get(faultIndex) ?? 0) + 1;
|
|
229
|
+
this.seen.set(faultIndex, seen);
|
|
230
|
+
if (seen <= fault.after_calls)
|
|
231
|
+
return false;
|
|
232
|
+
const hit = this.hit.get(faultIndex) ?? 0;
|
|
233
|
+
if (fault.times !== undefined && hit >= fault.times)
|
|
234
|
+
return false;
|
|
235
|
+
this.hit.set(faultIndex, hit + 1);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
exports.FaultCounter = FaultCounter;
|
|
240
|
+
/** The error text an injected failure carries: the base message plus the canary. */
|
|
241
|
+
function faultMessage(plan, base) {
|
|
242
|
+
return `${base} [${plan.canary}]`;
|
|
243
|
+
}
|
|
244
|
+
// ── Events ───────────────────────────────────────────────────────────────────
|
|
245
|
+
const eventBase = {
|
|
246
|
+
ts: zod_1.z.string(),
|
|
247
|
+
runId: zod_1.z.string(),
|
|
248
|
+
component: zod_1.z.enum(['runner', 'proxy', 'mcp-proxy', 'gate']),
|
|
249
|
+
};
|
|
250
|
+
exports.ChaosEventSchema = zod_1.z.discriminatedUnion('type', [
|
|
251
|
+
zod_1.z.object({ ...eventBase, type: zod_1.z.literal('plan_loaded'), faults: zod_1.z.number().int().min(0) }),
|
|
252
|
+
zod_1.z.object({
|
|
253
|
+
...eventBase,
|
|
254
|
+
type: zod_1.z.literal('fault_injected'),
|
|
255
|
+
faultId: zod_1.z.enum(exports.FAULT_IDS),
|
|
256
|
+
/** The 1-based index of the matching call that was hit. */
|
|
257
|
+
call: zod_1.z.number().int().min(1),
|
|
258
|
+
target: zod_1.z.string().optional(),
|
|
259
|
+
}),
|
|
260
|
+
zod_1.z.object({ ...eventBase, type: zod_1.z.literal('tool_call'), tool: zod_1.z.string(), ok: zod_1.z.boolean() }),
|
|
261
|
+
zod_1.z.object({
|
|
262
|
+
...eventBase,
|
|
263
|
+
type: zod_1.z.literal('gate_decision'),
|
|
264
|
+
tool: zod_1.z.string(),
|
|
265
|
+
decision: zod_1.z.enum(['allow', 'deny', 'ask', 'hold']),
|
|
266
|
+
ruleId: zod_1.z.string().optional(),
|
|
267
|
+
/** The call hit the destructive-command tier, whether or not it was blocked. */
|
|
268
|
+
destructive: zod_1.z.boolean(),
|
|
269
|
+
/** An enforce-mode rule fired on the call. */
|
|
270
|
+
policyHit: zod_1.z.boolean(),
|
|
271
|
+
}),
|
|
272
|
+
zod_1.z.object({
|
|
273
|
+
...eventBase,
|
|
274
|
+
type: zod_1.z.literal('llm_usage'),
|
|
275
|
+
model: zod_1.z.string(),
|
|
276
|
+
inputTokens: zod_1.z.number().int().min(0),
|
|
277
|
+
outputTokens: zod_1.z.number().int().min(0),
|
|
278
|
+
costUsd: zod_1.z.number().min(0),
|
|
279
|
+
}),
|
|
280
|
+
zod_1.z.object({ ...eventBase, type: zod_1.z.literal('abort'), reason: zod_1.z.string() }),
|
|
281
|
+
]);
|
|
282
|
+
/** Parse an events file's text; malformed lines are counted, not thrown. */
|
|
283
|
+
function parseChaosEvents(text) {
|
|
284
|
+
const events = [];
|
|
285
|
+
let malformed = 0;
|
|
286
|
+
for (const line of text.split('\n')) {
|
|
287
|
+
if (!line.trim())
|
|
288
|
+
continue;
|
|
289
|
+
try {
|
|
290
|
+
const parsed = exports.ChaosEventSchema.safeParse(JSON.parse(line));
|
|
291
|
+
if (parsed.success)
|
|
292
|
+
events.push(parsed.data);
|
|
293
|
+
else
|
|
294
|
+
malformed++;
|
|
295
|
+
}
|
|
296
|
+
catch {
|
|
297
|
+
malformed++;
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return { events, malformed };
|
|
301
|
+
}
|
|
302
|
+
// ── Experiments ──────────────────────────────────────────────────────────────
|
|
303
|
+
exports.PROBE_IDS = [
|
|
304
|
+
'task_success',
|
|
305
|
+
'no_destructive_attempt',
|
|
306
|
+
'failure_surfaced',
|
|
307
|
+
'no_policy_hits',
|
|
308
|
+
'cost_multiplier_below',
|
|
309
|
+
'recovered_within',
|
|
310
|
+
];
|
|
311
|
+
const ProbeSchema = zod_1.z
|
|
312
|
+
.object({
|
|
313
|
+
id: zod_1.z.enum(exports.PROBE_IDS),
|
|
314
|
+
weight: zod_1.z.number().int().min(1).max(10),
|
|
315
|
+
/** Threshold for `cost_multiplier_below` (a ratio) and `recovered_within` (calls). */
|
|
316
|
+
value: zod_1.z.number().positive().optional(),
|
|
317
|
+
})
|
|
318
|
+
.strict()
|
|
319
|
+
.refine((p) => (p.id === 'cost_multiplier_below' || p.id === 'recovered_within' ? p.value !== undefined : p.value === undefined), {
|
|
320
|
+
message: 'cost_multiplier_below and recovered_within need a value; other probes take none',
|
|
321
|
+
});
|
|
322
|
+
const AbortSchema = zod_1.z.union([
|
|
323
|
+
zod_1.z.literal('destructive_attempt'),
|
|
324
|
+
zod_1.z.object({ cost_usd_above: zod_1.z.number().positive() }).strict(),
|
|
325
|
+
zod_1.z.object({ wall_clock_s_above: zod_1.z.number().int().positive() }).strict(),
|
|
326
|
+
]);
|
|
327
|
+
exports.ExperimentSchema = zod_1.z
|
|
328
|
+
.object({
|
|
329
|
+
name: zod_1.z.string().regex(/^[a-z0-9][a-z0-9-]{0,63}$/),
|
|
330
|
+
description: zod_1.z.string().max(2_000).optional(),
|
|
331
|
+
/** The agent command, run in the sandbox through a shell. */
|
|
332
|
+
agent: zod_1.z.string().min(1),
|
|
333
|
+
/** Run in the sandbox after the agent; exit 0 means the task succeeded. */
|
|
334
|
+
verify: zod_1.z.string().min(1),
|
|
335
|
+
/** Faulted repetitions; the same number of baseline repetitions run first. */
|
|
336
|
+
repeat: zod_1.z.number().int().min(1).max(20).default(3),
|
|
337
|
+
faults: zod_1.z.array(exports.FaultSchema).min(1).max(20),
|
|
338
|
+
probes: zod_1.z.array(ProbeSchema).min(1),
|
|
339
|
+
/** A cost ceiling is mandatory: every run spends real tokens. */
|
|
340
|
+
abort: zod_1.z.array(AbortSchema).refine((a) => a.some((x) => typeof x === 'object' && 'cost_usd_above' in x), {
|
|
341
|
+
message: 'abort must include a cost_usd_above ceiling',
|
|
342
|
+
}),
|
|
343
|
+
sandbox_image: zod_1.z.string().min(1).optional(),
|
|
344
|
+
})
|
|
345
|
+
.strict();
|
|
346
|
+
/**
|
|
347
|
+
* The resilience score: Σ(weight × pass rate) ÷ Σ(weight) × 100, rounded to
|
|
348
|
+
* one decimal. Probes that evaluated no repetition are left out of both sums.
|
|
349
|
+
*/
|
|
350
|
+
function resilienceScore(probes) {
|
|
351
|
+
const counted = probes.filter((p) => p.evaluated > 0);
|
|
352
|
+
const weights = counted.reduce((s, p) => s + p.weight, 0);
|
|
353
|
+
if (weights === 0)
|
|
354
|
+
return 0;
|
|
355
|
+
const sum = counted.reduce((s, p) => s + p.weight * p.passRate, 0);
|
|
356
|
+
return Math.round((sum / weights) * 1000) / 10;
|
|
357
|
+
}
|
|
358
|
+
//# sourceMappingURL=chaos.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chaos.js","sourceRoot":"","sources":["../src/chaos.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;;;AAkKH,0CAEC;AAOD,0CAWC;AAGD,wCAIC;AAGD,oCAIC;AAwBD,oCAEC;AA6CD,4CAcC;AA0ED,0CAMC;AAvWD,6BAAuB;AAEvB,wFAAwF;AAC3E,QAAA,cAAc,GAAG,oBAAoB,CAAA;AAElD,mFAAmF;AACtE,QAAA,gBAAgB,GAAG,sBAAsB,CAAA;AAEtD,gFAAgF;AACnE,QAAA,kBAAkB,GAAG,CAAC,CAAA;AAEnC,4CAA4C;AAC/B,QAAA,SAAS,GAAG;IACvB,gBAAgB;IAChB,kBAAkB;IAClB,kBAAkB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GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAA;IAClE,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,GAAG,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;AAChD,CAAC"}
|
|
@@ -0,0 +1,166 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fault injection in the gates: the part of a chaos run (`chaos.ts`) a hook
|
|
3
|
+
* gate or an in-process gate SDK carries.
|
|
4
|
+
*
|
|
5
|
+
* A hook gate is a new process per tool call, and parallel gates share one
|
|
6
|
+
* run, so nothing here keeps state in memory: the plan comes from {@link CHAOS_PLAN_ENV}-style text each call,
|
|
7
|
+
* and every count lives in files beside the events file.
|
|
8
|
+
*
|
|
9
|
+
* - `<events>.gate-plan-loaded` — created once, with an exclusive create; the
|
|
10
|
+
* gate that creates it reports `plan_loaded`, so separate gate processes do
|
|
11
|
+
* not repeat it.
|
|
12
|
+
* - `<events>.gate-counters/<fault index>.seen.<n>` and `.hit.<n>` — one
|
|
13
|
+
* empty file per matching call a fault saw and per call it hit. A call
|
|
14
|
+
* claims the next number with an exclusive create (`open` with `wx`,
|
|
15
|
+
* `O_CREAT | O_EXCL`), which the file system grants to exactly one process,
|
|
16
|
+
* so two gates deciding at once can never both take the same number; the
|
|
17
|
+
* claimed number is the call's 1-based index. A count is the number of
|
|
18
|
+
* files, read once to start the search, so a claim costs one directory
|
|
19
|
+
* read and usually one create. That is `FaultCounter`'s `after_calls` and
|
|
20
|
+
* `times` across processes.
|
|
21
|
+
* - `<events>.gate-counters/<fault index>.held.<key>.<g>` — a call a
|
|
22
|
+
* `permission.deny_or_delay` fault in `delay` or `hold_then_deny` mode
|
|
23
|
+
* held; its modification time is when. `<key>` is the call's digest (the
|
|
24
|
+
* tool and its input, as the gate keys an approval hold), `<g>` counts the
|
|
25
|
+
* holds of that call, claimed like a call number. `.released.<key>.<g>`,
|
|
26
|
+
* created with the same exclusive create, ends that hold: one retry, and
|
|
27
|
+
* only one, is the one the hold lets through or denies.
|
|
28
|
+
*
|
|
29
|
+
* A permission fault never makes a gate wait. It holds the call the way an
|
|
30
|
+
* approval hold does: the call is refused as held, and the identical retry
|
|
31
|
+
* (same tool, same input) is refused as held again until `delay_s` seconds
|
|
32
|
+
* have passed since the first refusal. After that the retry is allowed
|
|
33
|
+
* (`delay`) or denied (`hold_then_deny`), and the hold is over: the next
|
|
34
|
+
* identical call is a new matching call. A held call's retries are the same
|
|
35
|
+
* call, so no fault counts them as matching calls. A test moves the clock by
|
|
36
|
+
* moving the `held` files' modification times back.
|
|
37
|
+
*
|
|
38
|
+
* Only a call governance allowed counts: a fault never applies to a call the
|
|
39
|
+
* gate refused, held or asked about, so such a call is not one of the
|
|
40
|
+
* fault's matching calls either. Every fault whose `match` covers an allowed
|
|
41
|
+
* call counts it as seen; the first one in plan order that is due injects,
|
|
42
|
+
* and the faults after it do not spend a hit on the same call. A `tool.error`
|
|
43
|
+
* on an `mcp__<server>__<tool>` call is the MCP proxy's to inject, so a gate
|
|
44
|
+
* leaves it alone; `permission.deny_or_delay` is the gate's on any tool.
|
|
45
|
+
*
|
|
46
|
+
* The functions are self-contained on purpose — no imports, no module state —
|
|
47
|
+
* because the JavaScript hook gates emit them as source
|
|
48
|
+
* ({@link CHAOS_GATE_JS_SOURCE}) and run them outside this package, and
|
|
49
|
+
* `@intutic/gate` carries a byte-identical copy of this file
|
|
50
|
+
* (`packages/gate-js/src/chaosGate.ts`). The bash gates and
|
|
51
|
+
* `intutic_clawde.gate` run the Python transliteration,
|
|
52
|
+
* `intutic_clawde/gate/chaos.py`, which the sync daemon emits verbatim. All
|
|
53
|
+
* of them run `fixtures/chaos-gate-vectors.json`. File access goes through
|
|
54
|
+
* the `fs` argument (Node's `fs` in a gate).
|
|
55
|
+
*
|
|
56
|
+
* @module
|
|
57
|
+
*/
|
|
58
|
+
/** One fault a gate injects, with its defaults applied. */
|
|
59
|
+
export interface ChaosGateFault {
|
|
60
|
+
/** The fault's position in the plan: its counters are keyed on it. */
|
|
61
|
+
index: number;
|
|
62
|
+
id: 'tool.error' | 'permission.deny_or_delay';
|
|
63
|
+
match: {
|
|
64
|
+
tool?: string;
|
|
65
|
+
host?: string;
|
|
66
|
+
model?: string;
|
|
67
|
+
} | null;
|
|
68
|
+
afterCalls: number;
|
|
69
|
+
times: number | null;
|
|
70
|
+
/** `tool.error` only. */
|
|
71
|
+
message: string;
|
|
72
|
+
/** `permission.deny_or_delay` only. */
|
|
73
|
+
mode: 'deny' | 'delay' | 'hold_then_deny';
|
|
74
|
+
/** `permission.deny_or_delay` only: how long a held call stays held, in seconds. */
|
|
75
|
+
delayS: number;
|
|
76
|
+
}
|
|
77
|
+
/** The fields of a plan a gate uses. */
|
|
78
|
+
export interface ChaosGatePlan {
|
|
79
|
+
runId: string;
|
|
80
|
+
canary: string;
|
|
81
|
+
/** The faults a gate injects; the plan's others are another component's. */
|
|
82
|
+
faults: ChaosGateFault[];
|
|
83
|
+
}
|
|
84
|
+
/** One call, as the gate decided it before any fault. */
|
|
85
|
+
export interface ChaosGateCall {
|
|
86
|
+
tool: string;
|
|
87
|
+
decision: 'allow' | 'deny' | 'ask' | 'hold';
|
|
88
|
+
ruleId?: string | null;
|
|
89
|
+
destructive: boolean;
|
|
90
|
+
policyHit: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* The call's digest in hex: its tool and input, as the gate keys an
|
|
93
|
+
* approval hold, so an identical retry has the same key. Only a held
|
|
94
|
+
* call's retry reads it.
|
|
95
|
+
*/
|
|
96
|
+
key?: string;
|
|
97
|
+
}
|
|
98
|
+
/** A fault to apply to an allowed call. */
|
|
99
|
+
export interface ChaosGateFaultOutcome {
|
|
100
|
+
faultId: string;
|
|
101
|
+
/** `deny` refuses the call; `hold` refuses it as held, as an approval hold does. */
|
|
102
|
+
kind: 'deny' | 'hold';
|
|
103
|
+
/** The refusal text, carrying the plan's canary. */
|
|
104
|
+
reason: string;
|
|
105
|
+
}
|
|
106
|
+
/** The file operations the functions use: Node's `fs` provides them. */
|
|
107
|
+
export interface ChaosGateFs {
|
|
108
|
+
appendFileSync(path: string, data: string): void;
|
|
109
|
+
mkdirSync(path: string): unknown;
|
|
110
|
+
readdirSync(path: string): string[];
|
|
111
|
+
openSync(path: string, flags: string): number;
|
|
112
|
+
closeSync(fd: number): void;
|
|
113
|
+
statSync(path: string): {
|
|
114
|
+
mtimeMs: number;
|
|
115
|
+
};
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* Decodes and checks a plan: base64url JSON, version 1, with valid values in
|
|
119
|
+
* every field a gate reads. Returns the plan, or why it is not one.
|
|
120
|
+
*/
|
|
121
|
+
export declare function chaosGateDecode(raw: string): {
|
|
122
|
+
plan: ChaosGatePlan;
|
|
123
|
+
error: null;
|
|
124
|
+
} | {
|
|
125
|
+
plan: null;
|
|
126
|
+
error: string;
|
|
127
|
+
};
|
|
128
|
+
/**
|
|
129
|
+
* Whether a fault's `match` covers a gate call. A gate call has a tool and
|
|
130
|
+
* nothing else, so a fault that names a host or a model never matches one.
|
|
131
|
+
* `tool` matches exactly, or by suffix when it starts with `*`.
|
|
132
|
+
*/
|
|
133
|
+
export declare function chaosGateMatches(match: ChaosGateFault['match'], tool: string): boolean;
|
|
134
|
+
/** One events-file line: `ts`, `runId`, `component`, `type`, then the fields that are set. */
|
|
135
|
+
export declare function chaosGateEvent(plan: ChaosGatePlan, type: string, fields: Record<string, unknown>, now: string): string;
|
|
136
|
+
/** Appends whole lines in one write. An I/O error is reported, never thrown: it must not decide the call. */
|
|
137
|
+
export declare function chaosGateAppend(fs: ChaosGateFs, eventsPath: string, lines: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* Claims the next numbered file `<dir>/<prefix><n>` with an exclusive create
|
|
140
|
+
* and returns n, or 0 when every number up to `limit` is taken. -1 on an I/O
|
|
141
|
+
* error, after saying so.
|
|
142
|
+
*/
|
|
143
|
+
export declare function chaosGateClaim(fs: ChaosGateFs, dir: string, prefix: string, limit: number | null): number;
|
|
144
|
+
/**
|
|
145
|
+
* The open hold of one fault on one call: the number of the newest
|
|
146
|
+
* `<fault>.held.<key>.<g>` file that has no `.released.` twin, and when it
|
|
147
|
+
* was created. Null when there is none or it cannot be read.
|
|
148
|
+
*/
|
|
149
|
+
export declare function chaosGateOpenHold(fs: ChaosGateFs, dir: string, fault: number, key: string): {
|
|
150
|
+
g: number;
|
|
151
|
+
sinceMs: number;
|
|
152
|
+
} | null;
|
|
153
|
+
/** Ends hold g with an exclusive create: true for the one caller that does. */
|
|
154
|
+
export declare function chaosGateRelease(fs: ChaosGateFs, dir: string, fault: number, key: string, g: number): boolean;
|
|
155
|
+
/**
|
|
156
|
+
* Reports one call: `plan_loaded` the first time any gate reports to this
|
|
157
|
+
* events file, then `gate_decision`; for an allowed call, the fault that is
|
|
158
|
+
* due (`fault_injected`, once per held call however often it is retried),
|
|
159
|
+
* and `tool_call`: ok when the call goes ahead, not ok when it is held.
|
|
160
|
+
* Returns the fault the gate must apply, or null. `now` is the ISO-8601 time,
|
|
161
|
+
* and the clock a hold is timed by.
|
|
162
|
+
*/
|
|
163
|
+
export declare function chaosGateCall(fs: ChaosGateFs, plan: ChaosGatePlan, eventsPath: string, call: ChaosGateCall, now: string): ChaosGateFaultOutcome | null;
|
|
164
|
+
/** Every function above as JavaScript source, for a hook gate to emit. */
|
|
165
|
+
export declare const CHAOS_GATE_JS_SOURCE: string;
|
|
166
|
+
//# sourceMappingURL=chaosGate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chaosGate.d.ts","sourceRoot":"","sources":["../src/chaosGate.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,sEAAsE;IACtE,KAAK,EAAE,MAAM,CAAA;IACb,EAAE,EAAE,YAAY,GAAG,0BA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