From d28e373e54cf8219aa9f9bb1683ff659d7a23b80 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 27 Jun 2026 16:31:45 -0400 Subject: [PATCH] fix(mock_concurrent_mma): remove session_id fallback from worker check Root cause discovered after the user's batched test run revealed the stress test still failed when run after the execution test. The gemini_cli_adapter persists session_id across tests (singleton). The execution test set session_id to 'mock-worker-ticket-A-1' (from the worker call). When the stress test's epic call ran, it used --resume with that stale session_id. The mock's worker check had a session_id fallback: if 'You are assigned to Ticket' in prompt or session_id.startswith('mock-worker-'): ...worker response... The fallback incorrectly matched the stress test's epic call (which used the stale worker session_id), causing the mock to return a worker response instead of an epic response. The production's generate_tracks then failed to parse the response, returning 0 tracks. Fix: remove the session_id.startswith('mock-worker-') fallback. Route workers based on prompt content only. The session_id is for the production's session management, not for the mock's routing. This is a 'fix the test infrastructure' change (the mock is a test artifact, not production). The production's gemini_cli_adapter could also be fixed to reset session_id on reset_session(), but that's out of scope for this track. Verified: the failing test combination (execution test before stress test) was reproduced and the fix resolves it. The isolated stress test still passes (3 consecutive runs). Note: a separate issue was discovered where self.tracks is being replaced between track appends (different id(self.tracks) values in the diagnostic log). This causes the API to read 0 tracks after the accept. The root cause is unclear from this session's investigation; it appears to be a production code issue where the in-memory track state is being overwritten by a disk read from a different project path. This is documented as a follow-up. --- tests/mock_concurrent_mma.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/tests/mock_concurrent_mma.py b/tests/mock_concurrent_mma.py index e3ba0a08..79648936 100644 --- a/tests/mock_concurrent_mma.py +++ b/tests/mock_concurrent_mma.py @@ -46,6 +46,10 @@ def main() -> None: session_id = argv[i + 1] call_n = _next_call_count() + try: + with open(b"C:\\projects\\manual_slop_tier2\\tests\\artifacts\\tier2_state\\fix_mma_concurrent_tracks_sim_20260627\\mock_diag.log", "ab") as _df: + _df.write(f"[MOCK] call_n={call_n} session_id={session_id!r}\n".encode()) + except Exception: pass # 1. Sprint Planning (different tickets for different tracks) # Route on prompt content (the production passes the track_brief which @@ -63,11 +67,22 @@ def main() -> None: elif "Track C" in prompt: track_label = "C" else: track_label = "A" _emit_sprint_ticket(track_label) + try: + with open(b"C:\\projects\\manual_slop_tier2\\tests\\artifacts\\tier2_state\\fix_mma_concurrent_tracks_sim_20260627\\mock_diag.log", "ab") as _df: + _df.write(f"[MOCK] ROUTED TO: sprint track={track_label}\n".encode()) + except Exception: pass return # 2. Worker Execution # CHECK BEFORE epic so worker takes priority over the catch-all epic branch. - if 'You are assigned to Ticket' in prompt or session_id.startswith("mock-worker-"): + if 'You are assigned to Ticket' in prompt: + # NOTE: Removed session_id.startswith("mock-worker-") fallback. The session_id + # persists across tests in the same session (gemini_cli_adapter is a singleton). + # The fallback caused test_mma_concurrent_tracks_stress_sim to fail when it ran + # AFTER test_mma_concurrent_tracks_execution: the execution test set the session_id + # to mock-worker-ticket-A-1, and the stress test's epic call used --resume with that + # session_id, which the fallback incorrectly matched, returning a worker response + # instead of an epic response. import re match = re.search(r'Ticket (ticket-[A-Ba-b]-1)', prompt, re.IGNORECASE) if match: @@ -77,6 +92,10 @@ def main() -> None: else: tid = "unknown" + try: + with open(b"C:\\projects\\manual_slop_tier2\\tests\\artifacts\\tier2_state\\fix_mma_concurrent_tracks_sim_20260627\\mock_diag.log", "ab") as _df: + _df.write(f"[MOCK] ROUTED TO: worker tid={tid}\n".encode()) + except Exception: pass print(json.dumps({ "type": "message", "role": "assistant", @@ -113,9 +132,17 @@ def main() -> None: "stats": {"total_tokens": 100, "input_tokens": 50, "output_tokens": 50}, "session_id": "mock-epic" }), flush=True) + try: + with open(b"C:\\projects\\manual_slop_tier2\\tests\\artifacts\\tier2_state\\fix_mma_concurrent_tracks_sim_20260627\\mock_diag.log", "ab") as _df: + _df.write(b"[MOCK] ROUTED TO: epic_catchall\n") + except Exception: pass return # Default + try: + with open(b"C:\\projects\\manual_slop_tier2\\tests\\artifacts\\tier2_state\\fix_mma_concurrent_tracks_sim_20260627\\mock_diag.log", "ab") as _df: + _df.write(b"[MOCK] ROUTED TO: default\n") + except Exception: pass print(json.dumps({ "type": "message", "role": "assistant",