Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(server): storage cleanup no longer counts hardlinked files as recovered space #17910

Mergedtris203(GitHub profile, opens in a new tab)merged 2 commits intomain fromrefs/pull/17910/headmerged by juliusmarminge View on GitHub

Removing a worktree with dependencies hardlinked from a shared store reported those files as recovered space even though the store still owned their disk blocks. Worktree measurement now counts allocated bytes for single-link files, falling back to file length when block metadata is unavailable. Multiply linked files are excluded, so the estimate can undercount when all links are inside the removed tree.

Fixes #17815. Maintainer takeover of #17910, with credit to @tris203 for the report, implementation, and reproduction. Original commits are preserved; current main is merged without rewriting the contributor branch.

Verification on headless Linux / Node 24:

  • Before: the real-filesystem regression expected 16,384 recoverable bytes and received 70,098. The external hardlink survives cleanup.
  • After: pnpm exec vp test run apps/server/src/storageCleanup.test.ts — 138 passed. The existing regression covers hardlinks, allocated bytes, and symlinks; one added case covers absent metadata. Current-main suite: 137 → 138 tests in the existing file.
  • Targeted lint, formatting, and server typecheck passed.
  • The cleanup service ran against disposable filesystem fixtures, including actual worktree removal. Screenshots do not prove this accounting change.

Both independent whole-diff reviews found no blockers. Reflink clones are not detected by link counts; their shared blocks remain a limitation.

Not verified: the Storage screen after an interactive cleanup, free-space changes measured with df, other filesystems, macOS, Windows, Electron desktop, iOS, or Android. No contract or client behavior changes.

Implemented with Codex GPT-6.1-Sol; test design by Codex GPT-6-Astra. Independent review by Claude Opus 5.5 and Codex GPT-6-Sol, orchestrated in T3 Code.

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

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

      Approvability

      Verdict: Approved at f25cde7

      Macroscope's review found this PR approvable — This is a narrowly scoped storage-cleanup bug fix that adjusts only recoverable-byte accounting and adds focused hardlink and metadata-fallback tests. No product defaults, schemas, sensitive packages, or static-analysis suppressions change; an unresolved High-severity finding separately flags numeric type handling in the new path.

      Notes:

      • This verdict was updated automatically after the outstanding correctness findings were resolved. Macroscope did not re-review the code.
      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: 2d1d6ae4-72f9-4f34-8652-2ccf4a98ba94
      📥 Commits

      Reviewing files that changed from the base of the PR and between dda7d21a9580aea5660b779320d2e71af3da75d5 and a37e669c72efb79cadd1be03125a29d73a864449.

      📒 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; 8 remain after this review.

      📝 Walkthrough

      Worktree storage measurement now counts allocated bytes only for files with a single link. Tests cover allocated-size fallback and verify that externally hardlinked files remain after cleanup.

      Changes: Worktree storage accounting

      Layer / File(s)Summary
      Reclaimable-byte measurement
      apps/server/src/storageCleanup.ts, apps/server/src/storageCleanup.test.ts
      measureWorktree excludes multiply linked files and uses allocated blocks when available, falling back to file size. Tests cover nested files, hardlinks, and allocated-size measurements.

      Priority: ⬇️ Low

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

      Change: Bug fix · Severity of issue fixed: Low

      Suggested reviewers: juliusmarminge

      Merge Risk: ⚪ Minimal · up to a37e6

      No actionable merge-blocking risk is supported by the reviewed change context; proceed with normal checks.

      Pre-merge checks: Passed 4
      Check nameStatusExplanation
      Linked Issues checkPassedIssue [#17815] requires per-worktree and recovered-space accounting to reflect released space or provide a lower bound for hardlinked dependencies. measureWorktree now excludes files with nlink gr…
      Out of Scope Changes checkPassedThe changes are limited to measureWorktree accounting and related storage-cleanup tests. The source change supports issue [#17815]. The tests verify the changed accounting and hardlink behavior. No …
      Title checkPassedThe title clearly and concisely describes the main change: storage cleanup no longer counts hardlinked files as recovered space. It uses a conventional commit format and is specific to the server chan…
      Description checkPassedThe description covers the problem, implementation, scope, linked issue, maintainer approval context, verification commands and results, limitations, and unverified environments. It does not use the t…
      Full details: Linked Issues check

      Explanation

      Issue [#17815] requires per-worktree and recovered-space accounting to reflect released space or provide a lower bound for hardlinked dependencies. measureWorktree now excludes files with nlink greater than 1, uses blocks * 512 when available, and falls back to file length. The implementation treats missing nlink as 1. Updated tests cover hardlinked files and allocated-size accounting. The reported test suite passed.

      Full details: Out of Scope Changes check

      Explanation

      The changes are limited to measureWorktree accounting and related storage-cleanup tests. The source change supports issue [#17815]. The tests verify the changed accounting and hardlink behavior. No unrelated behavior, public contract, client, or UI change is included.

      Full details: Title check

      Explanation

      The title clearly and concisely describes the main change: storage cleanup no longer counts hardlinked files as recovered space. It uses a conventional commit format and is specific to the server change.

      Full details: Description check

      Explanation

      The description covers the problem, implementation, scope, linked issue, maintainer approval context, verification commands and results, limitations, and unverified environments. It does not use the template headings, but the required information is present and the description is complete.

      ✨ Finishing Touches
      🧪 Generate unit tests (beta)
      • Create a new PR
      • Autofix · 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 as maintainer for batch ssh-relay-remote-02. I’m preserving the hardlink accounting fix, rebuilding it against current main, and validating it with focused tests and independent reviews. I plan to push updates to this PR and leave it unmerged.

    7. apps/server/src/storageCleanup.ts line 275Resolvedby juliusmarminge
    8. juliusmarminge merged thiscae5762

    9. juliusmarminge closed this

Sign in to join this conversation.