Skip to content

backport: upstream #2392 — keep terminated status with open PR#27

Merged
polymath-orchestrator merged 1 commit into
mainfrom
ao/agent-orchestrator-4/issue-12-backport-2392
Jul 6, 2026
Merged

backport: upstream #2392 — keep terminated status with open PR#27
polymath-orchestrator merged 1 commit into
mainfrom
ao/agent-orchestrator-4/issue-12-backport-2392

Conversation

@polymath-orchestrator

@polymath-orchestrator polymath-orchestrator commented Jul 6, 2026

Copy link
Copy Markdown

Summary

Backports upstream AgentWrapper#2392 as the canonical change.

This keeps a terminated session from being reported as merged while it still owns an open PR, preserving the documented invariant that merged/closed PRs only matter once no open PR remains.

Closes #12.

Verification

  • cd backend && env -u AO_PROJECT_ID -u AO_SESSION_ID go build ./...
  • cd backend && env -u AO_PROJECT_ID -u AO_SESSION_ID go vet ./...
  • cd backend && env -u AO_PROJECT_ID -u AO_SESSION_ID go test ./...
  • timeout 420s codex-fugu exec review --base origin/main --dangerously-bypass-approvals-and-sandbox

View with Codesmith Autofix with Codesmith
Need help on this PR? Tag /codesmith with what you need. Autofix is disabled.

deriveStatus's terminated branch short-circuited to `merged` whenever any
owned PR was merged, even if the session still owned an open PR. That
contradicts the function's documented invariant ("Merged/closed PRs only
matter once no open PR remains") and is inconsistent with the
non-terminated branch, which gates on openPRs before falling back to
anyMerged.

The mismatch is a regression from the single-PR -> multi-PR change: the
old branch tested `pr != nil && pr.Merged`, which in the single-PR world
implied no open PR remained. Generalizing to `anyMerged(prs)` dropped that
implicit condition. A session killed while it still owns an open PR (for
example, only the bottom of a stack merged, or one of two independent PRs
merged) was reported as cleanly "merged", hiding the abandoned open PR.

Gate the merged short-circuit on there being no open PR, mirroring the
non-terminated branch. Existing behavior is preserved (a terminated
session whose only PR is merged still reports merged); only the
merged+open combination changes to terminated. Add a table case covering it.
@polymath-orchestrator polymath-orchestrator merged commit db7b6a2 into main Jul 6, 2026
@polymath-orchestrator polymath-orchestrator deleted the ao/agent-orchestrator-4/issue-12-backport-2392 branch July 6, 2026 03:44
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.

backport: upstream #2392 — terminated session with open PR reads as merged

2 participants