feat(miner-concurrency): add git-worktree-per-attempt pool allocator (#4297) - #4598
Conversation
…SONbored#4297) New packages/gittensory-engine/src/miner/worktree-pool.ts: the pure, in-memory scheduling logic for a POOL of per-attempt git worktrees across concurrent fleet attempts, complementary to the isolation primitive (worktree-allocator.ts, JSONbored#4269). acquire/release under a configurable concurrency cap, plus orphan reclamation (free slots whose attempt is no longer live). Each slot's path/branch is derived via the primitive's planWorktree. Per JSONbored#4297, the pure allocation logic lives in gittensory-engine so it is unit-testable without a real filesystem or DB; the SQLite bookkeeping wrapper that persists WorktreePoolState is a thin miner-package layer. No IO here — every function takes state in, returns new state out. Closes JSONbored#4297
|
🚨 Contributor flagged. Click here for more info: Superagent Dashboard |
|
Superagent didn't find any vulnerabilities or security issues in this PR. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #4598 +/- ##
=======================================
Coverage 94.12% 94.13%
=======================================
Files 430 431 +1
Lines 38181 38198 +17
Branches 13922 13927 +5
=======================================
+ Hits 35939 35956 +17
Misses 1585 1585
Partials 657 657
🚀 New features to boost your workflow:
|
|
Tip 🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩🟩 ✅ Gittensory review result - approve/merge recommendedReview updated: 2026-07-10 07:46:50 UTC
✅ Suggested Action - Approve/Merge
Review summary Nits — 4 non-blocking
Flagged checks (non-blocking)
Linked issue satisfactionPartially addressed Review context
Contributor next steps
Signal definitions
🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed 💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →. Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.
|
Adds the git-worktree pool allocator (Closes #4297) — complementary to the isolation primitive (
worktree-allocator.ts, #4269, already merged): that plans/creates/tears down ONE worktree; this manages the POOL of them across concurrent fleet attempts.New
packages/gittensory-engine/src/miner/worktree-pool.ts:acquireWorktree(state, config, {attemptId, repoPath})— allocates a slot under a configurablemaxConcurrencycap; fails without mutating onalready_allocated(idempotency guard) orat_capacity. Each slot's path/branch comes from the primitive'splanWorktree.releaseWorktree(state, attemptId)— frees the slot for reuse (idempotent).reclaimOrphanedWorktrees(state, liveAttemptIds)— frees + returns allocations whose attempt is no longer live (so a crash can't leak worktree slots forever).availableWorktreeSlots/isWorktreeAllocatedhelpers.Per #4297's split option, the pure allocation logic lives in
gittensory-engineso it's unit-testable without a real filesystem or DB; the SQLite-bookkeeping wrapper that persistsWorktreePoolState(theclaim-ledger.js/run-state.jspattern) is a thin miner-package layer. No IO here — state in, new state out.Test
test/unit/miner-worktree-pool.test.ts— acquire (deterministic plan),already_allocated+at_capacity(both no-mutation), release + freed capacity + unknown-attempt no-op, orphan reclamation + all-live no-op, and the slots-clamp-at-0 case. Mirrors the primitive's test (imports engine src via vitest).site//CNAME/**/lovable/**; noCHANGELOG.md. New engine module + test + one entrypoint export; no secrets.