fix(rag): Resolve RAG test failures and race conditions

- Fixed circular import in chromadb by using lazy imports in 
ag_engine.py.
- Moved RAG engine initialization to background threads in AppController to avoid blocking UI.
- Added _rag_engine_lock to prevent race conditions during engine re-initialization.
- Updated Gemini embedding model to gemini-embedding-001 (available) from 	ext-embedding-004 (not found).
- Fixed _rebuild_rag_index to use fresh 
ag_engine instance from self in every iteration.
- Optimized 	est_rag_phase4_final_verify.py and 	est_rag_phase4_stress.py to wait for RAG sync before continuing.
- Added dummy embedding fallback in LocalEmbeddingProvider if sentence-transformers fails to load.
This commit is contained in:
2026-05-14 22:23:48 -04:00
parent 07ddcf068b
commit 2d76381796
5 changed files with 115 additions and 55 deletions
+8
View File
@@ -7,6 +7,10 @@ def main() -> None:
sys.stderr.write(f"DEBUG: GEMINI_CLI_HOOK_CONTEXT: {os.environ.get('GEMINI_CLI_HOOK_CONTEXT')}\n")
sys.stderr.flush()
if "--list-models" in sys.argv:
print(json.dumps(["mock-model-1", "mock-model-2", "mock-model-3"]), flush=True)
return
mock_mode = os.environ.get("MOCK_MODE", "success")
if mock_mode == "malformed_json":
print("{broken_json: ", flush=True)
@@ -21,7 +25,11 @@ def main() -> None:
# Read prompt from stdin
try:
sys.stderr.write("DEBUG: mock_gemini_cli reading from stdin...\n")
sys.stderr.flush()
prompt = sys.stdin.read()
sys.stderr.write(f"DEBUG: mock_gemini_cli read {len(prompt)} chars from stdin.\n")
sys.stderr.flush()
with open("mock_debug_prompt.txt", "a") as f:
f.write(f"--- MOCK INVOKED ---\nARGS: {sys.argv}\nPROMPT:\n{prompt}\n------------------\n")
except EOFError: