Skip to content

Commit efcf1f3

Browse files
Wolfvinclaude
andcommitted
test(graph): lock #223 module-level caller visibility in trace-up (+ #288 trace_source)
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent 5c9ea83 commit efcf1f3

1 file changed

Lines changed: 35 additions & 0 deletions

File tree

tests/test_graph_accuracy_golden.py

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,41 @@ def test_module_level_call_counts_toward_rc(self, backend):
186186
f"#219: expected a caller from mod_level.ts, got {callers}"
187187
)
188188

189+
def test_module_level_caller_visible_in_trace_up(self, scanned):
190+
"""#223: `trace --direction up` must surface the module-level caller.
191+
192+
`moduleLevelHelper` is called at the top level of mod_level.ts (not
193+
inside any function). That caller has a synthetic `<file>:0:<module>`
194+
source id with no `graph_nodes` row; before #223 it was dropped
195+
silently. It must appear as a caller entry marked `module_level=True`
196+
/ `fn="<module>"`. Also pins #288's additive `trace_source` key.
197+
"""
198+
ws, _ = scanned
199+
from commands.trace import execute
200+
201+
class _Args:
202+
name = "moduleLevelHelper"
203+
direction = "up"
204+
depth = 10
205+
domain = "auto"
206+
limit = 20
207+
offset = 0
208+
max_results = 1000
209+
use_graph = True
210+
deep = False
211+
format = "json"
212+
213+
result = execute(_Args(), ws)
214+
assert result.get("trace_source") == "graph", (
215+
f"#288: zero-config trace must annotate trace_source=graph, got {result.get('trace_source')}"
216+
)
217+
up = result.get("chains", {}).get("up", [])
218+
module_callers = [c for c in up if c.get("module_level") or c.get("fn") == "<module>"]
219+
assert module_callers, (
220+
f"#223 regression: module-level caller of moduleLevelHelper dropped from trace-up. "
221+
f"up callers: {up}"
222+
)
223+
189224
def test_async_handler_wrapped_call_registers_edge(self, backend):
190225
"""#231: getGoogleClient called inside asyncHandler(async ()=>{...})."""
191226
rc = _rc(backend, "getGoogleClient")

0 commit comments

Comments
 (0)