test(rag): wait for files setter before triggering RAG sync
The set_value('files', ...) call is async (push_event -> pending_gui_tasks
-> render loop). The RAG setters (rag_enabled, rag_source, rag_emb_provider)
are also async and each triggers a RAG sync via submit_io. The syncs and
the files setter are NOT ordered: the sync may fire before the files
setter is processed, in which case the sync sees self.files == [] and
skips the rebuild (RAG sync only triggers the rebuild if both
is_empty() AND self.files are truthy).
Fix: poll get_value('files') until the expected value is reflected,
guaranteeing the files setter is processed before the RAG setters
trigger their syncs. Belt-and-suspenders alongside the project-switch
fix from the previous commit.
The test was passing in 4d2a6666 because of timing; the project
switch added latency, so the race is now exposed.
This commit is contained in:
@@ -69,8 +69,18 @@ def test_phase4_final_verify(live_gui, live_gui_workspace):
|
||||
|
||||
try:
|
||||
# 2. Configure project through Hook API
|
||||
# set_value is async (push_event -> pending_gui_tasks -> render loop).
|
||||
# Wait for the files setter to be processed before triggering the RAG
|
||||
# sync, otherwise the sync sees self.files == [] and skips the rebuild
|
||||
# (RAG sync only triggers the rebuild if both is_empty() AND self.files
|
||||
# are truthy). The test was passing in 4d2a6666 because of timing;
|
||||
# the project switch added latency, so the race is now exposed.
|
||||
client.set_value('rag_collection_name', _collection_name)
|
||||
client.set_value('files', ['final_test_1.txt', 'final_test_2.py'])
|
||||
for _ in range(50):
|
||||
if client.get_value('files') == ['final_test_1.txt', 'final_test_2.py']:
|
||||
break
|
||||
time.sleep(0.1)
|
||||
client.set_value('rag_enabled', True)
|
||||
client.set_value('rag_source', 'chroma')
|
||||
client.set_value('rag_emb_provider', 'local')
|
||||
|
||||
Reference in New Issue
Block a user