Skip to content

Slice-loop fallback branch shape mismatches reconciler (egg/{pipeline_id}/work vs egg/{pipeline_id}) #2371

Closed

Description

@james-in-a-box

Spotted during the #2370 re-review (non-blocking). Filed as a follow-up because the path is degenerate (does not fire for issue-driven, qualified, or JIRA pipelines) and the surrounding fallback shape is broadly used elsewhere — disentangling it warrants its own design discussion rather than a drive-by tweak inside #2370.

Observation

orchestrator/routes/pipelines.py:10979-10989 derives pipeline_branch like this:

```python
pipeline_branch = pipeline.branch or (
f"egg/issue-{pipeline.issue_number}"
if pipeline.issue_number is not None
else f"egg/{pipeline_id}/work"
)
…
issue_branch = pipeline_branch
```

The third (degenerate) fallback emits `egg/{pipeline_id}/work`, so a slice would be created at `egg/{pipeline_id}/work/slice-N`.

The reconciler at `orchestrator/stacked_pr_reconciler.py:190` derives:

```python
issue_branch = f"egg/{contract.contract_key}"
```

— i.e. `egg/{pipeline_id}` (no `/work`). The producer creates `egg/{pipeline_id}/work/slice-N` but the consumer looks up `egg/{pipeline_id}/slice-N` — same cross-module silent-no-op shape as the bug just fixed in #2370.

Why this is latent (and not user-visible today)

  1. The fallback only fires when neither `pipeline.branch` nor `pipeline.issue_number` is set — none of the documented pipeline kinds (issue-driven, qualified-issue, JIRA) reach it.
  2. The synthetic-session exemption regex (`gateway/gateway.py` `SLICE_INTEGRATION_BRANCH_RE`) was tightened in Fix #2368: synthetic-session exemption for slice integration-branch pushes #2370 to `^egg/[A-Za-z0-9][A-Za-z0-9-]*/(?:slice|phase)-\d+$`. The `/work/` path-segment in the middle would be rejected by that regex, so any slice-integration push under the degenerate fallback would 403 at the gateway before reaching the reconciler.

So this is latent tech debt, not a live bug.

Options

  1. Drop `/work` — change the third branch of the ternary to `f"egg/{pipeline_id}"`. Aligns with the reconciler shape; minimum churn.
  2. Remove the fallback entirely — if no caller actually creates pipelines without both `branch` and `issue_number`, the third branch is dead code. Replace with an explicit error / log.
  3. Investigate `/work` semantics first — `egg/{x}/work` is the per-container/per-agent worktree convention used by `kubernetes_spawner.py`, `concurrent_executor.py`, `routes/pipelines.py:14510` & `:14867`. Before changing the slice-loop fallback we should confirm none of those paths leak into the slice-loop case.

Option 3 is probably the right starting point. The decision is small but has surface area; doing it properly here keeps it from being a one-line drive-by that re-introduces the same cross-module disagreement the reconciler fix just removed.

References

— Authored by egg

Activity

  1. added
    p3
    oneshot
    on May 5, 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

    oneshotp3

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions