You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When an upstream task in a stacked PR chain pushes new commits (e.g., from a FIX cycle after reviewer feedback, or user restarting a task), automatically rebase downstream tasks and re-run their agents. Cascades propagate sequentially down the chain.
Uses standard git checkout + git rebase for branch operations (no worktrees).
Context
In a stacked chain, task #2's branch is based on task #1's branch. When task #1 gets new commits, task #2's branch is stale. Without cascade, the user must manually rebase and re-run every downstream task — defeating the purpose of the chain.
Simplified Design (Sequential Only)
V1 is sequential:
Tasks run one at a time, so there's no "pause mid-agent" complexity
Cascade happens after all tasks in the chain are COMPLETE
When a user restarts an upstream task, downstream tasks are invalidated and re-run in order
Add cascade_prompt(original_prompt, upstream_changes_summary) — tells agent: "The upstream code changed. Review your implementation against the new base and adjust if needed."
Add rebase_conflict_prompt(original_prompt, conflict_files) — tells agent to resolve rebase conflicts in listed files
cli.py
Modify cmd_restart(): when restarting a task that has downstream dependents (part of a chain), after the task completes, trigger run_cascade() for downstream tasks
Design Decisions
Always re-run after rebase: even a clean rebase may produce logically incorrect code. The agent reviews the implementation against the new upstream.
Max cascade attempts per task: 2. If a downstream task can't stabilize after 2 re-runs, mark as needing manual attention.
Sequential propagation: cascade task 2, wait for COMPLETE, then cascade task 3. No parallel cascade.
Conflict resolution: agent gets conflict files in prompt. If it can't resolve, task pauses with clear status.
Parent Epic
Part of #52 — Sequential stacked PR chains
Summary
When an upstream task in a stacked PR chain pushes new commits (e.g., from a FIX cycle after reviewer feedback, or user restarting a task), automatically rebase downstream tasks and re-run their agents. Cascades propagate sequentially down the chain.
Uses standard
git checkout+git rebasefor branch operations (no worktrees).Context
In a stacked chain, task #2's branch is based on task #1's branch. When task #1 gets new commits, task #2's branch is stale. Without cascade, the user must manually rebase and re-run every downstream task — defeating the purpose of the chain.
Simplified Design (Sequential Only)
V1 is sequential:
Flow
autopilot restart <task1_id>— task 1 re-enters the review-fix loopgit checkout <task2_branch> && git rebase origin/<task1_branch>, re-run agent with same prompt + "upstream changed" contextChanges
chain.py(new module, created in #57)check_chain_staleness(epic_id)— for each task in chain, compare storedupstream_shavs current upstream HEADrebase_task(task_id, upstream_branch)—git checkout <branch> && git fetch origin && git rebase origin/<upstream_branch>git rebase --abort), return False with conflict inforun_cascade(epic_id, starting_from_task)— iterate downstream tasks, checkout + rebase + re-run each sequentiallypersistence.pyupstream_shacolumn (from Schema: parent_task_id, epic_id, base_branch, upstream_sha columns #55) — last-known HEAD SHA of the upstream branch when task startedget_chain_tasks(epic_id)returns ordered list (from Schema: parent_task_id, epic_id, base_branch, upstream_sha columns #55)prompts.pycascade_prompt(original_prompt, upstream_changes_summary)— tells agent: "The upstream code changed. Review your implementation against the new base and adjust if needed."rebase_conflict_prompt(original_prompt, conflict_files)— tells agent to resolve rebase conflicts in listed filescli.pycmd_restart(): when restarting a task that has downstream dependents (part of a chain), after the task completes, triggerrun_cascade()for downstream tasksDesign Decisions
Depends On
Testing