From 49e8683fa84ce68315287cd38af45d3ca278f184 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Sat, 27 Jun 2026 23:57:08 -0400 Subject: [PATCH] fix(rag): log when index_file silently no-ops on missing file Per Tier 1 addendum 3 (the 4th red flag): index_file had a silent `if not os.path.exists(full_path): return` no-op. When the RAG engine is misconfigured (e.g. stale active_project_path from a prior test's project switch), the files are not found and index_file silently returns. The user sees an empty collection with no indication of why. Fix: emit a stderr.write with base_dir, file_path, and cwd when the file is not found. This makes the misconfiguration visible in the subprocess log (tests/logs/sloppy_py_test.log) instead of invisible. This would have made the "index_file not called" diagnostic trivial during the 3-session investigation of test_rag_phase4_final_verify. Note: the test still fails (RAG search returns 0 chunks) even with the proper project switch + this log fix. The exact root cause of the empty collection is still under investigation. --- src/rag_engine.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/rag_engine.py b/src/rag_engine.py index f90523e7..fb568752 100644 --- a/src/rag_engine.py +++ b/src/rag_engine.py @@ -335,6 +335,15 @@ class RAGEngine: if os.path.exists(cwd_path): full_path = cwd_path else: + # Per Tier 1 addendum 3: log when index_file silently no-ops on a + # missing file. This makes misconfigured base_dir visible in the + # subprocess log instead of invisible (a real production bug that + # made this diagnostic chain 3 sessions long). + sys.stderr.write( + f"RAG index_file: file not found, base_dir={self.base_dir!r} " + f"file_path={file_path!r} cwd={os.getcwd()!r}\n" + ) + sys.stderr.flush() return mtime_result = self._get_file_mtime_result(full_path)