@intutic/gate 2.4.0 → 2.5.1
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 +42 -10
- package/dist/actions.d.ts +1 -0
- package/dist/actions.d.ts.map +1 -1
- package/dist/actions.js +1 -0
- package/dist/actions.js.map +1 -1
- package/dist/chaosGate.d.ts +166 -0
- package/dist/chaosGate.d.ts.map +1 -0
- package/dist/chaosGate.js +372 -0
- package/dist/chaosGate.js.map +1 -0
- package/dist/client.d.ts +85 -17
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +129 -34
- package/dist/client.js.map +1 -1
- package/dist/errors.d.ts +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +3 -0
- package/dist/errors.js.map +1 -1
- package/dist/eve.d.ts +1 -1
- package/dist/eve.d.ts.map +1 -1
- package/dist/eve.js +1 -1
- package/dist/eve.js.map +1 -1
- package/dist/gate.d.ts +81 -2
- package/dist/gate.d.ts.map +1 -1
- package/dist/gate.js +167 -17
- package/dist/gate.js.map +1 -1
- package/dist/harness.d.ts +0 -38
- package/dist/harness.d.ts.map +1 -1
- package/dist/harness.js +17 -6
- package/dist/harness.js.map +1 -1
- package/dist/hold.d.ts.map +1 -1
- package/dist/hold.js +5 -2
- package/dist/hold.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/opaqueRefusal.d.ts +40 -0
- package/dist/opaqueRefusal.d.ts.map +1 -0
- package/dist/opaqueRefusal.js +47 -0
- package/dist/opaqueRefusal.js.map +1 -0
- package/dist/registry.d.ts +2 -0
- package/dist/registry.d.ts.map +1 -1
- package/dist/registry.js +2 -0
- package/dist/registry.js.map +1 -1
- package/dist/snapshot.d.ts +15 -0
- package/dist/snapshot.d.ts.map +1 -1
- package/dist/snapshot.js +20 -0
- package/dist/snapshot.js.map +1 -1
- package/dist/soprules.d.ts +24 -2
- package/dist/soprules.d.ts.map +1 -1
- package/dist/soprules.js +35 -6
- package/dist/soprules.js.map +1 -1
- package/dist/vercel.d.ts +19 -5
- package/dist/vercel.d.ts.map +1 -1
- package/dist/vercel.js +27 -6
- package/dist/vercel.js.map +1 -1
- package/dist/wrapTools.d.ts +1 -0
- package/dist/wrapTools.d.ts.map +1 -1
- package/dist/wrapTools.js.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
|
@@ -15,9 +15,11 @@ eve's per-tool/per-connection `approval` policy surface — Vercel's
|
|
|
15
15
|
filesystem-first durable-agent framework, a pre-1.0 **Preview** product),
|
|
16
16
|
`@intutic/gate/harness` (Vercel's `@ai-sdk/harness` sandboxed coding-agent
|
|
17
17
|
runtime), `@intutic/gate/workflow` (Vercel's `@ai-sdk/workflow` durable
|
|
18
|
-
workflow agents),
|
|
18
|
+
workflow agents), `@intutic/gate/managed-agents` (Anthropic's Managed
|
|
19
19
|
Agents — a session-confirmation responder, not a hook, since Anthropic hosts
|
|
20
|
-
the tool-call loop; see below)
|
|
20
|
+
the tool-call loop; see below), and `@intutic/gate/trueforge`
|
|
21
|
+
(`intuticApprovalResponder()` answering TrueForge's `tool.approval_required`
|
|
22
|
+
pauses, for a process that embeds `@truefoundry/trueforge-core`). LangChain.js has no dedicated adapter planned
|
|
21
23
|
and instead uses the generic `wrapTool`/`wrapTools` helper directly.
|
|
22
24
|
|
|
23
25
|
## Quick start
|
|
@@ -42,6 +44,32 @@ implementation runs — this package's throw-based refusal contract, the same on
|
|
|
42
44
|
`packages/mcp-proxy/src/policy.ts` use elsewhere in this repo's gate
|
|
43
45
|
vocabulary.
|
|
44
46
|
|
|
47
|
+
## Fail mode
|
|
48
|
+
|
|
49
|
+
`GateClient` fails closed by default (`failClosed: true`). When the control
|
|
50
|
+
plane's hook gate cannot be reached, answers non-2xx, or answers
|
|
51
|
+
`GOVERNANCE_UNAVAILABLE` because a check it runs (the SOP register, the SSO
|
|
52
|
+
group policy, the MCP server registry, image provenance, promoted findings)
|
|
53
|
+
could not complete, there is no verdict, and the call is refused with
|
|
54
|
+
`HOOK_GATE`. Pass `failClosed: false` to let calls through during such an
|
|
55
|
+
outage. A request the hook gate cannot read (HTTP 400, `INVALID_REQUEST`) is
|
|
56
|
+
refused whatever `failClosed` says. intutic-clawde's `GateClient` behaves the
|
|
57
|
+
same way, held to it by `packages/shared-types/fixtures/hook-gate-response-vectors.json`.
|
|
58
|
+
|
|
59
|
+
Each hook-gate answer names its decision (`decisionId`). The gate reports the
|
|
60
|
+
call as `tool_blocked` or `tool_allowed` with it as `gateDecisionId`, so the
|
|
61
|
+
control plane files the decision's incident once and exports it to SIEM once,
|
|
62
|
+
as the hook gate's own record. A `GOVERNANCE_UNAVAILABLE` answer keeps the id
|
|
63
|
+
only while failing closed.
|
|
64
|
+
|
|
65
|
+
A `GateClient` with no API key (what `fromEnv()` builds when neither
|
|
66
|
+
`INTUTIC_API_KEY` nor `~/.intutic/credentials.json` has one) is local-only
|
|
67
|
+
(`client.localOnly`): it sends nothing, the gate skips the SOP register and
|
|
68
|
+
the hook gate, whose answer is an allow with code `LOCAL_ONLY`, and the
|
|
69
|
+
snapshot, SSO-group, MCP-registry and image tiers still decide. A key the
|
|
70
|
+
control plane refuses (401) is not local-only and fails closed as above. Both
|
|
71
|
+
SDKs run `packages/shared-types/fixtures/gate-client-credentials-vectors.json`.
|
|
72
|
+
|
|
45
73
|
## Public API surface
|
|
46
74
|
|
|
47
75
|
| Export | From | What it is |
|
|
@@ -50,15 +78,16 @@ vocabulary.
|
|
|
50
78
|
| `install(gate)`, `active()` | `gate.ts` | Process-wide default gate, so wrapped tools don't need the instance threaded through every call site. |
|
|
51
79
|
| `IntuticGateRefusal`, `GateError`, `GateConnectionError` | `errors.ts` | Thrown on refusal. `.reason`, `.code` (a `GateRefusalCode`, listed in `GATE_REFUSAL_CODES`), `.incidentId` carry the structured verdict; `.message` carries the `[Intutic Governance] BLOCKED: ...` text. |
|
|
52
80
|
| `IntuticGateHold` | `errors.ts` | The `IntuticGateRefusal` a hold rule throws (`code` `HELD`) after recording the hold for approval; `.holdId` names it. See `hold.ts`. |
|
|
53
|
-
| `GateClient` | `client.ts` | Control-plane client (`hookGate`, `emit`, `GateClient.fromEnv(...)`). |
|
|
81
|
+
| `GateClient` | `client.ts` | Control-plane client (`hookGate`, `emit`, `localOnly`, `GateClient.fromEnv(...)`). |
|
|
54
82
|
| `wrapTool(fn \| tool, opts?)`, `wrapTools(list \| record, gate?)` | `wrapTools.ts` | Generic wrapping for a plain async function or an `{ execute, ... }`-shaped tool object. **This is the integration point for any JS framework without a dedicated adapter — LangChain.js included.** |
|
|
55
83
|
| `intuticHeaders(opts?)` | `headers.ts` | Headers for a proxy-pointed HTTP/OpenAI-compatible client (`x-session-id`, `x-workspace-id`, `x-intutic-harness`). |
|
|
56
84
|
| `loadSnapshot`, `evaluate`, `Snapshot`, `guardDisabledFromEnv` | `snapshot.ts` | Tier A1: reads `~/.intutic/hooks/policy-snapshot.rules`. |
|
|
57
|
-
| `parseRules`, `firstMatch`, `fetchRules`, `SopRule` | `soprules.ts` | Tier A3: SOP-authored `WHERE`-clause rules. |
|
|
85
|
+
| `parseRules`, `firstMatch`, `fetchRules`, `fetchRegister`, `parseRegister`, `SopRule`, `SopRegister` | `soprules.ts` | Tier A3: SOP-authored `WHERE`-clause rules, and the register they come in (rules plus the workspace's intervention mode). |
|
|
58
86
|
| `checkCommand`, `checkImages`, `checkWrittenManifest`, `ImageVerdict` | `imagecheck.ts` | Tier A2: container-image provenance on deploy commands. |
|
|
59
87
|
| `McpRegistryRecord`, `McpAllowlistRecord` | `mcpRegistryRecord.ts` | Tier M: the snapshot's MCP server registry and allowlist (`Snapshot.mcpRegistry`, `Snapshot.mcpAllowlist`), decided as the hook gates and the MCP proxy decide them; a byte-identical copy of `@intutic/shared-types`' module. |
|
|
60
88
|
| `classify`, `isDeploy`, `isTest`, `touchesInfra` | `actions.ts` | Command classifier shared by A2's deploy trigger. |
|
|
61
89
|
| `canonicalJson`, `holdKey`, `holdMessage` | `hold.ts` | The hold helpers: key-sorted JSON, the tool name and argument hash an approved hold is matched on, and the message a held call carries. |
|
|
90
|
+
| (internal) | `chaosGate.ts` | A chaos run's plan, counters and faults, which `Gate.guard` applies when `INTUTIC_CHAOS_PLAN` is set (`CHAOS_FAULT`, or `IntuticGateHold` for a held call); a byte-identical copy of `@intutic/shared-types`' module, as the hook gates emit it. |
|
|
62
91
|
| `COMMAND_SIZE_LIMIT`, `ARGUMENTS_SIZE_LIMIT`, `GATE_DEADLINE_MS` | `limits.ts` | A command over 256 KiB or arguments over 1 MiB are refused with `COMMAND_TOO_LARGE` before any tier runs. `GATE_DEADLINE_MS` (9000) is how long the hook script `intuticSandboxBootstrap()` writes may evaluate, from process start, before it refuses with `GATE_DEADLINE`: one second under that hook entry's 10-second timeout, so a slow rule is refused rather than left to the harness. |
|
|
63
92
|
|
|
64
93
|
The snapshot must carry the `#digest <hash>` line the sync daemon writes (the
|
|
@@ -69,7 +98,7 @@ dropped, the SSO group policy still refuses, and every MCP call is refused with
|
|
|
69
98
|
`POLICY_SNAPSHOT_UNVERIFIED`. A hand-written snapshot for a test needs the line
|
|
70
99
|
too.
|
|
71
100
|
|
|
72
|
-
Full reference: [Gate SDK](https://docs.intutic.ai/reference/gate-sdk).
|
|
101
|
+
Full reference: [Gate SDK](https://docs.intutic.ai/reference/gate-sdk). Every export, with its signature and defaults: [API reference](https://docs.intutic.ai/reference/sdk/gate/).
|
|
73
102
|
|
|
74
103
|
### A note for sibling adapter phases
|
|
75
104
|
|
|
@@ -236,7 +265,7 @@ ordering gotcha.
|
|
|
236
265
|
|
|
237
266
|
## Subpath convention
|
|
238
267
|
|
|
239
|
-
|
|
268
|
+
Nine adapters exist today, one source file each: `@intutic/gate/dsh`
|
|
240
269
|
(`src/dsh.ts` — a Cordis plugin; see its module doc for the veto contract and
|
|
241
270
|
`services/sync-daemon/src/harness/dshHooks.ts` for profile registration),
|
|
242
271
|
`@intutic/gate/mastra` (`src/mastra.ts`), `@intutic/gate/vercel`
|
|
@@ -247,7 +276,8 @@ per-tool/per-connection `approval` surface, plus the observe-only
|
|
|
247
276
|
pre-1.0 Preview product, see its module doc), `@intutic/gate/harness`
|
|
248
277
|
(`src/harness.ts` — see above), `@intutic/gate/workflow` (`src/workflow.ts`
|
|
249
278
|
— see above), and `@intutic/gate/managed-agents` (`src/managedAgents.ts` — see
|
|
250
|
-
above)
|
|
279
|
+
above), and `@intutic/gate/trueforge` (`src/trueforge.ts` — embedded mode
|
|
280
|
+
only; see its module doc). Later adapter phases follow the SAME convention (also
|
|
251
281
|
`services/sync-daemon`'s existing subpath convention — see that package's
|
|
252
282
|
`package.json`):
|
|
253
283
|
|
|
@@ -257,10 +287,12 @@ above). Later adapter phases follow the SAME convention (also
|
|
|
257
287
|
```json
|
|
258
288
|
"./vercel": { "import": "./dist/vercel.js", "types": "./dist/vercel.d.ts" }
|
|
259
289
|
```
|
|
260
|
-
3. A matching `typesVersions` entry
|
|
261
|
-
|
|
290
|
+
3. A matching `typesVersions` entry pointing at the built declarations, so a
|
|
291
|
+
consumer resolving with `moduleResolution: node` finds the subpath's types
|
|
292
|
+
(only `dist/` is published, so a `src/` path here resolves to nothing;
|
|
293
|
+
`tools/scripts/check-package-entrypoints.js` fails the build on one):
|
|
262
294
|
```json
|
|
263
|
-
"typesVersions": { "*": { "vercel": ["
|
|
295
|
+
"typesVersions": { "*": { "vercel": ["dist/vercel.d.ts"] } }
|
|
264
296
|
```
|
|
265
297
|
4. Each adapter file imports from `./gate.js`, `./errors.js`, etc. (this
|
|
266
298
|
package's core, already built) rather than re-implementing any tier —
|
package/dist/actions.d.ts
CHANGED
|
@@ -80,6 +80,7 @@ export declare function toolIs(name: string, group: readonly string[]): boolean;
|
|
|
80
80
|
export declare function classify(toolName: string, toolInput: unknown): string[];
|
|
81
81
|
/** True when this call would deploy — the trigger for the image check. */
|
|
82
82
|
export declare function isDeploy(toolName: string, toolInput: unknown): boolean;
|
|
83
|
+
/** True when this call runs a test suite. */
|
|
83
84
|
export declare function isTest(toolName: string, toolInput: unknown): boolean;
|
|
84
85
|
/** True when a written path is infrastructure-as-code. */
|
|
85
86
|
export declare function touchesInfra(path: string | null | undefined): boolean;
|
package/dist/actions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAIH,eAAO,MAAM,aAAa,YAAY,CAAA;AAEtC,0DAA0D;AAC1D,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAe5C,CAAA;AAED,yEAAyE;AACzE,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAS7C,CAAA;AAED,mCAAmC;AACnC,eAAO,MAAM,gBAAgB,EAAE,SAAS,MAAM,EAO7C,CAAA;AAED,sCAAsC;AACtC,eAAO,MAAM,aAAa,EAAE,SAAS,MAAM,EAqB1C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAO/C,CAAA;AAED,yCAAyC;AACzC,eAAO,MAAM,iBAAiB,EAAE,SAAS,MAAM,EAS9C,CAAA;AAED;;;;;GAKG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAclD,CAAA;AAED,qEAAqE;AACrE,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAO/C,CAAA;AAED,0DAA0D;AAC1D,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAYxC,CAAA;AAED,kDAAkD;AAClD,eAAO,MAAM,UAAU,EAAE,SAAS,MAAM,EAAqD,CAAA;AAE7F,kDAAkD;AAClD,eAAO,MAAM,WAAW,EAAE,SAAS,MAAM,EAAmE,CAAA;AAE5G;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,EAAE,SAAS,MAAM,EASjD,CAAA;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,C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function isDeploy(toolName, toolInput) {
|
|
246
246
|
return classify(toolName, toolInput).includes(ACTION_PREFIX + 'deploy');
|
|
247
247
|
}
|
|
248
|
+
/** True when this call runs a test suite. */
|
|
248
249
|
export function isTest(toolName, toolInput) {
|
|
249
250
|
return classify(toolName, toolInput).includes(ACTION_PREFIX + 'run_tests');
|
|
250
251
|
}
|
package/dist/actions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.js","sourceRoot":"","sources":["../src/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,SAAS,EAAE,UAAU,EAAmB,MAAM,cAAc,CAAA;AAErE,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,0DAA0D;AAC1D,MAAM,CAAC,MAAM,eAAe,GAAsB;IAChD,UAAU;IACV,eAAe;IACf,iBAAiB;IACjB,cAAc;IACd,cAAc;IACd,iBAAiB;IACjB,aAAa;IACb,mBAAmB;IACnB,YAAY;IACZ,eAAe;IACf,mBAAmB;IACnB,YAAY;IACZ,aAAa;IACb,WAAW;CACZ,CAAA;AAED,yEAAyE;AACzE,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,aAAa;IACb,cAAc;IACd,cAAc;IACd,eAAe;IACf,cAAc;IACd,gBAAgB;IAChB,UAAU;IACV,sBAAsB;CACvB,CAAA;AAED,mCAAmC;AACnC,MAAM,CAAC,MAAM,gBAAgB,GAAsB;IACjD,mBAAmB;IACnB,SAAS;IACT,aAAa;IACb,eAAe;IACf,oBAAoB;IACpB,kBAAkB;CACnB,CAAA;AAED,sCAAsC;AACtC,MAAM,CAAC,MAAM,aAAa,GAAsB;IAC9C,UAAU;IACV,cAAc;IACd,WAAW;IACX,eAAe;IACf,WAAW;IACX,YAAY;IACZ,SAAS;IACT,QAAQ;IACR,kBAAkB;IAClB,QAAQ;IACR,MAAM;IACN,OAAO;IACP,OAAO;IACP,SAAS;IACT,WA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E;QACxE,sCAAsC;QACtC,IAAI,UAAU,CAAC,IAAI,EAAE,qBAAqB,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,aAAa,CAAC,CAAA;QACxE,IAAI,UAAU,CAAC,IAAI,EAAE,kBAAkB,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;QACpE,IAAI,aAAa,CAAC,KAAK,EAAE,kBAAkB,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC,CAAA;QACvE,IAAI,aAAa,CAAC,KAAK,EAAE,iBAAiB,CAAC;YAAE,OAAO,CAAC,IAAI,CAAC,UAAU,CAAC,CAAA;IACvE,CAAC;IAED,OAAO,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,aAAa,GAAG,CAAC,CAAC,CAAA;AAC9C,CAAC;AAED,0EAA0E;AAC1E,MAAM,UAAU,QAAQ,CAAC,QAAgB,EAAE,SAAkB;IAC3D,OAAO,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,aAAa,GAAG,QAAQ,CAAC,CAAA;AACzE,CAAC;AAED,6CAA6C;AAC7C,MAAM,UAAU,MAAM,CAAC,QAAgB,EAAE,SAAkB;IACzD,OAAO,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,CAAC,QAAQ,CAAC,aAAa,GAAG,WAAW,CAAC,CAAA;AAC5E,CAAC;AAED,0DAA0D;AAC1D,MAAM,UAAU,YAAY,CAAC,IAA+B;IAC1D,OAAO,UAAU,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,EAAE,oBAAoB,CAAC,CAAA;AACrE,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,0BAA0B,CAAA;IAC7C,KAAK,EAAE;QAAE,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAA;IAC9D,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAA;IACpB,yBAAyB;IACzB,OAAO,EAAE,MAAM,CAAA;IACf,uCAAuC;IACvC,IAAI,EAAE,MAAM,GAAG,OAAO,GAAG,gBAAgB,CAAA;IACzC,oFAAoF;I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