Skip to content

refactor(sandbox): single docker primitive; fix(sandbox): label + time-bound helper containers (#180 #173)#204

Merged
SUaDtL merged 3 commits into
mainfrom
fix/tribunal-sandbox-dedup
Jul 2, 2026
Merged

refactor(sandbox): single docker primitive; fix(sandbox): label + time-bound helper containers (#180 #173)#204
SUaDtL merged 3 commits into
mainfrom
fix/tribunal-sandbox-dedup

Conversation

@SUaDtL

@SUaDtL SUaDtL commented Jul 2, 2026

Copy link
Copy Markdown
Collaborator

Lane D — ca-sandbox dedup + container-lifecycle hardening.

What

Verification

  • npm run typecheck 0 errors; npm test 164 passed / 31 docker-gated skipped (no Docker engine — expected); npm run build + git diff --quiet -- sandbox.js clean (rebuilt bundle committed). No pre-existing test assertions modified (refactor parity).
  • security-reviewer: PASS — 0 critical/high/medium. Confirmed the MSYS_NO_PATHCONV guard survives on all 8 command paths, no shell:true introduced, every container-isolation control intact, and the Label and time-bound the sandbox helper containers to avoid orphaned containers #173 change strictly reduces leak surface. 3 LOWs, all no-action (timeout is a client-side bound backstopped by label+prune; stand-in test acceptable; global-prune blast radius arguably-correct).

Bumps ca-sandbox 0.1.2 → 0.1.3.

Closes #180
Closes #173

https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa

SUaDtL added 3 commits July 2, 2026 12:57
…bound helper containers

Extract docker.ts as the ONE shared docker-primitive module for ca-sandbox
(architecture-007, #180): DOCKER_ENV (the MSYS_NO_PATHCONV Windows/Git-Bash
guard) and defaultDockerRun were copy-pasted verbatim across build, cp,
create, exec, registry, run, claude-inside, and cli; the {code,stdout,stderr}
result shape recurred under three names (RunResult / ClaudeRunResult /
DockerResult). Every module now imports the single definitions from docker.ts
and re-exports the old type names for backward compatibility; the
injectable-runner test seam is unchanged. Behavior-preserving: the pre-existing
vitest suite passes unmodified (one existing test call site updated to add a
required arg introduced by the #173 fix below, no assertions changed).
typesafety-002 (build.ts's opts.env silently dropping DOCKER_ENV) was already
fixed in #197's typed RunOpts.

Label + time-bound the sandbox helper containers (reliability-015, #173): the
throwaway clone container and the docker-cp helper carried no ca.sandbox
label and no timeout, so a hung clone or a host crash mid-create could orphan
a networked container prune() could never reclaim. Both now carry
ca.sandbox=1 + ca.sandbox.id=<id>, and each docker step (clone, cp-helper
create, cp) is wall-clock timed out. createSandbox's failure teardown now
removes containers before the volume (matching destroySandbox's order), so an
in-use volume is no longer left un-retried.

Tests: pure unit coverage for the new labels + teardown order; docker-gated
integration tests proving prune() reclaims an orphaned, labeled helper-shaped
container (self-skip without a Docker engine, as documented in
tech-stack.md).

Closes #180
Closes #173
Claude-Session: https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa
Completes the previous commit: create.ts's clone container and docker-cp
helper now carry ca.sandbox=1 + ca.sandbox.id=<id>, each docker step is
wall-clock timed out, and createSandbox's failure teardown removes
containers before the volume. Adds create.test.ts coverage (pure + the
docker-gated prune() proxy tests). This was already reflected in the
previously-committed rebuilt sandbox.js; only the .ts sources were left
unstaged in the prior commit.

Claude-Session: https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa
…lper labels)

Payload change in plugins/ca-sandbox/tools/ requires a version bump (per-PR CI gate).

Claude-Session: https://claude.ai/code/session_01PVTCDji6bEuf9SifQ8tfsa
@SUaDtL
SUaDtL merged commit 22ccade into main Jul 2, 2026
18 checks passed
@SUaDtL
SUaDtL deleted the fix/tribunal-sandbox-dedup branch July 2, 2026 17:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant