refactor(rag_engine): obliterate legacy _chunk_code wrapper (Phase 5)
Phase 5 (1 of 9 cruft sites obliterated): OBLITERATED: RAGEngine._chunk_code wrapper. It delegated to _chunk_code_result and provided a fallback to _chunk_text on AST failure. Migration: index_file() now calls _chunk_code_result directly with .ok check + chunk-size threshold check + fallback to _chunk_text inline. The structured ErrorInfo is propagated if needed (no caller currently consumes it). Sub-track 5 tests updated: - tests/tier2/phase13_invariant_test.py: _chunk_code moved to obliterated list - tests/tier2/phase13_site2_test.py: _legacy_no_broad_except -> _legacy_obliterated - tests/test_cruft_removal.py: 2 new tests (wrapper-obliterated invariant + caller-uses-result invariant) PITFALL encountered: the edit_file tool removed a leading space on the next class method's 'def' line, causing an IndentationError. Fixed by binary-write replacement preserving CRLF + leading-space styleguide convention (project uses 1-space indentation; class body methods start at column 1). Test result: 124/124 pass. Audit gate: src/rag_engine.py --strict exits 0 (no new violations). Wrapper count: 3 -> 2 (Phase 6 remaining: gui_2 2).
This commit is contained in:
+5
-11
@@ -247,16 +247,6 @@ class RAGEngine:
|
||||
)
|
||||
|
||||
|
||||
def _chunk_code(self, content: str, file_path: str) -> List[str]:
|
||||
"""AST-aware chunking for Python code."""
|
||||
ast_result = self._chunk_code_result(content, file_path)
|
||||
if not ast_result.ok:
|
||||
return self._chunk_text(content)
|
||||
chunks = ast_result.data
|
||||
if not chunks or len(content) < self.config.chunk_size:
|
||||
return self._chunk_text(content)
|
||||
return chunks
|
||||
|
||||
def _get_file_mtime_result(self, full_path: str) -> Result[float]:
|
||||
"""Get file modification time. Returns Result[float]."""
|
||||
try:
|
||||
@@ -331,7 +321,11 @@ class RAGEngine:
|
||||
self.collection.delete(where={"path": file_path})
|
||||
|
||||
if file_path.lower().endswith(".py"):
|
||||
chunks = self._chunk_code(content, file_path)
|
||||
chunk_result = self._chunk_code_result(content, file_path)
|
||||
if not chunk_result.ok or not chunk_result.data or len(content) < self.config.chunk_size:
|
||||
chunks = self._chunk_text(content)
|
||||
else:
|
||||
chunks = chunk_result.data
|
||||
else:
|
||||
chunks = self._chunk_text(content)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user