@cygnuxlabs/tracekit 1.5.2 → 1.6.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 +8 -4
- package/dist/v2/adapters/claude-agent-sdk.d.ts +9 -2
- package/dist/v2/adapters/claude-agent-sdk.js +15 -6
- package/dist/v2/client.d.ts +5 -0
- package/dist/v2/client.js +14 -0
- package/dist/v2/executor.d.ts +2 -1
- package/dist/v2/executor.js +2 -1
- package/dist/v2/rpc_schema.d.ts +1 -1
- package/dist/v2/rpc_schema.js +7 -3
- package/dist/verify/detect.js +9 -1
- package/dist/verify/explain.js +20 -3
- package/dist/verify/index.d.ts +57 -5
- package/dist/verify/index.js +522 -47
- package/dist/verify/primitives.js +5 -2
- package/dist/verify/versions.json +7 -0
- package/dist/verify/zip.js +1 -1
- package/dist/verify.html +559 -56
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -39,11 +39,13 @@ const client = new Client(); // or new Client({ sig
|
|
|
39
39
|
const run = await client.registerRun("research-bot");
|
|
40
40
|
const d = await run.decide(call.id, "Bash", call.function.arguments); // the raw model string, or a parsed value
|
|
41
41
|
if (d.decision === "allow") {
|
|
42
|
-
|
|
43
|
-
|
|
42
|
+
if ((await run.approvalConsume(call.id, "Bash", call.function.arguments)).ok) // never throws: ok false means it doesn't run
|
|
43
|
+
await run.complete(call.id, "ok", { result: await runShell(call) }); // never throws: a recording failure is a warning
|
|
44
44
|
} else if (d.decision === "ask") {
|
|
45
45
|
const { approval_id } = await run.approvalRequest(call.id);
|
|
46
46
|
const { state } = await run.approvalWait(approval_id, 300_000); // on a connection of its own
|
|
47
|
+
if (state === "approved" && (await run.approvalConsume(call.id, "Bash", call.function.arguments, approval_id)).ok)
|
|
48
|
+
await run.complete(call.id, "ok", { result: await runShell(call) });
|
|
47
49
|
}
|
|
48
50
|
await run.close();
|
|
49
51
|
await client.close(); // waits for what is in flight
|
|
@@ -127,7 +129,8 @@ applies only when the signer cannot be reached at the decision; a refusal, or a
|
|
|
127
129
|
never lets the call run. Recording a finished call never throws and never changes its result (a failure is a
|
|
128
130
|
`TracekitWarning`). The frameworks are optional peer dependencies: the adapters import none of them, and the client
|
|
129
131
|
keeps no runtime dependencies. No adapter wraps a provider client, so the SDKs' own `APIPromise` (`.withResponse()`)
|
|
130
|
-
and streams (`messages.stream()`, `streamText`) work as without Tracekit. Offline examples: `examples/v2_*.mjs
|
|
132
|
+
and streams (`messages.stream()`, `streamText`) work as without Tracekit. Offline examples: `examples/v2_*.mjs`, and
|
|
133
|
+
[a Mastra workflow](examples/mastra/) that suspends on a held call and resumes with its approval id.
|
|
131
134
|
|
|
132
135
|
- **A server: a run per conversation.** Register a run per conversation and make it current around each request with
|
|
133
136
|
`withRun(run, () => runner.run(...))`: every adapter decides the calls made inside it in that run (its complete and
|
|
@@ -140,7 +143,8 @@ and streams (`messages.stream()`, `streamText`) work as without Tracekit. Offlin
|
|
|
140
143
|
keep the run's `runId` and `runToken` with the framework's saved state and re-attach:
|
|
141
144
|
`new RunHandle(new Client(), { run_id, run_token })`; close that client when you are done with it
|
|
142
145
|
(`run.client.close()`), or re-attach every run through one shared client. `process.exit()` skips all of this: close
|
|
143
|
-
first.
|
|
146
|
+
first. The [offline Vercel AI resume example](examples/v2_vercel_ai_resume.mjs) saves the run and messages, prints
|
|
147
|
+
the approval command, and resumes in a second process.
|
|
144
148
|
- **The LLM gateway.** Point the provider at it with the run in a header, e.g. OpenAI Agents
|
|
145
149
|
`setDefaultOpenAIClient(new OpenAI({ baseURL, apiKey: <gateway token>, defaultHeaders: { "X-Tracekit-Run":
|
|
146
150
|
`${run.runId}.${run.runToken}` } }))`, Vercel AI `createOpenAI({ baseURL, apiKey, headers })`. Register the run as
|
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
import { type RunHandle } from "../client.js";
|
|
2
2
|
export declare const HOOK_TIMEOUT_S = 600;
|
|
3
3
|
export declare const APPROVAL_WAIT_MS = 540000;
|
|
4
|
-
/** The `hooks` option of `query()`.
|
|
5
|
-
|
|
4
|
+
/** The `hooks` option of `query()`. `mcpServers`: the option given `query()`, when it holds a tool executor's server
|
|
5
|
+
* under SERVER; `executorActions`: the actions that server serves (executorActions()). To add hooks of your own,
|
|
6
|
+
* extend the lists. */
|
|
7
|
+
export declare function tracekitHooks(run: RunHandle, { mcpServers, executorActions }?: {
|
|
8
|
+
mcpServers?: Record<string, any>;
|
|
9
|
+
executorActions?: {
|
|
10
|
+
name: string;
|
|
11
|
+
}[];
|
|
12
|
+
}): {
|
|
6
13
|
PreToolUse: {
|
|
7
14
|
hooks: ((inp: any, toolUseID?: string) => Promise<{
|
|
8
15
|
hookSpecificOutput: {
|
|
@@ -13,9 +13,12 @@
|
|
|
13
13
|
* gets as the tool's error result, and the session goes on. `ask` holds the call in the hook until a person decides in
|
|
14
14
|
* the signer, for at most APPROVAL_WAIT_MS, below the hook's own timeout (HOOK_TIMEOUT_S, set on the matcher); a call
|
|
15
15
|
* not approved by then is blocked. An approval with a T2 executor runs the signer's copy of the arguments (the hook's
|
|
16
|
-
* `updatedInput`). PostToolUse and PostToolUseFailure complete the call; SessionEnd closes the run. The tools of
|
|
17
|
-
* server
|
|
18
|
-
*
|
|
16
|
+
* `updatedInput`). PostToolUse and PostToolUseFailure complete the call; SessionEnd closes the run. The tools of the
|
|
17
|
+
* MCP server under SERVER (`tracekit-executor`), whose handlers call a tool executor, are left to the executor, by
|
|
18
|
+
* the exact names of the `executorActions` the app hands the hooks, when the `mcpServers` it also hands them (those it
|
|
19
|
+
* gives `query()`) hold that server in-process (`type: "sdk"`, from createSdkMcpServer): the CLI connects it in place
|
|
20
|
+
* of a project .mcp.json server of the same name, and the hooks gate every other tool. The tools run in the CLI
|
|
21
|
+
* subprocess, so the signer's coding packs apply to them.
|
|
19
22
|
*/
|
|
20
23
|
import { randomUUID } from "node:crypto";
|
|
21
24
|
import { RPCError, SignerUnavailable } from "../client.js";
|
|
@@ -25,14 +28,20 @@ import { BLOCKED, Gate, failure, warn } from "./gate.js";
|
|
|
25
28
|
export const HOOK_TIMEOUT_S = 600; // the SDK's default (60 s) is too short to wait for a person
|
|
26
29
|
export const APPROVAL_WAIT_MS = 540_000; // below HOOK_TIMEOUT_S, so the hook answers before the CLI gives up on it
|
|
27
30
|
const deny = (why) => ({ hookSpecificOutput: { hookEventName: "PreToolUse", permissionDecision: "deny", permissionDecisionReason: why } });
|
|
28
|
-
/** The `hooks` option of `query()`.
|
|
29
|
-
|
|
31
|
+
/** The `hooks` option of `query()`. `mcpServers`: the option given `query()`, when it holds a tool executor's server
|
|
32
|
+
* under SERVER; `executorActions`: the actions that server serves (executorActions()). To add hooks of your own,
|
|
33
|
+
* extend the lists. */
|
|
34
|
+
export function tracekitHooks(run, { mcpServers, executorActions = [] } = {}) {
|
|
30
35
|
const gate = new Gate(run);
|
|
36
|
+
// the exact tool names of the app's in-process executor server: what the CLI routes to it, never a tool of a server
|
|
37
|
+
// a project file names (a key like `tracekit-executor__x` included)
|
|
38
|
+
const executor = (tool) => mcpServers?.[SERVER]?.type === "sdk" && mcpServers[SERVER].instance != null
|
|
39
|
+
&& executorActions.some((a) => tool === `mcp__${SERVER}__${a.name}`);
|
|
31
40
|
async function pre(inp, toolUseID) {
|
|
32
41
|
const id = inp.tool_use_id ?? toolUseID;
|
|
33
42
|
if (!id)
|
|
34
43
|
return deny(BLOCKED + "the hook got no tool_use_id"); // never defaulted: a result could not be bound to its decision
|
|
35
|
-
if (String(inp.tool_name ?? "")
|
|
44
|
+
if (executor(String(inp.tool_name ?? "")))
|
|
36
45
|
return {}; // the executor decides and records it (T2)
|
|
37
46
|
const why = await gate.admit(id, inp.tool_name ?? "?", inp.tool_input, { waitMs: APPROVAL_WAIT_MS });
|
|
38
47
|
if (why !== null)
|
package/dist/v2/client.d.ts
CHANGED
|
@@ -136,6 +136,11 @@ export declare class RunHandle {
|
|
|
136
136
|
approvalRequest(toolCallId: string, fields?: Frame): Promise<Frame>;
|
|
137
137
|
/** Waits up to `timeoutMs` (signer cap 300 s) for a decision, on a connection of its own. */
|
|
138
138
|
approvalWait(approvalId: string, timeoutMs?: number): Promise<Frame>;
|
|
139
|
+
/** Call right before running a call that was not denied: `{ ok: true }` when it may run now. `args` as for `decide`;
|
|
140
|
+
* `approvalIdHint` is the approval id the framework saved, if any. Never rejects: any failure (a signer that can't be
|
|
141
|
+
* reached, is incompatible or refuses) is `{ ok: false, reason }` (once decided there is no fail mode: the call
|
|
142
|
+
* doesn't run). */
|
|
143
|
+
approvalConsume(toolCallId: string, tool: string, args: unknown, approvalIdHint?: string, fields?: Frame): Promise<Frame>;
|
|
139
144
|
/** Records content that entered the run other than as a tool result (a mail, a ticket, a page the app fetched) for
|
|
140
145
|
* the signer's provenance index; the task or user prompt goes in with trust "trusted". Only its commitment is recorded. */
|
|
141
146
|
observe(value: unknown, source: string, trust?: "trusted" | "untrusted", fields?: Frame): Promise<Frame>;
|
package/dist/v2/client.js
CHANGED
|
@@ -677,6 +677,20 @@ export class RunHandle {
|
|
|
677
677
|
approvalWait(approvalId, timeoutMs) {
|
|
678
678
|
return this.call("approval_wait", { approval_id: approvalId, ...(timeoutMs === undefined ? {} : { timeout_ms: timeoutMs }) });
|
|
679
679
|
}
|
|
680
|
+
/** Call right before running a call that was not denied: `{ ok: true }` when it may run now. `args` as for `decide`;
|
|
681
|
+
* `approvalIdHint` is the approval id the framework saved, if any. Never rejects: any failure (a signer that can't be
|
|
682
|
+
* reached, is incompatible or refuses) is `{ ok: false, reason }` (once decided there is no fail mode: the call
|
|
683
|
+
* doesn't run). */
|
|
684
|
+
async approvalConsume(toolCallId, tool, args, approvalIdHint, fields = {}) {
|
|
685
|
+
try {
|
|
686
|
+
return await this.call("approval_consume", { tool_call_id: toolCallId, tool, args, args_source: typeof args === "string" ? "raw" : "parsed",
|
|
687
|
+
...(approvalIdHint ? { approval_id_hint: approvalIdHint } : {}), ...fields });
|
|
688
|
+
}
|
|
689
|
+
catch (e) {
|
|
690
|
+
warn(`tracekit: ${tool} is blocked: approval_consume failed: ${e.message}`);
|
|
691
|
+
return { ok: false, rule_ids: [], reason: `approval_consume failed: ${e.message}`.slice(0, 1024) };
|
|
692
|
+
}
|
|
693
|
+
}
|
|
680
694
|
/** Records content that entered the run other than as a tool result (a mail, a ticket, a page the app fetched) for
|
|
681
695
|
* the signer's provenance index; the task or user prompt goes in with trust "trusted". Only its commitment is recorded. */
|
|
682
696
|
observe(value, source, trust = "untrusted", fields = {}) {
|
package/dist/v2/executor.d.ts
CHANGED
|
@@ -20,7 +20,8 @@ export declare class ExecutorRefused extends Error {
|
|
|
20
20
|
}
|
|
21
21
|
/** Set on the tools built here: the Tracekit adapters don't gate them. */
|
|
22
22
|
export declare const EXECUTOR: unique symbol;
|
|
23
|
-
/** The Claude Agent SDK hooks leave the tools of
|
|
23
|
+
/** The Claude Agent SDK hooks leave the actions' tools of the in-process MCP server under this key
|
|
24
|
+
* (mcp__tracekit-executor__<action>) alone when the app hands them its `mcpServers` and `executorActions`. */
|
|
24
25
|
export declare const SERVER = "tracekit-executor";
|
|
25
26
|
export type Action = {
|
|
26
27
|
name: string;
|
package/dist/v2/executor.js
CHANGED
|
@@ -2,7 +2,8 @@ export class ExecutorRefused extends Error {
|
|
|
2
2
|
}
|
|
3
3
|
/** Set on the tools built here: the Tracekit adapters don't gate them. */
|
|
4
4
|
export const EXECUTOR = Symbol.for("tracekit.executor");
|
|
5
|
-
/** The Claude Agent SDK hooks leave the tools of
|
|
5
|
+
/** The Claude Agent SDK hooks leave the actions' tools of the in-process MCP server under this key
|
|
6
|
+
* (mcp__tracekit-executor__<action>) alone when the app hands them its `mcpServers` and `executorActions`. */
|
|
6
7
|
export const SERVER = "tracekit-executor";
|
|
7
8
|
/** Why `url` may not receive the run token and the agent's credential, or null: https, or plain http to loopback. */
|
|
8
9
|
function remoteUrlError(url) {
|
package/dist/v2/rpc_schema.d.ts
CHANGED
package/dist/v2/rpc_schema.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export const RPC_VERSION =
|
|
1
|
+
export const RPC_VERSION = 22;
|
|
2
2
|
export const REQUESTS = {
|
|
3
|
-
"register_run": { "type": "object", "additionalProperties": false, "required": ["request_id", "agent"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "tenant": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "principal": { "type": "string", "maxLength": 256 }, "principal_token": { "type": "string", "maxLength": 16384 }, "source": { "const": "migrated" }, "analyzes": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "replay_of": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "investigation": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "parent": { "type": "object", "additionalProperties": false, "required": ["run_id", "run_token"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 } } }, "caller": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "agent": { "type": "object", "additionalProperties": false, "required": ["name"], "properties": { "name": { "type": "string", "maxLength": 128, "minLength": 1 }, "version": { "type": "string", "maxLength": 64 } } } } },
|
|
3
|
+
"register_run": { "type": "object", "additionalProperties": false, "required": ["request_id", "agent"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "tenant": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "principal": { "type": "string", "maxLength": 256 }, "principal_token": { "type": "string", "maxLength": 16384 }, "source": { "const": "migrated" }, "analyzes": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "replay_of": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "investigation": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "parent": { "type": "object", "additionalProperties": false, "required": ["run_id", "run_token"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 } } }, "caller": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "box": { "type": "object", "additionalProperties": false, "required": ["id", "image_digest", "allow"], "properties": { "id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "image_digest": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" }, "channel": { "const": "agent" }, "allow": { "type": "array", "maxItems": 256, "items": { "type": "string", "maxLength": 261, "minLength": 1, "pattern": "^[A-Za-z0-9.*:\\[\\]_-]+(?![\\s\\S])" } } } }, "agent": { "type": "object", "additionalProperties": false, "required": ["name"], "properties": { "name": { "type": "string", "maxLength": 128, "minLength": 1 }, "version": { "type": "string", "maxLength": 64 } } } } },
|
|
4
4
|
"decide": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "stream", "client_seq", "tool_call_id", "tool", "args_source", "args"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "stream": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "client_seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "caller": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "tool_call_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "attempt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "tool": { "type": "string", "maxLength": 256, "minLength": 1 }, "tool_class_hint": { "type": "string", "maxLength": 64 }, "args_source": { "enum": ["raw", "parsed", "coerced"] }, "args": {} }, "if": { "properties": { "args_source": { "const": "raw" } } }, "then": { "properties": { "args": { "type": "string", "maxLength": 1048576 } } } },
|
|
5
5
|
"complete": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "stream", "client_seq", "tool_call_id", "decision_id", "args_digest", "status"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "stream": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "client_seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "caller": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "tool_call_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "attempt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "decision_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "args_digest": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" }, "status": { "enum": ["ok", "error"] }, "result": {}, "error": { "type": "string", "maxLength": 4096 }, "redacted": { "const": true }, "redaction": { "type": "object", "additionalProperties": false, "required": [], "properties": { "rules": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 64 } }, "count": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } },
|
|
6
6
|
"observe": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "stream", "client_seq", "source", "trust", "value"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "stream": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "client_seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "caller": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "source": { "type": "string", "maxLength": 256, "minLength": 1 }, "trust": { "enum": ["trusted", "untrusted"] }, "value": {} } },
|
|
@@ -30,7 +30,7 @@ export const REQUESTS = {
|
|
|
30
30
|
"content_get": { "type": "object", "additionalProperties": false, "required": ["run_id", "seqs", "purpose"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "seqs": { "type": "array", "maxItems": 1000, "items": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } }, "purpose": { "type": "string", "maxLength": 512, "minLength": 1 } } },
|
|
31
31
|
"content_erase": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "reason": { "type": "string", "maxLength": 1024 } } },
|
|
32
32
|
"why_finding": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "finding"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "finding": { "type": "object", "additionalProperties": false, "required": ["target", "intervention", "n", "p_with", "p_without", "effect", "interval", "verdict", "replay_runs", "models", "rung", "off_tape", "investigation", "looks", "family", "min_effect", "applied", "stopped"], "properties": { "target": { "type": "string", "maxLength": 1024 }, "intervention": { "type": "string", "maxLength": 1024 }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "p_with": { "type": "number", "minimum": 0, "maximum": 1 }, "p_without": { "type": "number", "minimum": 0, "maximum": 1 }, "effect": { "type": "number", "minimum": -1, "maximum": 1 }, "interval": { "type": "array", "minItems": 2, "maxItems": 2, "items": { "type": "number", "minimum": -1, "maximum": 1 } }, "verdict": { "enum": ["causal", "suppressive", "ruled-out", "inconclusive", "not-applied"] }, "replay_runs": { "type": "array", "maxItems": 4096, "items": { "type": "object", "additionalProperties": false, "required": ["run_id", "arm", "hit"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "arm": { "enum": ["control", "ablated"] }, "hit": { "type": "boolean" } } } }, "models": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 128 } }, "rung": { "enum": [1, 2] }, "off_tape": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "investigation": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "looks": { "type": "integer", "minimum": 1, "maximum": 4096 }, "family": { "type": "integer", "minimum": 1, "maximum": 4096 }, "min_effect": { "type": "number", "minimum": 0, "maximum": 1 }, "applied": { "type": "boolean" }, "stopped": { "enum": ["decisive", "futility", "n_max", "budget"] }, "uncounted": { "type": "array", "maxItems": 4096, "items": { "type": "object", "additionalProperties": false, "required": ["run_id", "reason"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "reason": { "enum": ["ranking", "budget"] } } } } } } } },
|
|
33
|
-
"review_finding": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "review"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "review": { "type": "object", "additionalProperties": false, "required": ["reviewer", "verdict", "cites"], "properties": { "reviewer": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._/+-]+(?![\\s\\S])" }, "cites": { "type": "array", "maxItems": 256, "items": { "type": "object", "additionalProperties": false, "required": ["run_seq", "hash"], "properties": { "run_seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "hash": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } } } }, "verdict": { "oneOf": [{ "type": "object", "additionalProperties": false, "required": ["kind", "rule", "severity"], "properties": { "kind": { "const": "finding" }, "rule": { "enum": ["TK-X201", "TK-X202", "TK-X203", "TK-X204", "TK-X205", "TK-X206", "TK-X207", "TK-X208", "TK-X210", "TK-X101", "TK-X102", "TK-X103", "TK-X104", "TK-X111", "TK-X112", "TK-X113", "TK-X114", "TK-X120", "TK-X211"] }, "severity": { "enum": ["info", "low", "medium", "high", "critical"] }, "tier": { "enum": ["gateway", "harness", "transcript", "sdk"] }, "order": { "enum": ["signed_before", "transcript_order", "after"] }, "redacted": { "type": "boolean" }, "lifted": { "type": "boolean" }, "digests": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } }, "alignment": { "enum": ["ok", "drift", "misaligned"] }, "reason": { "enum": ["none", "unrequested_action", "unexplained_action", "contradicted_reasoning", "scope_creep", "workaround", "false_success", "followed_tool_output", "injection", "other"] }, "asserted": { "type": "object", "additionalProperties": false, "required": ["model", "version", "prompt_hash"], "properties": { "model": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:/@+-]+(?![\\s\\S])" }, "version": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:/@+-]+(?![\\s\\S])" }, "prompt_hash": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } } }, "families": { "type": "object", "additionalProperties": false, "required": ["reviewer", "agent"], "properties": { "reviewer": { "enum": ["anthropic", "openai", "google", "meta", "mistral", "deepseek", "qwen", "xai", null] }, "agent": { "type": "array", "maxItems": 8, "items": { "enum": ["anthropic", "openai", "google", "meta", "mistral", "deepseek", "qwen", "xai"] } } } }, "window": { "type": "object", "additionalProperties": false, "required": ["grace_s", "skew_s"], "properties": { "grace_s": { "type": "number", "minimum": 0, "maximum": 86400 }, "skew_s": { "type": "number", "minimum": 0, "maximum": 86400 } } } } }, { "type": "object", "additionalProperties": false, "required": ["kind", "rule", "severity", "checks"], "properties": { "kind": { "const": "coverage" }, "rule": { "const": "TK-X200" }, "severity": { "const": "info" }, "checks": { "type": "object", "additionalProperties": false, "required": [], "properties": { "TK-X201": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X202": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X203": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X204": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X205": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X206": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X207": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X208": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X210": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X101": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X102": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X103": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X104": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X111": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X112": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X113": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X114": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X120": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X211": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } } } }, "partial": { "type": "boolean" }, "reasoning": { "type": "object", "additionalProperties": false, "required": [], "properties": { "full": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "summary": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "withheld": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "none": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } }] } } } } },
|
|
33
|
+
"review_finding": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "review"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "review": { "type": "object", "additionalProperties": false, "required": ["reviewer", "verdict", "cites"], "properties": { "reviewer": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._/+-]+(?![\\s\\S])" }, "cites": { "type": "array", "maxItems": 256, "items": { "type": "object", "additionalProperties": false, "required": ["run_seq", "hash"], "properties": { "run_seq": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "hash": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } } } }, "verdict": { "oneOf": [{ "type": "object", "additionalProperties": false, "required": ["kind", "rule", "severity"], "properties": { "kind": { "const": "finding" }, "rule": { "enum": ["TK-X201", "TK-X202", "TK-X203", "TK-X204", "TK-X205", "TK-X206", "TK-X207", "TK-X208", "TK-X210", "TK-X101", "TK-X102", "TK-X103", "TK-X104", "TK-X111", "TK-X112", "TK-X113", "TK-X114", "TK-X120", "TK-X211", "TK-X212"] }, "severity": { "enum": ["info", "low", "medium", "high", "critical"] }, "tier": { "enum": ["gateway", "harness", "transcript", "sdk"] }, "order": { "enum": ["signed_before", "transcript_order", "after"] }, "redacted": { "type": "boolean" }, "lifted": { "type": "boolean" }, "digests": { "type": "array", "maxItems": 32, "items": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } }, "alignment": { "enum": ["ok", "drift", "misaligned"] }, "reason": { "enum": ["none", "unrequested_action", "unexplained_action", "contradicted_reasoning", "scope_creep", "workaround", "false_success", "followed_tool_output", "injection", "other"] }, "asserted": { "type": "object", "additionalProperties": false, "required": ["model", "version", "prompt_hash"], "properties": { "model": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:/@+-]+(?![\\s\\S])" }, "version": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:/@+-]+(?![\\s\\S])" }, "prompt_hash": { "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" } } }, "families": { "type": "object", "additionalProperties": false, "required": ["reviewer", "agent"], "properties": { "reviewer": { "enum": ["anthropic", "openai", "google", "meta", "mistral", "deepseek", "qwen", "xai", null] }, "agent": { "type": "array", "maxItems": 8, "items": { "enum": ["anthropic", "openai", "google", "meta", "mistral", "deepseek", "qwen", "xai"] } } } }, "window": { "type": "object", "additionalProperties": false, "required": ["grace_s", "skew_s"], "properties": { "grace_s": { "type": "number", "minimum": 0, "maximum": 86400 }, "skew_s": { "type": "number", "minimum": 0, "maximum": 86400 } } } } }, { "type": "object", "additionalProperties": false, "required": ["kind", "rule", "severity", "checks"], "properties": { "kind": { "const": "coverage" }, "rule": { "const": "TK-X200" }, "severity": { "const": "info" }, "checks": { "type": "object", "additionalProperties": false, "required": [], "properties": { "TK-X201": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X202": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X203": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X204": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X205": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X206": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X207": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X208": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X210": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X101": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X102": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X103": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X104": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X111": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X112": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X113": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X114": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X120": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X211": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } }, "TK-X212": { "type": "object", "additionalProperties": false, "required": ["checked", "found"], "properties": { "checked": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "found": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "not_checkable": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["reason", "n"], "properties": { "reason": { "type": "string", "maxLength": 32, "minLength": 1, "pattern": "^[a-z][a-z_]*(?![\\s\\S])" }, "n": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } } } } }, "partial": { "type": "boolean" }, "reasoning": { "type": "object", "additionalProperties": false, "required": [], "properties": { "full": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "summary": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "withheld": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "none": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } } }] } } } } },
|
|
34
34
|
"constraint_add": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "constraint"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "constraint": { "type": "object", "additionalProperties": false, "required": ["kind"], "properties": { "kind": { "enum": ["keep_away", "only_change", "read_only", "no_push", "no_network"] }, "object": { "type": "string", "maxLength": 256, "minLength": 1 } } } } },
|
|
35
35
|
"incident_list": { "type": "object", "additionalProperties": false, "required": [], "properties": { "state": { "enum": ["open", "resolved"] }, "cursor": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "limit": { "type": "integer", "minimum": 1, "maximum": 1000 } } },
|
|
36
36
|
"incident_show": { "type": "object", "additionalProperties": false, "required": ["incident_id"], "properties": { "incident_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" } } },
|
|
@@ -46,4 +46,8 @@ export const REQUESTS = {
|
|
|
46
46
|
"pcm_grant": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "tool_call_id", "args"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "tool_call_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "attempt": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 }, "args": { "type": "object", "additionalProperties": false, "required": ["subject", "intent", "expires_at", "delegable"], "properties": { "subject": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "intent": { "type": "string", "maxLength": 136, "pattern": "^[a-z][a-z0-9_.-]{0,63}@sha256:[0-9a-f]{64}(?![\\s\\S])" }, "caveats": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["field", "op", "value"], "properties": { "field": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])" }, "op": { "enum": ["==", "<=", ">=", "<", ">", "in"] }, "value": {} } } }, "expires_at": { "type": "string", "maxLength": 27, "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z(?![\\s\\S])" }, "delegable": { "type": "boolean" } } } } },
|
|
47
47
|
"pcm_delegate": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "run_token", "parent", "subject", "expires_at", "delegable"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "parent": { "type": "object", "additionalProperties": false, "required": ["pcm_grant", "ts", "issuer", "subject", "intent", "caveats", "expires_at", "delegable", "parent", "sig"], "properties": { "pcm_grant": { "type": "integer", "const": 0 }, "ts": { "type": "string", "maxLength": 27, "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z(?![\\s\\S])" }, "issuer": { "type": "object", "additionalProperties": false, "required": ["kind", "id", "run", "tenant"], "properties": { "kind": { "enum": ["person", "agent"] }, "id": { "type": "string", "maxLength": 256 }, "person": { "type": "string", "maxLength": 256 }, "run": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "tenant": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "approval_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" } } }, "subject": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "intent": { "type": "string", "maxLength": 136, "pattern": "^[a-z][a-z0-9_.-]{0,63}@sha256:[0-9a-f]{64}(?![\\s\\S])" }, "caveats": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["field", "op", "value"], "properties": { "field": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])" }, "op": { "enum": ["==", "<=", ">=", "<", ">", "in"] }, "value": {} } } }, "expires_at": { "type": "string", "maxLength": 27, "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z(?![\\s\\S])" }, "delegable": { "type": "boolean" }, "parent": { "oneOf": [{ "type": "string", "maxLength": 71, "pattern": "^sha256:[0-9a-f]{64}(?![\\s\\S])" }, { "type": "null" }] }, "sig": { "type": "object", "additionalProperties": false, "required": ["key", "sig"], "properties": { "key": { "type": "string", "maxLength": 300, "minLength": 1 }, "sig": { "type": "string", "maxLength": 88 } } } } }, "subject": { "type": "string", "maxLength": 256, "pattern": "^[a-z0-9_]+:[^\\n]+(?![\\s\\S])" }, "caveats": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["field", "op", "value"], "properties": { "field": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])" }, "op": { "enum": ["==", "<=", ">=", "<", ">", "in"] }, "value": {} } } }, "expires_at": { "type": "string", "maxLength": 27, "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z(?![\\s\\S])" }, "delegable": { "type": "boolean" } } },
|
|
48
48
|
"pcm_evidence": { "type": "object", "additionalProperties": false, "required": ["run_id", "run_token", "run_seqs"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 }, "run_seqs": { "type": "array", "minItems": 1, "maxItems": 16, "items": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 } } } },
|
|
49
|
+
"channel_open": { "type": "object", "additionalProperties": false, "required": ["run_id", "run_token"], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_token": { "type": "string", "maxLength": 1024, "minLength": 1 } } },
|
|
50
|
+
"grant_issue": { "type": "object", "additionalProperties": false, "required": ["request_id", "run_id", "intent", "caveats", "limits", "expires_at"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "approval_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "intent": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_.-]{0,63}(?![\\s\\S])" }, "caveats": { "type": "array", "maxItems": 16, "items": { "type": "object", "additionalProperties": false, "required": ["field", "op", "value"], "properties": { "field": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])" }, "op": { "enum": ["==", "<=", ">=", "<", ">", "in"] }, "value": {} } } }, "limits": { "type": "array", "minItems": 1, "maxItems": 4, "items": { "type": "object", "additionalProperties": false, "required": ["op", "max"], "properties": { "op": { "enum": ["sum", "count"] }, "field": { "type": "string", "maxLength": 64, "pattern": "^[a-z][a-z0-9_]*(?![\\s\\S])" }, "max": { "type": "integer", "minimum": 1, "maximum": 9007199254740991 } } } }, "expires_at": { "type": "string", "maxLength": 27, "pattern": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}\\.\\d{6}Z(?![\\s\\S])" }, "description": { "type": "string", "maxLength": 512 }, "tools": { "type": "array", "maxItems": 16, "items": { "type": "string", "maxLength": 256, "minLength": 1 } } } },
|
|
51
|
+
"grant_list": { "type": "object", "additionalProperties": false, "required": [], "properties": { "run_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" } } },
|
|
52
|
+
"grant_revoke": { "type": "object", "additionalProperties": false, "required": ["request_id", "grant_id"], "properties": { "request_id": { "type": "string", "maxLength": 128, "minLength": 1, "pattern": "^[A-Za-z0-9._:-]+(?![\\s\\S])" }, "grant_id": { "type": "string", "maxLength": 18, "pattern": "^g-[0-9a-f]{16}(?![\\s\\S])" }, "reason": { "type": "string", "maxLength": 1024 } } },
|
|
49
53
|
};
|
package/dist/verify/detect.js
CHANGED
|
@@ -28,6 +28,14 @@ function glob(pat) {
|
|
|
28
28
|
}
|
|
29
29
|
return new RegExp(`^${out}$`, "u");
|
|
30
30
|
}
|
|
31
|
+
/** The owner of the run whose run.registered is `e`: the identity it records, but box:<uid>/<box id> for a run of a
|
|
32
|
+
* Tracekit Box box's agent channel (ext.box with parent_run), whose record names the daemon (tracekit/signer/detect.py
|
|
33
|
+
* recorded_owner). */
|
|
34
|
+
function recordedOwner(e) {
|
|
35
|
+
const i = e.data.identity, ext = e.ext, box = typeof ext === "object" && ext !== null ? ext.box : undefined;
|
|
36
|
+
return typeof box === "object" && box !== null && !Array.isArray(box) && typeof box.id === "string"
|
|
37
|
+
&& Object.hasOwn(e.data, "parent_run") ? `box:${i.subject}/${box.id}` : `${i.scheme}:${i.subject}`;
|
|
38
|
+
}
|
|
31
39
|
export class Detector {
|
|
32
40
|
label = new Map();
|
|
33
41
|
untrusted = new Set();
|
|
@@ -96,7 +104,7 @@ export class Detector {
|
|
|
96
104
|
const typ = e.type, d = e.data, rk = `${e.tenant}\0${e.run_id}`, t = ts(e.ts), fired = [];
|
|
97
105
|
const run = det.runs.get(rk) ?? null;
|
|
98
106
|
if (typ === "run.registered") {
|
|
99
|
-
det.runs.set(rk, { session: d.session ?? e.run_id, owner:
|
|
107
|
+
det.runs.set(rk, { session: d.session ?? e.run_id, owner: recordedOwner(e),
|
|
100
108
|
principal: e.principal_attested ? e.principal ?? null : null, pending: new Map(), n: new Map(),
|
|
101
109
|
capped: new Map(), minute: [0, 0, false] });
|
|
102
110
|
}
|
package/dist/verify/explain.js
CHANGED
|
@@ -3,15 +3,15 @@
|
|
|
3
3
|
* mean, what to do next, a line per check on what it means (docs/verdicts.md, shortened), and a summary of the bundle's
|
|
4
4
|
* runs. The report itself is the CLI's, unchanged: this module only reads it. No DOM, so Node tests it.
|
|
5
5
|
*/
|
|
6
|
-
import { EXIT_FAIL, EXIT_OK, VERSION, clean, formatReport, runFiles } from "./index.js";
|
|
6
|
+
import { EXIT_FAIL, EXIT_OK, NOT_RATED, VERSION, clean, formatReport, runFiles } from "./index.js";
|
|
7
7
|
/** `s` as one shell argument (POSIX shells; the page doesn't know the reader's). */
|
|
8
8
|
export const sh = (s) => /^[\w@%+=:,./-]+$/.test(s) ? s : `'${s.replace(/'/g, `'"'"'`)}'`;
|
|
9
9
|
const TRUST_FILE = "the sender's trust file: a small .json that names their signer's log key (tracekit last writes it next "
|
|
10
10
|
+ "to the bundle, as <name>.trust.json)";
|
|
11
11
|
/** The report as `tracekit verify --json` prints it (cli.ts prints this). */
|
|
12
12
|
export const asJson = (rep, code) => ({ exit_code: code, checks: rep.checks, failures: rep.failures,
|
|
13
|
-
warnings: rep.warnings, integrity: rep.integrity, assurance:
|
|
14
|
-
...rep.findings ? { findings: rep.findings } : {} });
|
|
13
|
+
warnings: rep.warnings, integrity: rep.integrity, assurance: code === EXIT_FAIL ? NOT_RATED : rep.assurance,
|
|
14
|
+
notes: rep.notes, ...rep.findings ? { findings: rep.findings } : {} });
|
|
15
15
|
/** The report as `tracekit verify` prints it, then its exit code. */
|
|
16
16
|
export const asText = (rep, code) => formatReport(rep) + `\nExit code ${code}`
|
|
17
17
|
+ (code === EXIT_OK && rep.warnings.length ? ` (3 with --strict: ${rep.warnings.length} warning(s))` : "") + ".\n";
|
|
@@ -239,6 +239,8 @@ export const MEANING = {
|
|
|
239
239
|
"break-glass approvals": { warn: "Approvals given under the break-glass role, with who and why." },
|
|
240
240
|
"not interpreted": { warn: "Records carry an extension this verifier doesn't read. They verified like every other "
|
|
241
241
|
+ "record." },
|
|
242
|
+
"verifier minimum": { warn: "The bundle's manifest, which isn't signed, asks for an older verifier than its records "
|
|
243
|
+
+ "need: an older verifier may have claimed more than they show. This one read every record." },
|
|
242
244
|
"gateway amendments": {
|
|
243
245
|
pass: "Requests the LLM gateway changed so the provider shows its reasoning; each record commits to the request "
|
|
244
246
|
+ "as sent.",
|
|
@@ -251,6 +253,21 @@ export const MEANING = {
|
|
|
251
253
|
warn: "A record carries an OpenShell policy change where or how the signer never writes one. The record verified "
|
|
252
254
|
+ "like every other.",
|
|
253
255
|
},
|
|
256
|
+
"boxed agent": {
|
|
257
|
+
pass: "Runs of a Tracekit Box box and of its agent: proof against the agent in that box only, whose box never held "
|
|
258
|
+
+ "the signing key. The records are the agent's own account; the box's doors are what held it.",
|
|
259
|
+
warn: "A record carries a box label where or how the signer never writes one: nothing is claimed about the key. "
|
|
260
|
+
+ "The record verified like every other.",
|
|
261
|
+
},
|
|
262
|
+
"intent grants": {
|
|
263
|
+
pass: "Payments people allowed the run's agent once, within limits, who allowed them, and the calls each grant let "
|
|
264
|
+
+ "run, each re-checked against its grant and its running totals.",
|
|
265
|
+
warn: "A grant, revocation or released call is recorded where or how the signer never writes one. The records "
|
|
266
|
+
+ "verified like every other.",
|
|
267
|
+
fail: "The signer recorded a call as released by a grant that doesn't allow it (another tool, other fields, over a "
|
|
268
|
+
+ "limit, totals that don't add up), by no grant the bundle holds, or by a grant whose record a signer never "
|
|
269
|
+
+ "writes.",
|
|
270
|
+
},
|
|
254
271
|
"constraints": {
|
|
255
272
|
pass: "What the person's request said not to do, added while the run was open, and the calls it held.",
|
|
256
273
|
fail: "A call held by a live constraint comes before any constraint in its run, or wasn't held for approval: the "
|
package/dist/verify/index.d.ts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* An independent verifier of `tracekit.bundle.v2` bundles, written from docs/format-v2.md (§11 is the algorithm) and
|
|
3
|
+
* checked against the reference (tracekit/verify/v2.py) by tests/test_ts_verifier.py: same checks, integrity, assurance
|
|
4
|
+
* and exit codes. Web Crypto and DecompressionStream only, so it runs in Node ≥ 20 and current browsers.
|
|
5
|
+
*
|
|
6
|
+
* import { verify } from "@cygnuxlabs/tracekit/verify";
|
|
7
|
+
* const { report, code } = await verify(bundleBytes, trustConfigBytes);
|
|
8
|
+
*
|
|
9
|
+
* Not implemented here, so never VERIFIED when a bundle relies on them (integrity `UNVERIFIABLE (...)` names them):
|
|
10
|
+
* SLH-DSA-SHA2-128s hybrid checkpoint lines (Web Crypto has no SLH-DSA), Rekor v2 anchors, record-key certificates,
|
|
11
|
+
* tracekit why findings and replay runs.
|
|
12
|
+
* Monitor reports, revocations and the v1 format bridge are inputs of the reference's CLI that this one doesn't take.
|
|
13
|
+
* A bundle that needs a newer verifier is UNVERIFIABLE, with the commands that verify it; one whose records carry ext
|
|
14
|
+
* names this verifier doesn't interpret (format 1.4's non-critical slot) verifies, with a `not interpreted` warning
|
|
15
|
+
* per name; it interprets `amended` (the fields an LLM gateway changed in a request to show reasoning),
|
|
16
|
+
* `openshell.policy` (OpenShell's sandbox policy changes, from the OpenShell middleware's OCSF import), `box` (a
|
|
17
|
+
* Tracekit Box box's run label) and `intent.grant`, `intent.revoked` and `grant` (intent grants and the calls they
|
|
18
|
+
* released).
|
|
19
|
+
* `verify(bundle, null)` (no trust config) checks what needs no pinned key and is never VERIFIED. web.ts is this
|
|
20
|
+
* verifier as a browser page (verify.html).
|
|
21
|
+
*/
|
|
22
|
+
import { type Floats } from "./jcs.js";
|
|
1
23
|
export { MAX_ENTRIES, MAX_ENTRY, MAX_TOTAL, Unusable, readZip } from "./zip.js";
|
|
2
24
|
export { StrictJSONError, canonicalize, strictParse, strictParseBytes } from "./jcs.js";
|
|
3
|
-
/**
|
|
4
|
-
export declare const VERSION = "1.
|
|
25
|
+
/** This verifier's release (the package's). */
|
|
26
|
+
export declare const VERSION = "1.6.0";
|
|
27
|
+
/** The newest bundle format version this verifier reads: the reference's VERSIONS' newest row (tracekit/bundle_v2.py),
|
|
28
|
+
* or VERSION when later (tracekit/verify/v2.py READS); a bundle needing a later one is UNVERIFIABLE. */
|
|
29
|
+
export declare const READS = "1.6.0";
|
|
5
30
|
export declare const EXIT_OK = 0, EXIT_FAIL = 1, EXIT_BAD = 2, EXIT_WARN = 3;
|
|
6
31
|
/** The integrity of a trust config that can't be used: nothing in the bundle was checked. */
|
|
7
32
|
export declare const TRUST_UNUSABLE = "UNVERIFIABLE (the trust file can't be used)";
|
|
@@ -22,6 +47,10 @@ export declare class Report {
|
|
|
22
47
|
findings: string | null;
|
|
23
48
|
/** Checks the bundle needs that this verifier does not implement. */
|
|
24
49
|
unsupported: string[];
|
|
50
|
+
/** For the box check: the pinned witnesses' cosignatures of the checkpoint, `name (class) at time`, and the seqs of
|
|
51
|
+
* the bundle's own runs' first records. */
|
|
52
|
+
anchored: string[];
|
|
53
|
+
firsts: Set<any>;
|
|
25
54
|
check(check: string, ok: boolean, detail?: string, problems?: string[], warn?: boolean): void;
|
|
26
55
|
unsupport(what: string): void;
|
|
27
56
|
}
|
|
@@ -39,16 +68,39 @@ export declare function verify(bundle: Uint8Array, trust: Uint8Array | null, nam
|
|
|
39
68
|
report: Report;
|
|
40
69
|
code: number;
|
|
41
70
|
}>;
|
|
71
|
+
/**
|
|
72
|
+
* intent.grant, intent.revoked and ext.grant (docs/intent-grants.md): the grants people issued for a run, their
|
|
73
|
+
* revocations, and the calls they released. Each grant is checked as grantIssued says; each released call against its
|
|
74
|
+
* grant, as the signer decided it: a policy.decision flagged with TK-GRANT, its grant recorded earlier in the same run
|
|
75
|
+
* and not revoked before it, decided before the grant expired, of a tool the grant covers, its fields those of the
|
|
76
|
+
* intent (whole numbers where they count) and within every caveat, its totals the previous call's plus its own, whole
|
|
77
|
+
* numbers within every limit, and its tier the record's (T2: an executor or gateway decided and ran the call; T1: the
|
|
78
|
+
* arguments the harness reported). A release that breaks its grant fails the line, and so does one whose grant the
|
|
79
|
+
* bundle doesn't hold earlier in its run, or holds only in a record a signer never writes, a decision flagged TK-GRANT
|
|
80
|
+
* without ext.grant, and a tier that isn't the record's: the records are the signer's own word that the call was within
|
|
81
|
+
* a person's grant. Any other record in a shape the signer never writes is a warning, as for every ext name. `events`
|
|
82
|
+
* also holds the decisions TK-GRANT names (checkExt); `floats`: the parser's, so a number written as a float is no whole
|
|
83
|
+
* number.
|
|
84
|
+
*/
|
|
85
|
+
export declare function checkGrants(rep: Report, events: J[], floats: Floats): Promise<void>;
|
|
86
|
+
/**
|
|
87
|
+
* A line per ext name the records carry: its EXT_CHECKS check, or a `not interpreted` warning. The records were checked
|
|
88
|
+
* like every other (signature, chain, inclusion); `full`: the manifest's advisory verifier_version; `floats`: the
|
|
89
|
+
* parser's.
|
|
90
|
+
*/
|
|
91
|
+
export declare function checkExt(rep: Report, events: J[], full: J, floats: Floats): Promise<void>;
|
|
42
92
|
/** §4: null when `r` is a v2 record signed by one of `keys` (SPKI DER) with an allowed algorithm that is the key's own,
|
|
43
|
-
* else why not. */
|
|
44
|
-
export declare function verifyRecord(r: J, keys: Uint8Array[], algs: string[]): Promise<string | null>;
|
|
93
|
+
* else why not. `floats`: where the parser read number tokens with a fraction or exponent (`v` is the integer 2). */
|
|
94
|
+
export declare function verifyRecord(r: J, keys: Uint8Array[], algs: string[], floats?: Floats): Promise<string | null>;
|
|
45
95
|
/** {run file: its entries in order} of a bundle's `names`: the run's file, runs/<id>.jsonl, or its parts,
|
|
46
96
|
* runs/<id>.part-0001.jsonl, ..., whose records read in that order are the run's (format-v2.md §9). */
|
|
47
97
|
export declare function runFiles(names: Iterable<string>): Map<string, string[]>;
|
|
48
98
|
/** `x` without control characters and the bidirectional and zero-width format characters that would reorder or hide
|
|
49
99
|
* the text around them, as the report prints bundle-derived strings. */
|
|
50
100
|
export declare const clean: (x: string) => string;
|
|
51
|
-
/**
|
|
101
|
+
/** A failed bundle's assurance: a level rates only evidence that verified. */
|
|
102
|
+
export declare const NOT_RATED = "not rated (the bundle failed verification)";
|
|
103
|
+
/** The Assurance line as the reports print it. */
|
|
52
104
|
export declare const assuranceLine: (rep: Report) => string;
|
|
53
105
|
/** The report as text, as the reference CLI prints it; `clean` drops characters from bundle-derived strings. */
|
|
54
106
|
export declare function formatReport(rep: Report): string;
|