nesquena-hermes
e68f74ac99
fix(approval): close SSE notify-ordering, head-fidelity, and trailing-approval gaps (Opus MUST-FIX A/C/D)
...
Pre-release Opus review caught three correctness bugs in the original
PR #1350 SSE wiring beyond the snapshot/subscribe race:
A) **Notify-ordering race (MUST-FIX A):** _approval_sse_notify took _lock
only for the subscriber-list snapshot, then released it before
put_nowait. With two parallel submit_pending calls, T2's notify
could fire before T1's, leaving the UI showing pending_count=1 while
the server actually had 2 queued.
C) **Trailing approval lost (MUST-FIX C):** _handle_approval_respond
never called _approval_sse_notify after popping. With parallel
tool-call approvals (#527 ), a second approval queued behind the one
being responded to was invisible until the next event ever fired —
in practice, the agent thread parked on it would appear hung.
D) **Payload showed tail not head (MUST-FIX D):** payload built from
the just-appended entry instead of queue[0]. /api/approval/pending
returns the head; SSE returned the tail. Diverging contracts.
Fix:
- Split into _approval_sse_notify_locked (caller holds _lock, no
internal locking) and _approval_sse_notify (convenience wrapper).
- submit_pending: call _locked variant inside the queue-mutation lock,
passing queue_list[0] as head.
- _handle_approval_respond: call _locked variant inside the pop lock,
passing the new head (or None/0 if queue is empty).
- Restore fallback poll to 1500ms (was bumped to 3000ms; degraded-mode
parity with v0.50.247 is more important than save 1.5s of polling).
New regression tests in tests/test_pr1350_sse_notify_correctness.py:
- test_second_submit_pending_sends_head_not_tail (D)
- test_respond_to_first_pushes_second_as_new_head (C)
- test_respond_to_only_pending_pushes_empty_state (C edge)
- test_pending_count_is_monotonic_under_contention (A)
Updated test_approval_sse.py to pin the new contract:
- _approval_sse_notify_locked(session_key, head, total)
- 1500ms fallback interval
Total: 3411 tests passing.
Co-authored-by: jasonjcwu <jasonjcwu@users.noreply.github.com >
2026-04-30 18:45:15 +00:00
..
2026-03-30 20:40:19 -07:00
2026-04-21 02:25:14 +00:00
2026-04-26 21:04:38 -07:00
2026-04-29 21:34:27 -07:00
2026-04-25 23:08:59 -07:00
2026-04-25 21:06:31 -07:00
2026-04-23 12:15:56 -07:00
2026-04-29 19:54:07 -07:00
2026-04-29 21:34:27 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 17:50:58 -07:00
2026-04-25 17:50:58 -07:00
2026-04-29 04:31:55 +00:00
2026-04-30 17:13:59 +00:00
2026-04-30 16:18:02 +00:00
2026-04-27 11:43:32 -07:00
2026-04-29 04:37:31 +00:00
2026-04-30 18:45:15 +00:00
2026-04-30 18:45:15 +00:00
2026-04-14 19:04:48 +00:00
2026-04-25 17:50:58 -07:00
2026-04-09 18:05:23 -07:00
2026-04-27 13:34:59 -07:00
2026-04-24 01:32:47 +00:00
2026-04-29 19:54:07 -07:00
2026-04-25 23:08:59 -07:00
2026-04-20 20:55:53 -07:00
2026-04-25 14:33:41 -07:00
2026-04-23 09:58:15 -07:00
2026-04-29 19:54:07 -07:00
2026-04-20 23:54:40 +00:00
2026-04-30 15:24:31 +00:00
2026-04-29 04:32:40 +00:00
2026-04-21 22:55:09 -07:00
2026-04-25 21:35:51 -07:00
2026-04-19 05:37:44 +00:00
2026-04-22 20:18:02 +00:00
2026-04-26 21:04:38 -07:00
2026-04-24 09:05:25 -07:00
2026-04-30 15:24:30 +00:00
2026-04-25 15:47:44 -07:00
2026-04-29 17:42:32 -07:00
2026-04-21 17:41:05 -07:00
2026-04-29 04:31:16 +00:00
2026-04-26 21:04:38 -07:00
2026-04-29 16:45:26 +08:00
2026-04-27 16:44:07 -07:00
2026-04-29 17:42:32 -07:00
2026-04-21 23:39:39 -07:00
2026-04-29 19:54:07 -07:00
2026-04-15 23:21:56 +08:00
2026-04-18 06:37:09 +00:00
2026-04-29 04:39:50 +00:00
2026-04-30 16:18:01 +00:00
2026-04-20 21:03:41 -07:00
2026-04-24 11:41:17 -07:00
2026-04-27 22:56:12 -07:00
2026-04-14 21:14:00 +00:00
2026-04-14 21:14:33 +00:00
2026-04-29 04:33:25 +00:00
2026-04-29 04:34:26 +00:00
2026-04-14 21:52:34 +00:00
2026-04-16 00:00:22 +00:00
2026-04-29 04:33:24 +00:00
2026-04-29 04:34:55 +00:00
2026-04-20 19:43:40 +00:00
2026-04-16 20:16:07 -07:00
2026-04-25 15:47:44 -07:00
2026-04-25 14:33:41 -07:00
2026-04-29 15:50:32 +08:00
2026-04-18 06:45:39 +00:00
2026-04-16 18:09:16 -07:00
2026-04-24 09:05:25 -07:00
2026-04-21 15:26:52 -07:00
2026-04-25 13:07:35 -07:00
2026-04-25 14:33:41 -07:00
2026-04-18 06:46:43 +00:00
2026-04-20 23:04:09 +00:00
2026-04-20 19:43:40 +00:00
2026-04-18 17:09:59 +00:00
2026-04-20 22:48:19 +00:00
2026-04-19 23:11:49 -07:00
2026-04-30 16:20:05 +00:00
2026-04-21 00:58:02 +00:00
2026-04-27 16:27:03 -07:00
2026-04-23 09:05:57 -07:00
2026-04-22 16:27:01 +00:00
2026-04-21 23:08:24 -07:00
2026-04-22 20:21:42 +00:00
2026-04-23 09:58:15 -07:00
2026-04-29 04:31:14 +00:00
2026-04-29 04:31:14 +00:00
2026-04-29 04:31:13 +00:00
2026-04-23 09:05:57 -07:00
2026-04-23 11:16:59 -07:00
2026-04-23 10:44:10 -07:00
2026-04-26 18:47:38 -07:00
2026-04-25 13:07:35 -07:00
2026-04-26 14:24:20 -07:00
2026-04-29 17:42:32 -07:00
2026-04-30 15:24:32 +00:00
2026-04-26 15:29:02 -07:00
2026-04-26 14:24:20 -07:00
2026-04-26 14:24:20 -07:00
2026-04-26 10:36:59 -07:00
2026-04-26 10:36:59 -07:00
2026-04-26 15:29:02 -07:00
2026-04-26 15:29:02 -07:00
2026-04-26 15:29:02 -07:00
2026-04-29 19:54:07 -07:00
2026-04-27 13:34:59 -07:00
2026-04-29 04:31:36 +00:00
2026-04-27 17:43:36 -07:00
2026-04-27 15:28:19 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 22:56:12 -07:00
2026-04-29 16:37:08 +08:00
2026-04-30 15:24:35 +00:00
2026-04-30 16:28:20 +00:00
2026-04-27 17:43:36 -07:00
2026-04-20 22:48:19 +00:00
2026-04-26 21:04:38 -07:00
2026-04-23 14:41:06 -07:00
2026-04-27 13:34:59 -07:00
2026-04-14 17:14:01 +00:00
2026-04-19 06:47:24 +00:00
2026-04-29 19:54:07 -07:00
2026-04-29 15:50:32 +08:00
2026-04-30 15:24:36 +00:00
2026-04-29 19:54:07 -07:00
2026-04-30 15:24:35 +00:00
2026-04-29 15:50:32 +08:00
2026-04-29 04:33:29 +00:00
2026-04-29 17:01:01 +08:00
2026-04-22 22:56:21 -07:00
2026-04-22 20:18:02 +00:00
2026-04-26 21:04:38 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 17:42:32 -07:00
2026-04-15 16:57:31 +00:00
2026-04-29 04:30:55 +00:00
2026-04-29 17:42:32 -07:00
2026-04-30 10:27:56 -07:00
2026-04-30 16:20:05 +00:00
2026-04-30 10:27:56 -07:00
2026-04-30 18:34:37 +00:00
2026-04-30 18:45:15 +00:00
2026-04-21 19:14:31 -07:00
2026-04-23 02:09:37 +00:00
2026-04-23 02:09:37 +00:00
2026-04-27 21:39:30 -07:00
2026-04-27 22:56:12 -07:00
2026-04-29 17:42:32 -07:00
2026-04-25 23:28:29 -07:00
2026-04-23 02:09:37 +00:00
2026-04-29 15:18:43 +00:00
2026-04-24 10:44:46 -07:00
2026-04-30 16:18:01 +00:00
2026-04-26 21:04:38 -07:00
2026-04-21 16:26:51 +00:00
2026-04-25 19:21:00 -07:00
2026-04-25 21:06:31 -07:00
2026-04-25 21:06:31 -07:00
2026-04-21 15:26:52 -07:00
2026-04-29 17:42:32 -07:00
2026-04-25 21:06:31 -07:00
2026-04-30 16:18:01 +00:00
2026-04-25 17:50:58 -07:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 17:42:32 -07:00
2026-04-25 13:07:35 -07:00
2026-04-25 13:07:35 -07:00
2026-04-27 13:34:59 -07:00
2026-04-27 13:34:59 -07:00
2026-04-21 22:11:32 -07:00
2026-04-25 17:50:58 -07:00
2026-04-29 04:31:37 +00:00
2026-04-14 19:04:48 +00:00
2026-04-24 09:05:25 -07:00
2026-04-29 21:34:27 -07:00
2026-04-29 17:42:32 -07:00
2026-04-29 17:42:32 -07:00
2026-04-11 20:06:37 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-27 21:39:30 -07:00
2026-04-14 19:04:48 +00:00
2026-04-23 02:35:58 +00:00
2026-04-24 09:05:25 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-30 16:18:01 +00:00
2026-04-29 21:06:30 -07:00
2026-04-18 06:46:43 +00:00
2026-04-23 10:44:10 -07:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-18 06:37:09 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-29 04:31:54 +00:00
2026-04-29 04:31:54 +00:00
2026-04-14 19:04:48 +00:00
2026-04-18 06:37:09 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-14 19:04:48 +00:00
2026-04-29 04:32:52 +00:00
2026-04-29 04:31:12 +00:00
2026-04-22 20:49:28 +00:00
2026-04-11 12:19:12 -07:00
2026-04-24 09:05:25 -07:00
2026-04-12 10:51:48 -07:00
2026-04-29 04:31:55 +00:00
2026-04-27 16:27:03 -07:00
2026-04-18 06:45:39 +00:00
2026-04-16 10:19:10 -07:00
2026-04-22 16:27:01 +00:00
2026-04-12 14:28:16 -07:00
2026-04-23 14:25:43 -07:00
2026-04-29 16:46:32 +08:00
2026-04-13 11:11:56 -07:00
2026-04-13 23:25:26 -07:00
2026-04-14 19:04:48 +00:00
2026-04-19 04:29:07 +00:00
2026-04-19 05:37:44 +00:00
2026-04-24 11:04:16 -07:00
2026-04-29 17:42:32 -07:00
2026-04-19 23:17:00 -07:00
2026-04-20 23:54:40 +00:00
2026-04-29 21:34:27 -07:00
2026-04-24 11:04:32 -07:00
2026-04-21 18:47:40 -07:00
2026-04-30 15:24:33 +00:00
2026-04-29 19:54:07 -07:00
2026-04-27 13:34:59 -07:00
2026-04-29 04:31:36 +00:00
2026-04-23 09:45:34 -07:00
2026-04-09 18:08:29 -07:00
2026-04-16 14:04:42 -07:00
2026-04-21 00:33:03 +00:00
2026-04-29 17:42:32 -07:00
2026-04-29 19:59:26 -07:00
2026-04-25 14:33:41 -07:00
2026-04-10 10:02:28 -07:00
2026-04-12 00:19:33 -07:00
2026-04-20 20:36:53 -07:00
2026-04-13 22:11:45 -07:00
2026-04-24 11:03:42 -07:00
2026-04-27 17:43:36 -07:00
2026-04-27 21:39:30 -07:00
2026-04-27 18:40:13 -07:00
2026-04-27 17:43:36 -07:00
2026-04-26 10:36:59 -07:00