path_between: directed call chains, connector-free related paths, honest misses (#17, step 2) - #89
Merged
Conversation
The old path_between walked UNDIRECTED over EVERY relation and cut each hop to sorted(frontier)[:200]. On proton-enterprise that (a) hid a depth-4 path entirely (the arbitrary cut visits ~9% of the graph) and (b) when uncapped returned shared-include junk -- HTTPHandler.cpp -imports-> Context <-imports- NativeLog.cpp -- through hubs like String (degree 5,226). Neither is a call path. Now: a bidirectional BFS with a total-visited budget (no per-hop cut). mode='calls' follows only calls/indirect_call, directed, trying A->B then B->A, always listing the chain caller-first with 'direction' saying which way it runs. mode='related' is undirected over all relations but never routes THROUGH a connector node (kind symbol/file) -- they may be endpoints, never bridges, and the two search sides meeting AT one is not a path. mode='auto' (default) tries calls then related and says which it found. Returns a dict; when nothing is found it explains why (depth / budget / no connection) and returns the direct callees of A and callers of B, because the extracted C++ call graph is incomplete and the agent needs a next step, not 'null'. Measured on the real graph: execute -> buildChainImpl found in 0.01s; asked backwards, reported as b_to_a; the #17 question (HTTP processQuery -> NativeLog produce) returns an honest 'no call chain' with executeQuery and NativeLog::doProcessRequest as next hops. Agent prompt now tells the model to bridge a broken chain with neighbors + read_source instead of stopping. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Step 2 of the plan in #17. Stacked on #88 (base branch
feat/ingest-kinds-and-names) because the connector filter relies on the newsymbolkind; merge #88 first and GitHub retargets this tomain.What was wrong (measured on
proton-enterprise@v3.3.1)path_betweenwalked undirected over every relation and cut each hop tosorted(frontier)[:200]:HTTPHandler.cpp →imports Context ←imports NativeLog_Net.cpp— two files sharing an include, routed through hubs likeString(degree 5,226). Not a call path.What it does now
MAX_PATH_VISITED = 5000,INlists chunked) — no per-hop cut; depth cap raised 6 → 12 (the two-sided search makes that cheap).mode="calls"— directed,calls/indirect_callonly; tries A→B then B→A; the chain is always listed caller-first anddirection(a_to_b/b_to_a) says which way it really runs, so "B calls A" is never reported as "A calls B".mode="related"— undirected over all relations, but never routed through a connector (kindsymbol/file): they can be an endpoint, never the bridge, and the two search sides meeting at one is not a path.mode="auto"(default) — calls first, then related, and the result says which it is.{found, mode, direction, path, note}. When nothing is found:notesays why (depth / budget / no connection) andcallees_of_a/callers_of_bgive the next hops — the extracted C++ call graph is incomplete (virtual dispatch, untyped member calls), so "null" was a dead end for the agent.relatedresult must not be described as a call path; when a chain breaks, walkneighbors(rels=["calls"])andread_sourcethe body at the break to bridge the virtual call. MCP and agent tools exposemode.On the real graph (local corpus, read-only)
execute→buildChainImplcalls,a_to_b, 0.01 sbuildChainImpl→execute(asked backwards)calls,b_to_a, listedexecute → buildChainImpl, 1.2 sprocessQuery→NativeLog::processProduceRequest,mode="calls"(the #17 question)callees_of_a = [executeQuery, …]andcallers_of_b = [NativeLog::doProcessRequest]— the honest answer, plus where to continuepath_betweenreturned a list ornull; it now returns an object. In-repo callers (MCP tool, agent tool, tests) are updated; the web UI / REST API don't use it.Testing
mode="calls"doesn't fall back and returns hints; unknown endpoint; depth clamp; 250-wide fan-out whose needed callee sorts last (the old cut would drop it); connector never bridges, including when both sides reach it (this one caught a real bug during development — found on real data, then reproduced in the test); visited budget.found: falseand neither its id nor its name appears anywhere in the response, hints included.pytest: 326 passed, 10 skipped, 1 failed —tests/test_ingest.py::test_ingest_repo_passes_extraction_and_backend, environment-dependent, failing onmaintoo.file), sorelatedmode is only fully meaningful after re-ingesting with ingest: derive code kinds and class-qualified names from graph structure (#17, step 1) #88.Next: step 3 — synthetic
overridesedges frominherits+method, measured against call-reach (median 3 / p90 17 today) and a small set of golden paths.🤖 Generated with Claude Code