Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): storage cleanup reaches archived threads' worktrees #16473

MergedInfo-Cado(GitHub profile, opens in a new tab)merged 3 commits intomain fromrefs/pull/16473/headmerged by juliusmarminge View on GitHub

Storage cleanup read only active threads, leaving archived checkouts outside its configured cleanup rules and missing archived worktree sharers. Cleanup now reads both groups in one snapshot on the existing read-only worker, and its removal rechecks include archived owners before and after measuring a checkout.

Continues @Info-Cado’s work in #16473, preserving the contributor’s commits and merging current main. The helper-only export and test were replaced by the existing cleanup integration fixture. The projection path query gains an optional archived-inclusive mode; its default remains active-only for other callers.

Verification:

  • storageCleanup.test.ts: 137 → 139 tests. The two added cases exercise automatic removal of an eligible archived checkout and a late archived sharer cancelling removal. Existing sharing coverage also checks an archived owner.
  • ProjectionStore.test.ts: 43 tests, extending the existing SQL and memory cases for default-active and archived-inclusive queries, including deleted/null-path exclusions.
  • Combined suite: 178 passed, 4 failed before the recheck/query fix → 182 passed. A separate negative control restoring active-only snapshot reads fails the archived candidate and archived sharing checks.
  • Scoped server typecheck, targeted lint, formatting, and git diff --check pass. One full snapshot per sweep and the read-only reader path remain in place.
  • Running Linux server with isolated worktree state: created a real managed Git checkout and a thread through app commands, archived it through the app command, then enabled the unchanged-worktree rule through settings. The automatic sweep removed that checkout, reported 1 removed, 0 kept, 0 failed, and freed 108 bytes. Git’s worktree list and the filesystem confirmed removal; the thread remained archived. Automatic server report.

This is a server behavior change with no UI layout change; focused failure output and the actual cleanup report provide the before/after evidence. Concurrent archived-owner arrival is verified with the existing Deferred-paused integration fixture, not a live race. Electron desktop, macOS, Windows, iOS, Android, relay/tunnel connections, and live provider sessions were not exercised. The common server service supplies the existing clients; no wire or client changes are included.

One fresh independent full-diff review round by Claude Opus 5.5 and GPT-6-sol found no blockers; both independently reran all 182 focused tests.

Implementation: GPT-6.1-sol; tests: GPT-6-astra; independent reviews: Claude Opus 5.5 and GPT-6-sol. All ran through T3 Code; Codex harness for the Codex agents.

    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched

    2. macroscopeapp[bot](GitHub profile, opens in a new tab)commented

      Approvability

      Verdict: Approved at 6c4d5d8

      Macroscope's review found this PR approvable — Storage cleanup now applies the existing configured worktree policies to archived threads and rechecks archived owners before deletion, while the projection API remains active-only by default. The change is small, localized, backward-compatible, and covered by focused tests without altering product defaults or static-analysis configuration.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. coderabbitai[bot](GitHub profile, opens in a new tab)commented
      Review in Change Stack →

      No actionable comments were generated in the recent review. 🎉

      ℹ️ Recent review info
      ⚙️ Run configuration
      • Configuration used: Path: .coderabbit.config.ts
      • Review profile: CHILL
      • Plan: Advanced
      • Run ID: bc6353c7-0a25-4923-8ebc-2d3da409fc1d
      📥 Commits

      Reviewing files that changed from the base of the PR and between 8d4b734be41108d83f6bf1ba5dcffe5917040b97 and e07ef533410409a5787ec9cba37d264413f121da.

      📒 Files selected for processing (2)
      • apps/server/src/storageCleanup.test.ts
      • apps/server/src/storageCleanup.ts

      Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

      📝 Walkthrough

      The storage-cleanup code now reads active and archived threads from one shell snapshot. readThreads uses the new helper, and a test checks that it returns IDs for both thread states.

      Changes: Storage cleanup thread reads

      Layer / File(s)Summary
      Read active and archived threads
      apps/server/src/storageCleanup.ts, apps/server/src/storageCleanup.test.ts
      The new readStorageCleanupThreads helper maps a shell snapshot to a combined active and archived thread list. readThreads uses the helper. A projection-backed test checks that both thread IDs are returned.

      Priority: ➖ Normal

      Estimated code review effort: 2 (Simple) | ~10 minutes

      Change: Bug fix

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to e07ef

      Archived threads are included in the storage-cleanup read. No issue identified here needs resolution before merging.

      Security Architecture Review

      Security architecture risk: 🔵 Low · up to e07ef

      The fix applies existing cleanup rules to archived checkouts and improves protection for shared checkouts. Existing removal safeguards remain in place. Concurrent resume and cleanup have not been verified end to end, so some lifecycle uncertainty remains.

      Retained concerns No architecture-level concerns identified.

      Security review details

      Security Blast Radius

      • observed — The expanded destructive-operation scope is archived checkout directories eligible under configured cleanup policies. Removal still requires a linked worktree beneath a managed root, rejects symlinked worktree directories and protects project-root overlap. Archived references also block deletion-path cleanup of a still-owned checkout.

      Security Findings and Attack Paths

      • inferred — The changed helper and test do not establish a new attacker-controlled entrypoint or a bypass of existing filesystem-removal controls. The demonstrated change is broader consumption of persisted owners through the existing cleanup path, rather than additional removal privileges.

      Trust Boundaries and Controls

      • observed — Persisted thread path and branch values are checked against managed filesystem boundaries, project ownership and current Git state before reaching worktree removal. Cleanup revalidates owner identity, activity, sessions, branch, commit, ignored files and settings, then requests non-forced removal under a workspace lease.

      Resilience and Maintainability Implications

      • inferred — Cleanup and provider startup are not demonstrated to be one atomic transition. Startup attempts missing-checkout recreation, and session opening checks that its working directory exists; those are counterevidence against silently proceeding with an absent checkout, not proof of complete race recovery. These mechanisms are unchanged from the base, and no introduced security failure was established.
      Pre-merge checks: Passed 5
      Check nameStatusExplanation
      Linked Issues checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck skipped because no linked issues were found for this pull request.
      ApprovabilityPassedThe pull request changes only apps/server/src/storageCleanup.ts and its test. The code fixes a focused archive-read bug by combining snapshot.threads and snapshot.archivedThreads. It does not ch…
      Title checkPassedThe title clearly identifies the server fix and the primary behavior change: storage cleanup now reaches archived threads' worktrees.
      Description checkPassedThe description explains the problem, implementation, scope, verification results, limitations, and test evidence. It does not use the template's explicit Problem, Change, or Scope and approval headin…
      Full details: Approvability

      Explanation

      The pull request changes only apps/server/src/storageCleanup.ts and its test. The code fixes a focused archive-read bug by combining snapshot.threads and snapshot.archivedThreads. It does not change defaults, static-analysis directives, dependencies, CI or review configuration, contracts, authentication, or external side effects. It does not add a subsystem or a broad workflow.

      Full details: Description check

      Explanation

      The description explains the problem, implementation, scope, verification results, limitations, and test evidence. It does not use the template's explicit Problem, Change, or Scope and approval headings, and it does not include an explicit maintainer approval comment or a clear approval exemption rationale.

      ✨ Finishing Touches 💡 1
      🧪 Generate unit tests (beta)
      • Create a new PR
      🛠️ Fix failing CI checks 💡
      • Commit to this branch
      • Create a new PR
      • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Comment `@coderabbitai help` to get the list of available commands.
    4. juliusmarminge added labelsmacroscope-review

    5. juliusmarminge assignedjuliusmarminge

    6. Taking over this one for the worktree-git-04 batch. I’ll preserve your commits, merge main, and finish the archived-owner removal rechecks while keeping the read-only snapshot path. Thanks for tracing the archived snapshot mismatch.

    7. juliusmarminge merged this034b506

    8. juliusmarminge closed this

Sign in to join this conversation.