@raytrace-cli/cli 0.4.0 → 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/README.md +132 -126
  2. package/bin/raytrace.mjs +41 -20
  3. package/dist/dashboard/assets/dm-sans-latin-400-normal-BwCSEQnW.woff +0 -0
  4. package/dist/dashboard/assets/dm-sans-latin-400-normal-CW0RaeGs.woff2 +0 -0
  5. package/dist/dashboard/assets/dm-sans-latin-500-normal-B9HHJjqV.woff2 +0 -0
  6. package/dist/dashboard/assets/dm-sans-latin-500-normal-Dr3UlScf.woff +0 -0
  7. package/dist/dashboard/assets/dm-sans-latin-600-normal-Aqo67rzb.woff2 +0 -0
  8. package/dist/dashboard/assets/dm-sans-latin-600-normal-BmdmIIQ2.woff +0 -0
  9. package/dist/dashboard/assets/dm-sans-latin-700-normal-CUSSCpQX.woff +0 -0
  10. package/dist/dashboard/assets/dm-sans-latin-700-normal-DvUfVpUG.woff2 +0 -0
  11. package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BjWJ59Pq.woff +0 -0
  12. package/dist/dashboard/assets/dm-sans-latin-ext-400-normal-BtiwyxMk.woff2 +0 -0
  13. package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-BJfUCQsA.woff2 +0 -0
  14. package/dist/dashboard/assets/dm-sans-latin-ext-500-normal-DR84L5F-.woff +0 -0
  15. package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-4vooXBpG.woff2 +0 -0
  16. package/dist/dashboard/assets/dm-sans-latin-ext-600-normal-DRtaDpgU.woff +0 -0
  17. package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-BLI3TTWz.woff +0 -0
  18. package/dist/dashboard/assets/dm-sans-latin-ext-700-normal-CJIcxD6K.woff2 +0 -0
  19. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-BSMlKf0J.woff2 +0 -0
  20. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-400-normal-CEL4l2ZJ.woff +0 -0
  21. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Ael50iVv.woff +0 -0
  22. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-500-normal-Bq9vWWag.woff2 +0 -0
  23. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-CTOM6hUh.woff2 +0 -0
  24. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-600-normal-fLZuRloM.woff +0 -0
  25. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-DMdlQ8Kv.woff +0 -0
  26. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-400-normal-xuaO2J-f.woff2 +0 -0
  27. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BIfNGwUT.woff +0 -0
  28. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-500-normal-BqneJy0T.woff2 +0 -0
  29. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-9HEixskS.woff +0 -0
  30. package/dist/dashboard/assets/ibm-plex-mono-cyrillic-ext-600-normal-V-xxqcpd.woff2 +0 -0
  31. package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-CvHOgSBP.woff +0 -0
  32. package/dist/dashboard/assets/ibm-plex-mono-latin-400-normal-DMJ8VG8y.woff2 +0 -0
  33. package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-CB9ihrfo.woff +0 -0
  34. package/dist/dashboard/assets/ibm-plex-mono-latin-500-normal-DSY6xOcd.woff2 +0 -0
  35. package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-BgSNZQsw.woff2 +0 -0
  36. package/dist/dashboard/assets/ibm-plex-mono-latin-600-normal-DWFSQ4vo.woff +0 -0
  37. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-BmRBH3aV.woff2 +0 -0
  38. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-400-normal-D3D2R8hC.woff +0 -0
  39. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CAhNIIs5.woff2 +0 -0
  40. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-500-normal-CZ70TYgx.woff +0 -0
  41. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-D38SheWl.woff2 +0 -0
  42. package/dist/dashboard/assets/ibm-plex-mono-latin-ext-600-normal-DmB0ttJJ.woff +0 -0
  43. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-BulugwFq.woff2 +0 -0
  44. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-400-normal-DDuiU_S-.woff +0 -0
  45. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-C8zxqsMH.woff +0 -0
  46. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-500-normal-DZ4AoWbu.woff2 +0 -0
  47. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-D2EvbN8M.woff2 +0 -0
  48. package/dist/dashboard/assets/ibm-plex-mono-vietnamese-600-normal-iLQfcSjf.woff +0 -0
  49. package/dist/dashboard/assets/index-DtV3UdEB.css +1 -0
  50. package/dist/dashboard/assets/index-jyV5iYHJ.js +38 -0
  51. package/dist/dashboard/index.html +2 -2
  52. package/package.json +3 -1
  53. package/proxy/call-assessment.mjs +385 -0
  54. package/proxy/call-category.mjs +461 -0
  55. package/proxy/capture.mjs +31 -0
  56. package/proxy/claude-code-adapter.mjs +46 -3
  57. package/proxy/evidence-store.mjs +617 -15
  58. package/proxy/exec-narrative.mjs +625 -0
  59. package/proxy/execution-correlation.mjs +185 -0
  60. package/proxy/experiment-engine.mjs +7 -4
  61. package/proxy/failure-signature.mjs +56 -0
  62. package/proxy/gvisor-forwarder.mjs +454 -0
  63. package/proxy/init-evidence-db.mjs +136 -12
  64. package/proxy/local-sandboxes.mjs +94 -0
  65. package/proxy/playground.mjs +411 -0
  66. package/proxy/prompt-context.mjs +12 -7
  67. package/proxy/prompt-traces.mjs +6 -0
  68. package/proxy/raytace-proxy.mjs +460 -176
  69. package/proxy/run-recap.mjs +139 -0
  70. package/proxy/runtime-attribution.mjs +110 -0
  71. package/proxy/sandbox-bridge.mjs +46 -0
  72. package/proxy/schema/EVIDENCE_DATABASE.md +276 -0
  73. package/proxy/schema/auxiliary.sql +48 -1
  74. package/proxy/schema/classification.sql +89 -0
  75. package/proxy/schema/file_context.sql +53 -0
  76. package/proxy/schema/runtime_evidence.sql +201 -0
  77. package/proxy/schema/search.sql +66 -0
  78. package/proxy/search.mjs +418 -0
  79. package/proxy/step-attribution.mjs +380 -0
  80. package/proxy/tool-metadata.mjs +36 -0
  81. package/proxy/trace-view.mjs +276 -0
  82. package/proxy/typesafe.mjs +63 -0
  83. package/src/commands.mjs +73 -4
  84. package/src/lima.mjs +135 -0
  85. package/src/local-sandbox.mjs +324 -0
  86. package/src/proxy-process.mjs +20 -1
  87. package/src/sandbox.mjs +24 -6
  88. package/worker/sandbox/Dockerfile +8 -0
  89. package/worker/sandbox/SYSCALL_CATALOG.md +197 -0
  90. package/worker/sandbox/claude-hook.mjs +331 -0
  91. package/worker/sandbox/collector.py +357 -0
  92. package/worker/sandbox/dns_forwarder.py +255 -0
  93. package/worker/sandbox/engine.py +940 -0
  94. package/worker/sandbox/file_scan.py +491 -0
  95. package/worker/sandbox/lima.yaml +29 -0
  96. package/worker/sandbox/network.py +90 -0
  97. package/worker/sandbox/projects.py +678 -0
  98. package/worker/sandbox/setup.py +159 -0
  99. package/worker/sandbox/syscall_catalog.sql +985 -0
  100. package/worker/sandbox/viewer.py +132 -0
  101. package/dist/dashboard/assets/index-BQ9_JxGq.js +0 -27
  102. package/dist/dashboard/assets/index-L5cUAvhE.css +0 -1
@@ -0,0 +1,324 @@
1
+ // `raytrace sandbox … --local`: sandboxes on this machine, in a Lima Linux VM.
2
+ //
3
+ // Your project never leaves the machine. The VM runs each sandbox as a Docker
4
+ // container under gVisor; the collector beside it (worker/sandbox) records the
5
+ // commands, files and connections it makes, independently of the agent, and the
6
+ // evidence viewer shows them on http://localhost:8798. The sandbox's Claude Code
7
+ // hook sends its transcript to this CLI's proxy through the sandbox bridge
8
+ // (proxy/sandbox-bridge.mjs), so its sessions show in the local dashboard.
9
+ //
10
+ // Lima picks the VM type for the host: macOS and Linux work; Windows is
11
+ // experimental. Sign in to Claude Code or Codex inside the sandbox: no key is
12
+ // passed in from here.
13
+ import { spawnSync } from 'node:child_process';
14
+ import { createHash, randomBytes } from 'node:crypto';
15
+ import { closeSync, existsSync, mkdirSync, openSync, readFileSync, readdirSync, renameSync, rmSync, writeFileSync } from 'node:fs';
16
+ import { basename, join } from 'node:path';
17
+ import { paths } from './paths.mjs';
18
+ import { portInUse, runningPid, start as startProxy, stop as stopProxy } from './proxy-process.mjs';
19
+ import { readConfig } from './config.mjs';
20
+ import { LIMA_VERSION, canDownload, checks, downloadLima, findLima } from './lima.mjs';
21
+
22
+ const say = (line = '') => console.log(line);
23
+ const VM = 'raytrace';
24
+ const ID = /^rtp-[a-f0-9]{32}$/;
25
+ // How a local sandbox is named on the command line: unique among them.
26
+ const NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,63}$/;
27
+ const SOURCE = join(paths.root, 'worker', 'sandbox');
28
+ const HOOK = join(SOURCE, 'claude-hook.mjs');
29
+ const REGISTRY = join(paths.home, 'sandboxes.json');
30
+ // Where the proxy keeps each sandbox's copy of its Claude Code transcripts,
31
+ // and where the first local sandboxes' bridge kept them.
32
+ const transcripts = (id) => join(paths.home, 'claude-code', id);
33
+ const earlierTranscripts = (id) => join(paths.home, 'sandboxes', id, 'claude');
34
+ // Logs kept when a sandbox is destroyed without them.
35
+ const ARCHIVE = join(paths.home, 'archive');
36
+ // What the VM's setup was last run from; a CLI upgrade that changes it runs setup again.
37
+ const SETUP_MARK = '/etc/raytace/cli-setup';
38
+ // Lima's and the VM setup's own output, which is long: shown only when a step fails.
39
+ const VM_LOG = join(paths.logs, 'sandbox-vm.log');
40
+
41
+ /** Local sandboxes this CLI made: id → {name, root, token, created}. */
42
+ export function registry() {
43
+ try { return JSON.parse(readFileSync(REGISTRY, 'utf8')); } catch { return {}; }
44
+ }
45
+ function save(boxes) {
46
+ mkdirSync(paths.home, { recursive: true });
47
+ writeFileSync(REGISTRY, `${JSON.stringify(boxes, null, 2)}\n`, { mode: 0o600 });
48
+ }
49
+ const byName = (boxes, name) => Object.keys(boxes).find((id) => boxes[id].name === name);
50
+ /** Whether a sandbox id or name is one of this machine's local sandboxes. */
51
+ export const isLocal = (ref) => Boolean(ref && (registry()[ref] || byName(registry(), ref)));
52
+
53
+ let lima = null;
54
+ /** The limactl to run: the user's own Lima, or the one RayTrace downloaded. */
55
+ function limactlBinary() {
56
+ lima ??= findLima()?.binary;
57
+ if (!lima) throw new Error('Lima is not set up. `raytrace sandbox create --local` sets it up; `raytrace doctor` says what is missing.');
58
+ return lima;
59
+ }
60
+
61
+ const tail = (file, lines = 25) => { try { return readFileSync(file, 'utf8').trimEnd().split('\n').slice(-lines).join('\n'); } catch { return ''; } };
62
+
63
+ /**
64
+ * Runs limactl. `inherit` gives it the terminal (a shell); `log` sends its
65
+ * output to the VM log instead, and on failure shows the log's last lines.
66
+ */
67
+ function limactl(args, { input, inherit = false, log = false, check = true } = {}) {
68
+ let fd = null;
69
+ if (log) {
70
+ mkdirSync(paths.logs, { recursive: true });
71
+ fd = openSync(VM_LOG, 'a');
72
+ writeFileSync(fd, `\n=== ${new Date().toISOString()} limactl ${args.join(' ')} ===\n`);
73
+ }
74
+ let result;
75
+ try {
76
+ result = spawnSync(limactlBinary(), args, {
77
+ input, stdio: inherit ? 'inherit' : [input === undefined ? 'ignore' : 'pipe', fd ?? 'pipe', fd ?? 'pipe'],
78
+ encoding: inherit || log ? undefined : 'utf8', maxBuffer: 64 * 1024 * 1024,
79
+ });
80
+ } finally { if (fd !== null) closeSync(fd); }
81
+ if (result.error) throw result.error;
82
+ if (check && result.status !== 0) {
83
+ const detail = log ? `${tail(VM_LOG)}\n(full log: ${VM_LOG})` : String(result.stderr ?? '').trim().split('\n').slice(-6).join('\n');
84
+ throw new Error(`limactl ${args[0]} failed${detail ? `:\n${detail}` : ''}`);
85
+ }
86
+ return result;
87
+ }
88
+
89
+ /** A command in the VM as root: projects.py and setup.py run there. */
90
+ const inVm = (args, options) => limactl(['shell', '--workdir', '/', VM, 'sudo', ...args], options);
91
+ const projects = (args, options) => inVm(['python3', '/opt/raytace/projects.py', ...args], options);
92
+
93
+ /** Removes the RayTrace VM and every local sandbox in it; false when there was none. */
94
+ export function deleteVm() {
95
+ if (!findLima()?.binary || !vmStatus()) return false;
96
+ limactl(['delete', '--force', VM], { log: true });
97
+ return true;
98
+ }
99
+
100
+ export function vmStatus() {
101
+ const listed = limactl(['list', '--format', '{{.Name}} {{.Status}}']).stdout;
102
+ const line = listed.split('\n').find((row) => row.split(' ')[0] === VM);
103
+ return line ? line.split(' ')[1] : null;
104
+ }
105
+
106
+ function setupVersion() {
107
+ const hash = createHash('sha256');
108
+ for (const name of readdirSync(SOURCE).sort()) hash.update(name).update(readFileSync(join(SOURCE, name)));
109
+ return hash.digest('hex').slice(0, 16);
110
+ }
111
+
112
+ /** The VM up, with gVisor, the collector and the sandbox image as this CLI ships them. */
113
+ function ensureVm() {
114
+ const status = vmStatus();
115
+ if (!status) {
116
+ say(`Creating the RayTrace VM "${VM}" (first time only: it downloads Ubuntu, a few minutes)...`);
117
+ limactl(['start', '--name', VM, '--tty=false', join(SOURCE, 'lima.yaml')], { log: true });
118
+ } else if (status !== 'Running') {
119
+ say(`Starting the RayTrace VM "${VM}"...`);
120
+ limactl(['start', '--tty=false', VM], { log: true });
121
+ }
122
+ const version = setupVersion();
123
+ const installed = inVm(['cat', SETUP_MARK], { check: false }).stdout?.trim();
124
+ if (installed === version) return;
125
+ say(`Installing gVisor, the evidence collector and the sandbox image in the VM (a few minutes; progress in ${VM_LOG})...`);
126
+ inVm(['rm', '-rf', '/tmp/raytrace-sandbox-source']);
127
+ limactl(['shell', '--workdir', '/', VM, 'mkdir', '-p', '/tmp/raytrace-sandbox-source']);
128
+ limactl(['copy', '-r', `${SOURCE}/.`, `${VM}:/tmp/raytrace-sandbox-source/`]);
129
+ inVm(['python3', '/tmp/raytrace-sandbox-source/setup.py'], { log: true });
130
+ inVm(['sh', '-c', `echo ${version} > ${SETUP_MARK}`]);
131
+ }
132
+
133
+ /** Transcripts reach the dashboard through the proxy's sandbox bridge. */
134
+ async function ensureBridge() {
135
+ try { await startProxy(); } catch (error) {
136
+ say(`Note: the RayTrace proxy did not start (${error.message.split('\n')[0]}). `
137
+ + 'Commands are still recorded in the VM; Claude Code transcripts reach the dashboard once `raytrace start` works.');
138
+ return;
139
+ }
140
+ // A proxy from before local sandboxes is reused as it is, and has no bridge.
141
+ if (!(await portInUse(Number(readConfig().RAYTRACE_BRIDGE_PORT || 8799)))) {
142
+ say('Note: the running RayTrace proxy has no sandbox bridge (it predates local sandboxes). '
143
+ + 'Restart it so Claude Code sessions reach the dashboard: raytrace stop && raytrace start');
144
+ }
145
+ }
146
+
147
+ /**
148
+ * Before anything is packed or started: what this machine lacks for a local
149
+ * sandbox, each with its fix, and Lima downloaded if the user agrees.
150
+ */
151
+ export async function preflight(flags, { confirm, interactive }) {
152
+ let vmRunning = false;
153
+ try { vmRunning = Boolean(findLima()?.binary) && vmStatus() === 'Running'; } catch { /* reported below */ }
154
+ const rows = await checks({ vmRunning });
155
+ for (const { ok, label, detail } of rows) if (ok === null && label !== 'lima') say(`Note (${label}): ${detail}`);
156
+ const failed = rows.filter((row) => row.ok === false);
157
+ if (failed.length) {
158
+ throw new Error(`This machine is not ready for local sandboxes:\n${failed.map((row) => ` ${row.label}: ${row.detail}${row.fix ? `\n fix: ${row.fix}` : ''}`).join('\n')}`);
159
+ }
160
+ if (findLima()?.binary) return;
161
+ if (!canDownload()) throw new Error('Local sandboxes need Lima: https://lima-vm.io/docs/installation/');
162
+ const question = `Local sandboxes run in a Linux VM made with Lima (open source, Apache-2.0), which is not installed. `
163
+ + `Download Lima ${LIMA_VERSION} (about 25-40 MB) into ${join(paths.home, 'lima')}? No admin rights needed.`;
164
+ if (!flags.yes) {
165
+ if (!interactive()) throw new Error(`${question}\nRun again with --yes to download it, or install Lima yourself: https://lima-vm.io/docs/installation/`);
166
+ if (!(await confirm(question, true))) throw new Error('Not downloaded. Install Lima yourself to use local sandboxes: https://lima-vm.io/docs/installation/');
167
+ }
168
+ lima = (await downloadLima(say)).binary;
169
+ }
170
+
171
+ /** A local sandbox's id, from its id or name; with neither, the only one there is. */
172
+ function pickId(ref) {
173
+ const boxes = registry();
174
+ if (ref) {
175
+ const id = boxes[ref] ? ref : byName(boxes, ref);
176
+ if (!id) throw new Error(`No local sandbox named ${ref}: raytrace sandbox list --local`);
177
+ return id;
178
+ }
179
+ const ids = Object.keys(boxes);
180
+ if (ids.length === 1) return ids[0];
181
+ throw new Error(ids.length ? 'More than one local sandbox; name one (raytrace sandbox list --local).'
182
+ : 'No local sandboxes yet: raytrace sandbox create --local');
183
+ }
184
+
185
+ /** The new sandbox's name: --name, or the repository folder's; unique among local sandboxes. */
186
+ export function sandboxName(flags, root) {
187
+ const name = flags.name ?? basename(root).replace(/[^A-Za-z0-9._-]+/g, '-').replace(/^[^A-Za-z0-9]+/, '').slice(0, 64);
188
+ if (!NAME.test(name)) throw new Error(`"${name}" cannot be a sandbox name: use letters, digits, dot, dash and underscore (up to 64), starting with a letter or digit.`);
189
+ if (byName(registry(), name)) throw new Error(`There is already a local sandbox named ${name}. Pick another with --name, or destroy that one: raytrace sandbox destroy ${name}`);
190
+ return name;
191
+ }
192
+
193
+ export async function create(name, { root, files, skipped, total, archive }) {
194
+ ensureVm();
195
+ const id = `rtp-${randomBytes(16).toString('hex')}`;
196
+ const token = randomBytes(32).toString('base64url');
197
+ say(`Copying ${files.length} files (${(total / 1048576).toFixed(1)} MiB) from ${root} into a new sandbox`);
198
+ if (skipped.length) say(`Left out (${skipped.length}): ${skipped.slice(0, 8).join(', ')}${skipped.length > 8 ? ', ...' : ''}`);
199
+ projects(['create', id, '--archive', '-'], { input: archive });
200
+ // Recorded before anything else can fail, so destroy can always find it.
201
+ save({ ...registry(), [id]: { name, root, token, created: new Date().toISOString() } });
202
+ projects(['start', id]);
203
+ projects(['enable-claude', id], { input: readFileSync(HOOK) });
204
+ projects(['set-token', id], { input: token });
205
+ await ensureBridge();
206
+ say(`\nLocal sandbox ${name} (${id}) is running.`);
207
+ say('Claude Code sessions in it go to your local dashboard; commands, files and connections are recorded in the VM.');
208
+ say(`Open it: raytrace connect ${name}`);
209
+ }
210
+
211
+ export async function list() {
212
+ const boxes = registry();
213
+ if (!Object.keys(boxes).length) { say('No local sandboxes. Create one from a Git repository: raytrace sandbox create --local'); return; }
214
+ const running = vmStatus() === 'Running';
215
+ const states = running ? Object.fromEntries(JSON.parse(projects(['list']).stdout || '[]').map((box) => [box.id, box.status])) : {};
216
+ for (const [id, box] of Object.entries(boxes)) {
217
+ const age = Math.round((Date.now() - Date.parse(box.created)) / 60000);
218
+ const status = running ? (states[id] === 'running' ? 'running' : states[id] ? 'stopped' : 'missing') : 'stopped';
219
+ say(`${box.name.padEnd(20)} ${status.padEnd(8)} ${id} (${age < 120 ? `${age} min` : `${Math.round(age / 60)} h`} old, local)`);
220
+ }
221
+ if (!running) say(`\nThe RayTrace VM is stopped; \`raytrace sandbox start <name>\` starts it.`);
222
+ }
223
+
224
+ export async function start(id) {
225
+ id = pickId(id);
226
+ ensureVm();
227
+ projects(['start', id]);
228
+ await ensureBridge();
229
+ say(`${registry()[id].name} running`);
230
+ }
231
+
232
+ export async function stop(id) {
233
+ id = pickId(id);
234
+ if (vmStatus() === 'Running') projects(['stop', id]);
235
+ say(`${registry()[id].name} stopped; its files are kept`);
236
+ }
237
+
238
+ const stamp = () => new Date().toISOString().replace(/[-:]/g, '').replace('T', '-').slice(0, 15);
239
+
240
+ /** The sandbox's Claude Code session ids, from the bridge's transcript copies. */
241
+ function sessionIds(id) {
242
+ const listed = (folder) => { try { return readdirSync(folder).filter((file) => file.endsWith('.jsonl')).map((file) => file.slice(0, -6)); } catch { return []; } };
243
+ return [...listed(transcripts(id)), ...listed(earlierTranscripts(id))];
244
+ }
245
+
246
+ /**
247
+ * Deletes a local sandbox, and asks about the logs captured in it: deleted
248
+ * with it, or moved to ~/.raytrace/archive/<name>-<time>/ (the Claude Code
249
+ * transcripts and the VM's command, file and network evidence), staying in
250
+ * the dashboard. --delete-logs / --keep-logs answer without asking; without a
251
+ * terminal and neither flag, the logs are kept.
252
+ */
253
+ export async function destroy(ref, flags, { ask, interactive }) {
254
+ const id = pickId(ref);
255
+ const box = registry()[id];
256
+ if (!flags.yes) {
257
+ if (!interactive()) throw new Error('Pass --yes to destroy without a prompt.');
258
+ say(`This deletes local sandbox ${box.name}: its files, and any sign-in made inside it.`);
259
+ if ((await ask('Type the sandbox name to confirm: ')) !== box.name) { say('Not destroyed.'); return; }
260
+ }
261
+ let deleteLogs = flags['delete-logs'] ? true : flags['keep-logs'] ? false : null;
262
+ if (deleteLogs === null) {
263
+ deleteLogs = interactive()
264
+ && /^y(es)?$/i.test((await ask('Also delete the logs captured in this sandbox? (yes/no) [no]: ')).trim());
265
+ }
266
+
267
+ ensureVm();
268
+ const inVmNow = JSON.parse(projects(['list']).stdout || '[]');
269
+ const exists = inVmNow.some((item) => item.id === id);
270
+ // Its Playground forks, which are sandboxes of their own in the VM.
271
+ const forks = inVmNow.filter((item) => item.fork_of === id).map((item) => item.id);
272
+ // Stopped first: stopping is recorded too, and must not land after the logs are dealt with.
273
+ if (exists) projects(['stop', id]);
274
+ if (deleteLogs) {
275
+ // Its sessions are filed under its id; ones recorded before that, under their own.
276
+ const { openEvidenceStore } = await import('../proxy/evidence-store.mjs');
277
+ const store = openEvidenceStore(paths.database);
278
+ try { store.forgetSessions([id, ...sessionIds(id)]); } finally { store.close(); }
279
+ rmSync(transcripts(id), { recursive: true, force: true });
280
+ rmSync(join(paths.home, 'sandboxes', id), { recursive: true, force: true });
281
+ } else {
282
+ const folder = join(ARCHIVE, `${box.name}-${stamp()}`);
283
+ mkdirSync(folder, { recursive: true, mode: 0o700 });
284
+ const { token, ...about } = box;
285
+ writeFileSync(join(folder, 'sandbox.json'), `${JSON.stringify({ id, ...about, destroyed: new Date().toISOString() }, null, 2)}\n`);
286
+ if (exists) writeFileSync(join(folder, 'runtime-evidence.jsonl'), projects(['evidence', id]).stdout);
287
+ for (const from of [transcripts(id), earlierTranscripts(id)]) {
288
+ if (existsSync(from)) { renameSync(from, join(folder, 'claude-code')); break; }
289
+ }
290
+ // Forks' transcripts are filed under their own ids; their recorded
291
+ // commands are already in the dashboard, with the forks themselves.
292
+ for (const fork of forks) {
293
+ if (!existsSync(transcripts(fork))) continue;
294
+ mkdirSync(join(folder, 'forks'), { recursive: true, mode: 0o700 });
295
+ renameSync(transcripts(fork), join(folder, 'forks', fork));
296
+ }
297
+ rmSync(join(paths.home, 'sandboxes', id), { recursive: true, force: true });
298
+ say(`Logs moved to ${folder}`);
299
+ say('Its Claude Code sessions stay in your dashboard.');
300
+ }
301
+ // The VM's record of it goes either way: deleted, or by now in the archive.
302
+ for (const fork of forks) projects(['fork-delete', fork, '--forget-evidence']);
303
+ if (deleteLogs) for (const fork of forks) rmSync(transcripts(fork), { recursive: true, force: true });
304
+ if (exists) projects(['delete', id, '--confirm', id, '--forget-evidence']);
305
+ const boxes = registry();
306
+ delete boxes[id];
307
+ save(boxes);
308
+ say(`${box.name} destroyed${forks.length ? `, with its ${forks.length} Playground fork${forks.length === 1 ? '' : 's'}` : ''}${deleteLogs ? ', and its logs' : ''}.`);
309
+ // The proxy keeps the Playground's forks in memory: one this CLI started is
310
+ // restarted, so the forks just deleted are not listed any more.
311
+ if (deleteLogs && forks.length && runningPid()) { await stopProxy(); await startProxy(); }
312
+ }
313
+
314
+ /** A terminal in the sandbox, through the VM. Leaving it keeps the sandbox running. */
315
+ export async function shell(id) {
316
+ id = pickId(id);
317
+ ensureVm();
318
+ await ensureBridge();
319
+ const { name } = registry()[id];
320
+ say(`Connected to ${name}. Run \`claude\` (or codex) here; exit to leave. The sandbox keeps running.`);
321
+ say('Recorded commands, files and connections: http://localhost:8798\n');
322
+ projects(['shell', id], { inherit: true, check: false });
323
+ say(`\nLeft ${name}. It is still running. Back in: raytrace connect ${name} Stop it: raytrace sandbox stop ${name}`);
324
+ }
@@ -10,6 +10,18 @@ import { setTimeout as sleep } from 'node:timers/promises';
10
10
  import { paths } from './paths.mjs';
11
11
  import { portOf, proxyEnv, readConfig } from './config.mjs';
12
12
 
13
+ // The proxy API this CLI's dashboard needs (proxy/raytace-proxy.mjs PROXY_API).
14
+ // A proxy from an older install answers without it, or with less.
15
+ export const PROXY_API = 2;
16
+
17
+ /** The running proxy's API version: 0 for one from before it said. */
18
+ export async function proxyApi(port) {
19
+ try {
20
+ const response = await fetch(`http://127.0.0.1:${port}/raytace/version`, { signal: AbortSignal.timeout(2000) });
21
+ return response.ok ? Number((await response.json()).api) || 0 : 0;
22
+ } catch { return 0; }
23
+ }
24
+
13
25
  export async function healthy(port) {
14
26
  try {
15
27
  const response = await fetch(`http://127.0.0.1:${port}/raytace/models`, { signal: AbortSignal.timeout(2000) });
@@ -58,7 +70,14 @@ function tail(file, lines = 8) {
58
70
  export async function start() {
59
71
  const config = readConfig();
60
72
  const port = portOf(config);
61
- if (await healthy(port)) return { started: false, port, pid: runningPid() };
73
+ if (await healthy(port)) {
74
+ if (await proxyApi(port) >= PROXY_API) return { started: false, port, pid: runningPid() };
75
+ // An older proxy, still running from before an upgrade: the dashboard it
76
+ // serves now is the new one, and it would answer it "Unknown local endpoint".
77
+ if (!runningPid()) throw new Error(`An older RayTrace proxy, not started by this CLI, is running on :${port}. Stop it where it was started, then run: raytrace start`);
78
+ await stop();
79
+ return { ...(await start()), replaced: true };
80
+ }
62
81
  if (await portInUse(port)) throw new Error(`Port ${port} is in use by something that is not answering as RayTrace. Free it, or set RAYTACE_PORT in ${paths.config}.`);
63
82
  if (!existsSync(paths.dashboard)) throw new Error(`The dashboard is missing from ${paths.dashboard}. Reinstall @raytrace/cli.`);
64
83
 
package/src/sandbox.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  // `raytrace sandbox`: cloud sandboxes, through RayTrace's API
2
- // (https://api.raytracer.si; RAYTRACE_API_URL points elsewhere).
2
+ // (https://api.raytracer.si; RAYTRACE_API_URL points elsewhere), or with
3
+ // --local on this machine (local-sandbox.mjs). A local sandbox's id is
4
+ // recognised wherever an id is given, so connect/stop/destroy need no flag.
3
5
  //
4
6
  // The project is packed here, so files that must stay on this machine never
5
7
  // leave it, then uploaded once; RayTrace creates an isolated sandbox from it
@@ -13,7 +15,8 @@ import { request as httpsRequest } from 'node:https';
13
15
  import { basename, join } from 'node:path';
14
16
  import { accessToken, account, login } from './auth.mjs';
15
17
  import { readConfig } from './config.mjs';
16
- import { ask, interactive } from './prompt.mjs';
18
+ import { ask, confirm, interactive } from './prompt.mjs';
19
+ import * as local from './local-sandbox.mjs';
17
20
 
18
21
  const say = (line = '') => console.log(line);
19
22
  // What one project upload may be. RayTrace's API holds the dashboard's folder
@@ -125,8 +128,13 @@ export async function create(flags) {
125
128
  if (top.status !== 0) throw new Error('Run this from inside a Git repository.');
126
129
  const root = top.stdout.trim();
127
130
  const name = flags.name || basename(root);
131
+ // What the machine lacks is said before the project is read, and Lima fetched if agreed.
132
+ const localName = flags.local ? local.sandboxName(flags, root) : null;
133
+ if (flags.local) await local.preflight(flags, { confirm, interactive });
128
134
  const { files, skipped, total } = projectFiles(root);
129
135
  if (!files.length) throw new Error('Nothing to upload.');
136
+ // The same files, packed the same way, as a cloud sandbox gets: only the copy stays here.
137
+ if (flags.local) return local.create(localName, { root, files, skipped, total, archive: await pack(root, files) });
130
138
  say(`Packing ${files.length} files (${(total / 1048576).toFixed(1)} MiB) from ${root}`);
131
139
  if (skipped.length) say(`Not uploaded (${skipped.length}): ${skipped.slice(0, 8).join(', ')}${skipped.length > 8 ? ', ...' : ''}`);
132
140
  const archive = await pack(root, files);
@@ -141,7 +149,8 @@ export async function create(flags) {
141
149
  say(`Open it: raytrace connect ${box.id}`);
142
150
  }
143
151
 
144
- export async function list() {
152
+ export async function list(flags = {}) {
153
+ if (flags.local) return local.list();
145
154
  const boxes = (await call('GET', '/v1/sandboxes')).filter((box) => box.status !== 'deleted');
146
155
  if (!boxes.length) { say('No sandboxes. Create one from a Git repository: raytrace sandbox create'); return; }
147
156
  for (const box of boxes) {
@@ -152,10 +161,17 @@ export async function list() {
152
161
  }
153
162
  }
154
163
 
155
- export async function start(id) { const box = await call('POST', `/v1/sandboxes/${await pickId(id)}/start`); say(`${box.id} running`); }
156
- export async function stop(id) { const box = await call('POST', `/v1/sandboxes/${await pickId(id)}/stop`); say(`${box.id} stopped; its files are kept`); }
164
+ export async function start(id, flags = {}) {
165
+ if (flags.local || local.isLocal(id)) return local.start(id);
166
+ const box = await call('POST', `/v1/sandboxes/${await pickId(id)}/start`); say(`${box.id} running`);
167
+ }
168
+ export async function stop(id, flags = {}) {
169
+ if (flags.local || local.isLocal(id)) return local.stop(id);
170
+ const box = await call('POST', `/v1/sandboxes/${await pickId(id)}/stop`); say(`${box.id} stopped; its files are kept`);
171
+ }
157
172
 
158
173
  export async function destroy(id, flags) {
174
+ if (flags.local || local.isLocal(id)) return local.destroy(id, flags, { ask, interactive });
159
175
  id = await pickId(id);
160
176
  if (!flags.yes) {
161
177
  if (!interactive()) throw new Error('Pass --yes to destroy without a prompt.');
@@ -168,8 +184,10 @@ export async function destroy(id, flags) {
168
184
 
169
185
  /** An interactive terminal in the sandbox, carried over one upgraded HTTP request.
170
186
  * `raytrace connect <id>` and `raytrace sandbox shell [id]` are the same thing. */
171
- export async function shell(id) {
187
+ export async function shell(id, flags = {}) {
172
188
  if (!interactive()) throw new Error('Connecting to a sandbox needs a terminal.');
189
+ // With no id and no cloud sign-in, the one local sandbox is the likely one.
190
+ if (flags.local || local.isLocal(id) || (!id && Object.keys(local.registry()).length && !account())) return local.shell(id);
173
191
  id = await pickId(id);
174
192
  const { url, key } = await api();
175
193
  const { stdin, stdout } = process;
@@ -0,0 +1,8 @@
1
+ FROM node:22-bookworm-slim
2
+ RUN apt-get update && apt-get install -y --no-install-recommends git ca-certificates python3 curl ripgrep \
3
+ && rm -rf /var/lib/apt/lists/*
4
+ RUN npm install -g @openai/codex @anthropic-ai/claude-code
5
+ RUN mkdir /workspace && chown node:node /workspace
6
+ USER node
7
+ WORKDIR /workspace
8
+ ENV HOME=/home/node CODEX_HOME=/home/node/.codex
@@ -0,0 +1,197 @@
1
+ # Syscall catalog
2
+
3
+ `syscall_catalog.sql` is a standalone, version-controlled SQLite catalog (catalog
4
+ version **2**). It has one row for every syscall name gVisor knows, 353 in all,
5
+ in eight groups: files, network, process, identity, memory, IPC, time and other.
6
+ Version 1 held the 84 file rows only; they are unchanged.
7
+
8
+ The catalog is the rulebook the sandbox host runs from:
9
+
10
+ - `setup.py` builds gVisor's trace configuration from the rows whose `capture`
11
+ is `yes` or `watcher`, so what is subscribed cannot drift from what is listed.
12
+ - `engine.py` names raw events with `syscall_numbers` and reads each captured
13
+ call with the rule its row names in `effect_rule`.
14
+
15
+ Loading the file into a database still enables nothing by itself, and changing
16
+ a row changes what is captured only after `setup.py` runs again on a host.
17
+
18
+ ## Import and query
19
+
20
+ From the repository root, create a disposable database:
21
+
22
+ ```sh
23
+ catalog_dir=$(mktemp -d)
24
+ sqlite3 "$catalog_dir/catalog.db" < worker/gvisor/syscall_catalog.sql
25
+ sqlite3 -header -column "$catalog_dir/catalog.db" \
26
+ "SELECT syscall_name, category, default_impact_level, capture, detail FROM syscall_catalog_readable WHERE syscall_name = 'unlinkat';"
27
+ ```
28
+
29
+ Expected result:
30
+
31
+ ```text
32
+ syscall_name category default_impact_level capture detail
33
+ ------------ -------- -------------------- ------- -----------
34
+ unlinkat Delete 3 watcher number_only
35
+ ```
36
+
37
+ What RayTrace captures, and how much gVisor can tell of each:
38
+
39
+ ```sh
40
+ sqlite3 -header -column "$catalog_dir/catalog.db" \
41
+ "SELECT group_id, syscall_name, capture, detail, effect_rule FROM syscall_catalog_readable WHERE capture != 'no' ORDER BY group_id, syscall_name;"
42
+ ```
43
+
44
+ The import is transactional and idempotent. Re-importing restores catalog-owned
45
+ rows using upserts and preserves unrelated rows. It does not delete removed
46
+ entries or upgrade a version 1 database; use a fresh database. Use a dedicated
47
+ database, not the application or runtime evidence database. The script does not
48
+ modify `PRAGMA user_version`.
49
+
50
+ ## Data model
51
+
52
+ | Table/view | Purpose |
53
+ | --- | --- |
54
+ | `syscall_impact_levels` | Four file impact levels and their meanings. |
55
+ | `syscall_groups` | The eight top-level groups. |
56
+ | `syscall_categories` | Stable operation identifiers, labels, and descriptions; the second level under a group. |
57
+ | `syscall_catalog` | One row per syscall name: description, group, category, nullable default level, rule identifier, required evidence, interpretation notes, the capture decision, and catalog version. |
58
+ | `syscall_numbers` | Generated. The number of each call on `x86_64` and `aarch64`, and whether gVisor implements it. |
59
+ | `syscall_coverage` | Generated. For the pinned gVisor release, whether a call has a typed trace point and with which optional fields, and what a live test observed. |
60
+ | `syscall_catalog_readable` | Joined view with group, category and impact labels, `detail` and `observed`, for inspection or export. |
61
+
62
+ | Level | Label | Meaning |
63
+ | --- | --- | --- |
64
+ | 0 | Observe | Read or inspect; sensitive reads and incidental access-time updates remain possible. |
65
+ | 1 | Create | Add an entry without replacing existing data. |
66
+ | 2 | Modify | Change contents, metadata, layout, or location. |
67
+ | 3 | Remove/replace | Remove an entry or replace an existing destination. |
68
+
69
+ Levels describe filesystem impact, **not maliciousness**. A level-0 secret read
70
+ can be concerning; a level-3 temporary-file deletion can be expected. Null means
71
+ conditional or not applicable, never level 0, and every row outside the file
72
+ group has a null level. Unknown syscall names have no row and must remain
73
+ unclassified. A recognized syscall with missing evidence may still have a known
74
+ operation category, but its actual effect stays unknown.
75
+
76
+ Names are not architecture-specific syscall numbers. For example, `newfstatat`
77
+ is a syscall name while `fstatat` is a common library interface. A listed name
78
+ need not exist on every architecture: `open`, `unlink` and `rename` have no
79
+ number on `aarch64`, where only the `*at` forms exist. Resolve numbers in
80
+ `syscall_numbers` against the execution architecture before lookup; do not
81
+ infer them from the collector host.
82
+
83
+ ## What is captured
84
+
85
+ `capture` is RayTrace's decision for each row:
86
+
87
+ | `capture` | Meaning | Rows |
88
+ | --- | --- | --- |
89
+ | `yes` | Its gVisor trace point is subscribed, with the optional fields in `capture_fields`. | `open`, `openat`, `creat`, `connect`, `listen`, `setuid`, `setgid`, `setresuid`, `setresgid` |
90
+ | `watcher` | Only its raw exit point is subscribed: which process, when, and whether it was refused. gVisor does not decode its path, so the host's file watcher supplies the name. | `unlink`, `unlinkat`, `rmdir`, `rename`, `renameat`, `renameat2`, `truncate`, `ftruncate`, `mkdir`, `mkdirat`, `chmod`, `fchmod`, `fchmodat` |
91
+ | `sentry` | Seen through gVisor's own process points (clone, exec, exit), whatever syscall caused them. | `clone`, `clone3`, `fork`, `vfork`, `execve`, `execveat`, `exit`, `exit_group` |
92
+ | `no` | Not captured. | everything else |
93
+
94
+ `read` and `write` are deliberately `no`: they are by far the most frequent
95
+ calls, and whether a file changed is settled by comparing it before and after.
96
+ Every other `no` row is there so that no call is without a group, and so the
97
+ coverage can be stated: "we read this", "we see it without its path", or "we do
98
+ not watch it".
99
+
100
+ `detail` in the view is what gVisor can tell of a call in the pinned release:
101
+ `full` (a typed point with decoded paths, flags or addresses), `number_only`
102
+ (the number and six integers) or `none` (that release has no such call, as for
103
+ `openat2`). `observed` records what a live test saw arrive and is null until
104
+ `spike_points.py` has run for the release.
105
+
106
+ ## Regenerating the generated tables
107
+
108
+ `syscall_numbers` and `syscall_coverage` come from gVisor's own source for the
109
+ release `setup.py` installs. After changing that release:
110
+
111
+ ```sh
112
+ python3 worker/gvisor/catalog_numbers.py # fetch the release, rewrite both tables
113
+ python3 worker/gvisor/catalog_numbers.py --check # change nothing; fail if a call has no row
114
+ ```
115
+
116
+ A syscall the new release has and the catalog lacks is refused until its row
117
+ is written. What a spike observed is kept for the same release and cleared for
118
+ a new one, since it has to be seen again.
119
+
120
+ ## Classification contract
121
+
122
+ The rule identifiers below are specifications. `engine.py` implements the ones
123
+ its captured rows name (`open_effect`, `remove_entry`, `rename_effect`,
124
+ `file_resize`, `directory_create`, `metadata_change`, `connect_effect`,
125
+ `listen_effect`, `identity_effect`); the others describe calls that are not
126
+ captured. Keep the raw observation, attempted operation, outcome, and confirmed
127
+ effect separate. Preserve the catalog version when persisting classifications.
128
+
129
+ Every event needs sandbox/process identity, timestamp, syscall identity, and
130
+ outcome. A missing exit result is unknown, not success. Apply the row-specific
131
+ `required_evidence` and rules only after decoding signed results and errno.
132
+
133
+ | Rule | Interpretation |
134
+ | --- | --- |
135
+ | `open_effect` | Read-only opens without mutation flags are level 0, but do not prove bytes were read. Confirmed creation is level 1; successful truncation of an existing file is level 2. Writable access alone has no confirmed mutation level. `O_CREAT` alone does not establish creation. `creat` implies `O_WRONLY\|O_CREAT\|O_TRUNC`; `openat2` requires decoding `open_how`. Successful `O_CREAT\|O_EXCL` can establish new creation. Other ambiguous cases stay unresolved. |
136
+ | `file_write` | Level 2 applies only to file targets. Positive returned bytes establish writes, not necessarily different contents or durable storage. Record actual bytes, not just requested bytes; zero-byte and failed writes do not confirm modification. Honor append/offset flags without inventing an unavailable actual offset. |
137
+ | `remove_entry` | Level 3 is the attempted operation. A successful result confirms entry removal; failure does not. `AT_REMOVEDIR` distinguishes directory deletion. Other hard links or open descriptors may retain data. |
138
+ | `rename_effect` | Confirmed non-replacing move is level 2; confirmed replacement is level 3. Unknown destination history remains unresolved. `RENAME_NOREPLACE` success excludes replacement; `RENAME_EXCHANGE` is an exchange at level 2. Same-object operations may be no-ops. `RENAME_WHITEOUT` and unsupported flag combinations stay unresolved until specifically decoded. An earlier directory scan alone is not race-free replacement evidence. |
139
+ | `file_resize` | Level 2 operation; record requested length. Success confirms a length-setting operation, not a change from an unknown prior size. |
140
+ | `directory_create` | Level 1 operation; success confirms creation. Requested mode may differ from effective permissions because of umask or ACLs. |
141
+ | `file_read` | Level 0 for file targets; positive returned bytes establish a read. Zero bytes, failures, and an open alone do not. Do not retain buffer contents. |
142
+ | `inspect` | Level 0 inspection; metadata and accessibility checks do not prove later content access. |
143
+ | `metadata_change` | Level 2 operation; success does not prove a value differed. Keep attribute names and relevant permissions/ownership/timestamps, not attribute payloads. |
144
+ | `link_create` | Level 1 entry creation; distinguish hard links from symbolic-link target text. No claim that contents were copied or the target is safe. |
145
+ | `copy_effect` | Positive transfer to a known existing file is level 2. Creation is established separately by creation evidence. Unknown targets remain unresolved; pipes and sockets are not filesystem edits. |
146
+ | `allocation_effect` | Successful, decoded file allocation/range changes are level 2. Distinguish allocation from punch-hole, zero-range, collapse-range and insert-range; allocation does not alone establish changed content. Unknown flags remain unresolved. |
147
+ | `ioctl_effect` | Decode command-specific semantics first. Supported file clone operations and attribute changes are level 2; supported inspection is level 0. Unknown commands have no default level. |
148
+ | `mapping_effect` | Record mapping capability/lifecycle, not confirmed reads or writes. `MAP_SHARED` plus writable protection permits edits but does not prove them. `msync`/`munmap` alone do not prove changed bytes. Leave confirmed impact unresolved without additional evidence. |
149
+ | `bookkeeping` | No direct filesystem impact level. Track descriptor duplication/reuse, working directories, offsets, synchronization, and command-dependent `fcntl` behavior as context. |
150
+ | `connect_effect` | Decode the address family, IP address and port. A zero result is a connection on a stream socket and only a default peer on a datagram socket. `EINPROGRESS` is an attempt whose outcome this call does not report. A destination in a range the sandbox firewall rejects is a refused attempt. The address is never a host name: a name shown beside it comes from DNS evidence and is a best match. No payload is captured. |
151
+ | `listen_effect` | Success means the process accepts connections on the bound address. Nothing outside the sandbox network is routed to it. |
152
+ | `identity_effect` | Record the requested IDs and the result. Success changes the identity the process acts as; the sandbox has no capabilities, so a successful change away from its one user is unexpected, and a failure is an attempt. |
153
+ | `process_lifecycle` | gVisor's clone, exec and exit points report every task, program start and exit, whichever syscall caused it. A successful exec proves a program started, not what it did; a zero result on the exec syscall point is not treated as success. Keep arguments as observed and, of the environment, only the two `RAYTRACE_` markers. |
154
+ | `not_classified` | The call is listed and grouped, and nothing is collected for it. No fact records its use and none rules it out. |
155
+
156
+ For example, successful `unlinkat` can display **L3 · Delete · Succeeded**;
157
+ `EACCES` can display **L3 · Delete · Failed: permission denied**. Neither label
158
+ requires a new process or PID. A failed operation must not appear in a list of
159
+ confirmed file changes.
160
+
161
+ Store the supplied pathname and directory base independently; do not label a
162
+ lexically joined path as fully resolved through symlinks. Descriptor identities
163
+ must account for reuse and inheritance. Unresolved target types/paths must stay
164
+ explicit. Preserve both source and destination for rename/link/copy events.
165
+
166
+ ## Boundaries and validation
167
+
168
+ A row is not a completeness guarantee, and a default level is not evidence of
169
+ success. What the captured set does not see:
170
+
171
+ - **Bytes read or written.** An open for reading is recorded as a read of the
172
+ file; whether a file changed comes from comparing it before and after.
173
+ - **Memory-mapped writes and `io_uring`.** Both change files without the
174
+ ordinary calls. The file still has to be opened, and the before/after
175
+ comparison still sees the change.
176
+ - **Datagrams sent without `connect`.** `sendto` and `sendmsg` name their own
177
+ destination and are not captured. The firewall still applies, and DNS is seen
178
+ by the host resolver.
179
+ - **Paths of `watcher` calls.** A refused delete or rename is known by process
180
+ and time, not by file.
181
+ - **Calls gVisor does not implement** (`support = 'unsupported'` in
182
+ `syscall_numbers`) fail inside the sandbox whatever the catalog says.
183
+
184
+ No buffer contents or environment values are required by these rules. This
185
+ catalog does not change existing evidence storage, retention, or redaction.
186
+
187
+ Run isolated validation, including repeat import and constraints:
188
+
189
+ ```sh
190
+ python3 -B -m unittest discover -s worker/gvisor -p 'test_syscall_catalog.py'
191
+ ```
192
+
193
+ Semantic references: [Linux syscall inventory](https://man7.org/linux/man-pages/man2/syscalls.2.html),
194
+ [open](https://man7.org/linux/man-pages/man2/open.2.html),
195
+ [rename](https://man7.org/linux/man-pages/man2/rename.2.html),
196
+ [memory mappings](https://man7.org/linux/man-pages/man2/mmap.2.html), and
197
+ [gVisor SecCheck](https://github.com/google/gvisor/blob/release-20260817.0/pkg/sentry/seccheck/README.md).