B13 — Linear cascade rebase via dependency markers (close F5 — O(N²) churn) #429

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

As an operator,
I want to mark some PRs as "depends on PR #M" so that rebases serialise instead of fanning out,
so that N PRs in a linear chain produce N rebases instead of N²/2.

Last night 8 PRs in flight produced 25 cascade rebase events. With explicit dependencies the same chain would produce ~7. Each unnecessary rebase costs an agent task + a CI run.

Acceptance criteria

Parser

  • PR body parser recognises Stacked on #M and Depends on #M (case-insensitive, both syntaxes accepted) in the description.
  • Re-runs on PR creation AND on PR body edits (pull_request.edited webhook).
  • Stores parsed dependencies in SQLite pr_dependencies(pr_number, depends_on) table.

Dispatch

  • When PR #M merges, fire rebase only for the PR(s) that name it as a dependency, not all open PRs.
  • PRs without an explicit dependency keep current cascade behaviour (full fan-out) — the marker is opt-in.
  • When a stacked PR's parent rebases (without merging), the stacked PR is also rebased onto the new parent tip.

Cycle detection

  • Parser rejects cycles (PR A → B → A) with a comment on the offending PR: Cycle detected in dependency graph: <chain>. Ignoring stacked-on directive.
  • Parser rejects cross-repo dependencies (out of scope).

Tests

  • Unit test: linear chain #1 → #2 → #3, merge #1 → only #2 rebases, not #3.
  • Unit test: #2 rebased without merge → #3 rebases too.
  • Unit test: cycle detection rejects + comments.
  • Unit test: PRs without markers keep fan-out.

Out of scope

  • Visualising the chain on the dashboard — covered by B15.
  • Auto-merging the chain when the head PR lands (separate spec).

References

  • Spec: docs/specs/automation-hardening.md §4 B13.
  • Existing dispatch: apps/server/src/http/webhook.ts post-merge handler.
  • Convention precedent: GitHub stacked-PR tools (Graphite, ghstack) use the same Stacked on body marker.
**As an** operator, **I want** to mark some PRs as "depends on PR #M" so that rebases serialise instead of fanning out, **so that** N PRs in a linear chain produce N rebases instead of N²/2. Last night 8 PRs in flight produced 25 cascade rebase events. With explicit dependencies the same chain would produce ~7. Each unnecessary rebase costs an agent task + a CI run. ## Acceptance criteria ### Parser - [ ] PR body parser recognises `Stacked on #M` and `Depends on #M` (case-insensitive, both syntaxes accepted) in the description. - [ ] Re-runs on PR creation AND on PR body edits (`pull_request.edited` webhook). - [ ] Stores parsed dependencies in SQLite `pr_dependencies(pr_number, depends_on)` table. ### Dispatch - [ ] When PR #M merges, fire rebase only for the PR(s) that name it as a dependency, not all open PRs. - [ ] PRs without an explicit dependency keep current cascade behaviour (full fan-out) — the marker is opt-in. - [ ] When a stacked PR's parent rebases (without merging), the stacked PR is also rebased onto the new parent tip. ### Cycle detection - [ ] Parser rejects cycles (PR A → B → A) with a comment on the offending PR: `Cycle detected in dependency graph: <chain>. Ignoring stacked-on directive.` - [ ] Parser rejects cross-repo dependencies (out of scope). ### Tests - [ ] Unit test: linear chain `#1 → #2 → #3`, merge `#1` → only `#2` rebases, not `#3`. - [ ] Unit test: `#2` rebased without merge → `#3` rebases too. - [ ] Unit test: cycle detection rejects + comments. - [ ] Unit test: PRs without markers keep fan-out. ## Out of scope - Visualising the chain on the dashboard — covered by B15. - Auto-merging the chain when the head PR lands (separate spec). ## References - Spec: `docs/specs/automation-hardening.md` §4 B13. - Existing dispatch: `apps/server/src/http/webhook.ts` `post-merge` handler. - Convention precedent: GitHub stacked-PR tools (Graphite, ghstack) use the same `Stacked on` body marker.
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#429
No description provided.