From c44a6cf7f1c96b6d792505f3b680d5dff5755620 Mon Sep 17 00:00:00 2001 From: safishamsi Date: Mon, 17 Aug 2026 15:41:59 +0100 Subject: [PATCH] cleanup(serve): drop dead <=budget sub-branch in the overshoot notice (#2784) The `if len(output) <= char_budget: return output` inside the cut_count==0 block sits within `if len(output) > char_budget`, so it can never be true. Remove it and note why the branch is reached only when nodes fit but edges overrun. Also adds the CHANGELOG entry. Co-Authored-By: Claude Opus 4.8 (1M context) --- CHANGELOG.md | 1 + graphify/serve.py | 5 +++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d175c40f..b16a8615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ Full release notes with details on each version: [GitHub Releases](https://githu ## 0.9.46 (unreleased) +- Fix: a `graphify query` whose node set fits the budget but whose edges push the total over now prints an honest "complete answer over budget" notice with the real size, instead of silently returning a payload several times the requested budget (and no longer advises raising the budget, which was the exact trigger); edges are still never dropped from a complete answer (#2784, thanks @AromalBiju1). - Fix: a `.gitignore`/`.graphifyignore` saved in a non-UTF-8 encoding no longer silently drops its rules (which let an explicitly-excluded directory get scanned anyway); the file is decoded UTF-8-first, then by a UTF-16 BOM, then the host codepage/latin-1, so the rule survives intact with a warning instead of being truncated (#2798, thanks @abhay-codes07). - Fix: when node dedup merges two nodes, any hyperedge that listed the merged-away node as a member now rewires that member to the survivor instead of silently dropping it, so a grouping no longer loses participants on dedup (#2805, thanks @abhay-codes07). - Fix: pruning a source file now also sweeps the external-import placeholder nodes it strands at degree 0, instead of leaving them to accumulate in the node count, `GRAPH_REPORT.md`, and exports; genuinely-isolated real nodes (which carry a `source_file`) are never touched (#2807, thanks @abhay-codes07). diff --git a/graphify/serve.py b/graphify/serve.py index 392368f8..21d30140 100644 --- a/graphify/serve.py +++ b/graphify/serve.py @@ -1097,8 +1097,9 @@ def _subgraph_to_text(G: nx.Graph, nodes: set[str], edges: list[tuple], token_bu # real size instead of silence — still the complete, non-truncated # answer, just an honest one. if cut_count == 0: - if len(output) <= char_budget: - return output + # Reached only inside `len(output) > char_budget`, so every node + # fits but the full nodes+edges output does not: an honest + # over-budget notice, never a truncation. total_edges = sum(1 for l in lines if l.startswith("EDGE ")) est_tokens = len(output) // 3 return (