mirror of
https://github.com/safishamsi/graphify.git
synced 2026-10-14 16:09:26 +00:00
test(query): a seed given with --seed renders first and survives truncation
The seeded path hands the resolved nodes to _subgraph_to_text as seeds (seeds=start_nodes, the BUG2 fix), so the
given seed is the first NODE line and still shows under a small token budget.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 67f65c44b0)
This commit is contained in:
1 parent
f2d4bd49d3
commit
3ba70ce9ac
1 file changed
+23
@@ -134,3 +134,26 @@ def test_query_cli_logs_the_seeds(monkeypatch, tmp_path, capsys):
|
||||
capsys.readouterr()
|
||||
record = json.loads(log.read_text().strip().splitlines()[-1])
|
||||
assert record.get("seeds") == ["build"]
|
||||
|
||||
|
||||
def _star_with_answer(n_spokes=40):
|
||||
"""A high-degree hub with many spokes plus one low-degree node, so a degree-sorted cut would drop that node."""
|
||||
G = nx.Graph()
|
||||
G.add_node("hub", label="Hub", source_file="hub.py", source_location="L1", community=0)
|
||||
for i in range(n_spokes):
|
||||
G.add_node(f"s{i}", label=f"spoke{i}", source_file=f"s{i}.py", source_location="L1", community=0)
|
||||
G.add_edge("hub", f"s{i}", relation="calls", confidence="EXTRACTED")
|
||||
G.add_node("answer", label="CompanySpacingGate", source_file="gate.py", source_location="L12", community=0)
|
||||
G.add_edge("s0", "answer", relation="calls", confidence="EXTRACTED")
|
||||
return G
|
||||
|
||||
|
||||
def test_given_seed_renders_first_and_survives_truncation():
|
||||
"""A seed given with --seed reaches the renderer as a seed (seeds=start_nodes), so it is the first NODE line and
|
||||
is still shown when the token budget cuts the output."""
|
||||
G = _star_with_answer()
|
||||
text = _query_graph_text(G, "hub", mode="bfs", depth=2, token_budget=40, seeds=["answer"])
|
||||
assert "Start (given): ['CompanySpacingGate']" in text
|
||||
node_lines = [line for line in text.splitlines() if line.startswith("NODE ")]
|
||||
assert node_lines and "CompanySpacingGate" in node_lines[0], "the given seed must render first"
|
||||
assert "TRUNCATED" in text
|
||||
Reference in new issue
Block a user