From d5d3da74f2fbff74abae3dcbf0bf1a8fba28a608 Mon Sep 17 00:00:00 2001 From: haelyra <49814733+haelyra@users.noreply.github.com> Date: Sat, 8 Aug 2026 17:41:42 -0400 Subject: [PATCH] docs(sandbox): record tiered sandbox conventions --- docs/design/sandbox-testing/BACKENDS.md | 27 ++++++ docs/design/sandbox-testing/CONVENTIONS.md | 103 +++++++++++++++++++++ docs/design/sandbox-testing/PROGRESS.md | 64 +++++++++++++ 3 files changed, 194 insertions(+) create mode 100644 docs/design/sandbox-testing/BACKENDS.md create mode 100644 docs/design/sandbox-testing/CONVENTIONS.md create mode 100644 docs/design/sandbox-testing/PROGRESS.md diff --git a/docs/design/sandbox-testing/BACKENDS.md b/docs/design/sandbox-testing/BACKENDS.md new file mode 100644 index 000000000..7089b6650 --- /dev/null +++ b/docs/design/sandbox-testing/BACKENDS.md @@ -0,0 +1,27 @@ +# Sandbox Backend Recon + +Verified against official upstream material on 2026-08-08. + +| Backend | License and maturity | v1 contract | +| --- | --- | --- | +| [SRT](https://github.com/anthropic-experimental/sandbox-runtime) | Apache-2.0; beta research preview | macOS Seatbelt, Linux bubblewrap, Windows alpha WFP/ACL support. ECC owns heuristic denial classification because SRT preserves child exit status. Nested-container mode is explicitly weaker. | +| [Podman](https://github.com/containers/podman) | Apache-2.0; mature | Native Linux containers; macOS/Windows use a Podman machine. Use rootless create/start/diff/remove lifecycle. Diff reports filesystem paths only; v1 network policy is none or unrestricted. | +| [Microsandbox](https://github.com/superradcompany/microsandbox) | Apache-2.0; beta | Current repository moved from earlier organizations. Its current README lists OCI images on Apple Silicon macOS, KVM Linux, and WHP Windows. [Disk snapshots](https://docs.microsandbox.dev/changelog/2026-05-15) can seed fresh independent runs; they do not capture memory and there is no documented filesystem diff. | +| [Lume](https://github.com/trycua/cua/tree/main/libs/lume) | MIT; active | Apple Silicon macOS 13+ host. Pull a versioned seed, clone per run, execute headlessly over its CLI/SSH surface, then delete. Respect the two-concurrent-macOS-guest limit. | +| [Lima](https://github.com/lima-vm/lima) | Apache-2.0; CNCF Incubating | Linux guests on macOS/Linux hosts. Disable default host-home mounts for clean-user fidelity; clone/snapshot only through supported CLI operations. | +| [Tart](https://github.com/openai/tart) | Fair Source 100; not OSI open source | Optional Apple Silicon macOS backend only when already installed. Emit the license notice on selection; never recommend it as the free/open default. | +| [dockur/windows](https://github.com/dockur/windows) | MIT wrapper; Windows guest licensing is separate | Detection-only/experimental in v1 because it needs Linux KVM or nested virtualization, elevated networking devices/capabilities, and large disk images. Prefer native Windows Sandbox or CI. | +| [GitHub-hosted runners](https://docs.github.com/en/actions/concepts/runners/github-hosted-runners) | Hosted service; public-repository usage is free | Terminal fallback for unavailable OSes. Use explicit runner mapping, record actual image/architecture, treat iOS as Xcode Simulator coverage, and never claim physical-device coverage. | + +## Current API corrections + +- `workflow_dispatch` cannot be exercised end to end until the workflow exists + on the default branch. Pre-merge tests use adapter mocks and direct reusable + logic; hosted dispatch evidence is a post-merge gate. +- CI dispatch includes a unique correlation input. The adapter resolves the + exact run before `gh run watch --exit-status` and artifact download. +- macOS/Linux VM scan diffs are best-effort system-tool normalization and must + report `method: scan` plus completeness notes. They are not equivalent to + Podman layer diffs. +- `ios-simulator` must be expressible as a capability or target; an `os: macos` + request alone does not declare simulator needs. diff --git a/docs/design/sandbox-testing/CONVENTIONS.md b/docs/design/sandbox-testing/CONVENTIONS.md new file mode 100644 index 000000000..41bda3172 --- /dev/null +++ b/docs/design/sandbox-testing/CONVENTIONS.md @@ -0,0 +1,103 @@ +# Sandbox Testing Conventions + +Phase 0 records the repository conventions the tiered sandbox implementation +must mirror. + +## Repository shape + +- Use Node.js 18+ CommonJS for CLI and library code. Entrypoints use + `#!/usr/bin/env node`, files normally use `'use strict'`, focused logic lives + under `scripts/lib/` or the feature directory, and direct-run files export + pure functions behind a `require.main === module` guard. +- Parse arguments explicitly, reject unknown arguments, print actionable + `Error: ...` messages to stderr, and use non-zero exit codes. Machine output + is formatted JSON on stdout with no human decoration. +- Spawn subprocesses with argv arrays, `shell: false`, finite timeouts, bounded + buffers, and explicit environment handling. +- Use AJV with checked-in JSON Schema files and `additionalProperties: false` + at every public object boundary. +- Add an exact direct YAML parser dependency. A transitive parser is not a + supported public contract. +- Tests are dependency-light CommonJS files discovered as + `tests/**/*.test.js`. They use Node `assert`, print `Passed:` and `Failed:` + totals, and exercise subprocess boundaries with temporary directories. +- Skills use YAML frontmatter with `name` and a trigger-oriented `description`, + then concise operational Markdown. `skills/` is the canonical workflow + surface; no command shim is needed for this standalone CLI. Register the + skill in `manifests/install-modules.json` and refresh the generated catalog. +- Hook declarations live in `hooks/hooks.json`, carry stable `id` and + `description` fields, and invoke bounded scripts through the existing plugin + root bootstrap. A sandbox-denial hook may suggest a manifest/escalation but + must never execute a sandbox run automatically. +- Workflows pin actions by full SHA, use `contents: read`, disable persisted + checkout credentials, set job timeouts, install with + `npm ci --ignore-scripts`, and avoid shared caches. +- User documentation belongs under `docs/`; implementation decisions and + evidence belong under `docs/design/sandbox-testing/`. + +## Docker PR salvage boundary + +PR #2625 is the predecessor and this branch is stacked on its clean head. +Retain its pinned Debian/Ubuntu image inputs, non-root uid/gid 1000 execution, +read-only source mounts, private tmpfs workspaces, offline package preparation, +bounded subprocesses, path confinement, network-off defaults, and truthful +Linux-only claims. + +Move reusable base-image definitions and setup into `images/sandbox/`. Replace +Docker Compose lifecycle and Docker-specific `exec` plans with Podman adapter +calls. Do not carry Docker-daemon assumptions, Docker install guidance, +cross-OS simulation claims, named interactive container lifecycle, or the +generic `docker-patterns` ownership of this new workflow. + +## Contract decisions required before adapters + +The supplied plan contains a few conflicting requirements. The implementation +uses these decisions to preserve its stated safety and fidelity goals: + +1. Routing produces an execution plan of target shards, not one backend. + `any` normalizes to the host OS; `all` expands to Linux, macOS, and Windows; + explicit OS/architecture lists fan out deterministically. +2. `services` means native service managers/registry and therefore routes to a + native VM or CI, like `gui` and `native: true`. A rootless Linux container + is not evidence for launchd, Windows registry, or host systemd behavior. +3. Multi-target results use an aggregate report with child reports. A single + report schema cannot truthfully represent three backends/OSes in scalar + `backend`, `tier`, `os`, and `arch` fields. +4. A microsandbox-to-Podman fallback is reported as degraded isolation. It is + never silent, and routing still defaults network to disabled unless the + manifest asks for it. +5. The escalation acceptance fixture starts with a manifest that does not + declare `pkg-install` and then encounters an installer/system-write denial. + A manifest that declares `pkg-install` correctly routes directly to Tier 1 + and cannot demonstrate Tier 0 escalation. +6. Normal runs never `podman commit` an untrusted container. Snapshot image + publication is a separate maintainer operation; runs inspect the diff and + destroy the container. +7. Adapter diagnostics go to stderr. The CLI's stdout contract is exactly one + JSON document, including for errors and `--dry-run`. +8. `clean-home` is part of the closed capability vocabulary. It means the test + must not see the host user's installed software, home state, or PATH and + therefore routes to Tier 1 or above. SRT is isolation around host state, not + a clean-machine simulator. +9. A strict Tier 1 domain allowlist requires a backend that enforces host-level + egress policy. It selects Microsandbox when available; otherwise routing + fails with an actionable error. Podman v1 supports network disabled or + unrestricted only and cannot be reported as satisfying a domain allowlist. +10. Podman execution is `create`, `start` or `exec`, `diff`, then explicit + `rm`. `run --rm` cannot preserve a stopped container for diff evidence. +11. Microsandbox snapshots are disk-only. They accelerate repeated pristine + starts but do not preserve memory, processes, or network state. +12. Windows Sandbox CLI is the preferred local Windows v1 adapter when its + current Windows edition/version requirements are met. Hyper-V and + dockur/windows remain detected fallbacks or CI redirects. +13. Mutable GitHub runner labels and images are recorded as observed runtime + facts. CI is a fresh hosted VM with many preinstalled developer tools, not + a blank consumer machine. + +The plan explicitly delegates uncovered decisions to the free, lightweight, +harness-agnostic option. Items 1, 2, 5, 8, and 9 resolve internal contract +contradictions or a missing clean-machine need and are therefore treated as +that delegated authority. They are surfaced here before code and in the user +handoff rather than hidden in implementation. Every matching code departure +from a written routing rule must include a `DECISION:` comment referring to the +applicable item above. diff --git a/docs/design/sandbox-testing/PROGRESS.md b/docs/design/sandbox-testing/PROGRESS.md new file mode 100644 index 000000000..0b18d4477 --- /dev/null +++ b/docs/design/sandbox-testing/PROGRESS.md @@ -0,0 +1,64 @@ +# Tiered Sandbox Progress + +Last updated: 2026-08-08 + +## User-visible acceptance path + +1. An agent writes a strict `sandbox.yaml` containing needs and commands, not a + backend name. +2. `scripts/sandbox/ecc-sandbox probe --refresh` returns the host capability + map as JSON. +3. `ecc-sandbox run sandbox.yaml --dry-run` validates the manifest, expands + target shards, and explains the first satisfying route for each shard. +4. `ecc-sandbox run sandbox.yaml` executes each local shard in the selected + adapter, captures bounded output and install evidence, and destroys the + disposable environment. +5. One recognized runtime denial may escalate one rung; the final JSON report + records the original attempt, reason, destination, degradation notes, and + cleanup outcome. +6. Unavailable local OS shards dispatch through the least-privilege GitHub + Actions matrix only when authenticated CI capability is present. The CLI + downloads and validates each artifact before emitting an aggregate report. +7. A caller can validate and interpret pass, fail, and error reports without + harness-specific SDKs or prose parsing. + +The representative success path is a clean Linux ECC package/install smoke in +an ephemeral rootless environment with an accurate diff. Representative +failure paths are a denied undeclared system write with one-hop escalation and +an unavailable native OS with an actionable CI-auth error. + +## Mission DAG + +| Mission | Owner | Depends on | Owned surface | Gate | +| --- | --- | --- | --- | --- | +| S0 recon | integrator | — | conventions, decisions, progress | Phase 0 note and predecessor salvage review | +| S1 contracts/router | integrator | S0 | schemas, manifest loader, router, fixtures | malformed schemas fail; routing fixtures pass | +| S2 probe | probe owner | S1 | probe modules/tests | mock matrix plus truthful dev-host output | +| S3 report/Tier 0 | process owner | S1, S2 | reporter and srt adapter/tests | schema-valid benign and denial reports | +| S4 Tier 1 | container owner | S1, S2 | images, Podman/microsandbox adapters/tests | real Podman lifecycle plus mock hardened path | +| S5 escalation | integrator | S3, S4 | orchestration integration tests | exactly one recorded reroute | +| S6 CI matrix | CI owner | S1, S2 | workflow, CI adapter/tests | secure mocked dispatch plus hosted probe evidence | +| S7 Tier 2 | VM owner | S1, S2 | Lume/Lima/Windows/Tart adapters/tests | mock coverage; real available-host gate or explicit v1 redirect | +| S8 agent surface | docs owner | S3–S7 | skill, hook, docs, demo | two-harness manifest/report interpretation evidence | +| SF final train | integrator | S5–S8 | combined tree | focused tests, full suite, lint, real local pipeline | + +The root agent is the integrator. Adapter missions are not released until S1's +schemas, routing result, adapter interface, and mock contract pass on the +combined tree. + +## Evidence log + +| Phase | Environment | Command/evidence | Result | +| --- | --- | --- | --- | +| 0 | local macOS worktree | Read root/project/dashboard instructions and central install handoff | Pass | +| 0 | predecessor branch | Reviewed PR #2625 five-commit diff and hardened Docker harness | Pass | +| 0 | predecessor branch | `docker compose config`, 11 harness tests, 7 skill tests, and 94 native install tests reported by recon | Pass; no real container run claimed | +| 0 | dashboard | `npm run check` after adding ECC-017 | Pass | +| 0 | official upstream sources | Verified SRT Apache-2.0 research preview, Podman Apache-2.0, microsandbox Apache-2.0 repo move, Lume MIT, Lima Apache-2.0, and dockur/windows MIT | Pass | +| 0 | official upstream sources | Verified Tart's Fair Source status, Microsandbox disk-only snapshot semantics, Windows Sandbox CLI, Podman diff lifecycle, and CI dispatch constraints | Pass | + +## Current gate + +S0 is complete. No adapter implementation has started. Phase 1 is released for +contract/schema/router implementation; adapter missions remain blocked until +S1 passes its focused and cross-contract tests.