Repository navigation
fix(llm): backfill edge source_file, add casefold recovery, pass allowed to on_chunk_done, and set ollama max_tokens (#3982) - #3985
Conversation
|
Thanks for the pull request, @Adityakk9031. 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. |
There was a problem hiding this comment.
Graphify reviewed this change.
Worth a look — the grounded gate found no coupling regressions or blocking issues, but 1 advisory finding(s) below merit a look before merge.
Formal verification. PR-changed functions: 0/3 verified (0 proven, 0 may-equivalent, 0 distinguished) · 3 not verified (2 unsupported, 1 error).
Not verified on this run: save\_semantic\_cache (unsupported), \_call\_openai\_compat (error), extract\_corpus\_parallel (unsupported).
Graphify review — findings
Fixes local/weak-model extraction gaps from #3982: - Source-file attribution. extract_corpus_parallel now fills in missing source_file values. In a single-file chunk, anything without one is attributed to that file; in multi-file chunks, edges inherit it from their source or target node, and any that still can't be placed trigger a RuntimeWarning with a count. - Chunk callback. on_chunk_done now also receives an allowed= list of the chunk's paths, falling back to the old 3-argument call when the callback rejects it. - Ollama and cache. Ollama requests now send max_tokens, since that endpoint ignores max_completion_tokens. save_semantic_cache falls back to a case-insensitive basename match when no exact match exists.
Worth a look
- Callback TypeError fallback re-invokes on_chunk_done, masking errors and duplicating side effects —
graphify/llm.py:2762· Escalate · medium- agreed by 2 of 2 members but NOT verified (no proof, no reproducing execution) — consensus is not a verdict; needs human review
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 2548 functions depend on the 503 functions this change touches.
Health — this change adds coupling hotspots:
- new:
extract()— 716 callers, 48 callees - new:
_rebuild_code()— 147 callers, 56 callees - new:
deduplicate_entities()— 79 callers, 24 callees - new:
detect()— 112 callers, 15 callees - new:
build_merge()— 76 callers, 14 callees - new:
save_semantic_cache()— 64 callers, 9 callees - new:
load_cached()— 54 callers, 7 callees - new:
extract_files_direct()— 17 callers, 20 callees - …and 44 more — each is listed as a finding
Verification — 2548 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: 1588 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
61 of 306 test file(s) selected (20%) via static blast radius.
tests/test_backend_env_isolation.py— impacttests/test_backend_extras.py— impacttests/test_build.py— impacttests/test_build_merge_dedup_scope.py— impacttests/test_build_merge_hyperedges_and_prune.py— impacttests/test_build_merge_shrink_guard.py— impacttests/test_cache.py— impacttests/test_carried_hyperedge_remap.py— impacttests/test_charmap_encoding.py— impacttests/test_chunking.py— impact, changed-testtests/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_survivor_richness.py— impacttests/test_definition_file_portability.py— impacttests/test_detect.py— impacttests/test_evidence_binding.py— impacttests/test_extract.py— impacttests/test_extract_cache_location.py— impacttests/test_extract_cli.py— impacttests/test_file_slice.py— impacttests/test_global_graph.py— impacttests/test_go_qualified_resolution.py— impacttests/test_hyperedge_member_shapes.py— impacttests/test_ignore_file_encoding.py— impacttests/test_image_vision.py— impacttests/test_incremental_mtime_collision.py— impacttests/test_injection_sentinel_coverage.py— impacttests/test_issue_3472_source_file_collision.py— impacttests/test_label_retry.py— impacttests/test_labeling.py— impacttests/test_llm_backends.py— impact, changed-testtests/test_llm_parser.py— impacttests/test_llm_parser_reasoning.py— impacttests/test_no_dedup_flag.py— impacttests/test_non_string_node_ids.py— impacttests/test_objc_field_table_remap.py— impacttests/test_ollama.py— impacttests/test_ollama_retry_cap.py— impacttests/test_out_dir_evidence.py— impacttests/test_oversized_document_slicing.py— impacttests/test_partial_cache.py— impacttests/test_pdf_slicing.py— impacttests/test_pdf_token_estimate.py— impacttests/test_pipeline.py— impacttests/test_provider_registry.py— impacttests/test_prs.py— impacttests/test_prune_sweeps_orphans.py— impact- … and 11 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.
Docs that may be stale (advisory)
CHANGELOG.md§ 0.9.65 (2026-09-20) (lines 83-95): references changed symbolsstubCHANGELOG.md§ 0.9.49 (2026-08-24) (lines 279-302): references changed symbolsstubCHANGELOG.md§ 0.9.43 (2026-08-14) (lines 368-376): references changed symbolscallbackCHANGELOG.md§ 0.9.38 (2026-08-09) (lines 435-443): references changed symbolscallbackCHANGELOG.md§ 0.9.13 (2026-07-12) (lines 745-764): references changed symbolsstubCHANGELOG.md§ 0.8.46 (2026-06-23) (lines 1011-1022): references changed symbolsstubworked/rsl-siege-manager/GRAPH_REPORT.md§ Community 26 - "Community 26" (lines 270-273): references changed symbolscallback
Formal verification
Could not verify: Could not verify save\_semantic\_cache.
The verifier did not have enough to check save\_semantic\_cache, 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: parameter `prompt` is annotated `'str | Path | None'` — outside the synthesizable primitive/collection set
Verification did not run: Verification did not run for \_call\_openai\_compat.
The verification could not execute (an environment/toolchain issue, not a statement about the code).
Guarantee: No guarantee, the check itself did not complete.
Note: Detail: harness produced no verdict (rc=124): timeout after 30s
Could not verify: Could not verify extract\_corpus\_parallel.
The verifier did not have enough to check extract\_corpus\_parallel, 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: parameter `on_chunk_done` is annotated `Callable | None` — outside the synthesizable primitive/collection set
· 52 more finding(s) on lines outside this diff (see the check run).
|
Thanks @Adityakk9031 — all four parts are genuinely still needed on current v8 (edge source_file backfill, casefold recovery, |
…wed to on_chunk_done, and set ollama max_tokens (Graphify-Labs#3982)
5f36393 to
82e973f
Compare
|
Addressed the review feedback:
|
Resolves #3982
Root Cause
source_filefield. During semantic cache grouping insave_semantic_cache, items withoutsource_fileare skipped.WEIRD_NAMED_FILE.pyvsweird_named_file.py) caused_recover_group_pathingraphify/cache.pyto fail basename matching and drop valid cache items.on_chunk_donecallback signature: Callers runningextract_corpus_parallelas a library did not receive the chunk allowlist (allowed), preventing proper downstream scoping / caching and risking unintended cache drops.max_tokensvsmax_completion_tokens: Ollama's OpenAI-compatible endpoint ignoresmax_completion_tokensand only respectsmax_tokens(oroptions: {num_predict: ...}).Changes
graphify/llm.py):source_fileon nodes, edges, and hyperedges to the lone file.source_filefrom endpoint node source files (sourceortarget).graphify/cache.py):_recover_group_path, fall back to case-insensitive basename matching againstallowed_paths.on_chunk_donecallback (graphify/llm.py):allowed=[unit_path(item) for item in chunk]toon_chunk_donewith backwards-compatible fallback for 3-argument callbacks.max_tokens(graphify/llm.py):backend == "ollama"in_call_openai_compat, supplykwargs["max_tokens"] = max_completion_tokens.source_filebackfill andon_chunk_doneintests/test_chunking.py.tests/test_semantic_cache_basename_recovery.py.max_tokensparameter intests/test_llm_backends.py.