Skip to content

ams: worktree orphan reclaim only runs once at allocator-open time, not per-acquire #8859

Description

@JSONbored

⚠️ Definition of Done: this issue must be completed in full, in a single PR. Do not split this
work across multiple PRs, and do not defer any Deliverable below to a follow-up issue. A PR that
satisfies only some of the Deliverables, stubs a required test, or leaves a checkbox
partially-done does NOT resolve this issue and will be closed.

Context

packages/loopover-miner/lib/worktree-allocator.ts:261-281's reclaimOrphanedAllocations runs exactly once inside openWorktreeAllocator(). A long-lived fleet worker that opens its allocator once and calls .acquire() for hours never re-sweeps a peer that crashes mid-lease after open -- only a process restart re-triggers reclaim. Contrast with the sibling packages/loopover-miner/lib/portfolio-queue-manager.ts:169-174's claimNextBatch(), which calls sweepStuckItems(...) on every claim.

Requirements

Call reclaimOrphanedAllocations (with a fresh Date.now()) at the start of every acquire() call, matching portfolio-queue-manager.ts's existing per-claim sweep pattern, so a peer's crashed/orphaned allocation is reclaimed promptly rather than only at process-restart time.

Deliverables

  • acquire() calls reclaimOrphanedAllocations at its start, on every invocation, not just at allocator-open time
  • A test simulating an orphaned allocation created after the allocator was opened, asserting a subsequent acquire() call reclaims it without requiring a fresh openWorktreeAllocator() call

All of the above Deliverables are required in the same PR unless the deliverable text itself states otherwise.

Test Coverage Requirements

packages/loopover-miner/** -- 99%+ patch coverage on the new per-acquire reclaim path.

Expected Outcome

A crashed peer's orphaned worktree allocation is reclaimed on the very next acquire() call by any live worker, not only after every worker restarts its allocator.

Links & Resources

  • packages/loopover-miner/lib/worktree-allocator.ts:261-281
  • packages/loopover-miner/lib/portfolio-queue-manager.ts:169-174

Metadata

Metadata

Assignees

No one assigned

    Labels

    gittensor:featureGittensor-scored feature linked to a feature issue — scores a 0.25x multiplier.help wantedExtra attention is needed

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions