Repository navigation
Conversation
The V2 port read archived threads from `getShellSnapshot({ location:
"archive" }).threads`, but the store returns them in `archivedThreads`,
so `.threads` was always empty there. Archived threads never became
cleanup candidates, and their worktrees stayed on disk.
Read one snapshot and include both `threads` and `archivedThreads`, as
V1 did with `getArchivedShellSnapshot`.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a small, well-scoped server bug fix that restores archived threads to the existing storage-cleanup pipeline without changing defaults or introducing new cleanup rules. The added projection-store test covers the corrected active-plus-archived thread read. You can add or adjust custom eligibility rules. Learn more. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review. 📝 WalkthroughWalkthroughThe storage-cleanup code now reads active and archived threads from one shell snapshot. ChangesStorage cleanup thread reads
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix Suggested reviewers: Merge Risk: ⚪ Minimal · up to Storage cleanup now includes archived threads in its thread read. No merge-blocking issue is identified; a live cleanup sweep was not validated. Security Architecture ReviewSecurity architecture risk: ⚪ Minimal · up to The fix restores cleanup eligibility for archived worktrees without weakening the existing deletion checks. Including archived owners also improves protection for shared worktrees. No new externally reachable operation or material security regression was identified. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Problem
Automatic storage cleanup never looks at archived threads, so their worktrees stay on disk under every worktree rule except deletion.
The V2 port of
readThreads(apps/server/src/storageCleanup.ts:152-157, from #2829) read archived threads withgetShellSnapshot({ location: "archive" }).threads. The store returns archived threads inarchivedThreadsand filtersthreadstoarchivedAt === null(ProjectionStore.tsSQL layer around line 5586, memory layer around line 5760). So that list is always empty. V1 included archived threads throughgetArchivedShellSnapshot(), and the storage guide does not exclude them.Change
Read one unfiltered shell snapshot and use both
threadsandarchivedThreads. The read moves into a small exportedreadStorageCleanupThreads(projections)so a test can run it against the real projection store.Archived threads then go through the same checks as active ones: idle, single owner, terminals, sessions, managed path, clean Git state, ignored files, and the re-read before removal. A side effect, also a fix: an archived thread that shares a worktree now counts as a sharer. Before, cleanup could not see it, so the single-owner check and the deleted-thread path could treat a worktree it still used as unowned.
Scope and approval
There is no prior issue. I believe this qualifies as a very small, focused fix for an obvious bug: one read misuses the snapshot contract, and the fix restores V1 and documented behavior with no new setting or policy. I found it while adding evidence to #15146. It is independent of #15146/#15150 (status gate), #14742/#14847 (squash merges) and #16472 (subagent-shared worktrees). #15080 happens to make the same change inside a much larger rewrite.
Verification
V2 storage cleanup thread reads > includes archived threadsseeds one active and one archived thread intoProjectionStore.layeron in-memory SQLite, then checks thatreadStorageCleanupThreadsreturns both.expected [ 'thread-active' ] to deeply equal [ 'thread-active', 'thread-archived' ]. With the fix:vp test run apps/server/src/storageCleanup.test.ts, 10 passed.tsc --noEmitinapps/server: no errors in the changed files. The only errors are 10 insrc/process/externalLauncher.test.ts, which already fail onmainat9bd1d8009a.vp lintandvp fmt --checkon both files are clean.Not checked: a live sweep removing an archived thread's worktree in a running app. The rest of the sweep needs Git, settings, terminal and session services, and no test harness covers it today.
Written by Claude Opus 5.5 in T3 Code's Claude Code harness, reviewed by GPT-6.1-Sol in T3 Code's Codex harness.
🤖 Generated with Claude Code