Milestone 5 — Isolated workspaces and ACP execution
Status: COMPLETE under the prompt's conditional live-execution acceptance. The offline ACP, routing, isolation, fencing, cancellation, and recovery evidence passed. A provider-backed repository edit was not run because no provider credential or separate spending authorization was supplied; the prompt explicitly permits recording that blocker. Do not treat the offline fake-router result as live-provider evidence.
The milestone 4 NO-GO remains in force: Harnessa's PostgreSQL scheduler is the only run and checkpoint authority. No LangGraph dependency, second checkpoint owner, or live-state migration was introduced. Milestone 6 was not started.
Baseline and prerequisites
M5 edits began on main at 119f1ab; the user-provided M4 commit 1c665dc98ac6722ee7d4947c6096c09195e48af4 is in its history. The branch later advanced to 24e0716 while this work was in progress, including newer planning/Dependabot commits; they were preserved. M5 changes are currently uncommitted.
Before editing, I read the applicable agent instructions, the revised specification, architecture decisions, planning index and M5 prompt, M1–M4 reports, and the existing scheduler, adapters, leases/fencing, recovery, effects, streams, workspace/sandbox, and contract-generation paths. Earlier milestone evidence was checked rather than inferred from report presence: pnpm lint, pnpm typecheck, and pnpm test passed, as did the disposable PostgreSQL/Redis integration suite. M3's optional provider check remains pending; M4's documented NO-GO remains unchanged.
Implementation
- Pinned the official stable agent-client-protocol==0.12.1 API in pyproject.toml and uv.lock. It was exercised on Python 3.12.15. The adapter uses connect_to_agent, SDK schemas, ACP protocol v1, permission callbacks, session updates, prompt lifecycle, and cancellation. The official release listings show 1.0.0 release candidates; they were not adopted because they are pre-release schema/runtime changes.
- Added a bounded ACP stdio transport: 1 MiB frames, 64 MiB total bytes, 30,000 messages, 300-second idle receive deadline, and 10,000 ACP updates. Protocol stdout stays separate from drained stderr. Thought/message content and tool input/output are not retained. SDK types remain behind the adapter boundary.
- Added the OpenCode ACP registry entry and a genuine supported path using OpenCode 2.0.32. Its ephemeral provider configuration exposes only the Harnessa route and a per-run bearer token. A trusted host broker reaches the sandbox through a private Unix socket and static loopback-only relay. The broker binds requests to organization, project, task, run, and fencing token; attempt identity remains with Harnessa and the sandbox labels. It ignores agent-selected model routing, enforces request and output bounds, checks cancellation/current fencing, and calls Harnessa's existing ModelRouter for both completion and streaming. Provider credentials remain behind the existing LiteLLM boundary.
- Kept all container-engine operations on the trusted host. The rootless Podman sandbox uses a digest-pinned image, --network=none, read-only root filesystem, dropped capabilities, no-new-privileges, userns=keep-id, and bounded CPU, memory, process, file, and tmpfs resources. The only writable user bind is /workspace; the socket, config, and relay are read-only. No provider keys or engine socket are mounted.
- Added per-run managed clones at the requested full base commit, with independent Git metadata, no configured remote, and no mount of the source checkout. Success removes the workspace; failure preserves it for operator recovery. Rootless Podman resources carry installation/run/task/attempt/fence labels; startup and periodic reconciliation remove only stale resources owned by this installation.
- Added scoped filesystem permission handling, traversal/symlink escape rejection, shell execution confined to the sandbox, and network-fetch denial. Checkpoints/progress use Harnessa's scheduler and durable events. Artifact publication validates the active lease/fence before and after CAS storage; stale writes cannot create a durable reference. Referenced artifacts are retained; old unreferenced CAS blobs are reconciled after the grace period.
- Task/run/attempt identity, leases/fences, model budgets, questions, domain events, and external-effect intent/reconciliation remain under Harnessa authority. The broker exposes only the scoped model route; no clarification or external-effect tool was added.
- Added disabled-by-default execution and broker configuration. The existing worker remains the scheduler owner; the Compose worker receives no Podman engine access. The clarification interface and session/ask_orchestrator remain untouched.
- Preserved OpenAPI-to-TypeScript generation. The existing ModelMessage contract gained tool_calls so OpenAI-compatible tool-call history can cross Harnessa's existing model-router contract; the generated TypeScript contract contains that field. No ACP SDK types were added to public APIs.
Versions and bounds
| Item | Verified value |
|---|---|
| Python | 3.12.15 via uv |
| Package managers | uv 0.13.1; pnpm 10.34.7 |
| ACP SDK | agent-client-protocol==0.12.1; ACP protocol v1 |
| Agent | OpenCode 2.0.32; opencode acp |
| Image | ghcr.io/anomalyco/opencode@sha256:85986f556e985e377bd24cd68a5ccfbc647bb49e591194edda8a0e4542303319 |
| Image platform/config ID | linux/amd64; sha256:8c8f06e8a1cb2000b7f386eaef57bac08601f59d05175d93bfff185676c47302 |
| Container runtime | rootless Podman 5.7.0; crun 1.21 |
| CPU / memory / pids | 2 CPUs / 2 GiB / 256 |
| /tmp / file size | 512 MiB tmpfs / 1 GiB fsize limit |
| Workspace size | 4 GiB monitored threshold, checked once per second; soft limit, not a hard quota |
| Run / idle deadline | 1,800 seconds / 300 seconds |
| ACP / artifact bounds | 1 MiB frame; 64 MiB total protocol bytes; 30,000 messages; 10,000 updates; 10 MiB patch |
| Broker HTTP bounds | 16 KiB headers; 1 MiB body; 2,000 messages; 256 tools; 2,000,000 estimated-input bytes/tokens; configured default 8,192 output tokens, hard cap 65,536 |
| Other bounds | 10,000 changed-file entries; 16 MiB Git status output; 1,024 file descriptors |
The image was already local and the runner uses --pull=never; the sandbox smoke did not fetch an image or contact an external service. In the broker smoke, OpenCode's ephemeral config and the routed request used a 128-token output ceiling.
Verification performed
No model provider call or provider prompt was made. Checks used local code, rootless Podman, and disposable local PostgreSQL/Redis only.
| Command/check | Result |
|---|---|
| uv run ruff check apps/api tests scripts | Passed. |
| pnpm lint | Passed: web ESLint and API Ruff. |
| pnpm typecheck | Passed: web TypeScript and mypy across 30 API/domain/service/adapter files. |
| pnpm test | Passed: 26 passed, 18 service-dependent integration skips, one existing Starlette/AnyIO deprecation warning. |
| TEST_DATABASE_URL=postgresql+asyncpg://postgres@127.0.0.1:44875/harnessa_m5_final_test TEST_REDIS_URL=redis://127.0.0.1:32957/1 uv run pytest -q tests/integration -m integration | Passed: 18 integration tests in 4.66 seconds on PostgreSQL 16.15 and Redis 7.4.2. The containers were disposable, loopback-bound, and removed after the run. They are not the project's locked deployment images. |
| DATABASE_URL=postgresql+asyncpg://postgres@127.0.0.1:44875/harnessa_m5_final_test uv run python -m alembic check from apps/api | Passed: No new upgrade operations detected. The integration fixture first upgraded this newly created database to Alembic head 5c0a4b6d1e9f. |
| HARNESSA_API_URL=http://127.0.0.1:28051 pnpm contracts:generate against temporary uvicorn | Passed with openapi-typescript 7.13.0. Generated the expected ModelMessage.tool_calls field in packages/contracts/src/generated.ts; no unrelated contract diff. |
| PYTHONPATH=apps/api uv run python scripts/m5_acp_offline_smoke.py | Passed against the pinned OpenCode image: protocol v1 initialize and new-session at fixture base commit 763000bea63f3504aeabb0ae027cd4ac7c00cabc; resume was advertised but is not persisted by Harnessa. Network none; workspace was the only user bind; observed memory 2,147,483,648 bytes, NanoCPUs 2,000,000,000, and pids limit 256. No prompt was sent in this protocol-only smoke. |
| cc -static -O2 -Wall -Wextra -Werror -pthread apps/api/harnessa/adapters/acp_socket_relay.c -o /tmp/harnessa-acp-model-relay | Passed; the real broker smoke also built and used this relay. |
| PYTHONPATH=apps/api uv run python scripts/m5_acp_broker_offline_smoke.py | Passed through real OpenCode ACP 2.0.32: initialize, new session, and a prompt completed with end_turn at fixture base commit 7767240558d06697a465cfc0b5ffa2b2384a4753. OpenCode streamed through the static relay and private Unix socket to an in-process fake ModelRouter, which returned offline-ok. The broker saw one request bound to the fake organization/project/task/run/fence and 128 output tokens. No provider prompt or call occurred. |
| Isolation assertions in the broker smoke | Passed: sandbox networking was none; mounts were exactly /workspace, the read-only broker socket/config, and the read-only relay. In-container checks found no host checkout, synthetic host secret, other-task workspace marker, Docker socket, or rootless Podman socket (five forbidden paths checked). |
The live-provider portion is explicitly deferred. The real-agent ACP prompt above used only a deterministic fake router and made no repository edit. No provider credential or separate spending authorization was supplied, and the user instructed not to make paid/provider calls without authorization. The acceptance prompt says to report this precise blocker when authorized real-agent execution is unavailable.
An earlier attempt against an existing disposable database whose Alembic version reported head but whose schema lacked tasks.event_sequence failed during fixture setup. That result was not counted. The final suite ran against a newly created, isolated PostgreSQL container and database, which Alembic upgraded before all 18 cases passed.
Limitations
- No provider-backed repository edit or live LiteLLM route was exercised. The feature remains disabled by default. A future live run requires an explicitly authorized provider credential and spending ceiling, kept behind LiteLLM.
- The Compose worker has no Podman executable or engine access. A separately managed trusted host worker with database/Redis access and private workspace/state/artifact directories is required to run ACP outside these local smokes.
- The workspace-size limit is a one-second watchdog and can overshoot; use filesystem/project quotas before treating 4 GiB as a hard aggregate limit.
- Podman is the only implemented and tested backend. Docker parity is unverified.
- OpenCode advertises session resume, but its session store is not persisted; lease recovery starts a fresh ACP session at the exact prior base commit with bounded, redacted durable context.
- Failed workspaces are preserved for audit/operator recovery; automated workspace-retention deletion and a public artifact retrieval endpoint are not implemented.
Recovery and rollback
- Disable/stop: keep ACP_EXECUTION_ENABLED=false and ACP_MODEL_BROKER_ENABLED=false (both default to false); stop the separately managed host worker. The Compose worker does not own Podman containers.
- Lost worker: the Harnessa scheduler expires the lease and gives a later attempt a higher fence. Startup and 30-second reconciliation inspect only containers bearing this installation's owner labels; stale owned containers are removed, live current-fence containers remain. Failed workspaces are preserved for review.
- Artifact cleanup: referenced CAS blobs are retained. Unreferenced blobs are eligible only after one hour. Back up the artifact root with PostgreSQL before operations or rollback.
- Schema rollback: stop the host worker, take a PostgreSQL backup, preserve the artifact root, then from apps/api run DATABASE_URL=
uv run python -m alembic downgrade b11f10974e82. This drops M5 artifact metadata and the internal task event sequence; CAS files remain on disk. Do not roll back M5 data without a recoverable backup. - Runtime decision: no LangGraph deployment or state conversion occurred; there is no second checkpoint owner to switch back to.
Milestone 6 prerequisites
M5 acceptance evidence is recorded and its prompt is archived. M6 was not started. The Harnessa scheduler, ACP adapter, broker contract, and compatibility registry are available for later work; the broker remains disabled until a separately configured trusted host worker is used. Any provider-backed ACP run still requires separate credential and spending authorization. The milestone 6 clarification interface remains reserved for that milestone and was not implemented here.