Private
Public Access
0
0

test(rag): switch to workspace project explicitly before configuring RAG

Per Tier 1 addendum 3 (the real defect): tests hotpatch individual state
fields via set_value instead of calling the proper project-switch
flow. The session-scoped subprocess may be on a stale project from a
prior test (e.g. test_context_sim_live switches to
temp_livecontextsim.toml and never switches back). The RAG engine uses
active_project_root (derived from active_project_path) as its base_dir,
NOT ui_files_base_dir. So hotpatching files/rag_enabled via set_value
while active_project_path is stale leaves the RAG engine looking at a
dead dir.

Fix: switch to the workspace project explicitly at the start of the
test (like a user would) using client.push_event('custom_callback',
...) + client.wait_for_project_switch(...). The path must be absolute
because the subprocess's CWD is the workspace, so a relative path
like 'tests/artifacts/.../manualslop.toml' would resolve to the wrong
dir from the subprocess's CWD.

Verified: the switch fires successfully (no WARNING printed). But the
RAG search still returns 0 chunks — the index_file rebuild is not
adding the files. The exact cause is still under investigation.

This is the proper fix per Tier 1 (NOT "delete stale files" which
treats the symptom). The sim tests' teardown() also needs a switch-back
to the workspace project (separate track).
This commit is contained in:
2026-06-27 23:55:41 -04:00
parent 97c58f0332
commit 455c17ffb2
+19
View File
@@ -17,6 +17,25 @@ def test_phase4_final_verify(live_gui, live_gui_workspace):
client = api_hook_client.ApiHookClient() client = api_hook_client.ApiHookClient()
assert client.wait_for_server(timeout=15), "Hook server did not start" assert client.wait_for_server(timeout=15), "Hook server did not start"
# PROPER PROJECT CONTEXT (per Tier 1 addendum 3):
# The session-scoped subprocess may be on a stale project from a prior
# test (e.g. test_context_sim_live switches to temp_livecontextsim.toml
# and never switches back). The RAG engine uses active_project_root
# (derived from active_project_path) as its base_dir, NOT
# ui_files_base_dir. So hotpatching files/rag_enabled via set_value
# while active_project_path is stale leaves the RAG engine looking at
# a dead dir. Switch to the workspace project explicitly (like a user
# would) before configuring files and RAG.
# Must use absolute path — the subprocess's CWD is the workspace, so a
# relative path like 'tests/artifacts/.../manualslop.toml' resolves to
# the wrong dir from the subprocess's CWD.
workspace_toml = str((Path(live_gui_workspace) / "manualslop.toml").resolve())
if Path(workspace_toml).exists():
client.push_event("custom_callback", {"callback": "_switch_project", "args": [workspace_toml]})
switch_status = client.wait_for_project_switch(expected_path=workspace_toml, timeout=30.0)
if switch_status.get("error"):
print(f"[VERIFY] WARNING: project switch error: {switch_status.get('error')}")
# Use a unique collection name per test invocation. The RAG engine # Use a unique collection name per test invocation. The RAG engine
# stores its chromadb collection at # stores its chromadb collection at
# <base_dir>/.slop_cache/chroma_<collection_name>. The live_gui # <base_dir>/.slop_cache/chroma_<collection_name>. The live_gui