fix(dispatch): dedup rebase against in-flight queue, not just task_history #859
No reviewers
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
2 participants
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
charles/claude-hooks!859
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "fix/dedup-rebase-inflight"
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?
Summary
#838 produced 16 duplicate
rebasetasks across two dev workers in under 20 minutes (live runaway captured at 2026-05-04 23:39 → 23:48). Two compounding loops with the same root cause — dedup measured against terminal state instead of in-flight state.Bug 1 —
tail-pr-rebase-watchdoghasRecentDispatch(repo, pr, 10min)queriestask_history WHERE started_at > since.persistTask()is only called fromonFinish, so tasks sitting in a worker queue have no row. Every 60 s tick the watchdog re-evaluated dedup, missed, and enqueued another rebase. Compounded until the running task finished.Bug 2 —
dispatchPrRebase(post-merge cascade + janitor)Dedup keyed
repo#pr@headSha. When the rebase agent pushes a fix commit, head SHA flips → cache miss → second rebase dispatched on top of the running one. Per-commit re-fire amplified Bug 1.Fix
New helper
hasInFlightTask(repo, issueNumber, taskType?)indomain/dispatch/registry.tsscansgetWorkers()for a matchingcurrentTaskor queued request. Wired as the first guard in:tail-pr-rebase-watchdog.ts(beforehasRecentDispatch)dispatchPrRebaseinevent-handlers.ts(before SHA-keyed dedup)Existing dedups stay as secondary nets. The watchdog now also tags
buildAgentRequestwithtask_type: "rebase"so the in-flight check can match on type — a normal review task on the same PR doesn't suppress a rebase.Test plan
just qaclean (3116 tests pass)hasInFlightTask: 6 cases (running, queued, no-match, repo isolation, taskType filter, empty registry)tail-pr-rebase-watchdog: 2 cases (skips on in-flight, called before history dedup)🤖 Generated with Claude Code
Correct fix.
hasInFlightTaskscanscurrentTask+ queue so the watchdog and post-merge cascade see pending work regardless of SHA churn — the two root causes confirmed.Tests cover both paths (queued case explicitly labelled as the bug being fixed). CI green,
task_type: "rebase"tag is set at both dispatch sites so the type filter works end-to-end.