Skip to content

fix(worktrees): periodic retention sweep so grace crossings are reclaimed while the app runs (#641) - #657

Merged
currentbits merged 4 commits into
mainfrom
coder/fork-worktree-retention-has-no-periodic--c4fa2e
Aug 22, 2026
Merged

currentbits merged 4 commits into
mainfrom
coder/fork-worktree-retention-has-no-periodic--c4fa2e

Conversation

@currentbits

Copy link
Copy Markdown
Owner

Closes #641.

enforceRetention only ran at boot (+15s) and on archive/merge, so a worktree crossing its grace period during a multi-day uptime sat on disk until the next launch.

  • createRetentionSweeper() in electron/worktrees.js: startup pass at 15s, then every 6h. Unref'd timers, boolean overlap latch (a tick during a running pass is a no-op, not queued), and it delegates to the existing scheduleRetention so failures stay silent. Same shape as createPrStateRefresher.
  • electron/main.js: the boot timer now only runs the orphan sweep; retention is owned by the sweeper, started in whenReady and stopped in installShutdown next to the PR refresher.
  • electron/test/retention-sweep.test.js: 9 tests over interval defaults, unref'd scheduling, the overlap latch (including latch release after a throwing pass), stop, the default scheduleRetention sweepFn, and the main.js wiring.

Cheap when idle: enforceRetention returns before any disk walk if no project sets a limit.

Size note: 437 lines vs the 400 cap, 270 of which are the new test file. Opened oversize deliberately rather than shipping the sweeper without its tests.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@currentbits
currentbits merged commit b2dade9 into main Aug 22, 2026
5 of 6 checks passed
@currentbits
currentbits deleted the coder/fork-worktree-retention-has-no-periodic--c4fa2e branch October 3, 2026 16:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

1 participant