Skip to content

[P1] Add an ownership ledger and orphan reconciliation for worker resources #34

Closed

Description

@anthonyandrei

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.ps1
  • scripts/execution-workspace.sh
  • scripts/cleanup-research-workspace.ps1
  • scripts/cleanup-research-workspace.sh
  • tests/

Activity

  1. anthonyandrei commented on Sep 4, 2026

    @anthonyandrei
    OwnerAuthor

    Resolved by PR #39 (#39). The merged implementation covers this issue, and the targeted acceptance tests pass. Closing as completed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions