oliver-zehentleitner / maity
runner: remove an agent's workspace when its placement is stopped, so disks don't fill up
tsk-34gb7frfbsk7 Review
Request from the maintainer, 2026-11-12, after the agents' VM ran out of disk again:
dieses problem sollte unser runner mit lösen. jeder agent arbeitet in einem eigenem workspace und den löschen wir auch wenn der agent gestoppt wird. sonst müllt es nach und nach die disk zu
(This problem is one our runner should solve too. Every agent works in its own workspace, and we delete it when the agent is stopped. Otherwise the disk slowly fills up.)
Today: maity runner gc --revoked [--yes] removes a workspace only by hand, and only when its credential is revoked (cli/src/maity/runner/operate.py cmd_gc, _collect). It already does the right safety checks:
- the path is the one its record implies, never a symlink;
- no placement uses it;
- git can say what is in it, and unsaved work is listed.
Nothing runs it on a stop.
Wanted:
- When a placement ends because it was stopped (by the human, by
stop-all, or by the hub ending it), the runner removes that workspace, under the same checks as gc. - Unsaved work (uncommitted changes, unpushed commits, stashes) is not silently lost. Decide and write down whether the workspace is then kept and reported (to the hub as the placement's end reason and in
runner status), or whether the work is pushed to a rescue ref first. - Per-workspace caches and tool state live inside the workspace, so they go with it. Say in the PR what stays outside: HOME-wide caches such as uv/pip/npm, and harness state such as
~/.codexor~/.claude. Propose either a bounded cleanup for them, or arunner checkwarning when the disk is low. - A placement that is only restarted, or adopted after a runner restart, keeps its workspace.
Process:
- Contract first (§15, what a stop does to the workspace and how a kept one is reported), then the CLI.
- docs/runners and the runner's user docs in the same PR.
- Evidence: a test that stops a placement and finds the workspace gone, one with unsaved work that finds it kept and reported, and one where a restart keeps it.
Notes
Lotse · Nov 12, 2026, 11:07 UTC
Owner decision (req-fdfb49yzqnhv, 11:06Z): after a Stop the workspace stays for a retention time the owner chooses (for example 3h or 24h), with "remove immediately" as one of the choices; then it is deleted. Neither of the two offered options. Plan to lotse before code.
Lotse · Nov 12, 2026, 11:10 UTC
Plan by q445 approved by the lead: placement field workspace_retention (immediate/3h/24h default/7d); clock starts at the reported stop; a Start within the time reuses the workspace; removal by the runner under the gc checks, credential revoked; unsaved work is kept and shown, never deleted on its own. PRs: contract, hub, CLI runner, web + docs.
Maity Test Team · Nov 28, 2026, 14:24 UTC
Test (maity-test-team): the hub side passes. The runner side (PR c) and the disk check are not on main, so the card's goal is not built yet.
Hub part: #1707, merged as 287b25e7e71d7d64de5b9705d30b7fa4c0b85f34 (contract #1690, 327c3592a). Both are ancestors of the 0.1.0a12 release commit 6adc6c8cddcfad3936f3198c02b2b636029ead8e, which is live on prod (
GET /health: 0.1.0a12, revision/head20261124170513_org_link_check).Local, at 6adc6c8 (worktree,
uv run --python 3.12 --extra dev pytest tests/test_placement_workspace.py): 58 passed in 2 min 29 s. That file covers retention, the runner's workspace report (retained/kept/removed, epochs),closed=trueand the human remove. I did nothing on prod: every path here is a write or needs a runner credential.Not built, checked at origin/main 520e84d64:
- The runner removes the clone (PR c). docs/api.md §17 on
maity runner servesaysPOST /runner/placements/{id}/workspaceis answered by the hub but "the runner does not call it yet, tsk-34gb7frfbsk7".cli/srcdoes not mentionretention, and nothing posts a workspace report.closed=trueis read only for scratch (#1917, a different card). - The low-disk warning in `maity runner check`. The contract marks it "not built yet, tsk-34gb7frfbsk7".
- The card's evidence: a stop that removes the workspace, unsaved work that is kept and reported, and a restart that keeps it. None of this exists on the runner side yet.
- Dashboard (PR d):
web/jsonly hides placements whoseworkspace_outcomeisremoved. I found no retention setting and no remove button.
No bug filed: what is built behaves to the contract. The card should not go to done until PR c (and d) land.
- The runner removes the clone (PR c). docs/api.md §17 on