Make code-producing flows open a best-effort PR and derive branch handoff from run target - #169
Merged
Merged
Conversation
Share the throwaway-branch rule between the lifecycle and the PR helper, so a --skip-branch run opens its PR. Derive the branch handoff from the header's branch mode, not this invocation's flags. Replay the PR stages on resume regardless of what the probe answers now. Retry the probe's gh legs, fold gh's output to one line, strip a GHES port from the host, and name the right next action in every skip line.
Member
Author
|
review.sc now fails instead of skipping Test |
Member
Author
|
Comment from Tulip's PR explanation, for the category: GitHub availability probe and host-aware PrHandle Test2 |
Require the outside-a-stage evidence on both PR helpers. Fail the no-code check open when git cannot measure the branch. Return the default base as an Either. Classify gh failures as hard or transient and retry only the transient ones. Refuse ported hosts instead of mis-linking. Split the availability enum into Available and Unavailable with one explanation per cause, so the flows no longer spell out each case. Probe review.sc's host inside its stage.
The flow context held the handle in a var, which a resumed run lost unless it reached the recording call again — hence the rule to call it outside the stage that opened the PR. The log survives replay, so put it there: the call now takes WorkspaceWrite and belongs inside that stage, where the stage's own commit carries it. Also make an unreadable log path read as corrupt rather than throw, which load() already promised.
Reading the log folded every failure into "corrupt", which let setup overwrite a run it could not read, and let teardown delete a branch whose PR is open. Split absent, corrupt and unreadable apart: setup aborts on unreadable, and teardown deletes only on a log that loaded and records no PR.
The progress log and the branch policy are git-level, but both named a PrHandle to answer a question neither asks in GitHub terms: only its presence was ever read. Record a plain reference instead, so a flow that publishes to something other than GitHub can set it without touching the log schema or the handoff rule. The PR-facing door keeps its name and signature and translates. The closing summary now names where the work went.
adamw
added a commit
that referenced
this pull request
Sep 16, 2026
#170) ## Summary The whole-run final review in the built-in flows allowed three fix rounds, and the flows discarded the loop's result. A run could end with findings still open and open a PR that said nothing about them. ## Changes - The final review loop in `implement.sc`, `implement-interactive.sc`, `implement-enhanced.sc`, `issue-pr.sc` and `issue-pr-bugfix.sc` now allows five rounds. The per-task loop and the library default stay at three. - New `renderOpenFindings` renders the loop's unfixed findings as a markdown section, verbatim, omitted when there are none. - `openPrFromBranch` takes a required `openFindings` parameter and appends that section to the PR body. No default, so a flow cannot drop the loop's result by omission. - The PR-opening flows pass the final review's result through. The bugfix flow appends the section when it updates its tentative PR. ## Limitation The loop returns only a title and reason per finding. Reviewer, location and suggestion are not retained, so they are not listed. ## Note Touches the same helper signature that #169 extends. Whichever lands second needs the pass-through added to `openPrIfGitHub`.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Every code-producing built-in flow now ends with a best-effort PR step: when the repository is on GitHub and
ghcan reach it, the flow pushes the branch and opens a PR; when it can't—no remote, not GitHub,ghunreachable—the flow reports why in one line and finishes successfully without a PR.The per-flow
returnToStartBranchflag is gone. The run now decides where to leave the checkout: aNewBranchrun 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 aGitHubAvailabilityenum (Available / NoRemote / NoHost / NotGitHub / Unreachable). MadePrHandlecarry the host as its first field so PR creation, lookup, and writes work on GitHub Enterprise Server. Derived the host from theoriginremote URL via the existingremoteHostparser.Flow runtime: Extracted the three stages of
openPrFromBranch(push → summarise → create) into private helpers. AddedopenPrIfGitHub, which probes first and either runs those stages or emits one Step naming the reason and returns None. Added a small explicit door onFlowControl—recordOpenedPr—so a flow that opens its PR with a baregh.createPrcan tell the lifecycle. AddedBranchHandoff.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 fromopenPrFromBranchtoopenPrIfGitHub. KeptopenPrFromBranchin issue-pr.sc (those flows require GitHub); addedrecordOpenedPrto issue-pr-bugfix.sc so the lifecycle learns about its tentative PR. RemovedreturnToStartBrancharguments and updated flow headers to describe the new behavior.Docs: Updated README to document
gh.availability, the new PR helper signatures, the host-awarePrHandle, 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 forkrun simple.sc in a sandbox with no remote, so the step skips cleanly there.