B9 — Tail-PR rebase trigger (close F3 — last-PR cascade dead end) #425

Closed
opened 2026-04-27 07:25:01 +00:00 by claude-desktop · 0 comments
Collaborator

As an orchestrator,
I want the last open PR to auto-rebase when its merge_base falls behind main,
so that the "approved + CI-green + waiting for rebase" terminal state self-clears without an operator nudge.

Today the cascade rebase is gated on post-merge events. With one PR left open, no other merge happens → infinite wait. Hit twice on PR #420 last night (06:00 + 08:08).

Acceptance criteria

Watchdog logic

  • New periodic check (every 60 s, alongside the existing pipeline cadence) walks all open PRs.
  • For each PR where mergeable === false AND merge_base !== main_tip AND CI aggregate is success AND there is no in-flight rebase task for that PR: fire the existing rebase-dispatch path.
  • Suppress duplicate dispatches: check the per-PR task-history within the last 10 min for an active rebase task before firing.
  • Skip if PR has do-not-auto-rebase label (escape hatch).

Logging + config

  • Logged as [tail-pr-watchdog] dispatching rebase for #N (merge base behind main). (Commit-count variant behind by M commits deferred — requires an extra compare-refs API call; see PR #436.)
  • Watchdog can be disabled via config/agents.jsonwatchdogs.tail_pr_rebase: false (default true).

Tests

  • Unit test: open PR with mergeable=false + CI green + no active rebase → dispatches.
  • Unit test: same conditions but active rebase task in last 10 min → skips.
  • Unit test: do-not-auto-rebase label → skips.
  • Integration test against a fixture forge: 1 PR, manually move main forward, watchdog fires within 60 s. (Deferred to #445 — requires fixture-forge infrastructure.)

Out of scope

  • Rebasing PRs that are CI-red — covered by existing [webhook] CI red on ... — dispatching fix-ci path.
  • Multi-PR concurrency control — covered by B13.
  • Visualising in dashboard — covered by B15.

References

  • Spec: docs/specs/automation-hardening.md §4 B9.
  • Existing rebase dispatch: apps/server/src/http/webhook.ts (post-merge handler).
  • Pipeline cadence: search apps/server/src/domain/views/pipeline.ts for the existing 60s interval.
  • Night-1 incident: PR #420 sat in this state for 16+24 min before manual retrigger.
**As an** orchestrator, **I want** the last open PR to auto-rebase when its `merge_base` falls behind `main`, **so that** the "approved + CI-green + waiting for rebase" terminal state self-clears without an operator nudge. Today the cascade rebase is gated on `post-merge` events. With one PR left open, no other merge happens → infinite wait. Hit twice on PR #420 last night (06:00 + 08:08). ## Acceptance criteria ### Watchdog logic - [ ] New periodic check (every 60 s, alongside the existing pipeline cadence) walks all open PRs. - [ ] For each PR where `mergeable === false` AND `merge_base !== main_tip` AND CI aggregate is `success` AND there is no in-flight rebase task for that PR: fire the existing rebase-dispatch path. - [ ] Suppress duplicate dispatches: check the per-PR task-history within the last 10 min for an active rebase task before firing. - [ ] Skip if PR has `do-not-auto-rebase` label (escape hatch). ### Logging + config - [ ] Logged as `[tail-pr-watchdog] dispatching rebase for #N (merge base behind main)`. _(Commit-count variant `behind by M commits` deferred — requires an extra compare-refs API call; see PR #436.)_ - [ ] Watchdog can be disabled via `config/agents.json` → `watchdogs.tail_pr_rebase: false` (default `true`). ### Tests - [ ] Unit test: open PR with mergeable=false + CI green + no active rebase → dispatches. - [ ] Unit test: same conditions but active rebase task in last 10 min → skips. - [ ] Unit test: do-not-auto-rebase label → skips. - [ ] Integration test against a fixture forge: 1 PR, manually move main forward, watchdog fires within 60 s. _(Deferred to #445 — requires fixture-forge infrastructure.)_ ## Out of scope - Rebasing PRs that are CI-red — covered by existing `[webhook] CI red on ... — dispatching fix-ci` path. - Multi-PR concurrency control — covered by B13. - Visualising in dashboard — covered by B15. ## References - Spec: `docs/specs/automation-hardening.md` §4 B9. - Existing rebase dispatch: `apps/server/src/http/webhook.ts` (`post-merge` handler). - Pipeline cadence: search `apps/server/src/domain/views/pipeline.ts` for the existing 60s interval. - Night-1 incident: PR #420 sat in this state for 16+24 min before manual retrigger.
Sign in to join this conversation.
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
charles/claude-hooks#425
No description provided.