Run Space Reclamation
Opt In Run Reclamation
Prune transcripts, purge detailed logs, and clear stale worktrees without erasing run records
3 milestones 17 tasks 40 agents
7 plan 17 execute 21 review
189k peak context
144k median execute
3h 29m total 9m 48s per task
1m 20s plan 1h 48m execute 32m 55s review
181 edits 1.2k commands
codex harness
Gantry keeps detailed run evidence by default, which is valuable for debugging, replay work, and later analysis, but expensive on disk once a project has a long build history. This run turned reclamation into an explicit operator workflow instead of treating artifact deletion as teardown. The build split the problem into the command foundation, transcript cleanup, and worktree cleanup. Reviews between those milestones found missing report detail, stage-log coverage, sidecar accounting, and corpus evidence, so the later cuts repaired the earlier contracts before extending the feature.
How this walkthrough is structured
Feature
What did the run build and ship?
Gantry now ships opt-in reclamation verbs that report exact planned impact, preserve durable run records, and distinguish transcript cleanup from stale checkout cleanup.
Build
How did Gantry structure the work?
The run used contract-first milestones for a destructive feature, and review feedback between milestones reshaped the remaining work without producing a red gate.
Milestone 1
Reclamation Command Base
5 tasks 13 agents 1h 9m wall time 162k peak context
The live CLI still exposes the reclamation verbs as first-class run-management commands, and the parser keeps their flags scoped to those verbs. `src/commands.rs` retains the request, candidate, plan, preview, and operation types that later actions consume. The docs still describe explicit targeting, dry runs, default refusal, and the rule that full capture remains the default.
This milestone carried the shared operator contract before any destructive transcript rewrite or worktree deletion existed. Its brief kept the scope to parsing, selection, reporting, confirmation, skip policy, and usage-sidecar preservation, which made the work divisible for fresh agents. The milestone finished green, but its review recorded that the next milestone had to repair the report so eligible artifacts were named individually.
CLI Request Surface
2 agents 12m 32s wall time 150k peak context
The current command surface still lists `prune` and `purge`, and dispatch routes them through the same bare first-argument rule as other run-management verbs. Their request parser resolves a single run name or an explicit all-runs scope, accepts dry-run and confirmation bypass flags, and rejects missing or conflicting scopes before planning.
This sprint introduced the command entry points and request payload without touching artifacts. The cut was narrow enough for one agent because it was about verb recognition, flag ownership, and name resolution, not cleanup behavior. Its boundary held through the gate and gave later sprints a stable request object.
Run Eligibility Planning
2 agents 11m 32s wall time 162k peak context
The candidate planner still separates requested runs, eligible runs, and skipped runs. It protects active and live-owned runs, applies age filters conservatively, inventories transcripts, stage logs, and usage sidecars, and skips tracked artifacts with local modifications. Those decisions feed both preview and apply paths.
This sprint turned a parsed request into a candidate set while leaving mutation out of scope. The brief made it responsible for stable ordering, active-run protection, dirty-artifact skips, missing-artifact visibility, and age filtering. It stayed green, so the report sprint could consume eligibility as data rather than redo selection.
Preview Accounting
2 agents 10m 9s wall time 109k peak context
The reporting code now renders an artifact action plan before any prompt or write. It shows scope, action meaning, skipped runs, per-artifact actions or skip reasons, and totals from the same plan the applier receives. Later transcript work replaced the early placeholders with transform-backed accounting rather than changing the report surface.
This sprint owned the reportable plan shape for destructive work. It was asked to make dry-run and pre-confirmation output use one shared rendering path, with byte accounting supplied by action previews. The gate stayed green, but the milestone review later found that the initial report still needed artifact-level eligible rows before transcript cleanup could be trusted.
Confirmation Safeguards
2 agents 15m 3s wall time 153k peak context
The operation path still treats dry runs, empty selections, declined prompts, confirmed runs, sidecar creation, preservation failures, and action failures as explicit outcomes. Missing usage sidecars are derived before prune or purge proceeds, and a preservation failure blocks that run from deletion or rewrite. The outcome renderer reports those cases separately.
This sprint connected the preview contract to the destructive-command confirmation model. The agent had a focused safety job: report first, refuse by default, let an explicit yes bypass prompting, and generate missing usage sidecars before later destructive actions could discard transcript-only evidence. It passed cleanly and left mutation hooks for the following milestone.
Docs And Compatibility
2 agents 8m 28s wall time 128k peak context
The CLI reference still documents the reclamation family beside other run-management verbs. It distinguishes reclamation from teardown, explains explicit scope and safety behavior, and keeps compatibility expectations around destructive commands in one place. Some original integration fixture files have since been reorganized, but the command documentation remains current.
This closing sprint made the foundation visible to operators and checked that the new flags did not disturb older command behavior. Its brief was intentionally lighter because the contracts already existed; the work was documentation plus compatibility coverage. The milestone closed green, with the review note becoming input to the transcript milestone rather than a failure to merge.
Milestone 2
Transcript Cleanup
5 tasks 16 agents 1h 8m wall time 189k peak context
Transcript reclamation still stands in the code and docs. Prune rewrites detailed transcripts into a readable retained form, while purge deletes detailed transcript and stage-log bulk but keeps ledgers, plans, about cards, progress, history, and usage sidecars. Compatibility docs now classify the retained-marker and missing-log states for older tooling.
This milestone had to both repair the foundation's report and implement the two transcript reclamation levels. The cut kept the deeper deletion work separate from pruning, so each agent could focus on either the retained transcript form, the apply path, purge semantics, or documentation. One sprint was re-planned and run again after review, and the milestone review pushed remaining stage-log, sidecar, and corpus-validation gaps into the final milestone.
Action Report
5 agents 26m 49s wall time 122k peak context 1 replan
The current artifact action plan still enumerates transcripts, stage logs, and usage sidecars with an action or skip reason per row. Report rendering uses that plan for dry runs and confirmation previews, and purge and prune both consume the same artifact rows. The earlier aggregate-only shape has been replaced by concrete artifact reporting.
This sprint reopened the shared report contract before destructive transcript behavior landed. The brief was precise: name every eligible artifact, every skipped artifact, exact before-and-after accounting, scope, and warning text from a single action plan. Review forced a re-plan and a second implementation pass, showing that the difficult boundary was report truthfulness rather than deletion.
Prune Contract
2 agents 13m 19s wall time 189k peak context
`prune_transcript_bytes` remains the core transcript transform. It replaces repository-sized file payloads with markers, truncates long command output while keeping readable head and tail text, preserves ordinary JSON lines, and recognizes already-pruned transcripts as no-work. The transform supplies the byte accounting used by prune previews.
This sprint isolated the data-loss decision into a deterministic transform. That made it right-sized for a fresh agent: it did not have to implement confirmed file replacement, only decide how a transcript changes and how preview bytes are computed. It passed cleanly and gave the apply sprint a pure contract to call.
Prune Apply
2 agents 9m 48s wall time 187k peak context
Confirmed prune now rewrites only the transcript rows named by the plan. Before replacing a file it re-runs the transform and refuses the rewrite if the current bytes no longer match the preview, then writes atomically. Tests still cover idempotent pruning and retained command identity, status, exit information, usage data, and final result classification.
This sprint turned the transform-backed preview into an actual rewrite command. Its brief kept the applier tied to the already planned artifact rows, so the agent only had to enforce atomic replacement, accounting parity, sidecar preservation, and idempotency. It stayed green because selection, reporting, and transformation were already settled.
Purge Apply
2 agents 7m 28s wall time 144k peak context
Confirmed purge now deletes only planned detailed transcript and stage-log artifacts after preservation has run. The implementation keeps usage sidecars and durable run materials, and it checks the planned byte state again before deletion. The CLI docs still state that purge is not run removal and that the run remains listable at summary level.
This sprint implemented the more destructive transcript action after prune had proven the report and preservation path. The brief made the unit about deletion boundaries: remove planned transcript and stage-log artifacts, keep the durable run record, and make purge visibly different from prune. It passed without a recorded red gate.
Docs And Compatibility
2 agents 4m 33s wall time 99k peak context
The CLI reference, versioning guide, replay corpus runbook, and screencast runbook still describe pruned and purged runs. They explain what transcript-dependent workflows lose, what replay can still use, and why retained markers and missing detailed logs are compatibility-relevant states. That documentation remains the operator-facing bridge between cleanup and downstream tooling.
This sprint closed the transcript milestone by documenting the completed prune and purge behavior. Its scope was public explanation and compatibility consequences rather than new reclamation machinery. The work finished green, but the milestone review found that some implementation evidence and purge coverage still belonged in the final milestone.
Milestone 3
Worktree Cleanup
7 tasks 16 agents 1h 4m wall time 185k peak context
The current tree has a complete reclamation family: transcript prune and purge, stale worktree removal, and rebuildable build-output cleanup. Worktree candidates distinguish live, orphaned, merged, unmerged, dirty, unreadable, and empty-output cases, while lifecycle docs clarify which retained worktrees are intentional handoff state rather than leaks.
This milestone completed the disk-space plan beyond tracked transcript artifacts. It first closed transcript gaps from review, then built worktree discovery, stale checkout removal, build-directory cleanup, lifecycle leak evidence, and final documentation. The run facts show the milestone stayed green, so the expanded scope was carried by sequencing remediation before the new worktree actions.
Transcript Cleanup
2 agents 7m 21s wall time 117k peak context
Purge planning now includes detailed stage logs as reclaimable artifacts and preserves usage sidecars as durable facts. Missing sidecars are accounted for even when the apply step must create them before deletion. The report and outcome paths still show these preservation and deletion decisions explicitly.
This sprint took the transcript remediation discovered at the previous milestone boundary. Its task was to finish stage-log purge coverage and make sidecar creation part of exact before-and-after accounting. The cut was corrective and contract-level, so the following worktree sprints could rely on the transcript story being closed.
Corpus Validation
2 agents 9m 7s wall time 185k peak context
The tests now exercise real Claude and Codex transcript semantics after pruning, including usage extraction and final-result parsing. Small fixture files for opencode and Gemini remain in the tree to capture the bounded-payload finding. This means prune behavior is still checked against the harness differences the plan called out.
This sprint upgraded prune evidence from synthetic shapes to real or corpus-shaped harness transcripts. The brief kept behavior changes optional unless the evidence exposed a mismatch, which let the agent focus on parser equivalence, command identity, and bounded payload characterization. It stayed green and gave the documentation a factual safety basis.
Worktree Candidate Contract
2 agents 12m 5s wall time 185k peak context
`WorktreeReclamationCandidate` still carries repository identity, run identity, checkout path, branch, age eligibility, live owner, Git-known state, merge safety, local risk, byte measurements, selected action, and skip reasons. Candidate planning also includes orphaned directories under the repository worktree prefix, so cleanup can see historical leftovers outside the run registry.
This sprint established the worktree-side discovery contract before any checkout removal could run. The unit was broad but coherent: enumerate candidates, classify liveness and version-control state, measure checkout and build-output bytes, apply age filters, and render skip reasons. The clean gate let later destructive actions consume candidate facts instead of probing independently.
Stale Worktree Removal
1 agents 10m 25s wall time 102k peak context
Confirmed worktree reclamation now removes eligible orphaned or fully merged disposable checkouts and removes known merged run branches through Git. It rechecks risk before deletion, refuses widened bare invocations, supports age filters, and reports byte mismatches or changed safety state as failures to rerun from a fresh plan. Dirty, unmerged, live, missing-branch, and unknown-safety checkouts stay protected by default.
This sprint turned the candidate contract into checkout removal. Its brief made the destructive boundary explicit: support named or all-runs scope, preserve live and risky local work, confirm by default, and remove only candidates already classified as safe. Because the planner had separated discovery first, the apply unit stayed focused on revalidation and removal.
Build Directory Cleanup
2 agents 7m 57s wall time 131k peak context
`build-directories` now removes rebuildable output such as Rust target directories while leaving the checkout itself in place. It uses the same report, dry-run, confirmation, all-runs scope, and age-filter machinery as worktree removal. Candidates with no build output are reported separately, and live worktrees remain protected.
This sprint added the less destructive worktree-space action after full checkout removal already existed. The brief kept it on the same candidate contract but changed the selected action to rebuildable output only, which made its safety story smaller than checkout deletion. It passed cleanly and kept the operator model consistent with the other reclamation verbs.
Teardown Leak Closure
2 agents 5m 29s wall time 123k peak context
The lifecycle tests now cover normal terminal cleanup removing the disposable checkout and branch, and failed or handoff paths retaining state for resume or by-hand repair. `src/engine/cleanup.rs` still documents teardown as botched-run removal, distinct from historical reclamation. The CLI docs direct historical leftover checkouts to the worktree reclamation report.
This sprint investigated whether cleanup commands were masking a lifecycle leak. Its brief required either a fix for a current leak or durable evidence that normal terminal paths already remove disposable worktrees while resumable handoff paths intentionally retain them. The work stayed green and did not broaden reclamation into lifecycle repair.
Reclamation Documentation
2 agents 4m wall time 104k peak context
The command reference now describes every reclamation choice in one place: doing nothing, pruning transcripts, purging detailed logs, removing stale worktrees, and cleaning rebuildable output. The versioning guide records the command-surface and artifact-format implications, while corpus and screencast docs state what remains possible after logs are pruned or purged.
This final sprint aligned the documentation with the completed contracts. It consumed both the artifact accounting and worktree candidate models, so its job was to describe the behavior that already existed rather than invent another command story. The final gate stayed green and no further re-plan was recorded.