diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_accept_id.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_accept_id.py new file mode 100644 index 00000000..2363758f --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_accept_id.py @@ -0,0 +1,31 @@ +"""Add id() logging at start of _cb_accept_tracks._bg_task.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Find the _bg_task function inside _cb_accept_tracks +# It starts with: def _bg_task() -> "Result[None]": +old = b' def _cb_accept_tracks(self) -> None:\r\n """\r\n [C: src/gui_2.py:App._render_track_proposal_modal]\r\n """\r\n self._show_track_proposal_modal = False\r\n\r\n def _bg_task()' +new = (b' def _cb_accept_tracks(self) -> None:\r\n' + b' """\r\n' + b' [C: src/gui_2.py:App._render_track_proposal_modal]\r\n' + b' """\r\n' + b' self._show_track_proposal_modal = False\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n' + b' _df.write(f"[PROD] _cb_accept_tracks: BEFORE id(self.tracks)={id(self.tracks)} len={len(self.tracks)}\\n".encode())\r\n' + b' except Exception: pass\r\n' + b'\r\n' + b' def _bg_task()') + +if old not in data: + print('NOT FOUND: _cb_accept_tracks anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added _cb_accept_tracks id() logging') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_api_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_api_diag.py new file mode 100644 index 00000000..a7e967e8 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_api_diag.py @@ -0,0 +1,25 @@ +"""Add diagnostic to the API endpoint to see what it returns for proposed_tracks.""" +import sys + +path = 'src/api_hooks.py' +with open(path, 'rb') as f: + data = f.read() + +# Add diagnostic right before result["proposed_tracks"] = ... +old = b' result["proposed_tracks"] = _get_app_attr(app, "proposed_tracks", [])' +new = (b' _pt = _get_app_attr(app, "proposed_tracks", [])\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\api_diag.log", "ab") as _af:\r\n' + b' _af.write(f"[API] get_mma_status: proposed_tracks count={len(_pt)} ids={[t.get(chr(105)+chr(100)) if isinstance(t, dict) else getattr(t, chr(105)+chr(100), None) for t in _pt]}\\n".encode())\r\n' + b' except Exception: pass\r\n' + b' result["proposed_tracks"] = _pt') + +if old not in data: + print('NOT FOUND: API anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added API diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_enter_log.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_enter_log.py new file mode 100644 index 00000000..64740dfb --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_enter_log.py @@ -0,0 +1,24 @@ +"""Add id() log at the very start of _start_track_logic_result.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' def _start_track_logic_result(self, track_data: Metadata, skeletons_str: str | None = None) -> "Result[None]":\r\n """Phase 6 Group 6.7: track-start pipeline with Result propagation.' +new = (b' def _start_track_logic_result(self, track_data: Metadata, skeletons_str: str | None = None) -> "Result[None]":\r\n' + b' """Phase 6 Group 6.7: track-start pipeline with Result propagation.\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n' + b' _df.write(f"[PROD] _start_track_logic_result ENTER: id(self.tracks)={id(self.tracks)} len={len(self.tracks)}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added ENTER log') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_id_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_id_diag.py new file mode 100644 index 00000000..7dde2727 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_id_diag.py @@ -0,0 +1,27 @@ +"""Add id() logging to compare production self.tracks with API app.tracks.""" +import sys + +path = 'src/api_hooks.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' _tk = _get_app_attr(app, "tracks", [])' +new = (b' _tk = _get_app_attr(app, "tracks", [])\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\api_diag.log", "ab") as _af:\r\n' + b' _af.write(f"[API] id(_tk)={id(_tk)} count={len(_tk)}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: tracks anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +# Also add to the old _tk replacement (in case there are two) +old2 = b' _tk = _get_app_attr(app, "tracks", [])\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\api_diag.log", "ab") as _af:\r\n _af.write(f"[API] id(_tk)={id(_tk)} count={len(_tk)}\\n".encode())\r\n except Exception: pass\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\api_diag.log", "ab") as _af:\r\n _af.write(f"[API] get_mma_status: tracks count={len(_tk)} ids={[t.get(chr(105)+chr(100)) if isinstance(t, dict) else getattr(t, chr(105)+chr(100), None) for t in _tk]}\\n".encode())\r\n except Exception: pass\r\n result["tracks"] = _tk' +# This is a no-op since old2 is the same as new. Skip. + +with open(path, 'wb') as f: + f.write(data) +print('OK: added id() logging to API') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_mock_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_mock_diag.py new file mode 100644 index 00000000..bd57435e --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_mock_diag.py @@ -0,0 +1,20 @@ +"""Add diagnostic to mock to see what's being returned.""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Add diagnostic log at the start of main() +old = b' session_id = ""\r\n argv = sys.argv[1:]\r\n if "--resume" in argv:\r\n i = argv.index("--resume")\r\n if i + 1 < len(argv):\r\n session_id = argv[i + 1]\r\n\r\n call_n = _next_call_count()' +new = b' session_id = ""\r\n argv = sys.argv[1:]\r\n if "--resume" in argv:\r\n i = argv.index("--resume")\r\n if i + 1 < len(argv):\r\n session_id = argv[i + 1]\r\n\r\n import os as _os\r\n _dl = b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log"\r\n try:\r\n with open(_dl, "ab") as _df:\r\n prompt = sys.stdin.read() if not _os.environ.get("MOCK_PROMPT_READ") else ""\r\n except Exception: pass\r\n call_n = _next_call_count()\r\n try:\r\n with open(_dl, "ab") as _df:\r\n _df.write(f"[MOCK] call_n={call_n} session_id={session_id!r} prompt_starts={prompt[:80]!r}\\n".encode())\r\n except Exception: pass' + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_diag.py new file mode 100644 index 00000000..595770e0 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_diag.py @@ -0,0 +1,26 @@ +"""Add production diagnostic to _cb_plan_epic to see what the mock returns.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Find the _cb_plan_epic._bg_task function and add diagnostic after generate_tracks +old = b' tracks = orchestrator_pm.generate_tracks(self.ui_epic_input, flat, file_items, history_summary=history)' +new = (b' tracks = orchestrator_pm.generate_tracks(self.ui_epic_input, flat, file_items, history_summary=history)\r\n' + b' import os as _os\r\n' + b' _dl = b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log"\r\n' + b' try:\r\n' + b' with open(_dl, "ab") as _df:\r\n' + b' _df.write(f"[PROD] _cb_plan_epic: ui_epic_input={self.ui_epic_input!r} tracks={tracks!r}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: generate_tracks call') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added production diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_id.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_id.py new file mode 100644 index 00000000..4e88d565 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_prod_id.py @@ -0,0 +1,23 @@ +"""Add id() logging to production _start_track_logic.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n _df.write(f"[PROD] _start_track_logic_result: appended track_id={track_id} title={title!r} self.tracks.len={len(self.tracks)}\\n".encode())\r\n except Exception: pass' +new = (b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n' + b' _df.write(f"[PROD] _start_track_logic_result: appended track_id={track_id} title={title!r} self.tracks.len={len(self.tracks)} id(self.tracks)={id(self.tracks)}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added id() to production') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_routing_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_routing_diag.py new file mode 100644 index 00000000..484318b4 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_routing_diag.py @@ -0,0 +1,39 @@ +"""Add diagnostic AFTER the routing to see which branch was taken.""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Add diagnostic after the epic catch-all (which is the last 'return' before Default) +old = b' "session_id": "mock-epic"\r\n }), flush=True)\r\n return\r\n\r\n # Default' +new = b' "session_id": "mock-epic"\r\n }), flush=True)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log", "ab") as _df:\r\n _df.write(b"[MOCK] ROUTED TO: epic_catchall\\n")\r\n except Exception: pass\r\n return\r\n\r\n # Default' + +if old not in data: + print('NOT FOUND: epic catchall return') + sys.exit(1) + +data = data.replace(old, new, 1) + +# Also add diagnostic at the end of each branch +# Sprint branch +data = data.replace( + b' _emit_sprint_ticket(track_label)\r\n return\r\n\r\n # 2. Worker Execution', + b' _emit_sprint_ticket(track_label)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log", "ab") as _df:\r\n _df.write(f"[MOCK] ROUTED TO: sprint track={track_label}\\n".encode())\r\n except Exception: pass\r\n return\r\n\r\n # 2. Worker Execution' +) + +# Worker branch (before the print) +data = data.replace( + b' else:\r\n tid = "unknown"\r\n\r\n print(json.dumps({\r\n "type": "message",\r\n "role": "assistant",\r\n "content": f"Working on {tid}. Done."', + b' else:\r\n tid = "unknown"\r\n\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log", "ab") as _df:\r\n _df.write(f"[MOCK] ROUTED TO: worker tid={tid}\\n".encode())\r\n except Exception: pass\r\n print(json.dumps({\r\n "type": "message",\r\n "role": "assistant",\r\n "content": f"Working on {tid}. Done."' +) + +# Default branch +data = data.replace( + b' # Default\r\n print(json.dumps({', + b' # Default\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log", "ab") as _df:\r\n _df.write(b"[MOCK] ROUTED TO: default\\n")\r\n except Exception: pass\r\n print(json.dumps({' +) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added routing diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_show_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_show_diag.py new file mode 100644 index 00000000..3666d1d1 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_show_diag.py @@ -0,0 +1,29 @@ +"""Add diagnostic to show_track_proposal handler and task dispatch.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Add diagnostic to _handle_show_track_proposal +old = b'def _handle_show_track_proposal(controller: \'AppController\', task: dict):\r\n """[SDM: AppController._handle_show_track_proposal]"""\r\n controller.proposed_tracks = task.get("payload", [])\r\n controller._show_track_proposal_modal = True' +new = (b'def _handle_show_track_proposal(controller: \'AppController\', task: dict):\r\n' + b' """[SDM: AppController._handle_show_track_proposal]"""\r\n' + b' import os as _os\r\n' + b' _dl = b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log"\r\n' + b' try:\r\n' + b' with open(_dl, "ab") as _df:\r\n' + b' _df.write(f"[PROD] _handle_show_track_proposal: payload={task.get(chr(112)+chr(97)+chr(121)+chr(108)+chr(111)+chr(97)+chr(100), [])!r}\\n".encode())\r\n' + b' except Exception: pass\r\n' + b' controller.proposed_tracks = task.get("payload", [])\r\n' + b' controller._show_track_proposal_modal = True') + +if old not in data: + print('NOT FOUND: show_track_proposal anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added show_track_proposal diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_start_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_start_diag.py new file mode 100644 index 00000000..90d507ad --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_start_diag.py @@ -0,0 +1,24 @@ +"""Add diagnostic to _start_track_logic to see if it appends to self.tracks.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Add diagnostic after self.tracks.append +old = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})' +new = (b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n' + b' _df.write(f"[PROD] _start_track_logic_result: appended track_id={track_id} title={title!r} self.tracks.len={len(self.tracks)}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: self.tracks.append anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added start_track_logic diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_tracks_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_tracks_diag.py new file mode 100644 index 00000000..f1ebddf8 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/add_tracks_diag.py @@ -0,0 +1,24 @@ +"""Add diagnostic for tracks field in API.""" +import sys + +path = 'src/api_hooks.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' result["tracks"] = _get_app_attr(app, "tracks", [])' +new = (b' _tk = _get_app_attr(app, "tracks", [])\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\api_diag.log", "ab") as _af:\r\n' + b' _af.write(f"[API] get_mma_status: tracks count={len(_tk)} ids={[t.get(chr(105)+chr(100)) if isinstance(t, dict) else getattr(t, chr(105)+chr(100), None) for t in _tk]}\\n".encode())\r\n' + b' except Exception: pass\r\n' + b' result["tracks"] = _tk') + +if old not in data: + print('NOT FOUND: tracks anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: added tracks diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding.py new file mode 100644 index 00000000..2e938279 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding.py @@ -0,0 +1,25 @@ +"""Append new finding to OUTSTANDING report.""" +with open('docs/reports/OUTSTANDING_MMA_TEST_FAILURES_20260627.md', 'r', encoding='utf-8') as f: + content = f.read() + +# Add a new section after the existing findings +new_section = ''' + +### 6. ✅ **RESOLVED** — Mock bug: epic branch only matches one literal prompt + +**Date:** 2026-06-27 (discovered after the fix_mma_concurrent_tracks_sim_20260627 track SHIPPED) + +The stress test (`tests/test_mma_concurrent_tracks_stress_sim.py::test_mma_concurrent_tracks_stress`) uses `mma_epic_input='STRESS TEST: TRACK A AND TRACK B'`, which the mock's epic branch did NOT match (it only matched `'PATH: Epic Initialization'`). The stress prompt fell to the Default branch which returns text (not JSON), and the production's `orchestrator_pm.generate_tracks` failed to parse it, returning 0 tracks. + +**Root cause:** The mock's epic branch was a literal-substring check for a single test-specific prompt. It was not robust to other test prompts. + +**Status:** ✅ **FIXED** in commit `fad1755b` (restructured routing so sprint and worker are checked first, and any non-empty prompt that doesn't match those patterns is treated as an epic request returning 2 tracks). + +**Verification:** 3 consecutive PASS runs of both `test_mma_concurrent_tracks_execution` AND `test_mma_concurrent_tracks_stress` (13.94s, 14.81s, 14.13s). +''' + +# Append to the file +with open('docs/reports/OUTSTANDING_MMA_TEST_FAILURES_20260627.md', 'a', encoding='utf-8') as f: + f.write(new_section) + +print('OK: appended section 6 to OUTSTANDING report') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding7.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding7.py new file mode 100644 index 00000000..392960ca --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/append_outstanding7.py @@ -0,0 +1,31 @@ +"""Append new finding to OUTSTANDING report.""" +with open('docs/reports/OUTSTANDING_MMA_TEST_FAILURES_20260627.md', 'r', encoding='utf-8') as f: + content = f.read() + +# Check if section 7 already exists +if '### 7. ' in content: + print('Section 7 already exists, skipping') +else: + new_section = ''' + +### 7. ✅ **RESOLVED** — Production bug: 'refresh_from_project' task overwrites self.tracks + +**Date:** 2026-06-27 (discovered after the second batched test run) + +After the epic catch-all fix, the batched test still failed. Diagnostic logging revealed that `self.tracks` was being replaced between track appends (different `id(self.tracks)` values in the log). Root cause: + +`_start_track_logic_result` (and `_cb_accept_tracks._bg_task`) appended a `'refresh_from_project'` task to `_pending_gui_tasks` at the end. The main thread processed this task by calling `_refresh_from_project`, which does: + + self.tracks = project_manager.get_all_tracks(self.active_project_root) + +This REPLACED `self.tracks` with a fresh disk read. In batched test environments, the disk read returned 0 tracks (due to timing or path issues), losing the in-memory tracks that were just appended by `self.tracks.append(...)`. + +**Fix:** Remove the `'refresh_from_project'` task appends from both `_start_track_logic_result` and `_cb_accept_tracks._bg_task`. The bg_task already updates `self.tracks` directly via `self.tracks.append(...)`. The refresh is unnecessary for the accept flow because the other state (files, disc_entries, etc.) doesn't change during the accept. + +**Status:** ✅ **FIXED** in commit `55dae159`. + +**Verification:** 3 consecutive PASS runs of the failing test combination (test_context_sim_live + test_mma_concurrent_tracks_execution + test_mma_concurrent_tracks_stress) at 100.57s, 100.29s, 100.18s. Also passes 15 wider tests (237.63s) with no regressions. +''' + with open('docs/reports/OUTSTANDING_MMA_TEST_FAILURES_20260627.md', 'a', encoding='utf-8') as f: + f.write(new_section) + print('OK: appended section 7 to OUTSTANDING report') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/check_call_n.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/check_call_n.py new file mode 100644 index 00000000..7f2f07dc --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/check_call_n.py @@ -0,0 +1,11 @@ +"""Check if call_n is used in mock routing.""" +with open('tests/mock_concurrent_mma.py', 'rb') as f: + data = f.read() +# Check if call_n is used in routing +import re +for m in re.finditer(b'call_n', data): + line_no = data[:m.start()].count(b'\n') + 1 + start = max(0, m.start() - 50) + end = min(len(data), m.end() + 100) + print(f'line {line_no}: {data[start:end]!r}') + print('---') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/cleanup_instrumentation.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/cleanup_instrumentation.py new file mode 100644 index 00000000..a6279b63 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/cleanup_instrumentation.py @@ -0,0 +1,104 @@ +"""Remove all diagnostic instrumentation from src/app_controller.py. + +Per edit_workflow.md §9 ("No Diagnostic Noise in Production Code"), the +diag lines added in commits 75fdebb0, d046394a, and the e9919059 fix must +be removed in a single cleanup commit. + +Removes: +- 3 stderr writes from the prior instrumentation (lines 4761-4765) +- 8 file-based diag log writes added in this track +- Restores the function to its production shape (no diag output) +""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Remove the ENTER log block (after "Phase 2: Calling Tech Lead...") +old1 = b' self.ai_status = "Phase 2: Calling Tech Lead..."\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] _start_track_logic_result ENTER title={title!r} goal={goal[:60]!r} skeletons_len={len(skeletons)}\\n".encode())\r\n except Exception: pass\r\n _t2_baseline = len(ai_client.get_comms_log())\r\n raw_tickets = conductor_tech_lead.generate_tickets(goal, skeletons)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] _start_track_logic_result AFTER generate_tickets title={title!r} raw_tickets_count={len(raw_tickets) if raw_tickets else 0}\\n".encode())\r\n except Exception: pass' +new1 = b' self.ai_status = "Phase 2: Calling Tech Lead..."\r\n _t2_baseline = len(ai_client.get_comms_log())\r\n raw_tickets = conductor_tech_lead.generate_tickets(goal, skeletons)' +if old1 not in data: + print('NOT FOUND: ENTER/AFTER generate_tickets block') + sys.exit(1) +data = data.replace(old1, new1, 1) + +# Remove the BEFORE/AFTER sort log block +old2 = b' self.ai_status = "Phase 2: Sorting tickets..."\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(b"[DIAG] BEFORE _topological_sort_tickets_result\\n")\r\n except Exception: pass\r\n sort_result = self._topological_sort_tickets_result(raw_tickets, title)\r\n sorted_tickets_data = sort_result.data\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] AFTER sort sorted_count={len(sorted_tickets_data) if sorted_tickets_data else 0} type={type(sorted_tickets_data[0]).__name__ if sorted_tickets_data else None}\\n".encode())\r\n except Exception: pass' +new2 = b' self.ai_status = "Phase 2: Sorting tickets..."\r\n sort_result = self._topological_sort_tickets_result(raw_tickets, title)\r\n sorted_tickets_data = sort_result.data' +if old2 not in data: + print('NOT FOUND: BEFORE/AFTER sort block') + sys.exit(1) +data = data.replace(old2, new2, 1) + +# Remove the BEFORE save_track_state log block +old3 = b' track = Track(id=track_id, description=title, tickets=tickets)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(b"[DIAG] BEFORE save_track_state\\n")\r\n except Exception: pass\r\n # Initialize track state in the filesystem' +new3 = b' track = Track(id=track_id, description=title, tickets=tickets)\r\n # Initialize track state in the filesystem' +if old3 not in data: + print('NOT FOUND: BEFORE save_track_state block') + sys.exit(1) +data = data.replace(old3, new3, 1) + +# Remove the AFTER save_track_state log block +old4 = b' project_manager.save_track_state(track_id, state, self.active_project_root)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(b"[DIAG] AFTER save_track_state\\n")\r\n except Exception: pass\r\n # Add to memory and notify UI\r\n self.tracks.append({"id": track_id, "title": title, "status": "todo"})' +new4 = b' project_manager.save_track_state(track_id, state, self.active_project_root)\r\n # Add to memory and notify UI\r\n self.tracks.append({"id": track_id, "title": title, "status": "todo"})' +if old4 not in data: + print('NOT FOUND: AFTER save_track_state block') + sys.exit(1) +data = data.replace(old4, new4, 1) + +# Remove the self.tracks.append OK log block +old5 = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] _start_track_logic_result self.tracks.append OK title={title!r} track_id={track_id}\\n".encode())\r\n except Exception: pass\r\n with self._pending_gui_tasks_lock:' +new5 = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\r\n with self._pending_gui_tasks_lock:' +if old5 not in data: + print('NOT FOUND: self.tracks.append OK block') + sys.exit(1) +data = data.replace(old5, new5, 1) + +# Remove the _cb_accept_tracks instrumentation +old6 = b' def _cb_accept_tracks(self) -> None:\r\n """\r\n [C: src/gui_2.py:App._render_track_proposal_modal]\r\n """\r\n import os as _os\r\n _dl = b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log"\r\n try:\r\n with open(_dl, "ab") as _df:\r\n _df.write(b"[DIAG] _cb_accept_tracks called\\n")\r\n except Exception: pass\r\n self._show_track_proposal_modal = False' +new6 = b' def _cb_accept_tracks(self) -> None:\r\n """\r\n [C: src/gui_2.py:App._render_track_proposal_modal]\r\n """\r\n self._show_track_proposal_modal = False' +if old6 not in data: + print('NOT FOUND: _cb_accept_tracks block') + sys.exit(1) +data = data.replace(old6, new6, 1) + +# Remove the _bg_task instrumentation +old7 = b' # Now loop through tracks and call _start_track_logic with generated skeletons\r\n total_tracks = len(self.proposed_tracks)\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] _bg_task ENTER total_tracks={total_tracks} proposed_ids={[(t.get(chr(105)+chr(100)) if isinstance(t, dict) else getattr(t, chr(105)+chr(100), chr(63))) for t in self.proposed_tracks]}\\n".encode())\r\n except Exception: pass\r\n print(f"[DEBUG] _cb_accept_tracks: Starting {total_tracks} tracks...")' +new7 = b' # Now loop through tracks and call _start_track_logic with generated skeletons\r\n total_tracks = len(self.proposed_tracks)\r\n print(f"[DEBUG] _cb_accept_tracks: Starting {total_tracks} tracks...")' +if old7 not in data: + print('NOT FOUND: _bg_task block') + sys.exit(1) +data = data.replace(old7, new7, 1) + +# Remove the [DEBUG_MMA_FIX] stderr writes (the original 3-line block) +old8 = b' sys.stderr.write(f"[DEBUG_MMA_FIX] _start_track_logic: ENTER title=\'{title}\' goal=\'{goal[:60]}\' skeletons_len={len(skeletons)}\\n")\r\n sys.stderr.flush()\r\n _t2_baseline = len(ai_client.get_comms_log())' +new8 = b' _t2_baseline = len(ai_client.get_comms_log())' +# Note: this should already be gone if the previous edits worked. Check: +if old8 in data: + data = data.replace(old8, new8, 1) + print('Removed [DEBUG_MMA_FIX] ENTER stderr block') +else: + print('No [DEBUG_MMA_FIX] ENTER stderr block found (already removed)') + +# Remove the generate_tickets [DEBUG_MMA_FIX] stderr write +old9 = b' raw_tickets = conductor_tech_lead.generate_tickets(goal, skeletons)\r\n sys.stderr.write(f"[DEBUG_MMA_FIX] _start_track_logic: generate_tickets returned {len(raw_tickets) if raw_tickets else 0} tickets for \'{title}\'\\n")\r\n sys.stderr.flush()' +new9 = b' raw_tickets = conductor_tech_lead.generate_tickets(goal, skeletons)' +if old9 in data: + data = data.replace(old9, new9, 1) + print('Removed [DEBUG_MMA_FIX] generate_tickets stderr block') +else: + print('No [DEBUG_MMA_FIX] generate_tickets stderr block found (already removed)') + +# Remove the EXCEPT block diagnostic (import traceback + diag write) +old10 = b' except (OSError, IOError, ValueError, TypeError, KeyError, AttributeError, RuntimeError) as e:\r\n import traceback\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mma_diag.log", "ab") as _df:\r\n _df.write(f"[DIAG] _start_track_logic_result EXCEPTION title={title!r} {type(e).__name__}: {e}\\n".encode())\r\n traceback.print_exc(file=_df)\r\n except Exception: pass\r\n err = ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e),\r\n source="app_controller._start_track_logic_result", original=e)\r\n return Result(data=None, errors=[err])' +new10 = b' except (OSError, IOError, ValueError, TypeError, KeyError, AttributeError, RuntimeError) as e:\r\n err = ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e),\r\n source="app_controller._start_track_logic_result", original=e)\r\n return Result(data=None, errors=[err])' +if old10 in data: + data = data.replace(old10, new10, 1) + print('Removed EXCEPT block diagnostic') +else: + print('No EXCEPT block diagnostic found (already removed)') + +with open(path, 'wb') as f: + f.write(data) +print('OK: all diagnostic instrumentation removed') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_batcher_tiers.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_batcher_tiers.py new file mode 100644 index 00000000..36ef31d7 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_batcher_tiers.py @@ -0,0 +1,13 @@ +"""Find tier defs in batcher.""" +import re +import sys +with open('tests/batcher.py', 'r', encoding='utf-8') as f: + content = f.read() +for m in re.finditer(r'tier[_-]\d', content, re.IGNORECASE): + line_no = content[:m.start()].count(chr(10)) + 1 + start = max(0, m.start() - 30) + end = min(len(content), m.end() + 100) + out = f'line {line_no}: {content[start:end]}' + with open('tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/batcher_tiers.txt', 'a', encoding='utf-8') as f: + f.write(out + chr(10)) + print(out[:200]) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_plan.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_plan.py new file mode 100644 index 00000000..54288701 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_plan.py @@ -0,0 +1,15 @@ +"""Find tier config in batched runner.""" +import re +import sys +with open('scripts/run_tests_batched.py', 'r', encoding='utf-8', errors='replace') as f: + content = f.read() +matches = list(re.finditer(r'tier', content, re.IGNORECASE)) +out = [] +for m in matches: + line_no = content[:m.start()].count(chr(10)) + 1 + start = max(0, m.start() - 20) + end = min(len(content), m.end() + 100) + out.append(f'line {line_no}: {content[start:end]}') +with open('tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/plan_func.txt', 'w', encoding='utf-8') as f: + f.write(chr(10).join(out)) +print(f'Wrote {len(out)} lines') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_refresh.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_refresh.py new file mode 100644 index 00000000..583cb35d --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_refresh.py @@ -0,0 +1,11 @@ +"""Find the refresh_from_project in _start_track_logic_result.""" +import re +with open('src/app_controller.py', 'rb') as f: + data = f.read() +# Find all refresh_from_project occurrences +for m in re.finditer(rb"self\._pending_gui_tasks\.append\(\{'action': 'refresh_from_project'\}\)", data): + line_no = data[:m.start()].count(b'\n') + 1 + start = max(0, m.start() - 200) + end = min(len(data), m.end() + 100) + print(f'line {line_no}: {data[start:end]!r}') + print('---') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tier_def.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tier_def.py new file mode 100644 index 00000000..21e4cddd --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tier_def.py @@ -0,0 +1,14 @@ +"""Find tier test file definitions.""" +import re +import sys +with open('scripts/run_tests_batched.py', 'r', encoding='utf-8', errors='replace') as f: + content = f.read() +# Find all string literals +for m in re.finditer(r'\"[^\"]*tier[^\"]*\"', content, re.IGNORECASE): + line_no = content[:m.start()].count(chr(10)) + 1 + print(f'line {line_no}: {m.group()[:200]}') +print('---') +# Also find list-like patterns +for m in re.finditer(r'\"tests[^\"]*\"', content): + line_no = content[:m.start()].count(chr(10)) + 1 + print(f'line {line_no}: {m.group()[:200]}') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tiers.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tiers.py new file mode 100644 index 00000000..03659f8a --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/find_tiers.py @@ -0,0 +1,16 @@ +"""Find tier references in batched runner.""" +import re +import sys +with open('scripts/run_tests_batched.py', 'r', encoding='utf-8') as f: + content = f.read() +# Find all unique lines with 'tier' +seen = set() +out_lines = [] +for line in content.split(chr(10)): + if 'tier' in line.lower(): + if line not in seen: + seen.add(line) + out_lines.append(line[:200]) +with open('tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/tiers.txt', 'w', encoding='utf-8') as f: + f.write(chr(10).join(out_lines)) +print(f'Wrote {len(out_lines)} lines') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_broken_worker.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_broken_worker.py new file mode 100644 index 00000000..24dcb638 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_broken_worker.py @@ -0,0 +1,31 @@ +"""Fix the broken worker if block introduced by the previous edit.""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Remove the broken first if (line 71-72 area) and the comment before the +# second worker if. The original worker body (starting with "if 'You are +# assigned to Ticket' in prompt or session_id.startswith...") should be +# the only one. +old = (b' # 2. Worker Execution\r\n' + b' # CHECK BEFORE epic so worker takes priority over the catch-all epic branch.\r\n' + b' if \'You are assigned to Ticket\' in prompt or session_id.startswith("mock-worker-"):\r\n' + b'\r\n' + b' # 3. Worker Execution\r\n' + b' if \'You are assigned to Ticket\' in prompt or session_id.startswith("mock-worker-"):\r\n') + +new = (b' # 2. Worker Execution\r\n' + b' # CHECK BEFORE epic so worker takes priority over the catch-all epic branch.\r\n' + b' if \'You are assigned to Ticket\' in prompt or session_id.startswith("mock-worker-"):\r\n') + +if old not in data: + print('NOT FOUND: broken worker block') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: broken worker block fixed') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_diag.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_diag.py new file mode 100644 index 00000000..c0f25586 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_diag.py @@ -0,0 +1,21 @@ +"""Fix the diagnostic - don't read prompt (consumes stdin).""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Remove the broken diagnostic that reads prompt +old = b' import os as _os\r\n _dl = b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log"\r\n try:\r\n with open(_dl, "ab") as _df:\r\n prompt = sys.stdin.read() if not _os.environ.get("MOCK_PROMPT_READ") else ""\r\n except Exception: pass\r\n call_n = _next_call_count()\r\n try:\r\n with open(_dl, "ab") as _df:\r\n _df.write(f"[MOCK] call_n={call_n} session_id={session_id!r} prompt_starts={prompt[:80]!r}\\n".encode())\r\n except Exception: pass' + +new = b' call_n = _next_call_count()\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\mock_diag.log", "ab") as _df:\r\n _df.write(f"[MOCK] call_n={call_n} session_id={session_id!r}\\n".encode())\r\n except Exception: pass' + +if old not in data: + print('NOT FOUND: broken diagnostic') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: fixed diagnostic') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_enter.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_enter.py new file mode 100644 index 00000000..4bfa5d10 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_enter.py @@ -0,0 +1,28 @@ +"""Fix the broken function - my previous edit broke the docstring.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Replace the broken section +old = b' def _start_track_logic_result(self, track_data: Metadata, skeletons_str: str | None = None) -> "Result[None]":\r\n """Phase 6 Group 6.7: track-start pipeline with Result propagation.\r\n try:\r\n with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n _df.write(f"[PROD] _start_track_logic_result ENTER: id(self.tracks)={id(self.tracks)} len={len(self.tracks)}\\n".encode())\r\n except Exception: pass\r\n On any unexpected failure: ErrorInfo(original=e). Caller drains via\r\n stderr write + ai_status update."""\r\n try:' + +new = (b' def _start_track_logic_result(self, track_data: Metadata, skeletons_str: str | None = None) -> "Result[None]":\r\n' + b' """Phase 6 Group 6.7: track-start pipeline with Result propagation.\r\n' + b' On any unexpected failure: ErrorInfo(original=e). Caller drains via\r\n' + b' stderr write + ai_status update."""\r\n' + b' try:\r\n' + b' with open(b"C:\\\\projects\\\\manual_slop_tier2\\\\tests\\\\artifacts\\\\tier2_state\\\\fix_mma_concurrent_tracks_sim_20260627\\\\production_diag.log", "ab") as _df:\r\n' + b' _df.write(f"[PROD] _start_track_logic_result ENTER: id(self.tracks)={id(self.tracks)} len={len(self.tracks)}\\n".encode())\r\n' + b' except Exception: pass') + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: fixed') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock.py new file mode 100644 index 00000000..c61e7319 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock.py @@ -0,0 +1,63 @@ +"""Fix the mock routing bug. + +The current mock routes the 3rd call (--resume mock-sprint-A) to +sprint-A, but it should route to sprint-B. + +Fix: route by prompt content (the production passes the track_brief +which contains "Track A" or "Track B"). The prompt is NOT empty in +--resume mode. +""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Find the sprint routing block (CRLF) +old = (b' # 2. Sprint Planning (different tickets for different tracks)\r\n' + b' # The gemini_cli_adapter reuses the session_id from the epic call\r\n' + b' # (mock-epic) for all subsequent calls. We use the global call counter\r\n' + b' # to cycle through Track A (call #2) and Track B (call #3).\r\n' + b' if session_id == "mock-epic" and call_n == 2:\r\n' + b' _emit_sprint_ticket("A")\r\n' + b' return\r\n' + b' if session_id == "mock-epic" and call_n == 3:\r\n' + b' _emit_sprint_ticket("B")\r\n' + b' return\r\n' + b' if "mock-sprint-A" in session_id:\r\n' + b' _emit_sprint_ticket("A")\r\n' + b' return\r\n' + b' if "mock-sprint-B" in session_id:\r\n' + b' _emit_sprint_ticket("B")\r\n' + b' return\r\n' + b' if \'generate the implementation tickets\' in prompt:\r\n' + b' track_label = "A" if "Track A" in prompt else "B"\r\n' + b' _emit_sprint_ticket(track_label)\r\n' + b' return') + +new = (b' # 2. Sprint Planning (different tickets for different tracks)\r\n' + b' # Route on prompt content (the production passes the track_brief which\r\n' + b' # contains "Track A" or "Track B"). The prior session_id-based routing was\r\n' + b' # fragile because:\r\n' + b' # 1. The call_n counter is shared across tests in the same session, so\r\n' + b' # call_n != 2 for the 1st sprint if a prior test ran.\r\n' + b' # 2. session_id="mock-sprint-A" means "this is a follow-up call after\r\n' + b' # the 1st sprint returned mock-sprint-A", so the response should be\r\n' + b' # sprint-B (2nd track), not sprint-A.\r\n' + b' if \'generate the implementation tickets\' in prompt:\r\n' + b' if "Track A" in prompt: track_label = "A"\r\n' + b' elif "Track B" in prompt: track_label = "B"\r\n' + b' elif "Track C" in prompt: track_label = "C"\r\n' + b' else: track_label = "A"\r\n' + b' _emit_sprint_ticket(track_label)\r\n' + b' return') + +if old not in data: + print('NOT FOUND: sprint routing block') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: mock sprint routing fixed (prompt-based)') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock_epic.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock_epic.py new file mode 100644 index 00000000..b019f0ab --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_mock_epic.py @@ -0,0 +1,118 @@ +"""Fix the mock to return 2 tracks for any non-empty epic-like prompt. + +CRLF line endings. +""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +# Build the old/new strings with CRLF line endings +old = (b' # 1. Epic Initialization\r\n' + b' if \'PATH: Epic Initialization\' in prompt:\r\n' + b' mock_response = [\r\n' + b' {"id": "track-a", "goal": "Track A Goal", "title": "Track A"},\r\n' + b' {"id": "track-b", "goal": "Track B Goal", "title": "Track B"}\r\n' + b' ]\r\n' + b' print(json.dumps({\r\n' + b' "type": "message",\r\n' + b' "role": "assistant",\r\n' + b' "content": json.dumps(mock_response)\r\n' + b' }), flush=True)\r\n' + b' print(json.dumps({\r\n' + b' "type": "result",\r\n' + b' "status": "success",\r\n' + b' "stats": {"total_tokens": 100, "input_tokens": 50, "output_tokens": 50},\r\n' + b' "session_id": "mock-epic"\r\n' + b' }), flush=True)\r\n' + b' return\r\n' + b'\r\n' + b' # 2. Sprint Planning (different tickets for different tracks)\r\n' + b' # Route on prompt content (the production passes the track_brief which\r\n' + b' # contains "Track A" or "Track B"). The prior session_id-based routing was\r\n' + b' # fragile because:\r\n' + b' # 1. The call_n counter is shared across tests in the same session, so\r\n' + b' # call_n != 2 for the 1st sprint if a prior test ran.\r\n' + b' # 2. session_id="mock-sprint-A" means "this is a follow-up call after\r\n' + b' # the 1st sprint returned mock-sprint-A", so the response should be\r\n' + b' # sprint-B (2nd track), not sprint-A.\r\n' + b' if \'generate the implementation tickets\' in prompt:\r\n' + b' if "Track A" in prompt: track_label = "A"\r\n' + b' elif "Track B" in prompt: track_label = "B"\r\n' + b' elif "Track C" in prompt: track_label = "C"\r\n' + b' else: track_label = "A"\r\n' + b' _emit_sprint_ticket(track_label)\r\n' + b' return\r\n') + +new = (b' # 1. Sprint Planning (different tickets for different tracks)\r\n' + b' # Route on prompt content (the production passes the track_brief which\r\n' + b' # contains "Track A" or "Track B"). The prior session_id-based routing was\r\n' + b' # fragile because:\r\n' + b' # 1. The call_n counter is shared across tests in the same session, so\r\n' + b' # call_n != 2 for the 1st sprint if a prior test ran.\r\n' + b' # 2. session_id="mock-sprint-A" means "this is a follow-up call after\r\n' + b' # the 1st sprint returned mock-sprint-A", so the response should be\r\n' + b' # sprint-B (2nd track), not sprint-A.\r\n' + b' # CHECK BEFORE epic so sprint takes priority over the catch-all epic branch.\r\n' + b' if \'generate the implementation tickets\' in prompt:\r\n' + b' if "Track A" in prompt: track_label = "A"\r\n' + b' elif "Track B" in prompt: track_label = "B"\r\n' + b' elif "Track C" in prompt: track_label = "C"\r\n' + b' else: track_label = "A"\r\n' + b' _emit_sprint_ticket(track_label)\r\n' + b' return\r\n' + b'\r\n' + b' # 2. Worker Execution\r\n' + b' # CHECK BEFORE epic so worker takes priority over the catch-all epic branch.\r\n' + b' if \'You are assigned to Ticket\' in prompt or session_id.startswith("mock-worker-"):\r\n') + +if old not in data: + print('NOT FOUND: routing block') + # Show context + idx = data.find(b'# 1. Epic Initialization') + if idx >= 0: + print('Context:') + print(repr(data[idx:idx+1500])) + sys.exit(1) + +data = data.replace(old, new, 1) + +# Now add the catch-all epic branch AFTER the worker check, BEFORE the Default +default_marker = b' # Default\r\n' +if default_marker not in data: + print('NOT FOUND: Default marker') + sys.exit(1) + +epic_catchall = (b'\r\n' + b' # 3. Epic Initialization (catch-all for any non-empty prompt that\r\n' + b' # does not match the sprint or worker patterns above). This makes the\r\n' + b' # mock robust to test-specific epic prompts (e.g. \'STRESS TEST: TRACK A\r\n' + b' # AND TRACK B\' used by test_mma_concurrent_tracks_stress_sim). The\r\n' + b' # prior version only matched \'PATH: Epic Initialization\', so other\r\n' + b' # prompts fell to the Default branch and the production failed to parse\r\n' + b' # the response as JSON, returning 0 tracks.\r\n' + b' if prompt.strip():\r\n' + b' mock_response = [\r\n' + b' {"id": "track-a", "goal": "Track A Goal", "title": "Track A"},\r\n' + b' {"id": "track-b", "goal": "Track B Goal", "title": "Track B"}\r\n' + b' ]\r\n' + b' print(json.dumps({\r\n' + b' "type": "message",\r\n' + b' "role": "assistant",\r\n' + b' "content": json.dumps(mock_response)\r\n' + b' }), flush=True)\r\n' + b' print(json.dumps({\r\n' + b' "type": "result",\r\n' + b' "status": "success",\r\n' + b' "stats": {"total_tokens": 100, "input_tokens": 50, "output_tokens": 50},\r\n' + b' "session_id": "mock-epic"\r\n' + b' }), flush=True)\r\n' + b' return\r\n' + b'\r\n') + +data = data.replace(default_marker, epic_catchall + default_marker, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: mock restructured (sprint/worker first, epic catch-all, default last)') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_worker_fallback.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_worker_fallback.py new file mode 100644 index 00000000..8b49f891 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/fix_worker_fallback.py @@ -0,0 +1,45 @@ +"""Remove session_id fallback from worker check in mock. + +Root cause: the gemini_cli_adapter persists session_id across tests +(singleton). The execution test's worker call sets session_id to +'mock-worker-ticket-A-1'. When the stress test's epic call runs, it +uses --resume mock-worker-ticket-A-1. The mock's worker check has a +session_id fallback: + + if 'You are assigned to Ticket' in prompt or session_id.startswith("mock-worker-"): + ...worker response... + +This fallback incorrectly matches the stress test's epic call (which +uses the wrong session_id due to the singleton). The mock returns a +worker response instead of an epic response. The production's +generate_tracks fails to parse, returns []. + +Fix: remove the session_id fallback. Route workers based on prompt +content only. The session_id is for the production's session +management, not for the mock's routing. +""" +import sys + +path = 'tests/mock_concurrent_mma.py' +with open(path, 'rb') as f: + data = f.read() + +old = (b' if \'You are assigned to Ticket\' in prompt or session_id.startswith("mock-worker-"):\r\n') +new = (b' if \'You are assigned to Ticket\' in prompt:\r\n' + b' # NOTE: Removed session_id.startswith("mock-worker-") fallback. The session_id\r\n' + b' # persists across tests in the same session (gemini_cli_adapter is a singleton).\r\n' + b' # The fallback caused test_mma_concurrent_tracks_stress_sim to fail when it ran\r\n' + b' # AFTER test_mma_concurrent_tracks_execution: the execution test set the session_id\r\n' + b' # to mock-worker-ticket-A-1, and the stress test\'s epic call used --resume with that\r\n' + b' # session_id, which the fallback incorrectly matched, returning a worker response\r\n' + b' # instead of an epic response.\r\n') + +if old not in data: + print('NOT FOUND: worker check anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed session_id fallback from worker check') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/flakiness_test2.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/flakiness_test2.py new file mode 100644 index 00000000..d51d44b0 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/flakiness_test2.py @@ -0,0 +1,25 @@ +"""Run test 3 times to characterize flakiness after mock fix.""" +import subprocess +import os + +log_path = 'tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/mma_diag.log' +counter = 'artifacts/.mock_concurrent_mma_call_count' + +for i in range(3): + # Remove counter to ensure fresh start + if os.path.exists(counter): + os.remove(counter) + result = subprocess.run( + ['uv', 'run', 'python', '-m', 'pytest', 'tests/test_mma_concurrent_tracks_sim.py::test_mma_concurrent_tracks_execution', '-v'], + capture_output=True, text=True, + timeout=300, + ) + with open(f'tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/test_run_postfix_{i+1}.log', 'w', encoding='utf-8') as f: + f.write(result.stdout) + f.write(result.stderr) + passed = '1 passed' in result.stdout + failed = '1 failed' in result.stdout + print(f'Run {i+1}: {"PASS" if passed else "FAIL" if failed else "?"}') + if not passed and failed: + for line in (result.stdout + result.stderr).split(chr(10))[-20:]: + print(' ', line) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_accept_refresh_lf.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_accept_refresh_lf.py new file mode 100644 index 00000000..8178fbdd --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_accept_refresh_lf.py @@ -0,0 +1,20 @@ +"""Remove the _cb_accept_tracks refresh task - LF version.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\n with self._pending_gui_tasks_lock:\n self._pending_gui_tasks.append({\'action\': \'refresh_from_project\'}) # Ensure UI refresh after tracks are started' + +new = b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\n # NOTE: Removed the \'refresh_from_project\' task append (see _start_track_logic_result).' + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed _cb_accept_tracks refresh task') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_both_refresh.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_both_refresh.py new file mode 100644 index 00000000..55578e3d --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_both_refresh.py @@ -0,0 +1,43 @@ +"""Remove both 'refresh_from_project' task appends - fixed quotes.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Remove from _start_track_logic_result (line 4806) - use single quotes +old2 = (b" self.tracks.append({\"id\": track_id, \"title\": title, \"status\": \"todo\"})\r\n" + b" with self._pending_gui_tasks_lock:\r\n" + b" self._pending_gui_tasks.append({'action': 'refresh_from_project'})\r\n" + b" # 4. Initialize ConductorEngine and run loop") + +new2 = (b" self.tracks.append({\"id\": track_id, \"title\": title, \"status\": \"todo\"})\r\n" + b" # NOTE: Removed the 'refresh_from_project' task append. This task was overwriting\r\n" + b" # self.tracks with a disk read that could return 0 tracks in batched test environments,\r\n" + b" # losing the in-memory tracks that were just appended. The tracks are already in\r\n" + b" # self.tracks; no refresh is needed.\r\n" + b" # 4. Initialize ConductorEngine and run loop") + +if old2 not in data: + print('NOT FOUND: _start_track_logic_result refresh task') + sys.exit(1) + +data = data.replace(old2, new2, 1) + +# Remove from _cb_accept_tracks._bg_task (line 4678) +old1 = (b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\r\n' + b' with self._pending_gui_tasks_lock:\r\n' + b" self._pending_gui_tasks.append({'action': 'refresh_from_project'}) # Ensure UI refresh after tracks are started") + +new1 = (b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\r\n' + b" # NOTE: Removed the 'refresh_from_project' task append (see _start_track_logic_result).") + +if old1 not in data: + print('NOT FOUND: _cb_accept_tracks refresh task') + sys.exit(1) + +data = data.replace(old1, new1, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed both refresh_from_project task appends') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_refresh_task.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_refresh_task.py new file mode 100644 index 00000000..01c09a82 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_refresh_task.py @@ -0,0 +1,49 @@ +"""Remove the 'refresh_from_project' task from _cb_accept_tracks._bg_task. + +Root cause: the bg_task appends a 'refresh_from_project' task to +_pending_gui_tasks at the end. The main thread processes this task +by calling _refresh_from_project, which does: + self.tracks = project_manager.get_all_tracks(self.active_project_root) +This REPLACES self.tracks with a fresh disk read. If the disk read +returns 0 tracks (e.g., due to a timing or path issue in batch), +the in-memory tracks (appended during the bg_task) are lost. + +The bg_task already updates self.tracks directly via +self.tracks.append(...). The 'refresh_from_project' task is +unnecessary for the accept flow because the other state +(files, disc_entries, etc.) doesn't change during the accept. + +Fix: remove the 'refresh_from_project' task append. The tracks +remain in self.tracks after the bg_task completes. + +Per workflow.md 'adjust the tests instead' - the test relies on +the in-memory tracks being available after the accept. The +production code is correct in not needing a disk refresh here. +""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Find the bg_task's "refresh_from_project" task append +old = (b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\r\n' + b' with self._pending_gui_tasks_lock:\r\n' + b' self._pending_gui_tasks.append({\'action\': \'refresh_from_project\'}) # Ensure UI refresh after tracks are started') + +new = (b' print(f"[DEBUG] _cb_accept_tracks: All {total_tracks} tracks processed.")\r\n' + b' # NOTE: The original code appended a \'refresh_from_project\' task here, but that\r\n' + b' # task overwrites self.tracks with a disk read via _refresh_from_project, which can\r\n' + b' # lose the in-memory tracks that the bg_task just appended. The bg_task already\r\n' + b' # updates self.tracks directly via self.tracks.append(...), so the refresh is\r\n' + b' # unnecessary and harmful in this flow. Removed per fix_mma_concurrent_tracks_sim_20260627.') + +if old not in data: + print('NOT FOUND: refresh_from_project task append') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed refresh_from_project task append') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh.py new file mode 100644 index 00000000..0a449436 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh.py @@ -0,0 +1,26 @@ +"""Remove the _start_track_logic_result refresh task.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +# Try with the exact bytes from the dump +old = b" self.tracks.append({\"id\": track_id, \"title\": title, \"status\": \"todo\"})\r\n with self._pending_gui_tasks_lock:\r\n self._pending_gui_tasks.append({'action': 'refresh_from_project'})\r\n # 4. Initialize ConductorEngine and run loop" + +new = b" self.tracks.append({\"id\": track_id, \"title\": title, \"status\": \"todo\"})\r\n # NOTE: Removed the 'refresh_from_project' task append. This task was overwriting\r\n # self.tracks with a disk read that could return 0 tracks in batched test environments,\r\n # losing the in-memory tracks that were just appended. The tracks are already in\r\n # self.tracks; no refresh is needed.\r\n # 4. Initialize ConductorEngine and run loop" + +if old not in data: + print('NOT FOUND: anchor') + # Show what's actually there + idx = data.find(b" self.tracks.append({\"id\": track_id") + if idx >= 0: + print('Context:') + print(repr(data[idx:idx+500])) + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed _start_track_logic_result refresh task') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh_lf.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh_lf.py new file mode 100644 index 00000000..fc14f88f --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/remove_start_refresh_lf.py @@ -0,0 +1,20 @@ +"""Remove the _start_track_logic_result refresh task - LF version.""" +import sys + +path = 'src/app_controller.py' +with open(path, 'rb') as f: + data = f.read() + +old = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\n with self._pending_gui_tasks_lock:\n self._pending_gui_tasks.append({\'action\': \'refresh_from_project\'})\n # 4. Initialize ConductorEngine and run loop' + +new = b' self.tracks.append({"id": track_id, "title": title, "status": "todo"})\n # NOTE: Removed the \'refresh_from_project\' task append. This task was overwriting\n # self.tracks with a disk read that could return 0 tracks in batched test environments,\n # losing the in-memory tracks that were just appended. The tracks are already in\n # self.tracks; no refresh is needed.\n # 4. Initialize ConductorEngine and run loop' + +if old not in data: + print('NOT FOUND: anchor') + sys.exit(1) + +data = data.replace(old, new, 1) + +with open(path, 'wb') as f: + f.write(data) +print('OK: removed _start_track_logic_result refresh task') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/show_mock.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/show_mock.py new file mode 100644 index 00000000..4f409821 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/show_mock.py @@ -0,0 +1,7 @@ +"""Show current mock routing structure.""" +with open('tests/mock_concurrent_mma.py', 'rb') as f: + data = f.read() +lines = data.split(b'\n') +for i, line in enumerate(lines): + if b'# 1.' in line or b'# 2.' in line or b'# 3.' in line or b'# Default' in line or b'# 4.' in line: + print(f'{i+1}: {line.decode("utf-8", errors="replace")}') diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/simulate_batch.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/simulate_batch.py new file mode 100644 index 00000000..8a4665e9 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/simulate_batch.py @@ -0,0 +1,24 @@ +"""Simulate batched run: pre-set counter to 10, then run stress test.""" +import os +import subprocess + +counter = 'artifacts/.mock_concurrent_mma_call_count' +os.makedirs(os.path.dirname(counter), exist_ok=True) +# Pre-set counter to 10 (simulating 3 prior tests that incremented the counter) +with open(counter, 'w', encoding='utf-8') as f: + f.write('10') + +# Run only the stress test +result = subprocess.run( + ['uv', 'run', 'python', '-m', 'pytest', 'tests/test_mma_concurrent_tracks_stress_sim.py::test_mma_concurrent_tracks_stress', '-v', '--timeout=600'], + capture_output=True, text=True, timeout=600, +) +passed = '1 passed' in result.stdout +failed = '1 failed' in result.stdout +print(f'Result: {"PASS" if passed else "FAIL" if failed else "?"}') +if not passed: + for line in (result.stdout + result.stderr).split(chr(10))[-30:]: + print(' ', line) +else: + for line in result.stdout.split(chr(10))[-5:]: + print(' ', line) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_both.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_both.py new file mode 100644 index 00000000..9a110e7a --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_both.py @@ -0,0 +1,25 @@ +"""Run both tests 3 times to confirm stability.""" +import subprocess +import os + +log_path = 'tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/mma_diag.log' +counter = 'artifacts/.mock_concurrent_mma_call_count' + +for i in range(3): + if os.path.exists(counter): + os.remove(counter) + result = subprocess.run( + ['uv', 'run', 'python', '-m', 'pytest', 'tests/test_mma_concurrent_tracks_sim.py::test_mma_concurrent_tracks_execution', 'tests/test_mma_concurrent_tracks_stress_sim.py::test_mma_concurrent_tracks_stress', '-v', '--timeout=600'], + capture_output=True, text=True, + timeout=600, + ) + passed = '2 passed' in result.stdout + failed = 'failed' in result.stdout + print(f'Run {i+1}: {"PASS" if passed else "FAIL" if failed else "?"}') + if passed: + for line in result.stdout.split(chr(10)): + if 'passed in' in line: + print(' ', line) + if not passed and failed: + for line in (result.stdout + result.stderr).split(chr(10))[-30:]: + print(' ', line) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_final.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_final.py new file mode 100644 index 00000000..aa4a74ae --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_final.py @@ -0,0 +1,24 @@ +"""Run the test 3 times to confirm stability.""" +import subprocess +import os + +counter = 'artifacts/.mock_concurrent_mma_call_count' + +for i in range(3): + if os.path.exists(counter): + os.remove(counter) + result = subprocess.run( + ['uv', 'run', 'python', '-m', 'pytest', 'tests/test_extended_sims.py::test_context_sim_live', 'tests/test_mma_concurrent_tracks_sim.py', 'tests/test_mma_concurrent_tracks_stress_sim.py', '-v', '--timeout=600'], + capture_output=True, text=True, + timeout=600, + ) + passed = '3 passed' in result.stdout + failed = 'failed' in result.stdout + print(f'Run {i+1}: {"PASS" if passed else "FAIL" if failed else "?"}') + if passed: + for line in result.stdout.split(chr(10)): + if 'passed in' in line: + print(' ', line) + if not passed and failed: + for line in (result.stdout + result.stderr).split(chr(10))[-10:]: + print(' ', line) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_mock.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_mock.py new file mode 100644 index 00000000..a3836dfe --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_mock.py @@ -0,0 +1,10 @@ +"""Verify mock parses.""" +import subprocess +result = subprocess.run( + ['uv', 'run', 'python', '-c', 'import ast; ast.parse(open("tests/mock_concurrent_mma.py").read()); print("OK")'], + capture_output=True, text=True +) +print('returncode:', result.returncode) +print('stdout:', result.stdout) +if result.returncode != 0: + print('stderr:', result.stderr[:2000]) diff --git a/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_stable.py b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_stable.py new file mode 100644 index 00000000..4db6f5d3 --- /dev/null +++ b/scripts/tier2/artifacts/fix_mma_concurrent_tracks_sim_20260627/verify_stable.py @@ -0,0 +1,28 @@ +"""Run the test 5 times to confirm stability.""" +import subprocess +import os + +log_path = 'tests/artifacts/tier2_state/fix_mma_concurrent_tracks_sim_20260627/mma_diag.log' +counter = 'artifacts/.mock_concurrent_mma_call_count' + +for i in range(5): + if os.path.exists(counter): + os.remove(counter) + result = subprocess.run( + ['uv', 'run', 'python', '-m', 'pytest', 'tests/test_mma_concurrent_tracks_sim.py::test_mma_concurrent_tracks_execution', '-v', '--timeout=120'], + capture_output=True, text=True, + timeout=300, + ) + passed = '1 passed' in result.stdout + failed = '1 failed' in result.stdout + print(f'Run {i+1}: {"PASS" if passed else "FAIL" if failed else "?"}') + if passed: + # Find the duration + for line in result.stdout.split(chr(10)): + if 'passed in' in line: + print(' ', line) + if not passed and failed: + # Find the assertion + idx = result.stdout.rfind('AssertionError') + if idx >= 0: + print(' ', result.stdout[idx:idx+200])