Daily expiration sweeper for sessions and worktrees #7
Labels
No labels
area:agents
area:dashboard
area:database
area:design
area:design-review
area:flows
area:infra
area:meta
area:security
area:sessions
area:webhook
area:workdir
security
type:bug
type:chore
type:meta
type:user-story
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks#7
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
User story
As ops, I want a periodic background job that drops stale sessions and worktrees, so that a missed cleanup webhook does not let state grow forever.
Acceptance criteria
Sweeper (
src/sweeper.ts)setIntervalat startup; default interval6h, configurable via env varSWEEPER_INTERVAL_HOURSclosed(or PRmerged) → drop the session AND remove the matching worktree for every agentMAX_AGE_DAYS(default 30) is dropped regardless of Forgejo state, to handle deleted repos/issuesfor…ofloop andawait Bun.sleep(200)between API calls. NoPromise.all/ concurrent fan-out.Logging
swept: 3 sessions, 2 worktrees, 0 cache clones; skipped: 12 (still active)Tests (
src/sweeper.test.ts)MAX_AGE_DAYSfallback by stubbingDate.now()(N-1) * 200 ms(use fake timers or a tolerance)Out of scope
/resetstory for per-key, and is overkill for full sweep)References
Dependencies
main