Cleanup webhooks — issues.closed and pull_request.merged #4
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#4
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 claude-hooks to drop persisted state for an issue or PR as soon as it closes/merges, so that worktrees and (later) session entries do not accumulate forever.
Acceptance criteria
New webhook routes (
src/webhook.ts)issuesevent withaction === "closed"→ callcleanupIssue(repo, issue_number)for each registered agentpull_requestevent withaction === "closed"andpayload.pull_request.merged === true→ derive the issue/branch and callcleanupIssue(or a parallelcleanupBranch) for the PR's source branchaction === "reopened") are intentionally a no-op — no cleanup, no auto-redispatchcleanup.tsmodule so the webhook layer stays declarativecleanup.tsshimcleanupIssue(repo, issue_number, opts?)andcleanupBranch(repo, branch, opts?)releaseWorktree({ keep: false })for each agentdropAllForIssueTests (
src/webhook.test.ts)issues.closedpayload triggerscleanupIssueonce per agentpull_request.closedwithmerged: truetriggerscleanupBranchpull_request.closedwithmerged: false(i.e. closed without merging) also triggerscleanupBranch— discarded work shouldn't keep state eitherOut of scope
releaseWorktreecall (lives in the workdir module's wiring story)References
modules/webhook/type.goDependencies
cleanup.ts)main