Skip to content

Commit 3d16807

Browse files
committed
docs: document sandbox ssh tests
1 parent cc296f3 commit 3d16807

8 files changed

Lines changed: 28 additions & 0 deletions

src/agents/sandbox/context.user-fallback.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Sandbox user fallback tests cover docker.user resolution from explicit config
2+
// or workspace ownership.
13
import { describe, expect, it } from "vitest";
24
import { resolveSandboxDockerUser } from "./context.js";
35
import type { SandboxDockerConfig } from "./types.js";

src/agents/sandbox/fs-bridge.backend.e2e.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Local backend fs bridge E2E tests run generated backend shell scripts against
2+
// a real temp workspace without Docker.
13
import { spawn } from "node:child_process";
24
import fs from "node:fs/promises";
35
import os from "node:os";
@@ -12,6 +14,8 @@ import type {
1214
async function runLocalShellCommand(
1315
params: SandboxBackendCommandParams,
1416
): Promise<SandboxBackendCommandResult> {
17+
// This backend shim executes the exact shell script the fs bridge emits, so
18+
// failures prove the generated POSIX script rather than a mocked Docker call.
1519
return await new Promise<SandboxBackendCommandResult>((resolve, reject) => {
1620
const child = spawn(
1721
"sh",

src/agents/sandbox/fs-bridge.shell.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Sandbox fs bridge shell tests cover POSIX shell compatibility, path
2+
// canonicalization, bind reads, and pinned mutation helpers.
13
import fs from "node:fs/promises";
24
import path from "node:path";
35
import { describe, expect, it } from "vitest";
@@ -144,6 +146,8 @@ describe("sandbox fs bridge shell compatibility", () => {
144146
});
145147

146148
it("writes via temp file + atomic rename (never direct truncation)", async () => {
149+
// Writes must go through the Python mutation helper so validation and
150+
// atomic replacement happen together inside the sandbox.
147151
const bridge = createSandboxFsBridge({ sandbox: createSandbox() });
148152

149153
await bridge.writeFile({ filePath: "b.txt", data: "hello" });

src/agents/sandbox/fs-bridge.test-helpers.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Shared fs bridge test helpers install Docker/path-safety mocks and provide
2+
// seeded sandbox fixtures for boundary and shell tests.
13
import fs from "node:fs/promises";
24
import os from "node:os";
35
import path from "node:path";
@@ -77,6 +79,8 @@ const DOCKER_SCRIPT_INDEX = 5;
7779
const DOCKER_FIRST_SCRIPT_ARG_INDEX = 7;
7880

7981
export function getDockerScript(args: string[]): string {
82+
// docker exec argv positions are stable in fs bridge tests; helpers keep
83+
// script assertions readable across many call sites.
8084
return args[DOCKER_SCRIPT_INDEX] ?? "";
8185
}
8286

src/agents/sandbox/ssh-backend.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SSH sandbox backend tests cover runtime description/removal, remote seeding,
2+
// command execution, bind validation, and backend config plumbing.
13
import os from "node:os";
24
import path from "node:path";
35
import {
@@ -73,6 +75,8 @@ function requireMockRecordArg(mock: ReturnType<typeof vi.fn>, callIndex: number,
7375
}
7476

7577
function requireSshRunCommandParams(callIndex = 0) {
78+
// Backend assertions inspect the normalized remote command params before the
79+
// ssh helper turns them into argv.
7680
return requireMockRecordArg(sshMocks.runSshSandboxCommand, callIndex, "ssh run command params");
7781
}
7882

src/agents/sandbox/ssh.spawn-env.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SSH spawn-env tests ensure subprocesses inherit only safe environment values
2+
// while command execution and uploads run through ssh.
13
import type { ChildProcess, SpawnOptions } from "node:child_process";
24
import { EventEmitter } from "node:events";
35
import fs from "node:fs/promises";
@@ -48,6 +50,8 @@ function mockSuccessfulSpawnCalls(times = 1) {
4850
}
4951

5052
function spawnOptionsAt(index: number): SpawnOptions {
53+
// Secret filtering happens at the child_process.spawn boundary, so tests read
54+
// the captured SpawnOptions env directly.
5155
const options = spawnMock.mock.calls[index]?.[2] as SpawnOptions | undefined;
5256
if (!options) {
5357
throw new Error(`expected spawn options for call ${index}`);

src/agents/sandbox/ssh.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// SSH sandbox helper tests cover temp auth materialization, remote command
2+
// validation, shell quoting, and upload symlink safety.
13
import fs from "node:fs/promises";
24
import os from "node:os";
35
import path from "node:path";
@@ -29,6 +31,8 @@ afterEach(async () => {
2931

3032
describe("sandbox ssh helpers", () => {
3133
it("materializes inline ssh auth data into a temp config", async () => {
34+
// Inline key/cert/known-host material is written to private temp files and
35+
// referenced from the generated ssh config.
3236
const session = await createSshSandboxSessionFromSettings({
3337
command: "ssh",
3438
target: "[email protected]:2222",

src/agents/test-helpers/agent-tools-sandbox-context.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
// Agent-tools sandbox context tests keep shared sandbox fixture defaults and
2+
// override behavior stable for tool tests.
13
import { describe, expect, it } from "vitest";
24
import { createAgentToolsSandboxContext } from "./agent-tools-sandbox-context.js";
35

0 commit comments

Comments
 (0)