From 67f65c44b019cb71e3bd15e962e0e27644cf0c6d Mon Sep 17 00:00:00 2001 From: devkancheti4-design <302103700+devkancheti4-design@users.noreply.github.com> Date: Mon, 12 Oct 2026 03:28:43 +0530 Subject: [PATCH] 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 --- tests/test_query_seeds.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/test_query_seeds.py b/tests/test_query_seeds.py index f4fed90d7..f09fc220d 100644 --- a/tests/test_query_seeds.py +++ b/tests/test_query_seeds.py @@ -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