Repository navigation
Description
Problem
The implement phase runs as a single monolithic unit: one agent team handles the whole ticket on one branch with one BRC consensus round. Tickets large enough to fill the context window cause compaction and a measurable drop in output quality.
Approach
Split implement into a DAG of independent slices. A slice is a self-contained unit of implementation work scoped small enough that a single agent can plausibly write it (rough guidance: ≲ ~1,000 LOC; not enforced — guidance to the plan phase). The plan phase emits the DAG.
The orchestrator schedules slices into waves using the existing DependencyNode / ExecutionWave machinery in shared/egg_contracts/dependency_graph.py (currently unused at runtime, role-keyed; needs extension to be slice-keyed). Independent slices run in parallel; each slice:
- Forks its own branch (
egg/issue-N/slice-Mor similar — branch naming TBD). For root slices the branch base is the pipeline branch; for child slices the base is the parent slice's branch (see Delivery shape below). - Gets a fresh agent team running the full implement-phase reviewer roster (after Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139 lands): coder, tester, documenter, dual-role tester→coder review, plus CRITICAL
reviewer_code_holistic,reviewer_contract,reviewer_security, andreviewer_concurrency. No subagent fan-out (already torn out by Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139). - Runs its own BRC consensus.
- On completion, opens its own PR.
Delivery shape: stacked PRs along the DAG
Each slice produces its own PR rather than merging back into a single pipeline branch. PRs stack along linear DAG chains so reviewers see incremental diffs:
- Root slice (no DAG parents): PR base = pipeline branch.
- Single-parent slice: PR base = parent slice's branch. Merging the parent's PR retargets child PRs onto the parent's former base, the way any stacked-PR workflow handles it.
- Multi-parent slice (diamond DAGs): out of MVP scope — see Out of scope. MVP enforces a forest constraint: each slice has ≤1 DAG parent. When the planner identifies what would otherwise be a multi-parent slice, it auto-serializes the upstream slices into a chain (heuristic: cluster by
files_affectedoverlap to minimize merge friction, then order by descending downstream fan-out). The chosen serialization is recorded in the plan draft so the HITL approver can override during plan approval — no separate HITL prompt for the choice itself.
This replaces the prior "slice branches topologically merged into the pipeline branch via a new gateway merge endpoint" model — there is no orchestrator-side merge step and no new gateway merge endpoint.
Failure handling: a failed slice does not cancel siblings or downstream slices. Downstream slices that depend on a failed slice will block, eventually deadlocking the pipeline → HITL escalation via shared/egg_contracts/hitl.py.
Renames
contract.phases[]→contract.slices[]plan_parser.to_contract_phases()→to_contract_slices()
Out of scope
- Reviewer roster cleanup and lens promotion (lands in Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139).
- Silent-failure ingestion fixes for
_populate_contract_from_plan_safe(lands in Contract phases[] left empty when plan yaml-tasks aren't ingested (issue-1931) #2134). - Refine and plan phases unchanged (their orchestration stays monolithic).
babysit_prpipelines unchanged (Re-evaluate babysit_pr subagent fan-out now that #1965 A+B shipped #2063 stays separate).- Multi-parent slices (diamond DAGs): MVP enforces a forest constraint. Lifting this requires a more complex stacking story (multi-parent rebases or a non-stacked PR shape) and is deferred to a follow-up.
Dependencies
- Contract phases[] left empty when plan yaml-tasks aren't ingested (issue-1931) #2134 must merge first — slice scheduling cannot be reliable until plan ingestion is reliable.
- Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139 must merge first — this ticket runs Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139's final reviewer roster per slice.
Acceptance criteria
- Plan phase emits
contract.slices[]withdependencies: list[str]per slice; the resulting DAG is validated to be a forest (each slice has ≤1 parent) — multi-parent slices are rejected at plan ingestion in MVP. - Orchestrator's run loop schedules slices via
ExecutionWave; independent slices spawn in parallel (no concurrency cap — DAG width drives parallelism). - Each slice runs on its own branch with a fresh agent team and its own BRC consensus round.
- Each slice's BRC consensus uses the full implement-phase reviewer roster (no per-slice roster customization; lens reviewers are CRITICAL per Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139).
- Each slice opens its own PR. Root slices target the pipeline branch; single-parent slices target their parent slice's branch (stacked). No orchestrator-side merge endpoint; PRs go through the normal review/merge flow.
- A failed slice does not cancel siblings; the resulting DAG deadlock triggers HITL escalation.
- End-to-end: a previously-oversized ticket completes without compaction and is delivered as a stack of PRs.
Open questions for plan phase
- Slice failure semantics — sibling and dependent behavior.
- Slice-level retry /
max_cycles— per-slice / global / two-tier. - Deadlock detection latency — deterministic on first failure, heartbeat-timeout, or hybrid.
- Contract task → slice mapping — 1:1 with today's
Phase, single-task slices, file-affected clusters, or a hybrid where the planner usesfiles_affectedto informdependencies[]so independent slices are merge-conflict-free by construction. - BRC tracker namespacing — nested pipeline IDs (
issue-N/slice-M) vs. aslice_idfield on every message. - Branch naming —
egg/issue-N/slice-M(slash) vs.egg/issue-N-slice-M(dash). - Operational concurrency caps — gateway, container, GHA queue, Anthropic rate limits.
- Regression benchmark — specific past ticket / pipeline to use as the "completes without compaction" reference.
- Stacked-PR rebase mechanics — rely on GitHub's auto-retarget when a parent PR merges, or have the orchestrator explicitly rebase children onto the new base.
- Auto-serialization heuristic —
files_affectedoverlap clustering is a starting point, but the exact ordering rule (descending fan-out, descending size, planner's pick) needs to be pinned down with examples.
Closes / supersedes
- Closes the slice-scheduling portions of BRC: fan out reviewer_security and reviewer_concurrency on large diffs #2127 / improve the generalized reviewer #1965 / Cleanup: reviewer_code fan-out prompt + contract-load nits from PR #2061 #2067 / BRC implementation agents (coder/tester/documenter) don't delegate to subagents when phase plan is large #2029 (orthogonal reviewer-roster cleanup lands in Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139).
Notes
- Original scope of this ticket bundled four loosely-coupled pieces; split into Contract phases[] left empty when plan yaml-tasks aren't ingested (issue-1931) #2134 + Reviewer roster reshape: remove subagent fan-out, promote lens reviewers to CRITICAL #2139 + this. The split was made because egg pipelines produce a single PR per ticket and the original scope didn't fit one PR. This ticket lifts the one-PR-per-pipeline constraint (one PR per slice, not per ticket), which is also a prerequisite for Add SDLC pipeline support for Jira epics #1557's epic pipeline producing per-child-ticket PRs cleanly.
Activity
refine: add analysis for #2137 (independent implement phases)
refine: revise #2137 analysis per reviewer_refine NACK
Reviewer roster reshape: drop reviewer_code fan-out, promote lens rev…
Reviewer roster reshape: drop reviewer_code fan-out, promote lens rev…
refine: rewrite #2137 analysis for revised issue text (stacked PRs, f…
refine: revise #2137 analysis per reviewer feedback
plan(architect): emit architecture analysis for #2137 slice scheduler
plan(2137): slice implement phase into a DAG of independent units
risk_analyst: technical risk assessment for #2137 (slice-scoped DAG)
docs(2137): v3 — close reviewer_code v2 NACK on doc↔code drift
refine: rewrite #2137 analysis for revised issue text (stacked PRs, f…
refine: revise #2137 analysis per reviewer feedback
plan(architect): emit architecture analysis for #2137 slice scheduler
plan(2137): slice implement phase into a DAG of independent units
risk_analyst: technical risk assessment for #2137 (slice-scoped DAG)
16 remaining items
Fix #2743: yaml-tasks fence truncation + depends_on alias (#2748)
Add refine analysis for #2766: Actionable Plan Framework conformance
Resolve yaml-tasks schema-vs-template drift (#2756 review)
Fix #2756: canonicalize yaml-tasks dependencies to a slice-N string (#…
slice-1 v3: address reviewer_code v2 NACK (validator key-presence + d…
fix(sandbox): get_assigned_tasks reads slices, not the pre-#2137 phas…
Address #3029 third-round review: cover upper no-op branch, redact 50…
Address #3029 fourth-round review: fix contract_cli phases→slices
fix(orchestrator): durable generic no-op propose; retire #2581 pre-se…
fix(orchestrator): reconcile diverged state-branch pushes and escalat…
fix(plan): linearize slice DAG to a forest (operator)
Validate slice DAG is a forest at plan propose time (#3211) (#3215)
implement(#3288): de-ledger slice-3 architecture pages
refactor(shared): decompose egg_contracts/plan_parser into sub-packag…
refactor(shared): decompose egg_contracts/plan_parser into sub-packag…