fix(tests): e2e group-restart test no longer flakes on cold SessionDB init

The /goal post-turn hook constructs a real SessionDB on an executor
thread at the turn boundary. On a cold or loaded CI runner that
state.db init can exceed send_and_capture's 2s poll window, so the
send lands after the assertion and the test reports the bare
'Expected mock to have been called once. Called 0 times.' (#92130).
Mock _run_post_turn_hooks in the e2e runner — these tests exercise
gateway command dispatch, not goal hooks.

Also scrub TELEGRAM_GROUP_ALLOWED_CHATS / *_GROUP_ALLOWED_USERS / QQ
allowlist env vars in the hermetic conftest: a developer shell with
those set flips _get_unauthorized_dm_behavior to 'ignore' and fails
the pairing e2e test locally.
This commit is contained in:
Teknium
2026-08-24 20:09:17 -07:00
parent 64a6f42cb3
commit bc47fcd3f9
2 changed files with 15 additions and 0 deletions

View File

@@ -347,6 +347,10 @@ _HERMES_BEHAVIORAL_VARS = frozenset({
# (user shell, earlier leaky test, CI env), they change gateway auth
# behavior and flake button-authorization tests.
"TELEGRAM_ALLOWED_USERS",
"TELEGRAM_GROUP_ALLOWED_USERS",
"TELEGRAM_GROUP_ALLOWED_CHATS",
"QQ_ALLOWED_USERS",
"QQ_GROUP_ALLOWED_USERS",
"DISCORD_ALLOWED_USERS",
"WHATSAPP_ALLOWED_USERS",
"SLACK_ALLOWED_USERS",

View File

@@ -235,6 +235,17 @@ def make_runner(platform: Platform, session_entry: SessionEntry = None) -> "Gate
# telegram param only — first parametrization pays the cold-resolution cost).
runner._reset_notice_session_info = lambda source: ""
# Keep the agent-turn path hermetic: _run_post_turn_hooks runs the /goal
# continuation, whose SessionDB warm-up constructs a REAL SessionDB on an
# executor thread at the turn boundary. On a cold/loaded CI runner that
# state.db init can exceed send_and_capture's 2s poll window, so the send
# lands after the assertion — the "Expected 'mock' to have been called
# once. Called 0 times." flake on
# test_plaintext_restart_gateway_in_group_stays_plain_text[telegram]
# (issue #92130; e.g. runs 32802504263 / 32799192528 / 32796821900).
# e2e tests exercise gateway command dispatch, not post-turn goal hooks.
runner._run_post_turn_hooks = AsyncMock()
runner.pairing_store = MagicMock()
runner.pairing_store._is_rate_limited = MagicMock(return_value=False)
runner.pairing_store.generate_code = MagicMock(return_value="ABC123")