Skip to content

feat(linear): re-integrate dependent child PRs when a predecessor changes (#247 A6) #305

@isadeks

Description

@isadeks

Component

API or orchestration, Agent runtime

Describe the feature

For #247 stacked child PRs (A4): when a lower child PR merges, its dependent PRs must be rebased onto the new base and force-pushed so the stack stays correct. Automate this so the human never hand-rebases.

The subtlety this issue exists to handle: GitHub auto-retargets a dependent PR's base pointer when the merged head branch is deleted, but it does not rewrite the dependent branch's commits. So an explicit restack is still required even though the base flips on its own.

Background — why a restack is needed (not just GitHub's auto-retarget)

With a stack A ← B ← C (B's branch cut from A's, C's from B's):

Net: the correct merge model is bottom-up, one PR at a time, delete the head branch to trigger retarget, then restack the dependents' commits. This issue automates the restack step.

Proposed solution

A restack reconciler triggered on a child PR closed+merged GitHub webhook:

  1. Find dependent child branches in the orchestration whose base was the merged branch.
  2. git rebase --onto <new-base> <old-base> <dependent-branch> + force-push.
  3. Conflict-free → fully automatic (the common case when the lower PR merged unchanged).
  4. Conflict case → spawn an AGENT task to resolve it (ABCA-native; do NOT escalate to the human). The agent rebases, resolves conflicts preserving both intents, and pushes. The PR's normal human review remains the safety net for a mis-resolved semantic conflict — so the resolution is automated, the result is still reviewed before merge.

Acceptance criteria

  • On a child PR merge, conflict-free dependents are rebased + force-pushed automatically (no human action).
  • A conflicting rebase spawns an agent task that resolves + pushes; the dependent PR ends in a reviewable state.
  • Idempotent / safe under webhook redelivery.
  • Bounded by max_sub_issues stack depth.

Depends on

Out of scope

  • Auto-MERGE of the stack (separate follow-up — gated on approvals + CI via merge queue).

Metadata

Metadata

Assignees

No one assigned

    Labels

    adaptersThird-party integrations: Linear, Slack, GitHub App, notification/deploy providersenhancementNew feature or requestorchestrationTask lifecycle, REST API handlers, orchestrator Lambdas, durable execution

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions