Skip to content

Independent implement phases #2137

Closed
Closed

Description

@jwbron

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:

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_affected overlap 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

Dependencies

Acceptance criteria

  • Plan phase emits contract.slices[] with dependencies: 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 uses files_affected to inform dependencies[] so independent slices are merge-conflict-free by construction.
  • BRC tracker namespacing — nested pipeline IDs (issue-N/slice-M) vs. a slice_id field 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_affected overlap 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

Notes

Activity

  1. added 2 commits that reference this issue on Apr 27, 2026
  2. 16 remaining items

  3. added a commit that references this issue on May 21, 2026
  4. added a commit that references this issue on May 22, 2026
  5. added 2 commits that reference this issue on Jun 9, 2026
  6. added 2 commits that reference this issue on Jun 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions