fix(orchestrator): harden external-PR supersede close-on-land

Scope close_pull_request repo resolution by project_id and thread the
umbrella's project into close-on-land, so a contributor PR is never
resolved (or closed) against a same-numbered PR in another project's
repo. Skip the comment + close PATCH when the PR is already closed, so a
retried sweep never re-posts the 'superseded' comment.

Require a non-cancelled descendant that actually landed a PR before
retiring the contributor PR, so an umbrella force-completed over a
cancelled code subtask leaves the contributor's still-valid PR open.

Run close-on-land from the always-on sweeper rather than the default-off
poll loop, so a supersede that lands after the feature is toggled off is
still reconciled. Serialize concurrent supersede triggers under a lock so
a double-click can't cut two branches / spawn two umbrellas. Anchor the
supersede marker checks to the marker line so appended CEO notes can't be
mistaken for the closed/dedup tokens. Make the fork-head branch cut
idempotent (forced refspec) so a commit-fail retry converges.

Also drop an importlib.reload(roboco.config) in a unit test that rebound
the settings singleton and leaked into the PM decision-window test.
This commit is contained in:
Renn F
2026-06-16 18:01:40 +02:00
parent 5511cf6e79
commit a9fc870415
7 changed files with 440 additions and 51 deletions
@@ -62,6 +62,8 @@ def test_pr_author_allowed(
("", None),
("no marker here", None),
("external_pr_supersede pr=notanint review=abc", None),
# A CEO note on a later line must not shadow the marker line's pr=.
("external_pr_supersede pr=11 review=abc\nceo_approval_notes: pr=99 ok", 11),
],
)
def test_parse_supersede_pr(quick_context: str, expected: int | None) -> None: