raytrace-cli 0.11.1__py3-none-win_arm64.whl
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.
- raytrace/__init__.py +1 -0
- raytrace/__main__.py +33 -0
- raytrace/app/LICENSE +21 -0
- raytrace/app/README.md +599 -0
- raytrace/app/bin/raytrace.mjs +297 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
- raytrace/app/dist/dashboard/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
- raytrace/app/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
- raytrace/app/dist/dashboard/assets/index-DepcI8Fi.js +38 -0
- raytrace/app/dist/dashboard/assets/index-H97VLD5l.css +1 -0
- raytrace/app/dist/dashboard/favicon.svg +6 -0
- raytrace/app/dist/dashboard/index.html +15 -0
- raytrace/app/package.json +48 -0
- raytrace/app/proxy/agent-intent-schema.test.mjs +142 -0
- raytrace/app/proxy/call-assessment.mjs +385 -0
- raytrace/app/proxy/call-assessment.test.mjs +167 -0
- raytrace/app/proxy/call-category.mjs +461 -0
- raytrace/app/proxy/capture-health.mjs +30 -0
- raytrace/app/proxy/capture-health.test.mjs +44 -0
- raytrace/app/proxy/capture.mjs +38 -0
- raytrace/app/proxy/capture.test.mjs +49 -0
- raytrace/app/proxy/claude-code-adapter.mjs +301 -0
- raytrace/app/proxy/claude-code-hook.mjs +22 -0
- raytrace/app/proxy/codex-config.mjs +36 -0
- raytrace/app/proxy/codex.mjs +14 -0
- raytrace/app/proxy/evidence-schema.test.mjs +240 -0
- raytrace/app/proxy/evidence-store.mjs +993 -0
- raytrace/app/proxy/evidence-store.test.mjs +301 -0
- raytrace/app/proxy/exec-narrative.mjs +625 -0
- raytrace/app/proxy/exec-narrative.test.mjs +262 -0
- raytrace/app/proxy/execution-correlation.mjs +185 -0
- raytrace/app/proxy/execution-correlation.test.mjs +146 -0
- raytrace/app/proxy/execution-runner.mjs +89 -0
- raytrace/app/proxy/execution-runner.test.mjs +38 -0
- raytrace/app/proxy/experiment-engine.mjs +195 -0
- raytrace/app/proxy/experiment-engine.test.mjs +93 -0
- raytrace/app/proxy/explanations.mjs +36 -0
- raytrace/app/proxy/explanations.test.mjs +20 -0
- raytrace/app/proxy/failure-signature.mjs +56 -0
- raytrace/app/proxy/gvisor-forwarder.mjs +493 -0
- raytrace/app/proxy/gvisor-forwarder.test.mjs +433 -0
- raytrace/app/proxy/init-evidence-db.mjs +227 -0
- raytrace/app/proxy/local-sandboxes.mjs +94 -0
- raytrace/app/proxy/local-token.mjs +30 -0
- raytrace/app/proxy/playground-recovery.test.mjs +130 -0
- raytrace/app/proxy/playground.mjs +439 -0
- raytrace/app/proxy/prompt-context.mjs +278 -0
- raytrace/app/proxy/prompt-traces.mjs +40 -0
- raytrace/app/proxy/prompt-traces.test.mjs +32 -0
- raytrace/app/proxy/providers.mjs +65 -0
- raytrace/app/proxy/providers.test.mjs +76 -0
- raytrace/app/proxy/proxy.integration.test.mjs +135 -0
- raytrace/app/proxy/raytace-proxy.mjs +941 -0
- raytrace/app/proxy/request-metrics.mjs +13 -0
- raytrace/app/proxy/request-metrics.test.mjs +19 -0
- raytrace/app/proxy/request-policy.mjs +45 -0
- raytrace/app/proxy/request-policy.test.mjs +47 -0
- raytrace/app/proxy/run-recap.mjs +139 -0
- raytrace/app/proxy/runtime-attribution.mjs +110 -0
- raytrace/app/proxy/sandbox-bridge.mjs +49 -0
- raytrace/app/proxy/schema/EVIDENCE_DATABASE.md +276 -0
- raytrace/app/proxy/schema/agent_intent.sql +101 -0
- raytrace/app/proxy/schema/auxiliary.sql +90 -0
- raytrace/app/proxy/schema/capture_health.sql +14 -0
- raytrace/app/proxy/schema/classification.sql +89 -0
- raytrace/app/proxy/schema/file_context.sql +53 -0
- raytrace/app/proxy/schema/runtime_evidence.sql +201 -0
- raytrace/app/proxy/schema/search.sql +66 -0
- raytrace/app/proxy/schema/shared_storage.sql +21 -0
- raytrace/app/proxy/search.mjs +418 -0
- raytrace/app/proxy/search.test.mjs +161 -0
- raytrace/app/proxy/smoke.test.mjs +93 -0
- raytrace/app/proxy/step-attribution.mjs +380 -0
- raytrace/app/proxy/step-lab.mjs +78 -0
- raytrace/app/proxy/step-lab.test.mjs +38 -0
- raytrace/app/proxy/summaries.mjs +151 -0
- raytrace/app/proxy/summaries.test.mjs +69 -0
- raytrace/app/proxy/tool-metadata.mjs +111 -0
- raytrace/app/proxy/tool-metadata.test.mjs +38 -0
- raytrace/app/proxy/trace-view.mjs +324 -0
- raytrace/app/proxy/trace-view.test.mjs +92 -0
- raytrace/app/proxy/typesafe.mjs +63 -0
- raytrace/app/proxy/typesafe.test.mjs +39 -0
- raytrace/app/src/agents.mjs +7 -0
- raytrace/app/src/api.mjs +57 -0
- raytrace/app/src/auth.mjs +205 -0
- raytrace/app/src/beta.mjs +96 -0
- raytrace/app/src/claude-code.mjs +93 -0
- raytrace/app/src/commands.mjs +285 -0
- raytrace/app/src/config.mjs +49 -0
- raytrace/app/src/export.mjs +200 -0
- raytrace/app/src/lima.mjs +176 -0
- raytrace/app/src/local-sandbox.mjs +358 -0
- raytrace/app/src/mcp.mjs +688 -0
- raytrace/app/src/paths.mjs +33 -0
- raytrace/app/src/prompt.mjs +42 -0
- raytrace/app/src/proxy-process.mjs +143 -0
- raytrace/app/src/sandbox.mjs +306 -0
- raytrace/app/src/share.mjs +86 -0
- raytrace/app/src/terminal.mjs +68 -0
- raytrace/app/src/upload.mjs +198 -0
- raytrace/app/worker/sandbox/Dockerfile +8 -0
- raytrace/app/worker/sandbox/SYSCALL_CATALOG.md +197 -0
- raytrace/app/worker/sandbox/claude-hook.mjs +364 -0
- raytrace/app/worker/sandbox/collector.py +405 -0
- raytrace/app/worker/sandbox/dns_forwarder.py +255 -0
- raytrace/app/worker/sandbox/engine.py +940 -0
- raytrace/app/worker/sandbox/file_scan.py +491 -0
- raytrace/app/worker/sandbox/lima.yaml +29 -0
- raytrace/app/worker/sandbox/network.py +90 -0
- raytrace/app/worker/sandbox/projects.py +702 -0
- raytrace/app/worker/sandbox/setup.py +159 -0
- raytrace/app/worker/sandbox/syscall_catalog.sql +985 -0
- raytrace/app/worker/sandbox/transcript-delivery.test.mjs +153 -0
- raytrace/app/worker/sandbox/viewer.py +195 -0
- raytrace/node/LICENSE +2946 -0
- raytrace/node/node.exe +4 -0
- raytrace_cli-0.11.1.dist-info/LICENSE +21 -0
- raytrace_cli-0.11.1.dist-info/METADATA +42 -0
- raytrace_cli-0.11.1.dist-info/RECORD +165 -0
- raytrace_cli-0.11.1.dist-info/WHEEL +4 -0
- raytrace_cli-0.11.1.dist-info/entry_points.txt +2 -0
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
# Evidence database — version 6
|
|
2
|
+
|
|
3
|
+
Version 6 adds the derived search index (`search.sql`): `search_events`, one
|
|
4
|
+
denormalized event per tool call, turn and proxy error with its failure
|
|
5
|
+
outcome decided at index time (`proxy/search.mjs`), plus the `search_fts`
|
|
6
|
+
FTS5 table over its text. These rows are derived, never evidence — the store
|
|
7
|
+
rebuilds them from the tables below on open (backfill) or on demand
|
|
8
|
+
(`reindexSearch`), so they may be dropped freely.
|
|
9
|
+
|
|
10
|
+
This is RayTrace's database: **20 evidence tables plus 7 auxiliary tables** in
|
|
11
|
+
one SQLite file, `.raytace/evidence.db`, created on the proxy's first start.
|
|
12
|
+
It describes agent intent, observed runtime activity, interpretation rules and
|
|
13
|
+
results, file context, and shared payloads; `auxiliary.sql` holds the lab's
|
|
14
|
+
experiment jobs and cached summaries, explanations, command descriptions and
|
|
15
|
+
Jev command assessments (`call_assessments`), and where a sandboxed Claude
|
|
16
|
+
Code session's project folder stood after each tool call (`workspace_snapshots`).
|
|
17
|
+
|
|
18
|
+
`proxy/evidence-store.mjs` is the only module that reads or writes it. The
|
|
19
|
+
agent-intent tables are filled as model requests are captured; the runtime
|
|
20
|
+
tables (`runtime_sandboxes`, `runtime_processes`, `runtime_events`,
|
|
21
|
+
`runtime_attributions`) by the gVisor forwarder. Nothing yet captures file
|
|
22
|
+
syscalls, normalizes `runtime_syscall_calls`, classifies, or labels files, so
|
|
23
|
+
those tables stay empty.
|
|
24
|
+
|
|
25
|
+
Version 2 added the columns the proxy and dashboard need: turn detection
|
|
26
|
+
(`agent_turns.prompt_key`), request routing and the request split
|
|
27
|
+
(`agent_exchanges.route`, `method`, `tools_sha`, `input_key`, `transport_json`),
|
|
28
|
+
the sandbox-to-session join (`runtime_sandboxes.project_id`), proxy-clock times
|
|
29
|
+
and lost-evidence marking on processes, and match details on attributions
|
|
30
|
+
(`score`, the causal window, `reported_check`).
|
|
31
|
+
|
|
32
|
+
Version 3 added `call_assessments`, the cache of Jev (TypeSafe) severity and
|
|
33
|
+
step labels per tool call (`proxy/call-assessment.mjs`). It is the first
|
|
34
|
+
version with a migration: a version-2 database gains that one table in place,
|
|
35
|
+
inside the initializer's transaction, and is then checked against the schema
|
|
36
|
+
files exactly as before. A database at any other version is still refused
|
|
37
|
+
untouched; delete it to start fresh.
|
|
38
|
+
|
|
39
|
+
Version 4 added `workspace_snapshots`: after each tool call that could change
|
|
40
|
+
files, the commit in the sandbox's own snapshot history that the project
|
|
41
|
+
folder stood at, and which files changed (`worker/gvisor/claude-hook.mjs`). The
|
|
42
|
+
lab uses it to put the folder back as it was at any step. A version-2 or
|
|
43
|
+
version-3 database gains it in place, the same way.
|
|
44
|
+
|
|
45
|
+
## Initialize and validate
|
|
46
|
+
|
|
47
|
+
From the repository root, with the project's Node version:
|
|
48
|
+
|
|
49
|
+
```sh
|
|
50
|
+
evidence_dir=$(mktemp -d)
|
|
51
|
+
node --disable-warning=ExperimentalWarning proxy/init-evidence-db.mjs "$evidence_dir/evidence.db"
|
|
52
|
+
node --disable-warning=ExperimentalWarning --test proxy/evidence-schema.test.mjs proxy/agent-intent-schema.test.mjs
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
An explicit file path is required; the parent directory must already exist.
|
|
56
|
+
There is no default pointing at a live database. The initializer rejects the
|
|
57
|
+
known live paths, unrelated schemas, and incompatible versions. It does not
|
|
58
|
+
delete existing files. A failed first import can leave an empty file; table
|
|
59
|
+
creation, seeding, and `user_version` are rolled back together.
|
|
60
|
+
|
|
61
|
+
The initializer owns one transaction for all modules. The existing agent-only
|
|
62
|
+
SQL retains its direct-import transaction; the loader removes that known wrapper
|
|
63
|
+
when composing it. Other modules are fragments loaded by the initializer in
|
|
64
|
+
agent → runtime → classification → file context → shared storage order.
|
|
65
|
+
|
|
66
|
+
`PRAGMA user_version=1` identifies the combined schema. Repeat initialization
|
|
67
|
+
compares schema objects (including triggers and indexes), verifies the seeded
|
|
68
|
+
catalog and file labels, and preserves all rows. It does not repair unexpected
|
|
69
|
+
changes. Even semantically equivalent manual DDL edits may fail this strict
|
|
70
|
+
comparison. Enable `PRAGMA foreign_keys=ON` on every writer connection.
|
|
71
|
+
|
|
72
|
+
The initializer imports the original `worker/gvisor/syscall_catalog.sql` into an
|
|
73
|
+
in-memory staging DB, then maps its 4 levels, 34 categories, and 353 rules. No
|
|
74
|
+
second manually maintained syscall list exists. Required-evidence prose becomes
|
|
75
|
+
a one-element JSON array. SHA-256 of the sorted canonical seed representation
|
|
76
|
+
identifies catalog contents. Version `syscall-catalog-v2` (catalog version 2:
|
|
77
|
+
every syscall group, not files only) has classifier version `not-implemented`;
|
|
78
|
+
initialization creates **zero classification results**. The catalog's capture
|
|
79
|
+
decisions, numbers and coverage stay in the catalog: the sandbox host reads them
|
|
80
|
+
there (`worker/gvisor/setup.py`, `engine.py`) and keeps the facts it draws.
|
|
81
|
+
A changed catalog needs a new version identifier and a deliberate initializer
|
|
82
|
+
update, never an overwrite under the old identifier. A database made with
|
|
83
|
+
schema version 4 holds `filesystem-catalog-v1-only`, the 84 file rules; opening
|
|
84
|
+
it adds version 2 beside it, since these tables are append-only.
|
|
85
|
+
|
|
86
|
+
## Field guide
|
|
87
|
+
|
|
88
|
+
`PK` = primary key, `FK` = foreign key, `?` = nullable. IDs are non-null text.
|
|
89
|
+
JSON is stored as validated text; packets are optional binary blobs. Timestamps
|
|
90
|
+
ending in `_ms` are integer epoch milliseconds. `_ns` values are canonical,
|
|
91
|
+
nonnegative decimal text; comparisons use digit length then binary lexical order
|
|
92
|
+
to avoid floating-point precision loss. Return values use canonical signed
|
|
93
|
+
decimal text. Unknown values stay null rather than becoming zero or success.
|
|
94
|
+
|
|
95
|
+
### Agent intent — 4 tables
|
|
96
|
+
|
|
97
|
+
| Table | Fields and meaning |
|
|
98
|
+
| --- | --- |
|
|
99
|
+
| `agent_sessions` | `id` PK; `external_session_id?` provider identifier; `agent_name?`; `started_at_ms`; `ended_at_ms?`; `metadata_json?` additional session metadata. |
|
|
100
|
+
| `agent_turns` | `id` PK; `session_id` FK to sessions; `sequence_number` position within session; `user_prompt_sha?` and `final_response_sha?` FKs to payloads; `started_at_ms`; `ended_at_ms?`; `status` agent lifecycle. |
|
|
101
|
+
| `agent_exchanges` | `id` PK; `session_id` FK; `turn_id?` with session-scoped FK to turns; `provider`; `model?`; `started_at_ms`; `completed_at_ms?`; `http_status?`; `request_sha?` and `response_sha?` FKs to payloads; `metrics_json?`. |
|
|
102
|
+
| `agent_tool_calls` | `id` PK; `exchange_id` FK; `external_call_id?`; `output_index` position within response; `tool_name`; `arguments_sha?` and `reported_result_sha?` FKs to payloads; `proposed_at_ms?`. |
|
|
103
|
+
|
|
104
|
+
Turn status is `unknown`, `active`, `completed`, `failed`, or `cancelled`.
|
|
105
|
+
External identifiers are not globally unique. Reported results are not
|
|
106
|
+
independent evidence of execution. See [agent schema guide](README.md) for details.
|
|
107
|
+
|
|
108
|
+
### Runtime evidence — 5 tables
|
|
109
|
+
|
|
110
|
+
| Table | Fields and meaning |
|
|
111
|
+
| --- | --- |
|
|
112
|
+
| `runtime_sandboxes` | `id` PK for one lifetime; `external_container_id` runtime container identifier; `runtime_name`; `runtime_version`; `runtime_build_digest?` custom build identity; `architecture` (`aarch64`/`x86_64`); `started_at_ms?`; `ended_at_ms?`; `capture_config_json` fixed monitoring configuration. |
|
|
113
|
+
| `runtime_processes` | `id` PK; `sandbox_id` FK; `pid`; `start_time_ns?`; `parent_process_id?` FK within the same sandbox; `observed_ppid?` unresolved numeric parent; `first_seen_ns`; `exited_at_ns?`; `exit_code?`; `exit_signal?`; `identity_basis` how the lifetime was distinguished. |
|
|
114
|
+
| `runtime_events` | `id` PK; `sandbox_id?` FK; `process_id?` sandbox-scoped FK; `stream_id` collector stream; `stream_sequence` collector-assigned position; `event_kind`; `observed_at_ns?` runtime time; `received_at_ms` collection time; `tid?` thread; `payload_json` decoded object; `retained_packet?` original bytes when permitted; `decoder_version`. |
|
|
115
|
+
| `runtime_syscall_calls` | `id` PK; `sandbox_id` FK; `process_id?` sandbox-scoped FK; `tid?`; `syscall_name?`; `syscall_number`; `entry_event_id?` and `exit_event_id?` sandbox-scoped FKs; `arguments_json` object; `return_value?`; `errno?`; `outcome`; `correlation_status`; `normalizer_version`. |
|
|
116
|
+
| `runtime_attributions` | `id` PK; `tool_call_id` FK to agent calls; `event_id` FK to observations; `method` matching technique; `confidence` strength; `status` candidate/accepted/rejected; `basis_json` supporting details; `attributor_version`; `created_at_ms`. |
|
|
117
|
+
|
|
118
|
+
Sandbox times describe the sandbox, not a prompt. An unknown end does not prove
|
|
119
|
+
it is running. A restarted lifetime gets a new internal ID. Configuration cannot
|
|
120
|
+
be updated in place; runtime version/build records what produced the evidence.
|
|
121
|
+
|
|
122
|
+
PID alone is not unique. Start identity is immutable, including an unknown start;
|
|
123
|
+
future reconciliation must be explicit rather than silently changing process
|
|
124
|
+
identity. Multiple exec events may describe executable changes in one process.
|
|
125
|
+
Normal exit code and terminating signal are mutually exclusive, and require an
|
|
126
|
+
exit time. A process reference always requires sandbox context.
|
|
127
|
+
|
|
128
|
+
Events are append-only, unique by `(stream_id, stream_sequence)`. Stream IDs must
|
|
129
|
+
be globally unique per collection connection/lifetime; their sequence is not a
|
|
130
|
+
kernel completeness guarantee. Collector-wide gaps may have neither sandbox nor
|
|
131
|
+
process. `event_kind` is extensible; normalized syscall phases are specifically
|
|
132
|
+
`syscall_enter` and `syscall_exit`. This differs from the old collector's return
|
|
133
|
+
label and will require an adapter in later integration.
|
|
134
|
+
|
|
135
|
+
For syscall evidence, decoded `payload_json` reserves these keys:
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{"syscall_number":35,"syscall_name":"unlinkat","return_value":"0","errno":0}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
The number above is an ARM64 example. Entry events omit return information.
|
|
142
|
+
Number/name may be absent if undecoded; present known identities must match the
|
|
143
|
+
normalized call. Known outcomes require matching textual `return_value` and
|
|
144
|
+
integer `errno` in the exit payload. No pathname or contents are invented by SQL.
|
|
145
|
+
|
|
146
|
+
Syscall states:
|
|
147
|
+
|
|
148
|
+
| Correlation | Evidence | Allowed outcome |
|
|
149
|
+
| --- | --- | --- |
|
|
150
|
+
| `paired` | Entry and exit | `succeeded`, `failed`, `unknown` |
|
|
151
|
+
| `entry_only` | Entry only | `unknown` |
|
|
152
|
+
| `exit_only` | Exit only | `succeeded`, `failed`, `unknown` |
|
|
153
|
+
| `uncertain` | At least one observation | `unknown` |
|
|
154
|
+
|
|
155
|
+
Known process/thread identities and phases must agree even if the normalized
|
|
156
|
+
call omits those identities. Exit time cannot precede entry time. A known outcome
|
|
157
|
+
requires a decoded return; success requires errno 0, failure errno > 0. An
|
|
158
|
+
exit-only call can have a known outcome while its arguments/path remain unknown.
|
|
159
|
+
|
|
160
|
+
Normalized calls are append-only snapshots. If later evidence permits a better
|
|
161
|
+
reconstruction, insert a new row referencing the same observations; do not edit
|
|
162
|
+
evidence underlying existing classifications. This schema does not choose a
|
|
163
|
+
current reconstruction or deduplicate such snapshots automatically. A future
|
|
164
|
+
normalizer must define that selection before user-facing aggregation.
|
|
165
|
+
|
|
166
|
+
Attribution confidence is `exact`, `corroborated`, or `inferred`. Status is
|
|
167
|
+
`candidate`, `accepted`, or `rejected`; only accepted associations should be
|
|
168
|
+
presented as the chosen match. No match leaves the observation intact. This
|
|
169
|
+
schema does not assert that a shared process automatically belongs to one turn.
|
|
170
|
+
|
|
171
|
+
### Classification — 5 tables
|
|
172
|
+
|
|
173
|
+
| Table | Fields and meaning |
|
|
174
|
+
| --- | --- |
|
|
175
|
+
| `classification_versions` | `id` PK; `catalog_version`; `classifier_version`; `content_sha256` canonical rule content digest; `created_at_ms`; `description`. |
|
|
176
|
+
| `classification_impact_levels` | `level` PK, integer 0–3; `label`; `description`. |
|
|
177
|
+
| `classification_categories` | `id` PK, stable operation name; `label`; `description`. |
|
|
178
|
+
| `classification_syscall_rules` | composite PK `(version_id, syscall_name)`; `version_id` FK; `description`; `category_id` FK; `default_impact_level?` FK; `rule_identifier`; `required_evidence_json` array; `interpretation_notes`. |
|
|
179
|
+
| `classification_results` | `id` PK; `syscall_call_id` FK; `version_id` FK; `input_sha256` digest of classifier input; `category_id?` FK; `operation_level?` and `confirmed_effect_level?` FKs; `effect_status`; `reason`; `classified_at_ms`. |
|
|
180
|
+
|
|
181
|
+
Version, rule, result, category and impact rows reject updates, deletes, and key
|
|
182
|
+
replacement. New versions/results are new rows; additions within a version must
|
|
183
|
+
be completed by its publisher before use. SQL does not compute arbitrary new
|
|
184
|
+
version digests; publication tooling must verify them. Initializer-owned seeds
|
|
185
|
+
are verified on every repeat initialization.
|
|
186
|
+
|
|
187
|
+
Result uniqueness is `(syscall_call_id, version_id, input_sha256)`. The future
|
|
188
|
+
classifier computes the digest over its canonical input, including relevant
|
|
189
|
+
evidence/context; SQL validates digest shape, not the hash calculation. States:
|
|
190
|
+
`confirmed`, `no_effect`, `unknown`, `not_applicable`. Only `confirmed` can and must
|
|
191
|
+
have a confirmed-effect level, and it requires a successful syscall. SQL success
|
|
192
|
+
alone is insufficient to infer a changed file: the classifier must still apply
|
|
193
|
+
the catalog's evidence rules. Impact 0 is observation, 1 creation, 2 modification,
|
|
194
|
+
3 removal/replacement. Impact is not maliciousness or a security risk score.
|
|
195
|
+
|
|
196
|
+
### File context — 4 tables
|
|
197
|
+
|
|
198
|
+
| Table | Fields and meaning |
|
|
199
|
+
| --- | --- |
|
|
200
|
+
| `file_objects` | `id` PK; `sandbox_id` FK; `object_type`; `filesystem_identity?`; `inode_number?`; `generation?`; `identity_basis`; `first_seen_ns`; `last_seen_ns`. |
|
|
201
|
+
| `file_operation_targets` | `id` PK; `syscall_call_id` and `sandbox_id` form a scoped FK; `sandbox_id` also references sandbox; `file_object_id?` scoped FK; `target_role`; `supplied_path?`; `observed_path?`; `dirfd?`; `fd?`; `base_path?`; `resolution_status`; `identity_basis_json?`. |
|
|
202
|
+
| `file_labels` | `id` PK; `label`; `description`. |
|
|
203
|
+
| `file_label_assignments` | `id` PK; `target_id` FK; `label_id` FK; `basis` source of label; `confidence`; `rule_version`; `reason`; `assigned_at_ms`. |
|
|
204
|
+
|
|
205
|
+
Object types: `regular`, `directory`, `symlink`, `pipe`, `socket`, `device`,
|
|
206
|
+
`unknown`. Filesystem identity, inode, and generation are opaque text; none alone
|
|
207
|
+
is a global permanent identity. Paths can be reused, and multiple hard links can
|
|
208
|
+
refer to one object. Do not merge objects without supporting evidence.
|
|
209
|
+
|
|
210
|
+
Targets can be `target`, `source`, `destination`, or `replaced_destination`;
|
|
211
|
+
rename/copy can reference multiple rows. A missing object ID does not discard a
|
|
212
|
+
path observation. File objects and calls must belong to the target's sandbox.
|
|
213
|
+
Resolution states: `unresolved`, `supplied_only`, `lexical`, `runtime_resolved`.
|
|
214
|
+
Supplied-only requires a supplied path; lexical/resolved requires an observed
|
|
215
|
+
path. Lexical joining is not actual resolution through symlinks. Negative `dirfd`
|
|
216
|
+
values accommodate special constants such as `AT_FDCWD`; ordinary FDs are
|
|
217
|
+
nonnegative. No uniqueness constraint makes pathname an identity.
|
|
218
|
+
|
|
219
|
+
Labels initially include source code, configuration, potentially sensitive,
|
|
220
|
+
documentation, generated output, and temporary. Assignment confidence uses
|
|
221
|
+
`exact`, `corroborated`, `inferred`; basis might be `user`, `filename_rule`, or
|
|
222
|
+
`content_inspection`. Multiple labels are allowed. Labels attach to target
|
|
223
|
+
observations so a rename need not rewrite historical labels. This step performs
|
|
224
|
+
no content inspection or automatic labeling.
|
|
225
|
+
|
|
226
|
+
### Shared storage — 2 tables
|
|
227
|
+
|
|
228
|
+
| Table | Fields and meaning |
|
|
229
|
+
| --- | --- |
|
|
230
|
+
| `agent_payloads` | `sha` PK, SHA-256 supplied by the writer; `content` validated JSON text. Shared despite its existing agent-prefixed name. |
|
|
231
|
+
| `agent_context_items` | composite PK `(exchange_id, position)`; `exchange_id` FK; nonnegative `position`; `role?`; `kind?`; `external_call_id?`; `payload_sha` FK; `preview?`. |
|
|
232
|
+
|
|
233
|
+
Context items preserve conversation ordering; external call IDs are reported
|
|
234
|
+
identifiers, not automatic runtime links. JSON strings represent plain text.
|
|
235
|
+
Writers must redact before hashing/storage and verify hashes; SQL cannot redact
|
|
236
|
+
or independently calculate SHA-256. Retained runtime packets must still obey
|
|
237
|
+
existing environment/secret withholding rules. No buffer contents are required.
|
|
238
|
+
|
|
239
|
+
## Example investigation query
|
|
240
|
+
|
|
241
|
+
This joins a selected syscall reconstruction to accepted tool attribution,
|
|
242
|
+
classification, targets, and optional labels. Supplying the chosen reconstruction
|
|
243
|
+
and classifier version avoids silently aggregating alternative snapshots.
|
|
244
|
+
|
|
245
|
+
```sql
|
|
246
|
+
SELECT tc.id AS tool_call_id, tc.tool_name,
|
|
247
|
+
sc.id AS syscall_call_id, sc.syscall_name, sc.outcome,
|
|
248
|
+
p.pid, target.observed_path, target.supplied_path,
|
|
249
|
+
category.label AS operation_category,
|
|
250
|
+
result.operation_level, result.confirmed_effect_level,
|
|
251
|
+
result.effect_status, labels.label AS file_label
|
|
252
|
+
FROM runtime_syscall_calls sc
|
|
253
|
+
LEFT JOIN runtime_processes p ON p.id = sc.process_id
|
|
254
|
+
LEFT JOIN runtime_attributions attribution
|
|
255
|
+
ON attribution.event_id = sc.exit_event_id AND attribution.status = 'accepted'
|
|
256
|
+
LEFT JOIN agent_tool_calls tc ON tc.id = attribution.tool_call_id
|
|
257
|
+
LEFT JOIN classification_results result
|
|
258
|
+
ON result.syscall_call_id = sc.id AND result.version_id = :version_id
|
|
259
|
+
LEFT JOIN classification_categories category ON category.id = result.category_id
|
|
260
|
+
LEFT JOIN file_operation_targets target ON target.syscall_call_id = sc.id
|
|
261
|
+
LEFT JOIN file_label_assignments assignment ON assignment.target_id = target.id
|
|
262
|
+
LEFT JOIN file_labels labels ON labels.id = assignment.label_id
|
|
263
|
+
WHERE sc.id = :syscall_call_id;
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
Multiple labels, classifications with different input hashes, or accepted
|
|
267
|
+
attributions can yield multiple rows; they are not additional syscall executions.
|
|
268
|
+
This query uses exit attribution; entry-only investigations can instead use
|
|
269
|
+
`entry_event_id`. Production code must select the intended classification input
|
|
270
|
+
and attribution rather than assuming all historical associations are current.
|
|
271
|
+
|
|
272
|
+
All domains live in one database here, so ordinary foreign keys work. A later
|
|
273
|
+
host/VM deployment split will require explicit replication and application-level
|
|
274
|
+
validation of cross-database relationships. Missing observations are not proof of
|
|
275
|
+
non-execution. These constraints preserve what is supplied; they cannot certify
|
|
276
|
+
collector completeness, resolve paths, or make untrusted input true.
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
-- Agent-intent domain, schema version 2.
|
|
2
|
+
-- Written by proxy/evidence-store.mjs as each model request is captured.
|
|
3
|
+
-- Import outside an existing transaction; enable foreign_keys on every writer.
|
|
4
|
+
PRAGMA foreign_keys = ON;
|
|
5
|
+
BEGIN TRANSACTION;
|
|
6
|
+
|
|
7
|
+
CREATE TABLE IF NOT EXISTS agent_payloads (
|
|
8
|
+
sha TEXT NOT NULL PRIMARY KEY,
|
|
9
|
+
content TEXT NOT NULL CHECK (json_valid(content))
|
|
10
|
+
);
|
|
11
|
+
|
|
12
|
+
CREATE TABLE IF NOT EXISTS agent_sessions (
|
|
13
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
14
|
+
external_session_id TEXT,
|
|
15
|
+
agent_name TEXT,
|
|
16
|
+
started_at_ms INTEGER NOT NULL CHECK (typeof(started_at_ms) = 'integer'),
|
|
17
|
+
ended_at_ms INTEGER CHECK (ended_at_ms IS NULL OR
|
|
18
|
+
(typeof(ended_at_ms) = 'integer' AND ended_at_ms >= started_at_ms)),
|
|
19
|
+
metadata_json TEXT CHECK (metadata_json IS NULL OR json_valid(metadata_json))
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
CREATE TABLE IF NOT EXISTS agent_turns (
|
|
23
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
24
|
+
session_id TEXT NOT NULL REFERENCES agent_sessions(id),
|
|
25
|
+
sequence_number INTEGER NOT NULL CHECK
|
|
26
|
+
(typeof(sequence_number) = 'integer' AND sequence_number >= 0),
|
|
27
|
+
user_prompt_sha TEXT REFERENCES agent_payloads(sha),
|
|
28
|
+
final_response_sha TEXT REFERENCES agent_payloads(sha),
|
|
29
|
+
started_at_ms INTEGER NOT NULL CHECK (typeof(started_at_ms) = 'integer'),
|
|
30
|
+
ended_at_ms INTEGER CHECK (ended_at_ms IS NULL OR
|
|
31
|
+
(typeof(ended_at_ms) = 'integer' AND ended_at_ms >= started_at_ms)),
|
|
32
|
+
status TEXT NOT NULL DEFAULT 'unknown'
|
|
33
|
+
CHECK (status IN ('unknown', 'active', 'completed', 'failed', 'cancelled')),
|
|
34
|
+
-- Digest of the conversation up to and including the user message that
|
|
35
|
+
-- opened this turn. A later request carrying the same prefix plus more
|
|
36
|
+
-- items is the agent still working on this turn, not a new one.
|
|
37
|
+
prompt_key TEXT,
|
|
38
|
+
UNIQUE (session_id, sequence_number),
|
|
39
|
+
-- Parent key for an exchange's session-scoped turn reference.
|
|
40
|
+
UNIQUE (id, session_id)
|
|
41
|
+
);
|
|
42
|
+
|
|
43
|
+
CREATE TABLE IF NOT EXISTS agent_exchanges (
|
|
44
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
45
|
+
turn_id TEXT,
|
|
46
|
+
session_id TEXT NOT NULL REFERENCES agent_sessions(id),
|
|
47
|
+
provider TEXT NOT NULL,
|
|
48
|
+
model TEXT,
|
|
49
|
+
started_at_ms INTEGER NOT NULL CHECK (typeof(started_at_ms) = 'integer'),
|
|
50
|
+
completed_at_ms INTEGER CHECK (completed_at_ms IS NULL OR
|
|
51
|
+
(typeof(completed_at_ms) = 'integer' AND completed_at_ms >= started_at_ms)),
|
|
52
|
+
http_status INTEGER,
|
|
53
|
+
request_sha TEXT REFERENCES agent_payloads(sha),
|
|
54
|
+
response_sha TEXT REFERENCES agent_payloads(sha),
|
|
55
|
+
metrics_json TEXT CHECK (metrics_json IS NULL OR json_valid(metrics_json)),
|
|
56
|
+
-- The HTTP route and method the agent called, e.g. POST /v1/responses.
|
|
57
|
+
route TEXT,
|
|
58
|
+
method TEXT,
|
|
59
|
+
-- request_sha holds the request minus its input items and tool list:
|
|
60
|
+
-- items go to agent_context_items and the tool list here, because both
|
|
61
|
+
-- repeat verbatim on every request and would otherwise be stored again
|
|
62
|
+
-- each time. input_key says which field held the items (input|messages).
|
|
63
|
+
tools_sha TEXT REFERENCES agent_payloads(sha),
|
|
64
|
+
input_key TEXT CHECK (input_key IS NULL OR input_key IN ('input', 'messages')),
|
|
65
|
+
-- Allowlisted headers, byte counts and body digests for each direction.
|
|
66
|
+
transport_json TEXT CHECK (transport_json IS NULL OR json_valid(transport_json)),
|
|
67
|
+
FOREIGN KEY (turn_id, session_id) REFERENCES agent_turns(id, session_id)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
CREATE TABLE IF NOT EXISTS agent_tool_calls (
|
|
71
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
72
|
+
exchange_id TEXT NOT NULL REFERENCES agent_exchanges(id),
|
|
73
|
+
external_call_id TEXT,
|
|
74
|
+
output_index INTEGER NOT NULL CHECK
|
|
75
|
+
(typeof(output_index) = 'integer' AND output_index >= 0),
|
|
76
|
+
tool_name TEXT NOT NULL,
|
|
77
|
+
arguments_sha TEXT REFERENCES agent_payloads(sha),
|
|
78
|
+
reported_result_sha TEXT REFERENCES agent_payloads(sha),
|
|
79
|
+
proposed_at_ms INTEGER CHECK
|
|
80
|
+
(proposed_at_ms IS NULL OR typeof(proposed_at_ms) = 'integer'),
|
|
81
|
+
UNIQUE (exchange_id, output_index)
|
|
82
|
+
);
|
|
83
|
+
|
|
84
|
+
CREATE INDEX IF NOT EXISTS agent_sessions_chronology
|
|
85
|
+
ON agent_sessions(started_at_ms, id);
|
|
86
|
+
CREATE INDEX IF NOT EXISTS agent_turns_session_chronology
|
|
87
|
+
ON agent_turns(session_id, started_at_ms, id);
|
|
88
|
+
CREATE INDEX IF NOT EXISTS agent_exchanges_turn_chronology
|
|
89
|
+
ON agent_exchanges(turn_id, started_at_ms, id);
|
|
90
|
+
CREATE INDEX IF NOT EXISTS agent_exchanges_session_chronology
|
|
91
|
+
ON agent_exchanges(session_id, started_at_ms, id);
|
|
92
|
+
CREATE INDEX IF NOT EXISTS agent_tool_calls_external_lookup
|
|
93
|
+
ON agent_tool_calls(exchange_id, external_call_id);
|
|
94
|
+
CREATE INDEX IF NOT EXISTS agent_tool_calls_external_call
|
|
95
|
+
ON agent_tool_calls(external_call_id);
|
|
96
|
+
CREATE INDEX IF NOT EXISTS agent_sessions_external
|
|
97
|
+
ON agent_sessions(external_session_id);
|
|
98
|
+
CREATE INDEX IF NOT EXISTS agent_turns_prompt
|
|
99
|
+
ON agent_turns(session_id, prompt_key);
|
|
100
|
+
|
|
101
|
+
COMMIT;
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
-- Features built on top of the evidence, not evidence themselves: the lab's
|
|
2
|
+
-- experiment jobs, cached model-written summaries and explanations, and
|
|
3
|
+
-- proxy errors. Loaded last by init-evidence-db.mjs.
|
|
4
|
+
--
|
|
5
|
+
-- exchange_id columns name an agent_exchanges.id but are not foreign keys:
|
|
6
|
+
-- these rows are caches and job documents that must still save when the
|
|
7
|
+
-- exchange they mention was never captured (a replay, an expired snapshot).
|
|
8
|
+
|
|
9
|
+
CREATE TABLE lab_experiments (
|
|
10
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
11
|
+
exchange_id TEXT,
|
|
12
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer'),
|
|
13
|
+
status TEXT,
|
|
14
|
+
kind TEXT,
|
|
15
|
+
model TEXT,
|
|
16
|
+
-- The full job document; still the source of truth for the lab.
|
|
17
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json))
|
|
18
|
+
);
|
|
19
|
+
CREATE INDEX lab_experiments_time ON lab_experiments(created_at_ms DESC);
|
|
20
|
+
|
|
21
|
+
CREATE TABLE exchange_summaries (
|
|
22
|
+
key TEXT NOT NULL PRIMARY KEY,
|
|
23
|
+
exchange_id TEXT,
|
|
24
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer'),
|
|
25
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json))
|
|
26
|
+
);
|
|
27
|
+
CREATE INDEX exchange_summaries_exchange ON exchange_summaries(exchange_id, created_at_ms);
|
|
28
|
+
|
|
29
|
+
CREATE TABLE step_explanations (
|
|
30
|
+
key TEXT NOT NULL PRIMARY KEY,
|
|
31
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer'),
|
|
32
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json))
|
|
33
|
+
);
|
|
34
|
+
|
|
35
|
+
-- Model-written sentences for sandbox commands the deterministic rules in
|
|
36
|
+
-- exec-narrative.mjs could not describe, keyed by a digest of the command so
|
|
37
|
+
-- the same command is paid for once. Rule-derived sentences are never cached.
|
|
38
|
+
CREATE TABLE command_descriptions (
|
|
39
|
+
key TEXT NOT NULL PRIMARY KEY,
|
|
40
|
+
command TEXT NOT NULL,
|
|
41
|
+
description TEXT NOT NULL,
|
|
42
|
+
model TEXT,
|
|
43
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer')
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
-- Jev (TypeSafe) severity and step labels for the commands one tool call ran,
|
|
47
|
+
-- keyed by a digest of the exact state sent, so the same call is paid for
|
|
48
|
+
-- once. body_json keeps the raw answers next to the combined levels, so a
|
|
49
|
+
-- level can always be traced back to the rule or probability behind it.
|
|
50
|
+
-- Added in schema version 3 (see MIGRATIONS in init-evidence-db.mjs).
|
|
51
|
+
CREATE TABLE call_assessments (
|
|
52
|
+
key TEXT NOT NULL PRIMARY KEY,
|
|
53
|
+
call_id TEXT,
|
|
54
|
+
model TEXT,
|
|
55
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer'),
|
|
56
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json))
|
|
57
|
+
);
|
|
58
|
+
CREATE INDEX call_assessments_call ON call_assessments(call_id, created_at_ms);
|
|
59
|
+
|
|
60
|
+
-- Where the project folder stood after a tool call (or when a prompt was
|
|
61
|
+
-- sent) in a sandboxed Claude Code session: a commit in the sandbox's own
|
|
62
|
+
-- snapshot history (worker/gvisor/claude-hook.mjs), and the files that call
|
|
63
|
+
-- changed. Written by a hook beside the agent, not above it, so it is a lab
|
|
64
|
+
-- tool for putting the folder back, not evidence of what ran. changes_json
|
|
65
|
+
-- holds {changes: [{path, status, added, removed}], too_big: [path]}; a file
|
|
66
|
+
-- in too_big kept its previous version. Added in schema version 4.
|
|
67
|
+
CREATE TABLE workspace_snapshots (
|
|
68
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
69
|
+
session_id TEXT NOT NULL,
|
|
70
|
+
agent_session_id TEXT,
|
|
71
|
+
taken_on TEXT NOT NULL CHECK (taken_on IN ('prompt','tool')),
|
|
72
|
+
call_id TEXT,
|
|
73
|
+
commit_sha TEXT NOT NULL,
|
|
74
|
+
parent_sha TEXT,
|
|
75
|
+
changed INTEGER NOT NULL CHECK (changed IN (0,1)),
|
|
76
|
+
taken_at_ms INTEGER NOT NULL CHECK (typeof(taken_at_ms)='integer'),
|
|
77
|
+
changes_json TEXT NOT NULL CHECK (json_valid(changes_json))
|
|
78
|
+
);
|
|
79
|
+
CREATE INDEX workspace_snapshots_session ON workspace_snapshots(session_id, taken_at_ms);
|
|
80
|
+
CREATE INDEX workspace_snapshots_call ON workspace_snapshots(call_id);
|
|
81
|
+
|
|
82
|
+
CREATE TABLE proxy_errors (
|
|
83
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
84
|
+
trace_id TEXT,
|
|
85
|
+
occurred_at_ms INTEGER CHECK (occurred_at_ms IS NULL OR typeof(occurred_at_ms)='integer'),
|
|
86
|
+
provider TEXT,
|
|
87
|
+
route TEXT,
|
|
88
|
+
error TEXT,
|
|
89
|
+
cause_json TEXT CHECK (cause_json IS NULL OR json_valid(cause_json))
|
|
90
|
+
);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
-- Recording metadata is mutable; raw evidence remains append-only.
|
|
2
|
+
CREATE TABLE runtime_capture_streams (
|
|
3
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
4
|
+
sandbox_id TEXT NOT NULL REFERENCES runtime_sandboxes(id),
|
|
5
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json))
|
|
6
|
+
);
|
|
7
|
+
CREATE INDEX runtime_capture_streams_sandbox ON runtime_capture_streams(sandbox_id);
|
|
8
|
+
CREATE TABLE runtime_capture_checkpoints (
|
|
9
|
+
sandbox_id TEXT NOT NULL REFERENCES runtime_sandboxes(id),
|
|
10
|
+
source_id TEXT NOT NULL,
|
|
11
|
+
cursor INTEGER NOT NULL CHECK (cursor >= 0),
|
|
12
|
+
body_json TEXT NOT NULL CHECK (json_valid(body_json)),
|
|
13
|
+
PRIMARY KEY(sandbox_id,source_id)
|
|
14
|
+
);
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
-- Classification reference and derived results. No classifier executes here.
|
|
2
|
+
CREATE TABLE classification_versions (
|
|
3
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
4
|
+
catalog_version TEXT NOT NULL,
|
|
5
|
+
classifier_version TEXT NOT NULL,
|
|
6
|
+
content_sha256 TEXT NOT NULL CHECK (length(content_sha256)=64 AND content_sha256 NOT GLOB '*[^0-9a-f]*'),
|
|
7
|
+
created_at_ms INTEGER NOT NULL CHECK (typeof(created_at_ms)='integer'),
|
|
8
|
+
description TEXT NOT NULL
|
|
9
|
+
);
|
|
10
|
+
CREATE TABLE classification_impact_levels (
|
|
11
|
+
level INTEGER NOT NULL PRIMARY KEY CHECK (typeof(level)='integer' AND level BETWEEN 0 AND 3),
|
|
12
|
+
label TEXT NOT NULL,
|
|
13
|
+
description TEXT NOT NULL
|
|
14
|
+
);
|
|
15
|
+
CREATE TABLE classification_categories (
|
|
16
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
17
|
+
label TEXT NOT NULL,
|
|
18
|
+
description TEXT NOT NULL
|
|
19
|
+
);
|
|
20
|
+
CREATE TABLE classification_syscall_rules (
|
|
21
|
+
version_id TEXT NOT NULL REFERENCES classification_versions(id),
|
|
22
|
+
syscall_name TEXT NOT NULL,
|
|
23
|
+
description TEXT NOT NULL,
|
|
24
|
+
category_id TEXT NOT NULL REFERENCES classification_categories(id),
|
|
25
|
+
default_impact_level INTEGER REFERENCES classification_impact_levels(level),
|
|
26
|
+
rule_identifier TEXT NOT NULL,
|
|
27
|
+
required_evidence_json TEXT NOT NULL CHECK (json_valid(required_evidence_json) AND json_type(required_evidence_json)='array'),
|
|
28
|
+
interpretation_notes TEXT NOT NULL,
|
|
29
|
+
PRIMARY KEY(version_id, syscall_name)
|
|
30
|
+
);
|
|
31
|
+
CREATE TABLE classification_results (
|
|
32
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
33
|
+
syscall_call_id TEXT NOT NULL REFERENCES runtime_syscall_calls(id),
|
|
34
|
+
version_id TEXT NOT NULL REFERENCES classification_versions(id),
|
|
35
|
+
input_sha256 TEXT NOT NULL CHECK (length(input_sha256)=64 AND input_sha256 NOT GLOB '*[^0-9a-f]*'),
|
|
36
|
+
category_id TEXT REFERENCES classification_categories(id),
|
|
37
|
+
operation_level INTEGER REFERENCES classification_impact_levels(level),
|
|
38
|
+
confirmed_effect_level INTEGER REFERENCES classification_impact_levels(level),
|
|
39
|
+
effect_status TEXT NOT NULL CHECK (effect_status IN ('confirmed','no_effect','unknown','not_applicable')),
|
|
40
|
+
reason TEXT NOT NULL,
|
|
41
|
+
classified_at_ms INTEGER NOT NULL CHECK (typeof(classified_at_ms)='integer'),
|
|
42
|
+
UNIQUE(syscall_call_id, version_id, input_sha256),
|
|
43
|
+
CHECK (effect_status='confirmed' OR confirmed_effect_level IS NULL),
|
|
44
|
+
CHECK (effect_status!='confirmed' OR confirmed_effect_level IS NOT NULL)
|
|
45
|
+
);
|
|
46
|
+
CREATE INDEX classification_rules_category ON classification_syscall_rules(category_id, version_id);
|
|
47
|
+
CREATE INDEX classification_results_version ON classification_results(version_id, classified_at_ms);
|
|
48
|
+
CREATE INDEX classification_results_category ON classification_results(category_id, operation_level);
|
|
49
|
+
CREATE TRIGGER classification_confirmed_success BEFORE INSERT ON classification_results
|
|
50
|
+
WHEN NEW.effect_status='confirmed' AND NOT EXISTS (
|
|
51
|
+
SELECT 1 FROM runtime_syscall_calls WHERE id=NEW.syscall_call_id AND outcome='succeeded'
|
|
52
|
+
)
|
|
53
|
+
BEGIN SELECT RAISE(ABORT, 'confirmed effect requires a successful syscall'); END;
|
|
54
|
+
CREATE TRIGGER classification_versions_no_update BEFORE UPDATE ON classification_versions
|
|
55
|
+
BEGIN SELECT RAISE(ABORT, 'classification_versions is append-only'); END;
|
|
56
|
+
CREATE TRIGGER classification_versions_no_delete BEFORE DELETE ON classification_versions
|
|
57
|
+
BEGIN SELECT RAISE(ABORT, 'classification_versions is append-only'); END;
|
|
58
|
+
CREATE TRIGGER classification_versions_no_replace BEFORE INSERT ON classification_versions
|
|
59
|
+
WHEN EXISTS (SELECT 1 FROM classification_versions WHERE id=NEW.id)
|
|
60
|
+
BEGIN SELECT RAISE(ABORT, 'classification_versions existing key cannot be replaced'); END;
|
|
61
|
+
CREATE TRIGGER classification_impact_levels_no_update BEFORE UPDATE ON classification_impact_levels
|
|
62
|
+
BEGIN SELECT RAISE(ABORT, 'classification_impact_levels is append-only'); END;
|
|
63
|
+
CREATE TRIGGER classification_impact_levels_no_delete BEFORE DELETE ON classification_impact_levels
|
|
64
|
+
BEGIN SELECT RAISE(ABORT, 'classification_impact_levels is append-only'); END;
|
|
65
|
+
CREATE TRIGGER classification_impact_levels_no_replace BEFORE INSERT ON classification_impact_levels
|
|
66
|
+
WHEN EXISTS (SELECT 1 FROM classification_impact_levels WHERE level=NEW.level)
|
|
67
|
+
BEGIN SELECT RAISE(ABORT, 'classification_impact_levels existing key cannot be replaced'); END;
|
|
68
|
+
CREATE TRIGGER classification_categories_no_update BEFORE UPDATE ON classification_categories
|
|
69
|
+
BEGIN SELECT RAISE(ABORT, 'classification_categories is append-only'); END;
|
|
70
|
+
CREATE TRIGGER classification_categories_no_delete BEFORE DELETE ON classification_categories
|
|
71
|
+
BEGIN SELECT RAISE(ABORT, 'classification_categories is append-only'); END;
|
|
72
|
+
CREATE TRIGGER classification_categories_no_replace BEFORE INSERT ON classification_categories
|
|
73
|
+
WHEN EXISTS (SELECT 1 FROM classification_categories WHERE id=NEW.id)
|
|
74
|
+
BEGIN SELECT RAISE(ABORT, 'classification_categories existing key cannot be replaced'); END;
|
|
75
|
+
CREATE TRIGGER classification_syscall_rules_no_update BEFORE UPDATE ON classification_syscall_rules
|
|
76
|
+
BEGIN SELECT RAISE(ABORT, 'classification_syscall_rules is append-only'); END;
|
|
77
|
+
CREATE TRIGGER classification_syscall_rules_no_delete BEFORE DELETE ON classification_syscall_rules
|
|
78
|
+
BEGIN SELECT RAISE(ABORT, 'classification_syscall_rules is append-only'); END;
|
|
79
|
+
CREATE TRIGGER classification_syscall_rules_no_replace BEFORE INSERT ON classification_syscall_rules
|
|
80
|
+
WHEN EXISTS (SELECT 1 FROM classification_syscall_rules WHERE version_id=NEW.version_id AND syscall_name=NEW.syscall_name)
|
|
81
|
+
BEGIN SELECT RAISE(ABORT, 'classification_syscall_rules existing key cannot be replaced'); END;
|
|
82
|
+
CREATE TRIGGER classification_results_no_update BEFORE UPDATE ON classification_results
|
|
83
|
+
BEGIN SELECT RAISE(ABORT, 'classification_results is append-only'); END;
|
|
84
|
+
CREATE TRIGGER classification_results_no_delete BEFORE DELETE ON classification_results
|
|
85
|
+
BEGIN SELECT RAISE(ABORT, 'classification_results is append-only'); END;
|
|
86
|
+
CREATE TRIGGER classification_results_no_replace BEFORE INSERT ON classification_results
|
|
87
|
+
WHEN EXISTS (SELECT 1 FROM classification_results WHERE id=NEW.id OR
|
|
88
|
+
(syscall_call_id=NEW.syscall_call_id AND version_id=NEW.version_id AND input_sha256=NEW.input_sha256))
|
|
89
|
+
BEGIN SELECT RAISE(ABORT, 'classification_results existing key cannot be replaced'); END;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
-- File identity and contextual labels; no automatic identity resolution or scanning.
|
|
2
|
+
CREATE TABLE file_objects (
|
|
3
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
4
|
+
sandbox_id TEXT NOT NULL REFERENCES runtime_sandboxes(id),
|
|
5
|
+
object_type TEXT NOT NULL CHECK (object_type IN ('regular','directory','symlink','pipe','socket','device','unknown')),
|
|
6
|
+
filesystem_identity TEXT,
|
|
7
|
+
inode_number TEXT,
|
|
8
|
+
generation TEXT,
|
|
9
|
+
identity_basis TEXT NOT NULL,
|
|
10
|
+
first_seen_ns TEXT NOT NULL CHECK (first_seen_ns='0' OR (first_seen_ns GLOB '[1-9]*' AND first_seen_ns NOT GLOB '*[^0-9]*')),
|
|
11
|
+
last_seen_ns TEXT NOT NULL CHECK (last_seen_ns='0' OR (last_seen_ns GLOB '[1-9]*' AND last_seen_ns NOT GLOB '*[^0-9]*')),
|
|
12
|
+
UNIQUE(id, sandbox_id),
|
|
13
|
+
CHECK (length(last_seen_ns)>length(first_seen_ns) OR (length(last_seen_ns)=length(first_seen_ns) AND last_seen_ns COLLATE BINARY >= first_seen_ns COLLATE BINARY))
|
|
14
|
+
);
|
|
15
|
+
CREATE TABLE file_operation_targets (
|
|
16
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
17
|
+
syscall_call_id TEXT NOT NULL,
|
|
18
|
+
sandbox_id TEXT NOT NULL REFERENCES runtime_sandboxes(id),
|
|
19
|
+
file_object_id TEXT,
|
|
20
|
+
target_role TEXT NOT NULL CHECK (target_role IN ('target','source','destination','replaced_destination')),
|
|
21
|
+
supplied_path TEXT,
|
|
22
|
+
observed_path TEXT,
|
|
23
|
+
dirfd INTEGER CHECK (dirfd IS NULL OR typeof(dirfd)='integer'),
|
|
24
|
+
fd INTEGER CHECK (fd IS NULL OR (typeof(fd)='integer' AND fd>=0)),
|
|
25
|
+
base_path TEXT,
|
|
26
|
+
resolution_status TEXT NOT NULL CHECK (resolution_status IN ('unresolved','supplied_only','lexical','runtime_resolved')),
|
|
27
|
+
identity_basis_json TEXT CHECK (identity_basis_json IS NULL OR json_valid(identity_basis_json)),
|
|
28
|
+
FOREIGN KEY(syscall_call_id, sandbox_id) REFERENCES runtime_syscall_calls(id, sandbox_id),
|
|
29
|
+
FOREIGN KEY(file_object_id, sandbox_id) REFERENCES file_objects(id, sandbox_id),
|
|
30
|
+
CHECK (resolution_status!='supplied_only' OR supplied_path IS NOT NULL),
|
|
31
|
+
CHECK (resolution_status NOT IN ('lexical','runtime_resolved') OR observed_path IS NOT NULL)
|
|
32
|
+
);
|
|
33
|
+
CREATE TABLE file_labels (
|
|
34
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
35
|
+
label TEXT NOT NULL,
|
|
36
|
+
description TEXT NOT NULL
|
|
37
|
+
);
|
|
38
|
+
CREATE TABLE file_label_assignments (
|
|
39
|
+
id TEXT NOT NULL PRIMARY KEY,
|
|
40
|
+
target_id TEXT NOT NULL REFERENCES file_operation_targets(id),
|
|
41
|
+
label_id TEXT NOT NULL REFERENCES file_labels(id),
|
|
42
|
+
basis TEXT NOT NULL,
|
|
43
|
+
confidence TEXT NOT NULL CHECK (confidence IN ('exact','corroborated','inferred')),
|
|
44
|
+
rule_version TEXT NOT NULL,
|
|
45
|
+
reason TEXT NOT NULL,
|
|
46
|
+
assigned_at_ms INTEGER NOT NULL CHECK (typeof(assigned_at_ms)='integer')
|
|
47
|
+
);
|
|
48
|
+
CREATE INDEX file_objects_sandbox ON file_objects(sandbox_id, filesystem_identity, inode_number);
|
|
49
|
+
CREATE INDEX file_targets_call ON file_operation_targets(syscall_call_id);
|
|
50
|
+
CREATE INDEX file_targets_object ON file_operation_targets(file_object_id);
|
|
51
|
+
CREATE INDEX file_targets_path ON file_operation_targets(sandbox_id, observed_path);
|
|
52
|
+
CREATE INDEX file_assignments_target ON file_label_assignments(target_id);
|
|
53
|
+
CREATE INDEX file_assignments_label ON file_label_assignments(label_id, assigned_at_ms);
|