github-actions[bot] commented on code in PR #68981:
URL: https://github.com/apache/doris/pull/68981#discussion_r4253920131
##########
.github/workflows/code-review-runner.yml:
##########
@@ -895,6 +896,20 @@ jobs:
status=$?
set -e
+ # The runner has stopped Codex and reaped descendants. Treat an
+ # obsolete head as a handled outcome, without publishing a verdict.
+ if [ "$status" -eq 75 ]; then
+ jq -e --arg repo "$REPO" --arg pr "$PR_NUMBER" --arg head
"$HEAD_SHA" '
+ .state == "superseded" and .repository == $repo and
+ (.pr_number | tostring) == $pr and .head_sha == $head and
+ (.superseding_head_sha | test("^[0-9a-f]{40}$")) and
+ .superseding_head_sha != $head' \
+ "$REVIEW_CONTEXT_DIR/review-result.json" > /dev/null
+ echo "review_state=superseded" >> "$GITHUB_OUTPUT"
+ jq -r '.message' "$REVIEW_CONTEXT_DIR/review-result.json" | tee -a
"$GITHUB_STEP_SUMMARY"
+ exit 0
Review Comment:
[P2] Preserve account diagnostics before returning on supersession
If Codex exits with a genuine terminal `refresh_token_reused` or usage-limit
error while the PR head moves, the runner's forced post-exit head check returns
75 before classifying that error. This early return then skips the account
diagnostics below, leaving `auth_invalid_reason` and
`usage_limit_retry_after_epoch` unset. Both account-recording steps
consequently skip, so the known invalid token or exhausted account remains
eligible for subsequent reviews. Process those terminal account diagnostics and
emit their finalizer outputs before returning for supersession, while keeping
the obsolete review verdict/status suppressed.
##########
.github/scripts/run_review_with_resume.py:
##########
@@ -39,6 +40,65 @@
CAPACITY_MESSAGE = "Selected model is at capacity. Please try a different
model."
UNSUPPORTED_CHATGPT_MODEL = "model is not supported when using Codex with a
ChatGPT account."
PROCESS_EXIT_GRACE_SECONDS = 5
+HEAD_POLL_SECONDS = 60
+HEAD_API_TIMEOUT_SECONDS = 10
+SUPERSEDED_EXIT_CODE = 75
+
+
+class ReviewSuperseded(Exception):
+ def __init__(self, head_sha):
+ self.head_sha = head_sha
+ super().__init__(f"PR head changed to {head_sha}; stopping superseded
review")
+
+
+def check_head(pr, expected):
+ """Only a complete, valid API head can supersede the frozen review
target."""
+ head = pr.get("head") if isinstance(pr, dict) else None
+ sha = head.get("sha") if isinstance(head, dict) else None
+ if not isinstance(sha, str) or not re.fullmatch(r"[0-9a-f]{40}", sha):
+ raise ValueError("PR API returned no valid head SHA")
+ if sha != expected:
+ raise ReviewSuperseded(sha)
+
+
+class HeadWatchdog:
+ def __init__(self, args, remaining):
+ self.args = args
+ self.remaining = remaining
+ self.next_check = 0
+
+ def seconds_until_check(self):
+ return max(0, self.next_check - time.monotonic())
+
+ def check(self, *, force=False):
+ if not force and self.seconds_until_check() > 0:
+ return
+ timeout = min(HEAD_API_TIMEOUT_SECONDS, self.remaining())
+ # Poll synchronously: gh is reaped before Codex cleanup/ChildReaper
runs.
+ # Include API time in the existing shared budget and polling interval.
+ self.next_check = time.monotonic() + HEAD_POLL_SECONDS
+ try:
+ response = subprocess.run(
Review Comment:
[P2] Clean up standalone head probes when cancellation interrupts spawn
The forced probe before the first attempt and the probes during capacity
backoff run outside `run_attempt`'s cleanup. If SIGTERM arrives after `gh` is
spawned but before its `Popen` constructor returns, the handler raises
`KeyboardInterrupt` before `subprocess.run` enters its kill-protected body.
Python closes the pipes without killing/waiting for that child, and
`run_review` returns 130 without invoking the reaper. The API process can
therefore outlive the cancelled helper, with the communicate timeout never
started. Apply cancellation cleanup to these standalone probes too, as the
existing attempt cleanup already does for interrupted Codex construction.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]