Repository navigation
fix(llm) : bisect splittable documents below char cap on output truncation (#5072) - #5078
aadilrizwan wants to merge 1 commit into
Conversation
|
Thanks for the pull request, @aadilrizwan. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
|
Thanks @aadilrizwan! One small thing: our changelog and release notes are built from PR titles, so we use the conventional-commits format, for example: Prefixes we use: |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 vacuous).
Not verified on this run: \_extract\_with\_adaptive\_retry (vacuous: never exercised).
Graphify review — findings
Lets adaptive retry recover from output truncation on splittable text files that sit below the char cap, by promoting the raw path to a full-range FileSlice and bisecting it instead of marking the file partial (#5072). The new make_full_slice builds that slice and returns None for code, binary, or unreadable files. Code files therefore still stay whole and are reported partial on truncation, with no bisecting. .yaml and .yml are now treated as splittable text, so dense YAML can be sliced like markdown or plain text.
No blocking issues surfaced. 3 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1227 functions depend on the 252 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
_extract_with_adaptive_retry()— 24 callers, 11 callees - new:
make_full_slice()— 5 callers, 3 callees
Verification — 1227 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 681 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
63 of 527 test file(s) selected (12%) via static blast radius.
tests/test_5072_splittable_under_cap_retry.py— impact, changed-testtests/test_backend_env_isolation.py— impacttests/test_backend_extras.py— impacttests/test_backend_opt_in.py— impacttests/test_build.py— impacttests/test_build_located_semantic_identity.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_ghost_fold_4955.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_c_include_resolution.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impacttests/test_claude_cli_backend.py— impacttests/test_corrupt_graph_json.py— impacttests/test_cross_extension_reexport_self_cycle.py— impacttests/test_dedup.py— impacttests/test_dedup_remaps_hyperedges.py— impacttests/test_dedup_shrink_refuses_force_write.py— impacttests/test_dedup_survivor_richness.py— impacttests/test_evidence_binding.py— impacttests/test_ext_tagged_id_clash.py— impacttests/test_file_id_collision_4854.py— impacttests/test_file_slice.py— impact, changed-testtests/test_file_truncation_warning.py— impacttests/test_global_graph.py— impacttests/test_go_qualified_resolution.py— impacttests/test_hyperedge_member_shapes.py— impacttests/test_image_vision.py— impacttests/test_injection_sentinel_coverage.py— impacttests/test_issue_3472_source_file_collision.py— impacttests/test_js_member_collisions.py— impacttests/test_label_retry.py— impacttests/test_labeling.py— impacttests/test_llm_backends.py— impacttests/test_llm_null_token_counts.py— impacttests/test_llm_parser.py— impacttests/test_llm_parser_reasoning.py— impacttests/test_merge_sweeps_reextract_orphans.py— impacttests/test_no_dedup_flag.py— impacttests/test_non_string_node_ids.py— impacttests/test_ollama.py— impacttests/test_ollama_ctx_sizing.py— impacttests/test_ollama_live.py— impacttests/test_ollama_native_chat.py— impacttests/test_ollama_retry_cap.py— impacttests/test_oversized_document_slicing.py— impacttests/test_partial_cache.py— impacttests/test_pdf_slicing.py— impact- … and 13 more
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_extract\_with\_adaptive\_retry.
The verifier did not have enough to check \_extract\_with\_adaptive\_retry, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: not verifiable: all 264 sampled inputs raised on both versions — the function never executed, so 'no divergence' would be vacuous (mostly TypeError — names the real obstacle, not a sampling gap)
· 1 grounded finding(s) anchored inline below; 1 more finding(s) on lines outside this diff (see the check run).
…ollow-up) The doc-bisect fix added .yaml/.yml to _SPLITTABLE_TEXT_SUFFIXES, but those are code, not documents (reclassified document->code in #2214), and never reach the semantic pass, so slicing them at prose boundaries is meaningless. Drop the two suffixes and their test parametrization; the core truncation-bisect fix stands. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Landed on |
Resolves (#5072)
What does this PR do?
When a splittable document below
_FILE_CHAR_CAP(20,000 characters) is extracted in semantic extraction,expand_oversized_files()leaves it as a raw Path unit. If the model's output truncates (finish_reason="length"),_extract_with_adaptive_retry()checks_split_lone_slice().Previously,
_split_lone_slice()only checkedisinstance(chunk[0], FileSlice). Because the single-unit chunk was a Path, it returned None, immediately marked the file partial, and abandoned bisection even when recursion depth permitted further retries.Adds
make_full_slice(path: Path) -> FileSlice | Noneingraphify/file_slice.pyto promote an eligible splittable text file (is_splittable_text) to a full-rangeFileSlice(path, 0, len(text), 0, 1), returning None for code and binary files.Updates
_split_lone_slice()ingraphify/llm.pyso that a lone Path eligible for text slicing is promoted to a FileSlice and bisected upon output truncation.Restores
".yaml" and ".yml"to_SPLITTABLE_TEXT_SUFFIXESingraphify/file_slice.py(matching existing module docstrings).Adds unit and regression tests proving bisection recovery across
.yaml,.yml,.md,.txt,.rstwhile verifying that code and binary files remain unsliced.Type of change
Verification & Invariants
Invariant 1 (Provenance & Source Attribution): Every slice produced by
make_full_slice()retains the originalPathasfs.path. In_read_files(),<untrusted_source path=...>points to the parent file so that extracted nodes and edges are attributed to the actual file and merge correctly.Invariant 2 (Code & Binary Boundary): Code files (
.py, .ts, .rs, etc.) and binary files (images/media) evaluate tois_splittable_text() == False. They are never sliced mid-symbol and continue to fail closed with a partial marker on persistent truncation.Invariant 3 (Bounded Recursion & Partial Markers): If output truncation persists up to
_depth >= max_depth,_split_lone_slice()returnsNone, _mark_partial()executes, and_partial_filespropagates up_merged_partial_files()Read the CONTRIBUTING.md guide.
Reproduced the issue and identified the invariant.
Made the smallest fix necessary.
Added a regression test (if bug fix) or isolated boundary test.
Kept the PR description synchronized with the final implementation.
Documented any limitations / unsupported cases explicitly.
How was this tested?
Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments.