Repository navigation
Description
Problem
The existing lifecycle helpers clean resources when the caller reaches cleanup. They do not provide one durable record for every process, worktree, temporary directory, and artifact created by all adapters. A crashed orchestrator can leave resources behind.
Deliverable
Add an orchestrator-owned resource ledger outside worker checkouts. Register resources before or at creation, update lifecycle state, and reconcile unfinished records on the next run.
The ledger must cover AGY-created worktrees and resources created by future adapters.
Cleanup must be idempotent and ownership-checked. Retain dirty, unmerged, unknown, or ambiguous resources for review.
Acceptance criteria
- Each resource record has assignment identity, parent identity, resource type, absolute path or process identity, owner marker, state, and timestamps.
- The ledger survives orchestrator failure and supports a later reconciliation pass.
- Normal completion, worker failure, timeout, cancellation, and quota handoff all enter cleanup or retention through the same lifecycle.
- Repeating cleanup does not damage retained evidence or report a false success.
- Cleanup removes only ledger-owned resources that pass the safety checks.
- Unknown, dirty, unmerged, or ambiguous worktrees remain available for review.
- A running worker is terminated and awaited before its owned resources are removed.
- AGY-native worktrees outside the current helper path are either registered or retained as unknown.
- A fake crash leaves records that a later reconciliation test can find and classify.
- Tests prove that no cleanup path reaches the caller checkout, a Git root, a reparse point, or an unowned directory.
Dependencies
- Depends on #31.
Related closed review issues
Build on the verified lifecycle and path-safety work in #6, #11, #12, and #16. Do not duplicate those fixes.
Out of scope
- Deleting resources that the ledger cannot prove are owned.
- Retaining full repository snapshots by default.
- Cleanup policies for unrelated applications.
Implementation pointers
scripts/execution-workspace.ps1scripts/execution-workspace.shscripts/cleanup-research-workspace.ps1scripts/cleanup-research-workspace.shtests/
Activity
anthonyandrei commentedon Sep 4, 2026
Resolved by PR #39 (#39). The merged implementation covers this issue, and the targeted acceptance tests pass. Closing as completed.