Private
Public Access
0
0
Files
manual_slop/tests/tier2/phase13_site2_test.py
T
ed 9646f7cf7b 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).
2026-06-20 20:13:10 -04:00

33 lines
1.1 KiB
Python

"""Phase 13 site 2: _chunk_code Result migration.
Site 2 (BC at L224): the AST-aware chunking has a fallback to text chunking
on any failure:
try:
parser = ASTParser('python')
tree = parser.parse(content)
...
return chunks
except Exception:
return self._chunk_text(content)
Body: broad catch + fallback to a different implementation. Per Phase 11
anti-sliming, this is an empty-default fallback. Migrate to Result.
"""
import sys
sys.path.insert(0, ".")
def test_phase13_site2_chunk_code_result_exists():
import src.rag_engine
assert hasattr(src.rag_engine.RAGEngine, "_chunk_code_result") or \
hasattr(src.rag_engine, "_chunk_code_result"), \
"_chunk_code_result helper missing"
def test_phase13_site2_chunk_code_legacy_obliterated():
"""_chunk_code wrapper OBLITERATED by cruft-removal Phase 5."""
import src.rag_engine
assert not hasattr(src.rag_engine.RAGEngine, "_chunk_code"), (
"_chunk_code wrapper must be DELETED; "
"callers must use _chunk_code_result(...).ok directly."
)