feat(dispatch): branch off parent PR when blocker has open PR #462

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

User story

As an operator, I want agent-runner to detect at dispatch time whether any blocker of the dispatched issue has an open PR, and if so, branch off that PR's head SHA (instead of main), so that the resulting PR auto-stacks on the parent and the existing rebase cascade handles everything downstream.

Acceptance criteria

Detection

  • On dispatch, for every blocker (native + body-parsed), check if it has an open PR via Forgejo API
  • If exactly one open blocker PR exists, that's the parent — branch off its head SHA
  • If multiple open blocker PRs exist (rare): pick the most recent; log a warning
  • If zero open blocker PRs but blockers are still open: fall back to current behaviour (waits for issues.closed propagator) — i.e. don't stack on a non-PR blocker

Branch + PR setup

  • Workdir/clone branches off pr/<parent> (latest head SHA), not main
  • When the agent opens its PR, body includes stacked on #<parent> so existing pr-deps.ts machinery picks it up
  • Base branch of the new PR is the parent PR's branch (not main)
  • ${parent_pr} available to the prompt template (Phase 2b)

Tests

  • Mock: blocker with open PR → child PR opened with correct base branch + stack marker
  • Mock: blocker with no PR → falls back to main-base behaviour
  • Mock: 2 blockers, 1 with open PR, 1 without → still stacks on the one PR (logs the partial-stack situation)

Out of scope

  • Cycle handling (already in pr-deps body parser)
  • 3+ deep stacks (works mechanically, no special handling)
  • Operator manual override (separate story — /ready-stack)

References

  • apps/server/src/domain/agent/agent-runner.ts
  • apps/server/src/infrastructure/vcs/workdir.ts
  • apps/server/src/domain/workflow/pr-deps.ts
  • Parent epic: #461
## User story As an operator, I want agent-runner to detect at dispatch time whether any blocker of the dispatched issue has an open PR, and if so, branch off that PR's head SHA (instead of `main`), so that the resulting PR auto-stacks on the parent and the existing rebase cascade handles everything downstream. ## Acceptance criteria ### Detection - [ ] On dispatch, for every blocker (native + body-parsed), check if it has an open PR via Forgejo API - [ ] If exactly one open blocker PR exists, that's the parent — branch off its head SHA - [ ] If multiple open blocker PRs exist (rare): pick the most recent; log a warning - [ ] If zero open blocker PRs but blockers are still open: fall back to current behaviour (waits for `issues.closed` propagator) — i.e. don't stack on a non-PR blocker ### Branch + PR setup - [ ] Workdir/clone branches off `pr/<parent>` (latest head SHA), not `main` - [ ] When the agent opens its PR, body includes `stacked on #<parent>` so existing `pr-deps.ts` machinery picks it up - [ ] Base branch of the new PR is the parent PR's branch (not `main`) - [ ] `${parent_pr}` available to the prompt template (Phase 2b) ### Tests - [ ] Mock: blocker with open PR → child PR opened with correct base branch + stack marker - [ ] Mock: blocker with no PR → falls back to `main`-base behaviour - [ ] Mock: 2 blockers, 1 with open PR, 1 without → still stacks on the one PR (logs the partial-stack situation) ## Out of scope - Cycle handling (already in pr-deps body parser) - 3+ deep stacks (works mechanically, no special handling) - Operator manual override (separate story — `/ready-stack`) ## References - `apps/server/src/domain/agent/agent-runner.ts` - `apps/server/src/infrastructure/vcs/workdir.ts` - `apps/server/src/domain/workflow/pr-deps.ts` - Parent epic: `#461`
Sign in to join this conversation.
No milestone
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#462
No description provided.