merge_autonomy_kill_state's retry debits GITHUB_LIMIT_WAITED_SECONDS inside a subshell, so the process-wide wait budget never sees it
Id: TD-PPagop-26083106 · Status: resolved · Filed: 2026-08-31 · Resolved: 2026-10-30 · Ref: https://github.com/Pullwright/agent-ops/pull/2756
lib/merge-autonomy.sh’s RETRY path (agent-ops#1081) runs GITHUB_LIMIT_WAITED_SECONDS=$(( ${GITHUB_LIMIT_WAITED_SECONDS:-0} + wait )) after sleeping, but — by the function’s own header — every real call site captures the function in a $(...) command substitution, so the increment dies with the subshell exactly as the retried global the same header rejects would have. Nothing breaks today: the wait is bounded by GITHUB_LIMIT_MAX_WAIT_SECONDS per call and the call site runs once per engagement. But the process-wide total-wait budget is never actually debited for this sleep, so a later rate-limit wait in the same cycle starts its accounting from a number that is short by up to one bounded wait per Approver engagement, and the cycle can exceed the total it was meant to spend — while the line reads as if the budget is counting, because approver_post_or_warn’s copy of the same idiom (agent-ops#1082) is called directly and does debit correctly. Where: lib/merge-autonomy.sh, merge_autonomy_kill_state’s retry branch. Suggested fixes: (1) debit through a file under the state dir, the way _fleet_flag_memo_root already solves the identical subshell-visibility problem, so the budget genuinely counts; or (2) drop the increment and leave a comment stating the budget is deliberately not debited here, so no future reader assumes it is. This was analysed in a Reviewer comment on PR #1111 but never filed.
Default: Debit through a file the way _fleet_flag_memo_root already solves the same subshell problem — it makes the budget actually count instead of documenting that it does not.
Section titled “Default: Debit through a file the way _fleet_flag_memo_root already solves the same subshell problem — it makes the budget actually count instead of documenting that it does not.”Noticed while the Approver was judging https://github.com/Poetic-Poems/agent-ops/pull/1111.
Migrated to https://github.com/Pullwright/agent-ops/issues/2011.