Ensures an open draft PR exists for branch (the run slug's branch),
opening one if there is none, and keeps its description current while the
framework still owns it. Steps: no remote.origin.url configured ->
skipped; branch isn't on origin yet -> skipped ("branch not pushed");
gh pr list --head <branch> --state all finds an open PR -> exists,
refreshing its generated title/body (#202) if the run's artifacts have moved
on; else gh pr create --draft ... -> created.
A closed PR is absent for this purpose (#207): the branch is still live and
still accruing commits, so a run that outlives its PR gets a replacement
rather than being left with no review surface. Two cases are not that, and
each declines to open anything:
A merged PR (#213) — that branch has shipped, and a replacement would be
a PR against landed work.
A close that still stands (closedForGood) — the run has not moved since a
human closed its PR, so the close was a decision, not an accident.
The listing asks for every state so all three rules can see what they need:
the merged verdict, the close's timestamp, and the name of the dead PR a
replacement stands in for.
A staged run opens nothing at all: it is inert until gateline arm, and
arming is what ensures its PR.
"Draft" in the name is the default, not the whole story (#232): the draft
flag tracks the run's phase, so a done run's PR is marked ready for review
in the same pass that writes its "Run complete" description.
Ensures an open draft PR exists for
branch(the runslug's branch), opening one if there is none, and keeps its description current while the framework still owns it. Steps: noremote.origin.urlconfigured -> skipped;branchisn't on origin yet -> skipped ("branch not pushed");gh pr list --head <branch> --state allfinds an open PR -> exists, refreshing its generated title/body (#202) if the run's artifacts have moved on; elsegh pr create --draft ...-> created.A closed PR is absent for this purpose (#207): the branch is still live and still accruing commits, so a run that outlives its PR gets a replacement rather than being left with no review surface. Two cases are not that, and each declines to open anything:
closedForGood) — the run has not moved since a human closed its PR, so the close was a decision, not an accident.The listing asks for every state so all three rules can see what they need: the merged verdict, the close's timestamp, and the name of the dead PR a replacement stands in for.
A staged run opens nothing at all: it is inert until
gateline arm, and arming is what ensures its PR."Draft" in the name is the default, not the whole story (#232): the draft flag tracks the run's phase, so a
donerun's PR is marked ready for review in the same pass that writes its "Run complete" description.