Intent
Container-runtime resources created for a task are released on the graceful path only. teardownEgressProxy (task-isolation.ts:1018) removes the squid container and both networks, and its single caller is the drain handler in workspace.ts:370, reached from SIGINT/SIGTERM.
The boot sweep does not compensate. sweepOrphanedHomeVolumes (task-isolation.ts:1480) covers HOME volumes and nothing else; workspace.ts:617 calls taskManager.sweepOrphanedVolumes() and there is no equivalent for containers or networks.
So an ungraceful death of the CLI (SIGKILL, OOM killer, host crash, and per #71 SIGHUP on terminal close) leaves behind:
- the squid container
codesema-proxy-<id>, started with -d --rm (:970-985) — --rm only fires when the container itself exits, and squid does not exit
- both networks
codesema-net-<id> and codesema-egress-<id> (:951-965)
- the agent container, which keeps running its turn with full Bash inside the worktree while the host-side watchdog that was supposed to bound it is gone
The last point is the one that matters: --rm will eventually clean the agent container up, but only after an unsupervised turn has finished writing to the worktree. The kill path is by container name (:2037-2038) and it dies with the process that knew the name.
Related but distinct: #71 covers orphaned agent processes and the missing SIGHUP handler; #72 covers boot reconciliation inferring orphanhood without a liveness signal. This issue is about the runtime resources nothing reclaims, which remain even once those two are fixed.
Scope
In scope:
- Squid containers, the two per-workspace networks, and agent containers left by an ungraceful exit.
- The boot sweep, which today reclaims only HOME volumes.
Out of scope:
Approach
Extend the labelling already used for HOME volumes (HOME_VOLUME_OWNER_LABEL, :331) to every container and network the workspace creates, then widen the boot sweep to reclaim any labelled resource whose owning workspace is no longer alive. The owner check must stay uid-scoped, for the same reason spelled out at :333-336.
ADDED Requirements
Requirement: Runtime resources MUST be reclaimable after an ungraceful exit
The system SHALL reclaim the containers and networks it created once the workspace that created them is no longer running, without requiring that workspace to have exited gracefully.
Scenario: the CLI is killed outright
- GIVEN a workspace running a caged turn, with a squid container and its two networks up
- WHEN the CLI process is terminated with SIGKILL
- AND a new workspace starts later on the same machine
- THEN the boot sweep removes the orphaned squid container and both networks
- AND it does not touch resources owned by another live workspace or another OS user
Scenario: an agent container outlives its supervisor
- GIVEN a caged turn in flight
- WHEN the CLI dies without running its kill path
- THEN the orphaned agent container is reported at next boot
- AND it is removed rather than left to finish its turn unsupervised
Tasks
1. Label what is created
2. Widen the sweep
3. Prove it
Intent
Container-runtime resources created for a task are released on the graceful path only.
teardownEgressProxy(task-isolation.ts:1018) removes the squid container and both networks, and its single caller is the drain handler inworkspace.ts:370, reached fromSIGINT/SIGTERM.The boot sweep does not compensate.
sweepOrphanedHomeVolumes(task-isolation.ts:1480) covers HOME volumes and nothing else;workspace.ts:617callstaskManager.sweepOrphanedVolumes()and there is no equivalent for containers or networks.So an ungraceful death of the CLI (
SIGKILL, OOM killer, host crash, and per #71SIGHUPon terminal close) leaves behind:codesema-proxy-<id>, started with-d --rm(:970-985) —--rmonly fires when the container itself exits, and squid does not exitcodesema-net-<id>andcodesema-egress-<id>(:951-965)The last point is the one that matters:
--rmwill eventually clean the agent container up, but only after an unsupervised turn has finished writing to the worktree. The kill path is by container name (:2037-2038) and it dies with the process that knew the name.Related but distinct: #71 covers orphaned agent processes and the missing
SIGHUPhandler; #72 covers boot reconciliation inferring orphanhood without a liveness signal. This issue is about the runtime resources nothing reclaims, which remain even once those two are fixed.Scope
In scope:
Out of scope:
squid.confin tmp, already documented as harmless if it outlives the process (:1041-1043).Approach
Extend the labelling already used for HOME volumes (
HOME_VOLUME_OWNER_LABEL,:331) to every container and network the workspace creates, then widen the boot sweep to reclaim any labelled resource whose owning workspace is no longer alive. The owner check must stay uid-scoped, for the same reason spelled out at:333-336.ADDED Requirements
Requirement: Runtime resources MUST be reclaimable after an ungraceful exit
The system SHALL reclaim the containers and networks it created once the workspace that created them is no longer running, without requiring that workspace to have exited gracefully.
Scenario: the CLI is killed outright
Scenario: an agent container outlives its supervisor
Tasks
1. Label what is created
2. Widen the sweep
sweepOrphanedHomeVolumesto containers and networks, keeping the "never touch a live workspace" guard3. Prove it