fix(miner): cover worktree-allocator's worktree_slots in purge-cli's right-to-be-forgotten sweep - #8570
Conversation
|
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 #8570 +/- ##
==========================================
+ Coverage 89.58% 89.70% +0.12%
==========================================
Files 97 100 +3
Lines 22706 22977 +271
Branches 3872 3946 +74
==========================================
+ Hits 20341 20612 +271
Misses 2187 2187
Partials 178 178
Flags with carried forward coverage won't be shown. Click here to find out more.
|
…right-to-be-forgotten sweep Adds WorktreeAllocator.purgeByRepo, a hand-written UPDATE that only ever blanks a free slot's repo_full_name -- never deletes a row (the pool is fixed-size) and never touches an active slot, since that would desync the allocator from a live attempt's real on-disk worktree checkout. LedgerPurgeSpec gains an optional extraWhereSql so --dry-run's row count stays in lockstep with that same free-only restriction.
…r fake Follow-up to the worktree-allocator purge-cli fix: the interface's new required method broke this test file's hand-constructed allocator stub, caught by the root typecheck (not the miner package's own scoped build, which doesn't see test/unit/**).
14f184f to
85acd2d
Compare
|
Tip ✅ LoopOver review result - approve/merge recommendedReview updated: 2026-07-24 21:36:09 UTC
Review summary Nits — 5 non-blocking
Decision drivers
Context & advisory signals — never blocks the verdict
Linked issue satisfactionAddressed Review context
Contributor next steps
Signal definitions
🧪 Chat with LoopOverAsk LoopOver a question about this PR directly in a comment — grounded only in the same cached, public-safe facts shown above, never a new claim.
Full command reference: https://loopover.ai/docs/loopover-commands 🧪 Experimental — new and may change. 🟩 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 LoopOver, a quiet PR intelligence layer for OSS maintainers.
|
Summary
packages/loopover-miner/lib/worktree-allocator.ts'sworktree_slotstable is a fixed pool (slot_indexis the primary key; every slot0..maxConcurrency-1always exists), so it needed a bespokepurgeByReporather than the genericDELETE-basedpurgeStoreByRepoevery other repo-scoped store reuses.WorktreeAllocator.purgeByRepois a hand-writtenUPDATEthat only ever blanksrepo_full_name/attempt_id/owner_pid/owner_host/allocated_aton astatus = 'free'row for the target repo — it never deletes a row, and it never touches astatus = 'active'row, since an active slot'srepo_full_namereflects a live, currently-running attempt's real on-disk worktree checkout. In normal operation this is expected to affect 0 rows in the overwhelming majority of real calls (release()/reclaimOrphanedAllocations()already blank a slot on every path that frees it) — it exists purely as a defensive backstop for a row that predates this fix or was left stale by an unexpected crash path.worktree-allocatoris now registered inpurge-cli.ts'sREAL_PURGE_TARGETS, followinggovernor-state's existing precedent for a store with custom (non-generic) purge logic.store-maintenance.ts'sLedgerPurgeSpecgains an optionalextraWhereSqlfield so--dry-run's read-only row count (countStoreByRepo) can stay in exact lockstep with the real purge'sstatus = 'free'restriction — every one of the other 12 existing specs leaves this field unset, so their behavior is unchanged.WorktreeAllocatoris now a required-purgeByRepointerface (matching every otherPurgeableStore), sotest/unit/miner-attempt-cli.test.ts's one hand-constructed inline allocator stub gained a matchingpurgeByRepo: vi.fn(() => 0)— the only other place in the repo that builds aWorktreeAllocator-shaped object without going through the realopenWorktreeAllocator.This is the same recurring "repo-scoped local store missing from the right-to-be-forgotten sweep" gap class already fixed three times before (#7091, #6599, #8009).
Scope
type(scope): short summaryConventional Commit format.CONTRIBUTING.mdand does not reintroduce GitHub Pages, VitePress,site/, orCNAME.Validation
git diff --checknpm run actionlintnpm --workspace @loopover/miner run build(typecheck +check-syntax.mjsover everybin//lib/file)tsc --noEmit(roottsconfig.json's full flag set) across every changed file plus every test file that referencesWorktreeAllocator's type (test/unit/miner-worktree-allocator.test.ts,test/unit/miner-purge-cli.test.ts,test/unit/miner-store-maintenance.test.ts,test/unit/miner-attempt-cli.test.ts) — cleannpx vitest run test/unit/miner-worktree-allocator.test.ts test/unit/miner-purge-cli.test.ts test/unit/miner-store-maintenance.test.ts test/unit/miner-attempt-cli.test.ts— 160/160 passing, covering: a free slot with a stalerepo_full_name(seeded directly, since normal operation never leaves one) is purged and counted; an active slot for the target repo is left completely untouched and not counted; no matching rows returns 0; an invalid repo name is rejected the same wayacquirealready rejects one;--dry-runreports the same count the real purge would remove for both the free-stale and active cases; the fullrunPurge/runPurgeDryRunintegration paths (seeded real stores, injected fakes, the real-default-on-disk-stores path, and the partial-failure path) all account for the 13th store;store-maintenance.ts'scountStoreByRepoANDsextraWhereSqlcorrectly and leaves every spec without one unaffected.If any required check was skipped, explain why:
npm run typecheck/npm run test:coverage(unsharded) reliably OOM in this sandbox regardless of diff size — a known sandbox resource constraint documented across many prior PRs, not a signal about this change.packages/loopover-miner/**is not included invitest.config.ts'scoverage.include(confirmed empirically — it doesn't appear in a coverage report at all, at any percentage), so it is not Codecov-gated; the gate here isnpm run test:cistaying green with real branch coverage in the four test files touched, which the 160 passing tests above satisfy directly.Safety
UI Evidencesection below with JPG/JPEG or PNG screenshots arranged as organized, captioned, clickable thumbnails. SVG screenshots are not used as review evidence. Review-only screenshots or recordings are not committed to the repository.UI Evidence
This is a backend-only CLI/store change (
packages/loopover-miner/**) with no rendered UI delta — before and after are the same production capture at each required viewport.apps/loopover-uiis dark-mode-only, so only the Dark row per viewport applies.Notes
governor-state.ts's ownpurgeByRepo(the closest existing precedent for a store needing custom, non-generic purge logic) and itsspecs(notspec) entry inpurge-cli.ts'sREAL_PURGE_TARGETS.validate-code/typecheck failure: makingpurgeByRepoa required field onWorktreeAllocatorbroke a hand-constructed allocator stub intest/unit/miner-attempt-cli.test.tsthat this PR's own scoped@loopover/minerbuild didn't cover (that file lives under roottest/unit/, outside the miner package's own tsconfig). This PR fixes that stub directly and widens the local scoped-typecheck sweep to include every test file that referencesWorktreeAllocator's type, not just the ones this change's own tests live in.