axstack 0.66.0 → 0.68.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 (92) hide show
  1. package/README.md +3 -3
  2. package/docs/host-operations.md +8 -8
  3. package/docs/installation.md +8 -8
  4. package/docs/workflows.md +5 -9
  5. package/package.json +2 -2
  6. package/skills/axstack/references/automations.md +11 -19
  7. package/skills/axstack/references/autopilot.md +1 -0
  8. package/skills/axstack/references/candidate-publication.md +7 -12
  9. package/skills/axstack/references/capture-receipts.md +22 -0
  10. package/skills/axstack/references/fleet-verification.md +3 -3
  11. package/skills/axstack/references/lifecycle.md +2 -2
  12. package/skills/axstack/references/live-run.md +59 -0
  13. package/skills/axstack/references/pr-shape.md +14 -9
  14. package/skills/axstack/references/review-manager-prompt.md +37 -19
  15. package/skills/axstack/references/run-record.md +2 -2
  16. package/skills/axstack/references/schedule-policy.json +123 -0
  17. package/skills/axstack/references/t3-runtime.md +5 -5
  18. package/skills/axstack/references/test-audit-weekly.md +1 -2
  19. package/skills/axstack/references/ui-verification.md +5 -3
  20. package/skills/axstack/references/workspace-hygiene.md +12 -3
  21. package/skills/axstack/sandbox/Dockerfile +28 -0
  22. package/skills/axstack/sandbox/host-execution.md +14 -0
  23. package/skills/axstack/sandbox/inventory.json +503 -0
  24. package/skills/axstack/sandbox/launcher-capture.js +63 -0
  25. package/skills/axstack/sandbox/launcher-contract.schema.json +341 -0
  26. package/skills/axstack/sandbox/launcher-contracts.js +35 -0
  27. package/skills/axstack/sandbox/launcher-docker.js +75 -0
  28. package/skills/axstack/sandbox/launcher-host-budget.json +10 -0
  29. package/skills/axstack/sandbox/launcher-host.js +165 -0
  30. package/skills/axstack/sandbox/launcher-host.json +5 -0
  31. package/skills/axstack/sandbox/launcher-image.json +4 -0
  32. package/skills/axstack/sandbox/launcher-interface.md +7 -0
  33. package/skills/axstack/sandbox/launcher-policy.js +135 -0
  34. package/skills/axstack/sandbox/launcher-policy.json +121 -0
  35. package/skills/axstack/sandbox/launcher-runtime.js +157 -0
  36. package/skills/axstack/sandbox/launcher-source.js +72 -0
  37. package/skills/axstack/sandbox/launcher.js +106 -0
  38. package/skills/axstack/sandbox/network-address.js +39 -0
  39. package/skills/axstack/sandbox/network-firewall.js +81 -0
  40. package/skills/axstack/sandbox/network-rules.js +86 -0
  41. package/skills/axstack/sandbox/network-runtime.js +109 -0
  42. package/skills/axstack/sandbox/network.js +49 -0
  43. package/skills/axstack/sandbox/probes-android-platform.xml +17 -0
  44. package/skills/axstack/sandbox/probes-check.js +185 -0
  45. package/skills/axstack/sandbox/probes-exec.js +20 -0
  46. package/skills/axstack/sandbox/probes-image-build.js +129 -0
  47. package/skills/axstack/sandbox/probes-image-pins.json +370 -0
  48. package/skills/axstack/sandbox/probes-link-local.js +25 -0
  49. package/skills/axstack/sandbox/probes-storage.js +33 -0
  50. package/skills/axstack/sandbox/probes-udp.js +44 -0
  51. package/skills/axstack/sandbox/probes.js +239 -0
  52. package/skills/axstack/sandbox/proxy-command.js +6 -0
  53. package/skills/axstack/sandbox/proxy-config.json +9 -0
  54. package/skills/axstack/sandbox/proxy-dns.js +114 -0
  55. package/skills/axstack/sandbox/proxy-policy.js +22 -0
  56. package/skills/axstack/sandbox/proxy.js +119 -0
  57. package/skills/axstack/sandbox/reap.md +7 -0
  58. package/skills/axstack/sandbox/sidecars.json +153 -0
  59. package/skills/axstack/sandbox/storage-checks.js +39 -0
  60. package/skills/axstack/sandbox/storage-cleanup.js +49 -0
  61. package/skills/axstack/sandbox/storage-execution.js +110 -0
  62. package/skills/axstack/sandbox/storage-plan.js +78 -0
  63. package/skills/axstack/sandbox/storage-support.js +91 -0
  64. package/skills/axstack/sandbox/storage.js +75 -0
  65. package/skills/axstack/scripts/archive-evidence.js +2 -2
  66. package/skills/axstack/scripts/capture-identity.js +122 -0
  67. package/skills/axstack/scripts/check-run.js +248 -0
  68. package/skills/axstack/scripts/check-staged-file-tokens.js +6 -3
  69. package/skills/axstack/scripts/command-capture.js +81 -0
  70. package/skills/axstack/scripts/evidence-inspector.js +182 -0
  71. package/skills/axstack/scripts/git-argv.js +6 -0
  72. package/skills/axstack/scripts/image-evidence.js +183 -0
  73. package/skills/axstack/scripts/pr-shape.js +206 -22
  74. package/skills/axstack/scripts/readiness-run.js +3 -75
  75. package/skills/axstack/scripts/readiness.js +2 -2
  76. package/skills/axstack/scripts/run-init.js +13 -11
  77. package/skills/axstack/scripts/schedule-drift.js +132 -0
  78. package/skills/axstack/scripts/scratch.js +201 -0
  79. package/skills/axstack-audit/SKILL.md +2 -0
  80. package/skills/axstack-audit/references/record.md +1 -1
  81. package/skills/axstack-explain/references/inline-pages.md +8 -4
  82. package/skills/axstack-implement/SKILL.md +6 -5
  83. package/skills/axstack-review/references/candidate-brief.md +12 -21
  84. package/skills/axstack-review/references/codebase-brief.md +1 -0
  85. package/skills/axstack-review/references/codebase-mode.md +4 -1
  86. package/skills/axstack-review/references/codebase-report.md +2 -1
  87. package/skills/axstack-review/references/review-candidate.md +2 -2
  88. package/skills/axstack-review/references/review-receipt.md +8 -3
  89. package/skills/axstack-verify/SKILL.md +18 -5
  90. package/skills/axstack-watch/references/proven-verification.md +3 -2
  91. package/skills/axstack-watch/references/readiness.md +56 -61
  92. package/skills/voa/references/verification.md +5 -2
@@ -0,0 +1,63 @@
1
+ import { lstatSync, readFileSync, readdirSync, realpathSync, writeFileSync } from 'node:fs';
2
+ import { runCommand } from '../scripts/command-capture.js';
3
+ import { captureTerms, sha256, sourceIdentity } from '../scripts/capture-identity.js';
4
+ import { hold } from './launcher-policy.js';
5
+ import { checkFilesystem } from './probes-storage.js';
6
+
7
+ export function receiptBytes(evidenceDir) {
8
+ let bytes = 0;
9
+ for (const name of readdirSync(evidenceDir)) {
10
+ const s = lstatSync(`${evidenceDir}/${name}`);
11
+ if (!s.isFile() || s.isSymbolicLink()) hold('evidence directory contains non-regular entries');
12
+ if (!name.endsWith('.log')) bytes += s.size;
13
+ }
14
+ return bytes;
15
+ }
16
+ function workloadExec(p, role, argv) {
17
+ const c = p.containers.find(c => c.role === role);
18
+ return ['docker', 'exec', '--user', p.policy.user, '--workdir', '/work', c.id, '/bin/sh', '-c', 'cp -R /source/. /work/ && chmod -R u+w /work && cd /work && exec "$@"', 'axstack', ...argv];
19
+ }
20
+ export function verifyCapture(path, p, argv) {
21
+ const bytes = readFileSync(path), step = JSON.parse(bytes.toString());
22
+ const expected = { repository: p.request.repository, head: p.request.head, base: p.request.base };
23
+ const terms = captureTerms(step, expected);
24
+ if (terms.some(t => t.status !== 'pass')) hold('W3-1 capture identity/log/source/proof incomplete');
25
+ const role = step.kind === 'sandbox-fetch' ? 'fetch' : 'test';
26
+ if (step.cwd !== realpathSync(p.request.repo) || JSON.stringify(step.argv) !== JSON.stringify(argv) || JSON.stringify(step.spawnArgv) !== JSON.stringify(workloadExec(p, role, argv)) || step.sandboxImageDigest !== p.containers.find(c => c.role === 'test').image.split('@')[1] || step.tool.name !== 'axstack-sandbox' || step.tool.version !== '1.0.0') hold('capture does not match effective sandbox plan');
27
+ return { schemaVersion: 1, receiptPath: realpathSync(path), receiptSha256: sha256(bytes) };
28
+ }
29
+ export async function recordCapture(p, evidenceDir, active, checkStorage = role => checkFilesystem({ storage: p.storage, containerId: p.containers.find(c => c.role === role).id })) {
30
+ const registryPlanBytes = new TextEncoder().encode(`${JSON.stringify(p)}\n`).length;
31
+ if (receiptBytes(evidenceDir) + registryPlanBytes > p.policy.receiptMaxBytes) hold('insufficient receipt directory budget');
32
+ const initial = sourceIdentity(p.request);
33
+ const binding = { ...p.request, snapshot: initial.snapshot, tool: { name: 'axstack-sandbox', version: '1.0.0' }, sandboxImageDigest: p.containers.find(c => c.role === 'test').image.split('@')[1], writableRoots: [p.sourceExport.path] };
34
+ const commands = [], state = { active: null, signal: null };
35
+ const started = performance.now();
36
+ let used = 0, last;
37
+ for (const role of ['fetch', 'test']) {
38
+ const argv = role === 'fetch' ? p.request.fetchArgv : p.request.testArgv;
39
+ if (!argv.length) continue;
40
+ await checkStorage(role);
41
+ active();
42
+ const spawnArgv = workloadExec(p, role, argv);
43
+ const reserveBytes = 16384 + 4 * new TextEncoder().encode(JSON.stringify({ binding, argv, spawnArgv, initial })).length;
44
+ // W3-1 bounds log writes; reserve metadata before its host-side writer runs.
45
+ if (receiptBytes(evidenceDir) + registryPlanBytes + reserveBytes > p.policy.receiptMaxBytes) hold('insufficient host capture receipt reserve');
46
+ const logBytes = role === 'fetch' ? Math.floor(p.policy.captureMaxBytes / 2) : p.policy.captureMaxBytes - used;
47
+ const remainingMs = Math.max(1, p.policy.wallTimeSeconds * 1000 - (performance.now() - started));
48
+ last = await runCommand(commands, { evidence: evidenceDir }, `sandbox-${role}`, argv, p.request.repo,
49
+ { PATH: '/usr/sbin:/usr/bin:/sbin:/bin', LANG: 'C', HOME: '/nonexistent', DOCKER_HOST: 'unix:///var/run/docker.sock', DOCKER_CONFIG: '/nonexistent' },
50
+ { timeoutMs: remainingMs, logBytes }, state, spawnArgv, binding);
51
+ used += last.logBytes;
52
+ if (receiptBytes(evidenceDir) + registryPlanBytes > p.policy.receiptMaxBytes) hold('host capture/receipt directory cap exceeded');
53
+ active();
54
+ const reference = verifyCapture(last.receiptPath, p, argv);
55
+ if (last.exitCode !== 0 || role === 'test') return reference;
56
+ }
57
+ hold('test capture unavailable');
58
+ }
59
+ export async function saveReceipt(receipt, evidenceDir, p) {
60
+ const bytes = `${JSON.stringify(receipt)}\n`;
61
+ if (receiptBytes(evidenceDir) + new TextEncoder().encode(bytes).length > p.policy.receiptMaxBytes) hold('sandbox envelope exceeds receipt directory cap');
62
+ writeFileSync(`${evidenceDir}/${p.runId}-sandbox.json`, bytes, { flag: 'wx', mode: 0o600 });
63
+ }
@@ -0,0 +1,341 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://axstack.dev/schemas/sandbox-contract-v1.json",
4
+ "$ref": "#/$defs/plan",
5
+ "$defs": {
6
+ "term": {
7
+ "type": "object",
8
+ "required": ["id", "status", "evidence"],
9
+ "additionalProperties": false,
10
+ "properties": {
11
+ "id": {"type": "string", "minLength": 1},
12
+ "status": {"enum": ["pass", "fail", "unknown", "n/a"]},
13
+ "evidence": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1}
14
+ }
15
+ },
16
+ "owner": {
17
+ "type": "object",
18
+ "required": ["label", "runId", "pid", "startTimeTicks", "bootId"],
19
+ "additionalProperties": false,
20
+ "properties": {
21
+ "label": {"const": "axstack.sandbox"},
22
+ "runId": {"type": "string", "minLength": 1},
23
+ "pid": {"type": "integer", "minimum": 1},
24
+ "startTimeTicks": {"type": "string", "minLength": 1},
25
+ "bootId": {"type": "string", "minLength": 1}
26
+ }
27
+ },
28
+ "hostBinding": {
29
+ "type": "object",
30
+ "required": ["schemaVersion", "hostname", "machineIdSha256"],
31
+ "additionalProperties": false,
32
+ "properties": {
33
+ "schemaVersion": {"const": 1},
34
+ "hostname": {"const": "axat-vps"},
35
+ "machineIdSha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}
36
+ }
37
+ },
38
+ "hostBudget": {
39
+ "type": "object",
40
+ "required": ["schemaVersion", "host", "inventoryDate", "maxConcurrent", "memoryBudgetBytes", "diskBudgetBytes", "reserveMemoryBytes", "reserveDiskBytes"],
41
+ "additionalProperties": false,
42
+ "properties": {
43
+ "schemaVersion": {"const": 1},
44
+ "host": {"const": "axat-vps"},
45
+ "inventoryDate": {"type": "string", "pattern": "^\\d{4}-\\d{2}-\\d{2}$"},
46
+ "maxConcurrent": {"const": 2},
47
+ "memoryBudgetBytes": {"type": "integer", "minimum": 1},
48
+ "diskBudgetBytes": {"type": "integer", "minimum": 1},
49
+ "reserveMemoryBytes": {"type": "integer", "minimum": 1},
50
+ "reserveDiskBytes": {"type": "integer", "minimum": 1}
51
+ }
52
+ },
53
+ "containerCaps": {
54
+ "type": "object",
55
+ "required": ["cpus", "memoryBytes", "memorySwapBytes", "pids", "logMaxBytes", "logMaxFiles", "logDriver", "restart"],
56
+ "additionalProperties": false,
57
+ "properties": {
58
+ "cpus": {"type": "number", "exclusiveMinimum": 0},
59
+ "memoryBytes": {"type": "integer", "minimum": 1},
60
+ "memorySwapBytes": {"type": "integer", "minimum": 1},
61
+ "pids": {"type": "integer", "minimum": 1},
62
+ "logMaxBytes": {"type": "integer", "minimum": 1},
63
+ "logMaxFiles": {"const": 1},
64
+ "logDriver": {"const": "local"},
65
+ "restart": {"const": "no"}
66
+ }
67
+ },
68
+ "environment": {
69
+ "type": "object",
70
+ "required": ["name", "value"],
71
+ "additionalProperties": false,
72
+ "properties": {
73
+ "name": {"type": "string", "minLength": 1},
74
+ "value": {"type": "string"}
75
+ }
76
+ },
77
+ "launchPolicy": {
78
+ "type": "object",
79
+ "required": ["schemaVersion", "user", "environment", "workloadCaps", "proxyCaps", "sidecarCaps", "writableBytes", "dependencyBytes", "dependencyInodes", "sourceMaxBytes", "captureMaxBytes", "receiptMaxBytes", "wallTimeSeconds", "graceSeconds", "maxWallTimeSeconds"],
80
+ "additionalProperties": false,
81
+ "properties": {
82
+ "schemaVersion": {"const": 1},
83
+ "user": {"type": "string", "pattern": "^[1-9][0-9]*:[1-9][0-9]*$"},
84
+ "environment": {"type": "array", "items": {"$ref": "#/$defs/environment"}},
85
+ "workloadCaps": {"$ref": "#/$defs/containerCaps"},
86
+ "proxyCaps": {"$ref": "#/$defs/containerCaps"},
87
+ "sidecarCaps": {"$ref": "#/$defs/containerCaps"},
88
+ "writableBytes": {"type": "integer", "minimum": 1},
89
+ "dependencyBytes": {"type": "integer", "minimum": 1},
90
+ "dependencyInodes": {"type": "integer", "minimum": 1},
91
+ "sourceMaxBytes": {"type": "integer", "minimum": 1},
92
+ "captureMaxBytes": {"type": "integer", "minimum": 1},
93
+ "receiptMaxBytes": {"type": "integer", "minimum": 1},
94
+ "wallTimeSeconds": {"type": "integer", "minimum": 1},
95
+ "graceSeconds": {"type": "integer", "minimum": 1},
96
+ "maxWallTimeSeconds": {"type": "integer", "minimum": 1}
97
+ }
98
+ },
99
+ "proxyConfig": {
100
+ "type": "object",
101
+ "required": ["schemaVersion", "image", "allowlistFile", "allowlistPointer", "resolverIpv4", "resolverIpv6", "port"],
102
+ "additionalProperties": false,
103
+ "properties": {
104
+ "schemaVersion": {"const": 1},
105
+ "image": {"$ref": "#/$defs/image"},
106
+ "allowlistFile": {"const": "inventory.json"},
107
+ "allowlistPointer": {"const": "/registryAllowlist"},
108
+ "resolverIpv4": {"type": "string", "minLength": 1},
109
+ "resolverIpv6": {"type": "string", "minLength": 1},
110
+ "port": {"type": "integer", "minimum": 1}
111
+ }
112
+ },
113
+ "image": {"type": "string", "pattern": "^.+@sha256:[a-f0-9]{64}$"},
114
+ "tmpfs": {
115
+ "type": "object",
116
+ "required": ["path", "bytes", "uid", "gid", "mode", "noexec"],
117
+ "additionalProperties": false,
118
+ "properties": {
119
+ "path": {"type": "string", "minLength": 1},
120
+ "bytes": {"type": "integer", "minimum": 1},
121
+ "uid": {"type": "integer", "minimum": 1},
122
+ "gid": {"type": "integer", "minimum": 1},
123
+ "mode": {"type": "string", "minLength": 1},
124
+ "noexec": {"type": "boolean"}
125
+ }
126
+ },
127
+ "sidecar": {
128
+ "type": "object",
129
+ "required": ["id", "image", "argv", "declaredVolumes"],
130
+ "additionalProperties": false,
131
+ "properties": {
132
+ "id": {"type": "string", "minLength": 1},
133
+ "image": {"$ref": "#/$defs/image"},
134
+ "argv": {"type": "array", "items": {"type": "string", "minLength": 1}},
135
+ "declaredVolumes": {"type": "array", "items": {"$ref": "#/$defs/tmpfs"}}
136
+ }
137
+ },
138
+ "sidecars": {
139
+ "type": "object",
140
+ "required": ["schemaVersion", "images"],
141
+ "additionalProperties": false,
142
+ "properties": {
143
+ "schemaVersion": {"const": 1},
144
+ "images": {"type": "array", "items": {"$ref": "#/$defs/sidecar"}}
145
+ }
146
+ },
147
+ "network": {
148
+ "type": "object",
149
+ "required": ["id", "name", "interface", "profile", "internal", "subnets", "createArgv", "removeArgv"],
150
+ "additionalProperties": false,
151
+ "properties": {
152
+ "id": {"type": "string", "minLength": 1},
153
+ "name": {"type": "string", "minLength": 1},
154
+ "interface": {"type": "string", "minLength": 1},
155
+ "profile": {"enum": ["fetch", "service", "egress"]},
156
+ "internal": {"type": "boolean"},
157
+ "subnets": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
158
+ "createArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
159
+ "removeArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1}
160
+ }
161
+ },
162
+ "rule": {
163
+ "type": "object",
164
+ "required": ["id", "family", "table", "chain", "interfaces", "expression", "installArgv", "checkArgv", "removeArgv"],
165
+ "additionalProperties": false,
166
+ "properties": {
167
+ "id": {"type": "string", "minLength": 1},
168
+ "family": {"const": "inet"},
169
+ "table": {"const": "axstack_sandbox"},
170
+ "chain": {"type": "string", "minLength": 1},
171
+ "interfaces": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
172
+ "expression": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
173
+ "installArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
174
+ "checkArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
175
+ "removeArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1}
176
+ }
177
+ },
178
+ "container": {
179
+ "type": "object",
180
+ "required": ["id", "role", "image", "networkIds", "argv", "caps", "tmpfs"],
181
+ "additionalProperties": false,
182
+ "properties": {
183
+ "id": {"type": "string", "minLength": 1},
184
+ "role": {"enum": ["fetch", "test", "proxy", "sidecar", "probe"]},
185
+ "image": {"$ref": "#/$defs/image"},
186
+ "networkIds": {"type": "array", "items": {"type": "string", "minLength": 1}},
187
+ "argv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
188
+ "caps": {"$ref": "#/$defs/containerCaps"},
189
+ "tmpfs": {"type": "array", "items": {"$ref": "#/$defs/tmpfs"}}
190
+ }
191
+ },
192
+ "step": {
193
+ "type": "object",
194
+ "required": ["id", "phase", "executor", "containerId", "argv", "path"],
195
+ "additionalProperties": false,
196
+ "properties": {
197
+ "id": {"type": "string", "minLength": 1},
198
+ "phase": {"enum": ["prepare", "check", "cleanup"]},
199
+ "executor": {"enum": ["host", "container"]},
200
+ "containerId": {"type": ["string", "null"]},
201
+ "argv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
202
+ "path": {"type": "string", "minLength": 1}
203
+ }
204
+ },
205
+ "storage": {
206
+ "type": "object",
207
+ "required": ["imageFile", "volumeName", "filesystem", "bytes", "inodes", "mountOptions", "keepFreeLoops", "autoclear", "steps", "checks", "cleanup"],
208
+ "additionalProperties": false,
209
+ "properties": {
210
+ "imageFile": {"type": "string", "minLength": 1},
211
+ "volumeName": {"type": "string", "minLength": 1},
212
+ "filesystem": {"const": "ext4"},
213
+ "bytes": {"type": "integer", "minimum": 1},
214
+ "inodes": {"type": "integer", "minimum": 1},
215
+ "mountOptions": {"const": ["nosuid", "nodev"]},
216
+ "keepFreeLoops": {"const": 1},
217
+ "autoclear": {"const": false},
218
+ "steps": {"type": "array", "items": {"$ref": "#/$defs/step"}, "minItems": 1},
219
+ "checks": {"type": "array", "items": {"$ref": "#/$defs/step"}, "minItems": 1},
220
+ "cleanup": {"type": "array", "items": {"$ref": "#/$defs/step"}, "minItems": 1}
221
+ }
222
+ },
223
+ "target": {
224
+ "type": "object",
225
+ "required": ["id", "kind", "address", "port", "protocol", "evidence"],
226
+ "additionalProperties": false,
227
+ "properties": {
228
+ "id": {"type": "string", "minLength": 1},
229
+ "kind": {"enum": ["host-listener", "host-address", "gateway", "other-container", "tailnet", "fixed", "dns"]},
230
+ "address": {"type": "string", "minLength": 1},
231
+ "port": {"type": ["integer", "null"]},
232
+ "protocol": {"enum": ["tcp", "udp", "icmp"]},
233
+ "evidence": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1}
234
+ }
235
+ },
236
+ "enumeration": {
237
+ "type": "object",
238
+ "required": ["runId", "terms", "targets"],
239
+ "additionalProperties": false,
240
+ "properties": {
241
+ "runId": {"type": "string", "minLength": 1},
242
+ "terms": {"type": "array", "items": {"$ref": "#/$defs/term"}, "minItems": 1},
243
+ "targets": {"type": "array", "items": {"$ref": "#/$defs/target"}, "minItems": 1}
244
+ }
245
+ },
246
+ "probe": {
247
+ "type": "object",
248
+ "required": ["id", "containerId", "position", "targetIds", "argv", "expected"],
249
+ "additionalProperties": false,
250
+ "properties": {
251
+ "id": {"type": "string", "minLength": 1},
252
+ "containerId": {"type": "string", "minLength": 1},
253
+ "position": {"enum": ["fetch", "none", "service", "proxy-bypassed"]},
254
+ "targetIds": {"type": "array", "items": {"type": "string", "minLength": 1}},
255
+ "argv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
256
+ "expected": {"enum": ["deny", "allow", "non-root-empty-caps", "capped-filesystem"]}
257
+ }
258
+ },
259
+ "networkPlan": {
260
+ "type": "object",
261
+ "required": ["networks", "rules", "proxy"],
262
+ "additionalProperties": false,
263
+ "properties": {
264
+ "networks": {"type": "array", "items": {"$ref": "#/$defs/network"}},
265
+ "rules": {"type": "array", "items": {"$ref": "#/$defs/rule"}},
266
+ "proxy": {"type": "object", "required": ["image", "networkIds", "environment"], "additionalProperties": false, "properties": {"image": {"$ref": "#/$defs/image"}, "networkIds": {"type": "array", "items": {"type": "string", "minLength": 1}}, "environment": {"type": "array", "items": {"$ref": "#/$defs/environment"}}}}
267
+ }
268
+ },
269
+ "caps": {
270
+ "type": "object",
271
+ "required": ["maxConcurrent", "perRunMemoryBytes", "perRunDiskBytes", "sourceMaxBytes", "captureMaxBytes", "receiptMaxBytes", "wallTimeSeconds", "graceSeconds"],
272
+ "additionalProperties": false,
273
+ "properties": {
274
+ "maxConcurrent": {"const": 2},
275
+ "perRunMemoryBytes": {"type": "integer", "minimum": 1},
276
+ "perRunDiskBytes": {"type": "integer", "minimum": 1},
277
+ "sourceMaxBytes": {"type": "integer", "minimum": 1},
278
+ "captureMaxBytes": {"type": "integer", "minimum": 1},
279
+ "receiptMaxBytes": {"type": "integer", "minimum": 1},
280
+ "wallTimeSeconds": {"type": "integer", "minimum": 1},
281
+ "graceSeconds": {"type": "integer", "minimum": 1}
282
+ }
283
+ },
284
+ "request": {
285
+ "type": "object",
286
+ "required": ["repo", "repository", "head", "base", "pr", "fetchArgv", "testArgv", "sidecarIds"],
287
+ "additionalProperties": false,
288
+ "properties": {
289
+ "repo": {"type": "string", "minLength": 1},
290
+ "repository": {"type": "string", "minLength": 1},
291
+ "head": {"type": "string", "minLength": 1},
292
+ "base": {"type": "string", "minLength": 1},
293
+ "pr": {"type": ["string", "null"]},
294
+ "fetchArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
295
+ "testArgv": {"type": "array", "items": {"type": "string", "minLength": 1}, "minItems": 1},
296
+ "sidecarIds": {"type": "array", "items": {"type": "string", "minLength": 1}}
297
+ }
298
+ },
299
+ "plan": {
300
+ "type": "object",
301
+ "required": ["schemaVersion", "runId", "owner", "request", "hostBinding", "hostBudget", "policy", "sourceExport", "containers", "networks", "rules", "storage", "enumeration", "probes", "caps", "terms"],
302
+ "additionalProperties": false,
303
+ "properties": {
304
+ "schemaVersion": {"const": 1},
305
+ "runId": {"type": "string", "minLength": 1},
306
+ "owner": {"$ref": "#/$defs/owner"},
307
+ "request": {"$ref": "#/$defs/request"},
308
+ "hostBinding": {"$ref": "#/$defs/hostBinding"},
309
+ "hostBudget": {"$ref": "#/$defs/hostBudget"},
310
+ "policy": {"$ref": "#/$defs/launchPolicy"},
311
+ "sourceExport": {"type": "object", "required": ["path", "commit", "maxBytes"], "additionalProperties": false, "properties": {"path": {"type": "string", "minLength": 1}, "commit": {"type": "string", "minLength": 1}, "maxBytes": {"type": "integer", "minimum": 1}}},
312
+ "containers": {"type": "array", "items": {"$ref": "#/$defs/container"}, "minItems": 1},
313
+ "networks": {"type": "array", "items": {"$ref": "#/$defs/network"}},
314
+ "rules": {"type": "array", "items": {"$ref": "#/$defs/rule"}},
315
+ "storage": {"$ref": "#/$defs/storage"},
316
+ "enumeration": {"$ref": "#/$defs/enumeration"},
317
+ "probes": {"type": "array", "items": {"$ref": "#/$defs/probe"}, "minItems": 1},
318
+ "caps": {"$ref": "#/$defs/caps"},
319
+ "terms": {"type": "array", "items": {"$ref": "#/$defs/term"}, "minItems": 1}
320
+ }
321
+ },
322
+ "receipt": {
323
+ "type": "object",
324
+ "required": ["schemaVersion", "runId", "planSha256", "owner", "hostBinding", "engineVersion", "imageDigests", "effectivePolicy", "probeResults", "terms", "capture"],
325
+ "additionalProperties": false,
326
+ "properties": {
327
+ "schemaVersion": {"const": 1},
328
+ "runId": {"type": "string", "minLength": 1},
329
+ "planSha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"},
330
+ "owner": {"$ref": "#/$defs/owner"},
331
+ "hostBinding": {"$ref": "#/$defs/hostBinding"},
332
+ "engineVersion": {"type": "string", "minLength": 1},
333
+ "imageDigests": {"type": "array", "items": {"type": "string", "pattern": "^sha256:[a-f0-9]{64}$"}, "minItems": 1},
334
+ "effectivePolicy": {"$ref": "#/$defs/launchPolicy"},
335
+ "probeResults": {"type": "array", "items": {"$ref": "#/$defs/term"}, "minItems": 1},
336
+ "terms": {"type": "array", "items": {"$ref": "#/$defs/term"}, "minItems": 1},
337
+ "capture": {"type": "object", "required": ["schemaVersion", "receiptPath", "receiptSha256"], "additionalProperties": false, "properties": {"schemaVersion": {"const": 1}, "receiptPath": {"type": "string", "minLength": 1}, "receiptSha256": {"type": "string", "pattern": "^[a-f0-9]{64}$"}}}
338
+ }
339
+ }
340
+ }
341
+ }
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Shared interface v1. JSON wire shapes are authoritative in launcher-contract.schema.json.
3
+ * B–E may add private helpers; changes to these shared signatures belong to Int.
4
+ * Implementations: invalid input/I/O errors throw Error (CLI exit 1); failed/unknown
5
+ * containment throws Error with sandboxHold:true (CLI exit 2), before untrusted code.
6
+ * Fact results use Term; they never grant review, merge or execution authority.
7
+ * @typedef {{id:string, status:'pass'|'fail'|'unknown'|'n/a', evidence:string[]}} Term
8
+ * @typedef {{label:'axstack.sandbox', runId:string, pid:number, startTimeTicks:string, bootId:string}} Owner
9
+ * @typedef {{schemaVersion:1, hostname:'axat-vps', machineIdSha256:string}} HostBinding
10
+ * @typedef {{schemaVersion:1, host:'axat-vps', inventoryDate:string, maxConcurrent:2, memoryBudgetBytes:number, diskBudgetBytes:number, reserveMemoryBytes:number, reserveDiskBytes:number}} HostBudget
11
+ * @typedef {{cpus:number, memoryBytes:number, memorySwapBytes:number, pids:number, logMaxBytes:number, logMaxFiles:1, logDriver:'local', restart:'no'}} ContainerCaps
12
+ * @typedef {{name:string, value:string}} Environment
13
+ * @typedef {{path:string, bytes:number, uid:number, gid:number, mode:string, noexec:boolean}} Tmpfs
14
+ * @typedef {{schemaVersion:1, user:string, environment:Environment[], workloadCaps:ContainerCaps, proxyCaps:ContainerCaps, sidecarCaps:ContainerCaps, writableBytes:number, dependencyBytes:number, dependencyInodes:number, sourceMaxBytes:number, captureMaxBytes:number, receiptMaxBytes:number, wallTimeSeconds:number, graceSeconds:number, maxWallTimeSeconds:number}} LaunchPolicy
15
+ * @typedef {{schemaVersion:1, image:string, allowlistFile:'inventory.json', allowlistPointer:'/registryAllowlist', resolverIpv4:string, resolverIpv6:string, port:number}} ProxyConfig
16
+ * @typedef {{id:string, image:string, argv:string[], declaredVolumes:Tmpfs[]}} Sidecar
17
+ * @typedef {{schemaVersion:1, images:Sidecar[]}} Sidecars
18
+ * @typedef {{id:string, name:string, interface:string, profile:'fetch'|'service'|'egress', internal:boolean, subnets:string[], createArgv:string[], removeArgv:string[]}} Network
19
+ * @typedef {{id:string, family:'inet', table:'axstack_sandbox', chain:string, interfaces:string[], expression:string[], installArgv:string[], checkArgv:string[], removeArgv:string[]}} Rule
20
+ * @typedef {{networks:Network[], rules:Rule[], proxy:{image:string, networkIds:string[], environment:Environment[]}}} NetworkPlan
21
+ * @typedef {{id:string, role:'fetch'|'test'|'proxy'|'sidecar'|'probe', image:string, networkIds:string[], argv:string[], caps:ContainerCaps, tmpfs:Tmpfs[]}} Container
22
+ * @typedef {{id:string, phase:'prepare'|'check'|'cleanup', executor:'host'|'container', containerId:string|null, argv:string[], path:string}} Step
23
+ * @typedef {{imageFile:string, volumeName:string, filesystem:'ext4', bytes:number, inodes:number, mountOptions:['nosuid','nodev'], keepFreeLoops:1, autoclear:false, steps:Step[], checks:Step[], cleanup:Step[]}} StoragePlan
24
+ * @typedef {{id:string, kind:'host-listener'|'host-address'|'gateway'|'other-container'|'tailnet'|'fixed'|'dns', address:string, port:number|null, protocol:'tcp'|'udp'|'icmp', evidence:string[]}} Target
25
+ * @typedef {{runId:string, terms:Term[], targets:Target[]}} Enumeration
26
+ * @typedef {{id:string, containerId:string, position:'fetch'|'none'|'service'|'proxy-bypassed', targetIds:string[], argv:string[], expected:'deny'|'allow'|'non-root-empty-caps'|'capped-filesystem'}} Probe
27
+ * @typedef {{maxConcurrent:2, perRunMemoryBytes:number, perRunDiskBytes:number, sourceMaxBytes:number, captureMaxBytes:number, receiptMaxBytes:number, wallTimeSeconds:number, graceSeconds:number}} Caps
28
+ * @typedef {{repo:string, repository:string, head:string, base:string, pr:string|null, fetchArgv:string[], testArgv:string[], sidecarIds:string[]}} Request
29
+ * @typedef {{schemaVersion:1, runId:string, owner:Owner, request:Request, hostBinding:HostBinding, hostBudget:HostBudget, policy:LaunchPolicy, sourceExport:{path:string, commit:string, maxBytes:number}, containers:Container[], networks:Network[], rules:Rule[], storage:StoragePlan, enumeration:Enumeration, probes:Probe[], caps:Caps, terms:Term[]}} Plan
30
+ * @typedef {{schemaVersion:1, runId:string, planSha256:string, owner:Owner, hostBinding:HostBinding, engineVersion:string, imageDigests:string[], effectivePolicy:LaunchPolicy, probeResults:Term[], terms:Term[], capture:{schemaVersion:1, receiptPath:string, receiptSha256:string}}} Receipt
31
+ * @typedef {{hostBinding:HostBinding, hostBudget:HostBudget, policy:LaunchPolicy, proxy:ProxyConfig, sidecars:Sidecars, workloadImage:string, registryAllowlist:string[], ownedDir:string}} Assets
32
+ * @typedef {{hostname:string, machineIdSha256:string, freeMemoryBytes:number, freeDiskBytes:number, addresses:string[], terms:Term[]}} HostFacts
33
+ * @typedef {{runId:string, owner:Owner, request:Request, assets:Assets, host:HostFacts, enumeration:Enumeration}} PlanInput
34
+ */
35
+ export {};
@@ -0,0 +1,75 @@
1
+ import { fact, hold } from './launcher-policy.js';
2
+
3
+ function canonicalImage(reference) {
4
+ const [repository, digest] = reference.split('@');
5
+ const parts = repository.split('/');
6
+ if (!parts[0].includes('.') && !parts[0].includes(':') && parts[0] !== 'localhost') parts.unshift('docker.io');
7
+ if (parts[0] === 'docker.io' && parts.length === 2) parts.splice(1, 0, 'library');
8
+ return `${parts.join('/')}@${digest}`;
9
+ }
10
+
11
+ export function dockerObservers(execute) {
12
+ const inspect = async (kind, id) => {
13
+ const r = await execute(['docker', kind, 'inspect', id]);
14
+ if (r.exitCode !== 0) {
15
+ if (/No such (container|object|image)/i.test(r.stderr)) return null;
16
+ hold(`cannot inspect ${kind} ${id}`);
17
+ }
18
+ try { const [item] = JSON.parse(r.stdout); if (item) return item; } catch { /* Unknown is a hold. */ }
19
+ hold(`incomplete ${kind} inspection ${id}`);
20
+ };
21
+ function owned(item, owner) {
22
+ const labels = item.Config?.Labels;
23
+ return labels?.['axstack.sandbox'] === 'true' && Object.entries(owner).every(([key, value]) => labels[`axstack.sandbox.${key}`] === String(value));
24
+ }
25
+ return {
26
+ async inspectImages(p) {
27
+ const volumes = {};
28
+ for (const c of p.containers) {
29
+ if (Object.hasOwn(volumes, c.image)) continue;
30
+ const image = await inspect('image', c.image);
31
+ if (!image?.Config || !image.RepoDigests?.some(reference => canonicalImage(reference) === canonicalImage(c.image))) hold(`image pin/config unavailable: ${c.image}`);
32
+ volumes[c.image] = Object.keys(image.Config?.Volumes ?? {});
33
+ }
34
+ return volumes;
35
+ },
36
+ async removeContainer(owner, c) {
37
+ const item = await inspect('container', c.id);
38
+ if (!item) return;
39
+ if (!owned(item, owner)) hold(`refuse unlabelled/foreign container ${c.id}`);
40
+ await execute(['docker', 'rm', '--force', c.id]);
41
+ },
42
+ async containersGone(p) {
43
+ for (const c of p.containers) if (await inspect('container', c.id)) return false;
44
+ return true;
45
+ },
46
+ async inspectMounts(p) {
47
+ const terms = [];
48
+ for (const c of p.containers) {
49
+ const item = await inspect('container', c.id);
50
+ if (!item || !owned(item, p.owner)) hold(`container identity missing: ${c.id}`);
51
+ if (!Array.isArray(item.Mounts)) hold(`mount observation unavailable: ${c.id}`);
52
+ for (const t of c.tmpfs) {
53
+ const expected = `rw,nosuid,nodev,${t.noexec ? 'noexec' : 'exec'},size=${t.bytes},uid=${t.uid},gid=${t.gid},mode=${t.mode}`;
54
+ if (item.HostConfig?.Tmpfs?.[t.path] !== expected) hold(`missing/changed capped tmpfs: ${c.id} ${t.path}`);
55
+ }
56
+ if (['fetch', 'test'].includes(c.role)) {
57
+ if (!item.Mounts.some(m => m.Type === 'bind' && m.Source === p.sourceExport.path && m.Destination === '/source' && m.RW === false)) hold(`source mount missing: ${c.id}`);
58
+ if (!item.Mounts.some(m => m.Type === 'volume' && m.Name === p.storage.volumeName && m.Destination === '/dependencies' && m.RW === (c.role === 'fetch'))) hold(`capped dependency mount missing/changed: ${c.id}`);
59
+ }
60
+ for (const m of item.Mounts) {
61
+ if (m.Type === 'volume' && !(m.Name === p.storage.volumeName && m.Destination === '/dependencies' && ['fetch', 'test'].includes(c.role))) hold(`uncreated volume mount: ${c.id} ${m.Destination}`);
62
+ if (m.Type === 'tmpfs' && !c.tmpfs.some(t => t.path === m.Destination)) hold(`unplanned tmpfs: ${c.id}`);
63
+ if (m.Type === 'bind' && !(m.Source === p.sourceExport.path && m.Destination === '/source' && m.RW === false)) hold(`unplanned bind mount: ${c.id}`);
64
+ }
65
+ terms.push(fact(`mounts-${c.id}`, 'pass', 'all volume mounts are launcher-created; declared VOLUME paths use capped tmpfs'));
66
+ }
67
+ return terms;
68
+ },
69
+ async engineVersion() {
70
+ const r = await execute(['docker', 'version', '--format', '{{.Server.Version}}']);
71
+ if (r.exitCode !== 0 || !r.stdout.trim()) hold('engine version unknown');
72
+ return r.stdout.trim();
73
+ },
74
+ };
75
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "schemaVersion": 1,
3
+ "host": "axat-vps",
4
+ "inventoryDate": "2026-11-16",
5
+ "maxConcurrent": 2,
6
+ "memoryBudgetBytes": 25769803776,
7
+ "diskBudgetBytes": 107374182400,
8
+ "reserveMemoryBytes": 4294967296,
9
+ "reserveDiskBytes": 10737418240
10
+ }