graphify icon indicating copy to clipboard operation
graphify copied to clipboard

fix(llm): unwrap FileSlice via unit_path in the checkpoint allowlist (#1870)

Open HerenderKumar opened this issue 4 months ago • 0 comments

Fixes #1870

_checkpoint_chunk resolved each unit's source file with getattr(item, "rel", None) or item, but FileSlice carries its file in .path — it has no .rel — so for every sliced document the FileSlice object itself leaked into allowed_source_files. save_semantic_cache then raised on Path(FileSlice), the best-effort guard downgraded that to the incremental cache checkpoint failed warning, and every chunk containing a slice silently lost its checkpoint — so a resumed run re-billed those chunks instead of reusing the cache.

  • llm.py: build the allowlist with unit_path(...) — file_slice.py's canonical unwrap (parent Path for a slice, bare Path unchanged), already imported and used elsewhere in the module — and fix the stale .rel comment
  • tests/test_chunking.py: regression test that drives extract_corpus_parallel over a corpus whose document slices into 7 units and asserts the checkpoint fires with real paths; on current v8 it fails with the exact FileSlice leak from the report

Since a slice's .path is the same value the file would have had as a bare Path, the allowlist entries for sliced files now match unsliced behavior exactly.

HerenderKumar avatar Jul 14 '26 05:07 HerenderKumar