Skip to content

Make code-producing flows open a best-effort PR and derive branch handoff from run target - #169

Open
adamw wants to merge 15 commits into
masterfrom
best-effort-pr-unified-branch
Open

Make code-producing flows open a best-effort PR and derive branch handoff from run target#169
adamw wants to merge 15 commits into
masterfrom
best-effort-pr-unified-branch

Conversation

@adamw

@adamw adamw commented Sep 11, 2026

Copy link
Copy Markdown
Member

Summary

Every code-producing built-in flow now ends with a best-effort PR step: when the repository is on GitHub and gh can reach it, the flow pushes the branch and opens a PR; when it can't—no remote, not GitHub, gh unreachable—the flow reports why in one line and finishes successfully without a PR.

The per-flow returnToStartBranch flag is gone. The run now decides where to leave the checkout: a NewBranch run that opened a PR hands you back the branch you started on (the work is on the PR); every other run stays put.

What changed

Tools: Added gh.availability(), a read-only probe answering whether a PR can be opened as a GitHubAvailability enum (Available / NoRemote / NoHost / NotGitHub / Unreachable). Made PrHandle carry the host as its first field so PR creation, lookup, and writes work on GitHub Enterprise Server. Derived the host from the origin remote URL via the existing remoteHost parser.

Flow runtime: Extracted the three stages of openPrFromBranch (push → summarise → create) into private helpers. Added openPrIfGitHub, which probes first and either runs those stages or emits one Step naming the reason and returns None. Added a small explicit door on FlowControlrecordOpenedPr—so a flow that opens its PR with a bare gh.createPr can tell the lifecycle. Added BranchHandoff.of(target, worktree, openedPr) to compute the checkout location: ReturnToStart only for NewBranch runs outside a worktree that opened a PR; everything else stays put.

Built-in flows: Appended openPrIfGitHub(codingAgent.cheap) to implement.sc, implement-interactive.sc, and simple.sc. Switched implement-enhanced.sc from openPrFromBranch to openPrIfGitHub. Kept openPrFromBranch in issue-pr.sc (those flows require GitHub); added recordOpenedPr to issue-pr-bugfix.sc so the lifecycle learns about its tentative PR. Removed returnToStartBranch arguments and updated flow headers to describe the new behavior.

Docs: Updated README to document gh.availability, the new PR helper signatures, the host-aware PrHandle, and the target-derived branch handoff rule. Added a dated amendment to ADR 0018 R3. Updated AGENTS.md to list the new test fakes.

The PR step runs outside a worktree by construction; orca create/orca fork run simple.sc in a sandbox with no remote, so the step skips cleanly there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant