run_approver_stage's second fresh kill-switch read can still fail closed and skip the ready PR silently — the window #1112's fix would also close
Id: TD-PPagop-26083103 · Status: open · Filed: 2026-08-31
After #1111, run_approver_stage (lib/approver.sh) reads the kill switch twice per engagement: merge_autonomy_kill_state … fresh retry (warned and retried on fail-closed), then — when the switch is clear — merge_autonomy_effective_level … fresh, which re-reads the kill switch with no retry and no fail-closed distinction. A clear first read leaves no cache (fleet_flag_fetch_status deletes the cache file on the flag’s ordinary 404), so if the second read alone hits a transport failure or the rate-limit budget’s exact exhaustion boundary, merge_autonomy_effective_level collapses to human, and run_approver_stage’s [[ "$level" != "human" ]] || return 0 skips the ready pull request with no App review and no warning — the exact silent-strand #1081 fixed, surviving in a narrower window (failure onset falling between two back-to-back reads instead of anywhere in the cycle).
Why it matters
Section titled “Why it matters”Issue #1112 already records the doubled read, but argues only the REST-budget cost (2→4 calls per engagement); nothing records that the same doubled read reopens a correctness window in requirement 8b’s warn-on-every-failure contract. A future decision to resolve #1112 by simply accepting the cost would leave this window open unknowingly. Until #890’s recovery sweep lands, a PR stranded through this window sits unrecovered, as #1059 did for ~16h.
- lib/approver.sh —
run_approver_stage’s fall-through tomerge_autonomy_effective_level … freshafter a clear kill-state read. - lib/merge-autonomy.sh —
merge_autonomy_effective_level’s internal re-read of the kill switch.
Suggested fix
Section titled “Suggested fix”The same change #1112 proposes: let the caller hand its already-read kill state to merge_autonomy_effective_level (optional KILL_STATE_JSON argument or an _after_kill variant), keeping the freeze read’s own FRESH. That removes the second kill read entirely, closing both the cost and this window with one signature change. Resolve this item together with #1112.
Noticed by the Approver stage while reviewing #1111 (implements #1081).
Default: Implement #1112’s suggested KILL_STATE_JSON pass-through in one PR resolving both items — it is the only listed option that closes the correctness window as well as the doubled cost.
Section titled “Default: Implement #1112’s suggested KILL_STATE_JSON pass-through in one PR resolving both items — it is the only listed option that closes the correctness window as well as the doubled cost.”Noticed while the Approver was judging https://github.com/Poetic-Poems/agent-ops/pull/1111.
Migrated to https://github.com/Pullwright/agent-ops/issues/2010.