Skip to content

Worktree retention has no periodic sweep: grace-period crossings while the app runs are never reclaimed #641

Closed

Description

@currentbits

enforceRetention runs exactly twice in the app's life: once at boot (+15 s, electron/main.js:380-405) and on archive/merge events (scheduleRetention). Nothing re-checks on a timer.

Live evidence (2026-08-21): of 62 worktree dirs (48 GB), 61 belong to archived threads. 42 of those are inside the 3-day UNMERGED_GRACE_MS window (worktrees.js:3877) — they will cross grace while the app stays running, and with multi-day uptimes nothing will reclaim them until the next launch or the next archive. The result: the worktree dir regrew 29 GB → 48 GB in two days even with retention=10 persisted on every project.

Fix: a low-frequency unref'd interval (e.g. every 6 h, same pattern as createPrStateRefresher) that calls enforceRetention({ store, worktreeBase, broadcast }). Cheap when there is nothing to do: enforceRetention already early-returns before any disk walk when no project has explicit retention.

Activity

  1. added
    plan:todo
    plan:doing
    and removed
    plan:todo
    on Aug 21, 2026
  2. currentbits commented on Aug 22, 2026

    @currentbits
    OwnerAuthor

    Implemented in this worktree.

    createRetentionSweeper (same shape as createPrStateRefresher): unref'd startup at 15s, then every 6h, overlap latch, failure-silent via scheduleRetention. Cheap no-op when no project sets a limit.

    The boot +15s timer is now orphan-sweep only. Archive/merge still call scheduleRetention immediately.

    Tests: electron/test/retention-sweep.test.js (timers, unref, latch, default sweep, main.js wiring).

  3. added
    plan:done
    plan:doing
    and removed
    plan:doing
    on Aug 22, 2026
  4. removed
    plan:doing
    on Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    plan:done

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions