@fusionkit/ensemble 0.1.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 (51) hide show
  1. package/dist/agent.d.ts +21 -0
  2. package/dist/agent.js +186 -0
  3. package/dist/artifacts.d.ts +21 -0
  4. package/dist/artifacts.js +36 -0
  5. package/dist/claude-code.d.ts +25 -0
  6. package/dist/claude-code.js +398 -0
  7. package/dist/codex.d.ts +69 -0
  8. package/dist/codex.js +467 -0
  9. package/dist/command.d.ts +15 -0
  10. package/dist/command.js +82 -0
  11. package/dist/dashboard.d.ts +62 -0
  12. package/dist/dashboard.js +788 -0
  13. package/dist/external-executor.d.ts +56 -0
  14. package/dist/external-executor.js +288 -0
  15. package/dist/harness.d.ts +337 -0
  16. package/dist/harness.js +1 -0
  17. package/dist/index.d.ts +30 -0
  18. package/dist/index.js +15 -0
  19. package/dist/isolation.d.ts +25 -0
  20. package/dist/isolation.js +509 -0
  21. package/dist/judge.d.ts +77 -0
  22. package/dist/judge.js +16 -0
  23. package/dist/mock.d.ts +20 -0
  24. package/dist/mock.js +56 -0
  25. package/dist/run.d.ts +5 -0
  26. package/dist/run.js +520 -0
  27. package/dist/synthesis.d.ts +25 -0
  28. package/dist/synthesis.js +221 -0
  29. package/dist/test/codex.test.d.ts +1 -0
  30. package/dist/test/codex.test.js +237 -0
  31. package/dist/test/dashboard.test.d.ts +1 -0
  32. package/dist/test/dashboard.test.js +214 -0
  33. package/dist/test/ensemble.test.d.ts +1 -0
  34. package/dist/test/ensemble.test.js +780 -0
  35. package/dist/test/external-executor.test.d.ts +1 -0
  36. package/dist/test/external-executor.test.js +273 -0
  37. package/dist/test/isolation.test.d.ts +1 -0
  38. package/dist/test/isolation.test.js +359 -0
  39. package/dist/test/tool-executor.test.d.ts +1 -0
  40. package/dist/test/tool-executor.test.js +113 -0
  41. package/dist/test/unified.test.d.ts +1 -0
  42. package/dist/test/unified.test.js +150 -0
  43. package/dist/tool-executor.d.ts +14 -0
  44. package/dist/tool-executor.js +156 -0
  45. package/dist/trace.d.ts +8 -0
  46. package/dist/trace.js +7 -0
  47. package/dist/unified.d.ts +101 -0
  48. package/dist/unified.js +422 -0
  49. package/dist/worktree.d.ts +25 -0
  50. package/dist/worktree.js +75 -0
  51. package/package.json +35 -0
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,273 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { test } from "node:test";
6
+ import { assertToolExecutionRecordV1, MODEL_FUSION_SCHEMA_BUNDLE_HASH, toolArgumentsHash } from "@fusionkit/protocol";
7
+ import { executeFusionKitToolBatch, FusionKitToolExecutorClient, FusionKitToolExecutorClientError, FusionKitToolExecutorError, startFusionKitToolExecutorServer } from "../external-executor.js";
8
+ import { createToolExecutor, registerDemoTools } from "../tool-executor.js";
9
+ function contract(overrides = {}) {
10
+ return {
11
+ executor_id: "exec_fusionkit",
12
+ mode: "demo_safe",
13
+ environment_id: "env_local",
14
+ tool_policy_id: "policy_readonly",
15
+ allowed_tools: ["read_file", "list_files", "echo", "write_file", "fetch"],
16
+ side_effects: ["none", "read"],
17
+ limits: { timeoutMs: 1000, maxOutputBytes: 4096 },
18
+ timeoutMs: 1000,
19
+ budget: { maxSpendUsd: 0 },
20
+ audit_sink: "memory",
21
+ ...overrides
22
+ };
23
+ }
24
+ function repoFixture() {
25
+ const root = mkdtempSync(join(tmpdir(), "fusionkit-tool-executor-"));
26
+ const repo = join(root, "repo");
27
+ mkdirSync(repo);
28
+ mkdirSync(join(repo, "packages"));
29
+ writeFileSync(join(repo, "README.md"), "hello fusionkit\n");
30
+ writeFileSync(join(repo, "packages", "demo.txt"), "demo\n");
31
+ return { repo, cleanup: () => rmSync(root, { recursive: true, force: true }) };
32
+ }
33
+ function executorFixture(repo, overrides = {}) {
34
+ const executor = createToolExecutor(contract(overrides));
35
+ registerDemoTools(executor, repo);
36
+ executor.register({
37
+ definition: {
38
+ tool_name: "list_files",
39
+ side_effects: "read",
40
+ description: "Return a deterministic file list."
41
+ },
42
+ execute() {
43
+ return { files: ["README.md", "packages/demo.txt"] };
44
+ }
45
+ });
46
+ return executor;
47
+ }
48
+ function plan(toolName, args, sideEffects = "read_only", planId = `plan_${toolName}`) {
49
+ return {
50
+ schema: "tool-call-plan.v1",
51
+ schema_version: "v1",
52
+ schema_bundle_hash: MODEL_FUSION_SCHEMA_BUNDLE_HASH,
53
+ producer: "test",
54
+ producer_version: "0.1.0",
55
+ producer_git_sha: "0".repeat(40),
56
+ created_at: "2026-06-16T00:00:00.000Z",
57
+ plan_id: planId,
58
+ tool_name: toolName,
59
+ arguments_hash: toolArgumentsHash(args),
60
+ side_effects: sideEffects,
61
+ status: "pending"
62
+ };
63
+ }
64
+ function request(overrides = {}) {
65
+ const args = overrides.arguments ?? { path: "README.md" };
66
+ return {
67
+ candidate_id: "candidate_a",
68
+ tool_call_id: "tool_call_a",
69
+ plan: plan("read_file", args),
70
+ arguments: args,
71
+ environment_id: "env_local",
72
+ tool_policy_id: "policy_readonly",
73
+ ...overrides
74
+ };
75
+ }
76
+ async function close(server) {
77
+ await new Promise((resolve) => {
78
+ server.close(() => resolve());
79
+ });
80
+ }
81
+ test("batch execution returns schema-valid records grouped by candidate and tool call", async () => {
82
+ const fixture = repoFixture();
83
+ try {
84
+ const executor = executorFixture(fixture.repo);
85
+ const response = await executeFusionKitToolBatch(executor, {
86
+ requests: [
87
+ request({
88
+ candidate_id: "candidate_a",
89
+ tool_call_id: "tool_call_read",
90
+ plan: plan("read_file", { path: "README.md" }, "read_only", "plan_read"),
91
+ arguments: { path: "README.md" }
92
+ }),
93
+ request({
94
+ candidate_id: "candidate_b",
95
+ tool_call_id: "tool_call_list",
96
+ plan: plan("list_files", { path: "packages" }, "read_only", "plan_list"),
97
+ arguments: { path: "packages" }
98
+ })
99
+ ]
100
+ });
101
+ assert.equal(response.results.length, 2);
102
+ assert.equal(response.results[0]?.candidate_id, "candidate_a");
103
+ assert.equal(response.results[0]?.tool_call_id, "tool_call_read");
104
+ assert.equal(response.results[0]?.record.plan_id, "plan_read");
105
+ assert.equal(response.results[1]?.candidate_id, "candidate_b");
106
+ assert.equal(response.results[1]?.tool_call_id, "tool_call_list");
107
+ for (const result of response.results) {
108
+ assertToolExecutionRecordV1(result.record);
109
+ assert.equal(result.record.status, "succeeded");
110
+ }
111
+ }
112
+ finally {
113
+ fixture.cleanup();
114
+ }
115
+ });
116
+ test("identical read-only requests dedupe under matching policy and environment", async () => {
117
+ const fixture = repoFixture();
118
+ try {
119
+ const executor = executorFixture(fixture.repo);
120
+ const response = await executeFusionKitToolBatch(executor, {
121
+ requests: [
122
+ request({
123
+ candidate_id: "candidate_a",
124
+ tool_call_id: "tool_call_a",
125
+ plan: plan("read_file", { path: "README.md" }, "read_only", "plan_a"),
126
+ arguments: { path: "README.md" }
127
+ }),
128
+ request({
129
+ candidate_id: "candidate_b",
130
+ tool_call_id: "tool_call_b",
131
+ plan: plan("read_file", { path: "README.md" }, "read_only", "plan_b"),
132
+ arguments: { path: "README.md" }
133
+ })
134
+ ]
135
+ });
136
+ assert.equal(response.results[0]?.deduped, false);
137
+ assert.equal(response.results[1]?.deduped, true);
138
+ assert.equal(response.results[1]?.record.execution_id, response.results[0]?.record.execution_id);
139
+ assert.equal(response.results[1]?.record.plan_id, "plan_b");
140
+ const otherEnvironment = executorFixture(fixture.repo, { environment_id: "env_other" });
141
+ const third = await executeFusionKitToolBatch(otherEnvironment, {
142
+ requests: [
143
+ request({
144
+ environment_id: "env_other",
145
+ plan: plan("read_file", { path: "README.md" }, "read_only", "plan_c"),
146
+ arguments: { path: "README.md" }
147
+ })
148
+ ]
149
+ });
150
+ assert.notEqual(third.results[0]?.record.execution_id, response.results[0]?.record.execution_id);
151
+ }
152
+ finally {
153
+ fixture.cleanup();
154
+ }
155
+ });
156
+ test("write, external, and unknown tools return failure taxonomy records", async () => {
157
+ const fixture = repoFixture();
158
+ try {
159
+ const executor = executorFixture(fixture.repo, {
160
+ allowed_tools: ["read_file", "list_files", "echo", "write_file", "fetch", "missing_tool"],
161
+ side_effects: ["none", "read", "write", "external"]
162
+ });
163
+ const response = await executeFusionKitToolBatch(executor, {
164
+ requests: [
165
+ request({
166
+ tool_call_id: "tool_call_write",
167
+ plan: plan("write_file", { path: "README.md" }, "writes_workspace", "plan_write"),
168
+ arguments: { path: "README.md" }
169
+ }),
170
+ request({
171
+ tool_call_id: "tool_call_fetch",
172
+ plan: plan("fetch", { url: "https://example.com" }, "network", "plan_fetch"),
173
+ arguments: { url: "https://example.com" }
174
+ }),
175
+ request({
176
+ tool_call_id: "tool_call_missing",
177
+ plan: plan("missing_tool", {}, "read_only", "plan_missing"),
178
+ arguments: {}
179
+ })
180
+ ]
181
+ });
182
+ assert.equal(response.results[0]?.record.status, "failed");
183
+ assert.equal(response.results[0]?.record.error?.kind, "tool_denied");
184
+ assert.equal(response.results[1]?.record.status, "failed");
185
+ assert.equal(response.results[1]?.record.error?.kind, "tool_denied");
186
+ assert.equal(response.results[2]?.record.status, "unsupported");
187
+ assert.equal(response.results[2]?.record.error?.kind, "capability_missing");
188
+ }
189
+ finally {
190
+ fixture.cleanup();
191
+ }
192
+ });
193
+ test("batch validation rejects policy and argument mismatches", async () => {
194
+ const fixture = repoFixture();
195
+ try {
196
+ const executor = executorFixture(fixture.repo);
197
+ await assert.rejects(() => executeFusionKitToolBatch(executor, {
198
+ requests: [request({ environment_id: "env_other" })]
199
+ }), (error) => error instanceof FusionKitToolExecutorError &&
200
+ error.status === 403 &&
201
+ error.code === "environment_mismatch");
202
+ const badPlan = plan("read_file", { path: "README.md" }, "read_only", "plan_bad");
203
+ await assert.rejects(() => executeFusionKitToolBatch(executor, {
204
+ requests: [
205
+ request({
206
+ plan: badPlan,
207
+ arguments: { path: "packages/demo.txt" }
208
+ })
209
+ ]
210
+ }), (error) => error instanceof FusionKitToolExecutorError &&
211
+ error.status === 400 &&
212
+ error.code === "arguments_hash_mismatch");
213
+ const invalidPlan = {
214
+ ...plan("read_file", { path: "README.md" }, "read_only", "plan_invalid"),
215
+ status: "not-a-status"
216
+ };
217
+ await assert.rejects(() => executeFusionKitToolBatch(executor, {
218
+ requests: [request({ plan: invalidPlan })]
219
+ }), (error) => error instanceof FusionKitToolExecutorError &&
220
+ error.status === 400 &&
221
+ error.code === "invalid_request" &&
222
+ error.message.includes("plan invalid"));
223
+ }
224
+ finally {
225
+ fixture.cleanup();
226
+ }
227
+ });
228
+ test("HTTP server and client enforce auth and validate bad requests", async () => {
229
+ const fixture = repoFixture();
230
+ const executor = executorFixture(fixture.repo);
231
+ const started = await startFusionKitToolExecutorServer({
232
+ executor,
233
+ port: 0,
234
+ authToken: "secret"
235
+ });
236
+ try {
237
+ const health = await fetch(`${started.url}/v1/health`);
238
+ assert.equal(health.status, 200);
239
+ assert.deepEqual(await health.json(), {
240
+ ok: true,
241
+ service: "warrant-tool-executor"
242
+ });
243
+ const unauthenticated = await fetch(`${started.url}/v1/fusionkit/tool-executions`, {
244
+ method: "POST",
245
+ headers: { "content-type": "application/json" },
246
+ body: JSON.stringify({ requests: [] })
247
+ });
248
+ assert.equal(unauthenticated.status, 401);
249
+ const client = new FusionKitToolExecutorClient(started.url, "secret");
250
+ const success = await client.execute({
251
+ requests: [request()]
252
+ });
253
+ assert.equal(success.results[0]?.record.status, "succeeded");
254
+ const malformed = await fetch(`${started.url}/v1/fusionkit/tool-executions`, {
255
+ method: "POST",
256
+ headers: {
257
+ authorization: "Bearer secret",
258
+ "content-type": "application/json"
259
+ },
260
+ body: "{"
261
+ });
262
+ assert.equal(malformed.status, 400);
263
+ const malformedBody = (await malformed.json());
264
+ assert.equal(malformedBody.code, "invalid_json");
265
+ await assert.rejects(() => client.execute({
266
+ requests: [request({ tool_policy_id: "policy_other" })]
267
+ }), (error) => error instanceof FusionKitToolExecutorClientError && error.status === 403);
268
+ }
269
+ finally {
270
+ await close(started.server);
271
+ fixture.cleanup();
272
+ }
273
+ });
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,359 @@
1
+ import assert from "node:assert/strict";
2
+ import { mkdtempSync, rmSync, writeFileSync } from "node:fs";
3
+ import { tmpdir } from "node:os";
4
+ import { join } from "node:path";
5
+ import { test } from "node:test";
6
+ import { runCandidateCommandWithIsolation, secretAbsenceMetadata, secretValueHash } from "../isolation.js";
7
+ function workspaceFixture() {
8
+ const root = mkdtempSync(join(tmpdir(), "candidate-isolation-"));
9
+ writeFileSync(join(root, "README.md"), "# isolated\n");
10
+ return { root, cleanup: () => rmSync(root, { recursive: true, force: true }) };
11
+ }
12
+ test("process isolation preserves current command behavior and records hardening", async () => {
13
+ const workspace = workspaceFixture();
14
+ try {
15
+ const result = await runCandidateCommandWithIsolation({
16
+ command: "printf process-ok",
17
+ cwd: workspace.root,
18
+ timeoutMs: 1000
19
+ });
20
+ assert.equal(result.exitCode, 0);
21
+ assert.equal(result.stdout, "process-ok");
22
+ assert.equal(result.hardening.requested_isolation, "process");
23
+ assert.equal(result.hardening.actual_isolation, "process");
24
+ assert.equal(result.hardening.cleanup.status, "not_required");
25
+ assert.equal(result.hardening.network_policy.default_deny, true);
26
+ assert.equal(result.hardening.network_policy.enforced, false);
27
+ }
28
+ finally {
29
+ workspace.cleanup();
30
+ }
31
+ });
32
+ test("fake container isolation records runtime, mounts, network, and cleanup", async () => {
33
+ const workspace = workspaceFixture();
34
+ const driver = {
35
+ id: "fake-container",
36
+ supportsNetworkPolicy: true,
37
+ execute(input) {
38
+ assert.equal(input.image, "node:22-test");
39
+ assert.equal(input.workdir, "/workspace");
40
+ assert.deepEqual(input.mountPolicy.readOnlyCachePaths, ["/tmp/cache"]);
41
+ assert.deepEqual(input.networkPolicy.allowHosts, ["registry.example.com"]);
42
+ return {
43
+ stdout: "container-ok",
44
+ stderr: "",
45
+ exitCode: 0,
46
+ cleanup: { attempted: true, succeeded: true }
47
+ };
48
+ }
49
+ };
50
+ try {
51
+ const result = await runCandidateCommandWithIsolation({
52
+ command: "printf container-ok",
53
+ cwd: workspace.root,
54
+ isolation: {
55
+ kind: "container",
56
+ image: "node:22-test",
57
+ driver,
58
+ mountPolicy: { readOnlyCachePaths: ["/tmp/cache"] },
59
+ networkPolicy: {
60
+ defaultDeny: true,
61
+ allowHosts: ["registry.example.com"],
62
+ enforce: true
63
+ }
64
+ }
65
+ });
66
+ assert.equal(result.exitCode, 0);
67
+ assert.equal(result.stdout, "container-ok");
68
+ assert.equal(result.hardening.requested_isolation, "container");
69
+ assert.equal(result.hardening.runtime.image, "node:22-test");
70
+ assert.equal(result.hardening.runtime.driver, "fake-container");
71
+ assert.equal(result.hardening.cleanup.status, "succeeded");
72
+ }
73
+ finally {
74
+ workspace.cleanup();
75
+ }
76
+ });
77
+ test("container isolation fails closed when network policy cannot be enforced", async () => {
78
+ const workspace = workspaceFixture();
79
+ const driver = {
80
+ id: "weak-container",
81
+ supportsNetworkPolicy: false,
82
+ execute() {
83
+ throw new Error("should not execute");
84
+ }
85
+ };
86
+ try {
87
+ const result = await runCandidateCommandWithIsolation({
88
+ command: "printf never",
89
+ cwd: workspace.root,
90
+ isolation: {
91
+ kind: "container",
92
+ driver,
93
+ networkPolicy: {
94
+ defaultDeny: true,
95
+ allowHosts: ["api.example.com"],
96
+ enforce: true
97
+ }
98
+ }
99
+ });
100
+ assert.equal(result.exitCode, 1);
101
+ assert.match(result.stderr, /cannot enforce/);
102
+ assert.equal(result.hardening.cleanup.status, "failed");
103
+ assert.equal(result.hardening.network_policy.enforced, true);
104
+ }
105
+ finally {
106
+ workspace.cleanup();
107
+ }
108
+ });
109
+ test("container cleanup is recorded for failures and timeouts", async () => {
110
+ const workspace = workspaceFixture();
111
+ const driver = {
112
+ id: "timeout-container",
113
+ supportsNetworkPolicy: true,
114
+ execute() {
115
+ return {
116
+ stdout: "",
117
+ stderr: "timed out",
118
+ exitCode: 1,
119
+ timedOut: true,
120
+ cleanup: { attempted: true, succeeded: true }
121
+ };
122
+ }
123
+ };
124
+ try {
125
+ const result = await runCandidateCommandWithIsolation({
126
+ command: "sleep 10",
127
+ cwd: workspace.root,
128
+ isolation: { kind: "container", driver }
129
+ });
130
+ assert.equal(result.timedOut, true);
131
+ assert.equal(result.hardening.cleanup.status, "succeeded");
132
+ }
133
+ finally {
134
+ workspace.cleanup();
135
+ }
136
+ });
137
+ test("fake microVM isolation records vercel-sandbox runtime evidence", async () => {
138
+ const workspace = workspaceFixture();
139
+ const driver = {
140
+ id: "fake-vercel-sandbox",
141
+ provider: "vercel-sandbox",
142
+ supportsNetworkPolicy: true,
143
+ execute(input) {
144
+ assert.equal(input.provider, "vercel-sandbox");
145
+ assert.equal(input.runtime, "node24");
146
+ assert.equal(input.snapshotId, "snap_test");
147
+ assert.equal(input.workdir, "/workspace");
148
+ assert.deepEqual(input.networkPolicy.allowHosts, []);
149
+ return {
150
+ stdout: "microvm-ok",
151
+ stderr: "",
152
+ exitCode: 0,
153
+ actualIsolation: "vercel-sandbox",
154
+ runtime: {
155
+ provider: "vercel-sandbox",
156
+ runtime: "node24",
157
+ snapshotId: "snap_test",
158
+ sandboxId: "sbx_test",
159
+ runtimeDigest: "sha256:" + "c".repeat(64)
160
+ },
161
+ cleanup: { attempted: true, succeeded: true }
162
+ };
163
+ }
164
+ };
165
+ try {
166
+ const result = await runCandidateCommandWithIsolation({
167
+ command: "printf microvm-ok",
168
+ cwd: workspace.root,
169
+ isolation: {
170
+ kind: "microvm",
171
+ driver,
172
+ snapshotId: "snap_test",
173
+ networkPolicy: { defaultDeny: true, allowHosts: [], enforce: true }
174
+ }
175
+ });
176
+ assert.equal(result.exitCode, 0);
177
+ assert.equal(result.stdout, "microvm-ok");
178
+ assert.equal(result.hardening.requested_isolation, "microvm");
179
+ assert.equal(result.hardening.actual_isolation, "vercel-sandbox");
180
+ assert.equal(result.hardening.runtime.provider, "vercel-sandbox");
181
+ assert.equal(result.hardening.runtime.runtime, "node24");
182
+ assert.equal(result.hardening.runtime.snapshot_id, "snap_test");
183
+ assert.equal(result.hardening.runtime.sandbox_id, "sbx_test");
184
+ assert.equal(result.hardening.runtime.driver, "fake-vercel-sandbox");
185
+ assert.equal(result.hardening.network_policy.enforced, true);
186
+ assert.equal(result.hardening.cleanup.status, "succeeded");
187
+ }
188
+ finally {
189
+ workspace.cleanup();
190
+ }
191
+ });
192
+ test("fake microVM isolation fails closed when network policy cannot be enforced", async () => {
193
+ const workspace = workspaceFixture();
194
+ const driver = {
195
+ id: "weak-microvm",
196
+ provider: "vercel-sandbox",
197
+ supportsNetworkPolicy: false,
198
+ execute() {
199
+ throw new Error("should not execute");
200
+ }
201
+ };
202
+ try {
203
+ const result = await runCandidateCommandWithIsolation({
204
+ command: "printf never",
205
+ cwd: workspace.root,
206
+ isolation: {
207
+ kind: "microvm",
208
+ driver,
209
+ networkPolicy: {
210
+ defaultDeny: true,
211
+ allowHosts: ["api.example.com"],
212
+ enforce: true
213
+ }
214
+ }
215
+ });
216
+ assert.equal(result.exitCode, 1);
217
+ assert.match(result.stderr, /cannot enforce/);
218
+ assert.equal(result.hardening.requested_isolation, "microvm");
219
+ assert.equal(result.hardening.actual_isolation, "vercel-sandbox");
220
+ assert.equal(result.hardening.cleanup.status, "failed");
221
+ assert.equal(result.hardening.network_policy.enforced, true);
222
+ }
223
+ finally {
224
+ workspace.cleanup();
225
+ }
226
+ });
227
+ test("fake microVM cleanup failures and timeouts are recorded distinctly", async () => {
228
+ const workspace = workspaceFixture();
229
+ const cleanupFailureDriver = {
230
+ id: "cleanup-failure-microvm",
231
+ provider: "vercel-sandbox",
232
+ supportsNetworkPolicy: true,
233
+ execute() {
234
+ return {
235
+ stdout: "",
236
+ stderr: "cleanup failed",
237
+ exitCode: 1,
238
+ actualIsolation: "vercel-sandbox",
239
+ cleanup: { attempted: true, succeeded: false, error: "stop failed" }
240
+ };
241
+ }
242
+ };
243
+ const cleanupTimeoutDriver = {
244
+ id: "cleanup-timeout-microvm",
245
+ provider: "vercel-sandbox",
246
+ supportsNetworkPolicy: true,
247
+ execute() {
248
+ return {
249
+ stdout: "",
250
+ stderr: "cleanup timed out",
251
+ exitCode: 1,
252
+ actualIsolation: "vercel-sandbox",
253
+ cleanup: {
254
+ attempted: true,
255
+ succeeded: false,
256
+ timedOut: true,
257
+ error: "stop timed out"
258
+ }
259
+ };
260
+ }
261
+ };
262
+ try {
263
+ const failed = await runCandidateCommandWithIsolation({
264
+ command: "exit 1",
265
+ cwd: workspace.root,
266
+ isolation: { kind: "microvm", driver: cleanupFailureDriver }
267
+ });
268
+ assert.equal(failed.hardening.cleanup.status, "failed");
269
+ assert.equal(failed.hardening.cleanup.error, "stop failed");
270
+ const timedOut = await runCandidateCommandWithIsolation({
271
+ command: "exit 1",
272
+ cwd: workspace.root,
273
+ isolation: { kind: "microvm", driver: cleanupTimeoutDriver }
274
+ });
275
+ assert.equal(timedOut.hardening.cleanup.status, "timed_out");
276
+ assert.equal(timedOut.hardening.cleanup.timed_out, true);
277
+ assert.equal(timedOut.hardening.cleanup.error, "stop timed out");
278
+ }
279
+ finally {
280
+ workspace.cleanup();
281
+ }
282
+ });
283
+ test("fake microVM secret absence evidence omits raw secret values", async () => {
284
+ const workspace = workspaceFixture();
285
+ const secretValue = "microvm-secret-value";
286
+ const secretHash = secretValueHash(secretValue);
287
+ const driver = {
288
+ id: "secretless-microvm",
289
+ provider: "vercel-sandbox",
290
+ supportsNetworkPolicy: true,
291
+ execute(input) {
292
+ assert.equal(JSON.stringify(input).includes(secretValue), false);
293
+ assert.deepEqual(input.secretPolicy.secretNames, ["VERCEL_TOKEN"]);
294
+ assert.deepEqual(input.secretPolicy.secretValueHashes, [secretHash]);
295
+ assert.deepEqual(input.secretPolicy.injectedEnvNames, ["VERCEL_TOKEN"]);
296
+ return {
297
+ stdout: "secretless",
298
+ stderr: "",
299
+ exitCode: 0,
300
+ actualIsolation: "vercel-sandbox",
301
+ cleanup: { attempted: true, succeeded: true }
302
+ };
303
+ }
304
+ };
305
+ try {
306
+ const result = await runCandidateCommandWithIsolation({
307
+ command: "printf secretless",
308
+ cwd: workspace.root,
309
+ isolation: {
310
+ kind: "microvm",
311
+ driver,
312
+ secretPolicy: {
313
+ secretNames: ["VERCEL_TOKEN"],
314
+ secretValueHashes: [secretHash],
315
+ injectedEnvNames: ["VERCEL_TOKEN"]
316
+ }
317
+ }
318
+ });
319
+ assert.equal(result.hardening.secret_absence.scanned, true);
320
+ assert.equal(result.hardening.secret_absence.leaks_found, false);
321
+ assert.equal(result.hardening.secret_absence.secret_names[0], "VERCEL_TOKEN");
322
+ assert.equal(result.hardening.secret_absence.secret_value_hashes[0], secretHash);
323
+ assert.equal(JSON.stringify(result.hardening).includes(secretValue), false);
324
+ }
325
+ finally {
326
+ workspace.cleanup();
327
+ }
328
+ });
329
+ test("secret absence scanning records names and hashes without raw values", () => {
330
+ const workspace = workspaceFixture();
331
+ const secretValue = "super-secret-value";
332
+ try {
333
+ const clean = secretAbsenceMetadata({
334
+ cwd: workspace.root,
335
+ transcript: "no secrets here",
336
+ secretPolicy: {
337
+ secretNames: ["API_TOKEN"],
338
+ secretValueHashes: [secretValueHash(secretValue)],
339
+ injectedEnvNames: ["API_TOKEN"]
340
+ }
341
+ });
342
+ assert.equal(clean.scanned, true);
343
+ assert.equal(clean.leaks_found, false);
344
+ assert.equal(JSON.stringify(clean).includes(secretValue), false);
345
+ writeFileSync(join(workspace.root, "leak.txt"), "API_TOKEN should not be here\n");
346
+ const leaked = secretAbsenceMetadata({
347
+ cwd: workspace.root,
348
+ transcript: secretValue,
349
+ secretPolicy: { secretNames: ["API_TOKEN"] },
350
+ knownSecretValues: [secretValue]
351
+ });
352
+ assert.equal(leaked.leaks_found, true);
353
+ assert.equal(leaked.leak_count > 0, true);
354
+ assert.equal(JSON.stringify(leaked).includes(secretValue), false);
355
+ }
356
+ finally {
357
+ workspace.cleanup();
358
+ }
359
+ });
@@ -0,0 +1 @@
1
+ export {};