fix(rag): stop live_gui tests from polluting session-scoped subprocess

Per Tier 1 investigation
(docs/reports/INVESTIGATION_rag_phase4_final_verify_20260627.md),
two live_gui tests were leaking temp/relative paths into the shared
subprocess's ui_files_base_dir, which survived across @clean_baseline
tests and caused RAGEngine.index_file to silently no-op on a dead
base_dir.

Three fixes:

1. tests/test_rag_visual_sim.py: stop using tempfile.mkdtemp() (which
   defaults to C:\Users\Ed\AppData\Local\Temp\tmpXXXX) and instead use
   tempfile.mkdtemp(dir="tests/artifacts", ...). Also restore
   files_base_dir and rag_enabled in finally so the next live_gui test
   in the session doesn't inherit the dead path.

2. tests/test_visual_sim_mma_v2.py: stop changing files_base_dir to
   'tests/artifacts/temp_workspace' and stop clicking btn_project_save
   (which persisted the path to manual_slop.toml). The MMA lifecycle
   does not depend on a specific files_base_dir.

3. src/app_controller.py _handle_reset_session: defensive fix that
   resets ui_files_base_dir from the default project's base_dir. This
   makes reset_session() robust to any future polluter (not just the
   two known ones). Without this, a test that sets files_base_dir via
   set_value leaves a dead path in the session-scoped subprocess even
   after reset_session().

Verified: tests/test_rag_visual_sim.py passes 2/2 after the fix.
This commit is contained in:
ed
2026-06-27 22:39:19 -04:00
parent 08264e550a
commit ab16f2f278
3 changed files with 53 additions and 20 deletions
+8 -3
View File
@@ -71,10 +71,15 @@ def test_mma_complete_lifecycle(live_gui) -> None:
time.sleep(0.3)
client.set_value('gcli_path', f'"{sys.executable}" "{os.path.abspath("tests/mock_gemini_cli.py")}"')
time.sleep(0.3)
client.set_value('files_base_dir', 'tests/artifacts/temp_workspace')
# Per Tier 1 investigation: do NOT change files_base_dir here and do NOT
# click btn_project_save. The previous version set files_base_dir to
# 'tests/artifacts/temp_workspace' and persisted it via btn_project_save,
# which polluted the session-scoped subprocess's ui_files_base_dir (and
# the workspace's manual_slop.toml) with a test-only path that persisted
# into subsequent live_gui tests (e.g. test_rag_phase4_final_verify).
# The MMA lifecycle does not depend on a specific files_base_dir — the
# mock_gemini_cli returns canned responses regardless.
time.sleep(0.3)
client.click('btn_project_save')
time.sleep(1.0) # one full second — let GUI process all set_value tasks
# ------------------------------------------------------------------
# Stage 2: Start epic planning