Repository navigation
Conversation
Contributor
ApprovabilityVerdict: Approved at Macroscope's review found this PR approvable — This is a narrowly scoped server bug fix that corrects storage cleanup's archived-thread read and adds focused ProjectionStore coverage. Archived worktrees now follow the existing cleanup safeguards and operator-configured policies, while active-thread behavior remains unchanged. You can add or adjust custom eligibility rules. Learn more. |
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>
juliusmarminge
force-pushed
the
fix/storage-cleanup-archived-threads
branch
from
October 7, 2026 17:23
8d4b734 to
e07ef53
Compare
macroscopeapp
Bot
dismissed
their stale review
October 11, 2026 06:10
Dismissing prior approval to re-evaluate e07ef53
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
Closes #17811