Skip to content

The agent that grows with you

test(delegation): consumers restore the ledger before reading the completion queue (#123265)

teknium1b7e24becf9fe
diff --git a/tests/tools/test_async_delegation.py b/tests/tools/test_async_delegation.py
index e8d551e7a55..1125639f599 100644
--- a/tests/tools/test_async_delegation.py
+++ b/tests/tools/test_async_delegation.py
@@ -519,9 +519,11 @@ print(r["delegation_id"])
)
delegation_id = first.stdout.strip().splitlines()[-1]
+ # The ledger replays on the first consumer, not at import (#123265).
consumer = r'''
import json
from tools.process_registry import process_registry
+process_registry.restore_completions()
evt = process_registry.completion_queue.get_nowait()
print(json.dumps(evt, sort_keys=True))
'''
@@ -544,7 +546,7 @@ assert ad.mark_completion_delivered({delegation_id!r})
text=True, capture_output=True, timeout=15, check=True,
)
probe = subprocess.run(
- [sys.executable, "-c", "from tools.process_registry import process_registry; print(process_registry.completion_queue.qsize())"],
+ [sys.executable, "-c", "from tools.process_registry import process_registry; process_registry.restore_completions(); print(process_registry.completion_queue.qsize())"],
cwd=repo, env=env, text=True, capture_output=True, timeout=15, check=True,
)
assert probe.stdout.strip().splitlines()[-1] == "0"
diff --git a/tests/tui_gateway/test_notification_turn_release.py b/tests/tui_gateway/test_notification_turn_release.py
index d35edbc8331..248d610bf0b 100644
--- a/tests/tui_gateway/test_notification_turn_release.py
+++ b/tests/tui_gateway/test_notification_turn_release.py
@@ -108,7 +108,8 @@ def test_the_poller_thread_survives_a_dispatch_that_raises(monkeypatch):
mailbox; an exception out of one event's dispatch used to end the thread for good."""
events: queue.Queue = queue.Queue()
events.put({"type": "completion", "session_id": "proc_a"})
- monkeypatch.setattr("tools.process_registry.process_registry", SimpleNamespace(completion_queue=events))
+ monkeypatch.setattr("tools.process_registry.process_registry",
+ SimpleNamespace(completion_queue=events, restore_completions=lambda: 0))
for name in ("_poll_bot_live_delivery_guarded", "_maybe_fire_tui_loop_tick",
"_maybe_fire_tui_heartbeat_tick", "_notif_poll_kanban"):
monkeypatch.setattr(server, name, lambda *a, **k: None)