Repository navigation
1. High-Level Summary (TL;DR)
-
Impact: High. 57 PRs since 4.9.0, closing 54 issues and fixing 6 more in part. Most are call-graph answers that were wrong without saying so:
- a C++
statichelper took calls from other files; - a Go bare call bound to another package's function, and a Python
open()to the project'sopen; - a production call bound to a test helper;
- a name two functions share was answered as one;
- a linked worktree counted every call twice.
The C++ and Kotlin outlines gain most of what they were missing, and
searchstops printing megabyte chunks. The one new flag iscontext --kind. JSON changes are additive only. - a C++
-
Key Changes:
- 🎯 Call resolution follows each language's scoping:
- 🧭 A name several definitions share is answered per definition (#192):
callers/calleesprint one section each, andcontext --kind callable|typepicks between a function and a type with one qualified name. - 🧱 C++ and Kotlin outlines:
- 🔗 More calls reach the graph:
- 📦 Deps:
- 🔎 Search:
- ⚡ Quadratic cases made linear: comment runs above a declaration (part of #196), and same-file call lookup (#197).
- 🛡️ Robustness:
2. Visual Overview (Code & Logic Map)
Where a call f() without a receiver looks for its target in 4.10.0.
graph TD
c["a call f() with no receiver"] --> l{"caller's language"}
l -- "Go" --> g["own package (its directory), then dot-imports;<br/>functions only, never a method;<br/>none: unresolved (a builtin, or outside code)"]
l -- "Python" --> p{"bound by an import,<br/>or defined in the file?"}
p -- "yes" --> pa["pass A: Exact"]
p -- "no, and f is a builtin's name<br/>with no star import" --> pb["the builtin: unresolved"]
p -- "no" --> B
l -- "TS/JS, Rust" --> m["methods dropped from the candidates"] --> B
l -- "C++" --> k["another file's static or<br/>unnamed-namespace function dropped<br/>(headers excepted)"] --> B
l -- "other" --> B
B["pass B: candidates the language family can reach,<br/>test-only ones dropped for a production caller"] --> one{"one left?"}
one -- "yes" --> e["Exact"]
one -- "several" --> C["pass C: the caller's import closure"]
one -- "none" --> u["unresolved"]3. Detailed Change Analysis
Every before/after output, count and timing below was measured on the release binaries: 4.9.0 as published, and 4.10.0 as built by CI for this release, on macOS arm64. Each case ran in a fresh directory per binary.
🎯 Call resolution
C++ internal linkage (#172)
In a translation unit (.cpp, .cc, .cxx, .c++, .cu), a static free function, and anything in an unnamed namespace, takes calls from its own file only.
- Prototypes: a definition after a
staticprototype of the same function inherits its linkage. "Same" means the same full name (a reopened namespace orN::fcounts, templates too) and the same parameter types (const int x,int*forint[]andf()forf(void)all match). - Headers: they are untouched, since every file that includes one gets its own copy.
map --no-privateanddigestleave these functions out.
$ ast-bro callees use_b . # 4.9.0
b.cpp:3 a.cpp::log_it (Exact)
b.cpp:3 a.cpp::?::hidden (Exact)
$ ast-bro callees use_b . # 4.10.0
b.cpp:3 [unresolved] hidden (Ambiguous)
b.cpp:3 [unresolved] log_it (Ambiguous)callers log_it goes from 2 callers, use_a and b.cpp's use_b, to use_a alone.
Go package scope (#171)
A Go call without a receiver looks in its own package, then in dot-imported ones. It never looks in another imported package, and never at a method. A builtin like min no longer binds to a project min.
Call in app/a.go |
4.9.0 | 4.10.0 |
|---|---|---|
Helper() (also in app/b.go and in util) |
util/util.go::util::Helper (Inferred) |
app/b.go::app::Helper (Exact) |
util.Helper() |
util/util.go::util::Helper (Inferred) |
unchanged |
min(1, 2), the builtin |
util/util.go::util::min (Exact) |
[unresolved] min |
Python (#173, #150, #166)
| Case | 4.9.0 | 4.10.0 |
|---|---|---|
import time beside a project pkg/time.py (deps) |
pkg/time.py (import) |
[external] time |
from .globals import helper as h, then h() |
[unresolved] h (Ambiguous) |
pkg/globals.py::helper (Exact) |
from pkg import helper with helper in pkg/__init__.py and a pkg/helper.py |
pkg/helper.py::helper (Exact) |
pkg/__init__.py::helper (Exact) |
open("app.toml") beside a project open in another module |
helpers.py::open (Exact) |
[unresolved] open (Ambiguous) |
- Import roots: an absolute import matches only from an import root, and packages in a
src/layout are found by their__init__. - Builtins: a builtin's name with no import binding, no definition in the file and no star import is the builtin.
No method for a call without a receiver (part of #167 and #109)
In Python, TS/TSX/JS and Rust a method is called through self, this or Self::, so a bare call never binds to one. That includes the method itself: in impl W { fn flush(&self) { flush() } }, the call went from src/lib.rs::W::flush (Exact), a call to itself, to the free function src/lib.rs::flush (Exact).
Test helpers (#177)
A production call no longer binds by name to a function defined only in test code. Tests still reach their helpers.
$ ast-bro callees signup . # 4.9.0
src/signup.php:2 tests/helpers.php::make_user (Exact)
$ ast-bro callees signup . # 4.10.0
src/signup.php:2 [unresolved] make_user (Ambiguous)Rust unit tests are test code (#186)
- What counts:
#[test],#[cfg(test)]modules and the files only they load. - Where it applies:
--testsand--exclude-tests,impact --mode testsandreview. - C and C++:
_unittestsuffixes,unittests/directories andFooTest.cppcount as test files too.
src/lib.rs: run() and two #[test]s call compute |
4.9.0 | 4.10.0 |
|---|---|---|
callers compute --tests |
0 | 2 |
callers compute --exclude-tests |
3 | 1 (run) |
Smaller resolution fixes
- Families: a type meets its bases, implementors and constructions within its own language family. A TS class no longer has a Python
Baseas its ancestor (#176). - Rust:
- Generic bases: a base written through a generic outer type (
Outer<String>.Inner, or Scala'sOuter[Int]#Inner) is matched as the inner type (#212). - Updates:
🧭 One name, several definitions (#192, #97, #252, #100)
$ ast-bro callers parse . --depth 2 # 4.9.0: one list
# 4 caller(s) for 'parse':
src/lib.rs:3 depth=1 src/lib.rs::load_json (Inferred)
src/lib.rs:5 depth=2 src/lib.rs::app (Exact)
src/lib.rs:4 depth=1 src/lib.rs::load_toml (Inferred)
src/lib.rs:5 depth=2 src/lib.rs::app (Exact)
$ ast-bro callers parse . --depth 2 # 4.10.0: one section per definition
# 4 caller(s) for 'parse' across 2 definitions:
## 2 caller(s) of src/json.rs::parse:
src/lib.rs:3 depth=1 src/lib.rs::load_json (Inferred)
src/lib.rs:5 depth=2 src/lib.rs::app (Exact)
## 2 caller(s) of src/toml.rs::parse:
src/lib.rs:4 depth=1 src/lib.rs::load_toml (Inferred)
src/lib.rs:5 depth=2 src/lib.rs::app (Exact)- Each definition gets its own count and its own share of
--limit. context --kind callable|type(MCP argumentkind) picks between a function and a type that share one qualified name, such as Kotlinfun Job()besideinterface Job. The note says which to pass.- Constructed classes:
callers Fooon a class built once goes from# 2 caller(s)(the construction counted again as a call) to# 1 caller(s);impact Foogoes from a function report with the note'Foo' matched 2 symbolsto one class report and no note.
- MCP:
callersandcalleesanswer type targets as the CLI does, and reject a name nothing declares. MCPcontextputs the ambiguity note in the response itself. --limitorder: production callers come before test callers when the list is cut (part of #191).
🧱 C++ and Kotlin outlines (#178, #182, #76, #184, #66)
- Preprocessor conditionals: declarations inside
#if,#ifdefand include guards are read in C++ and C#, except a switched-off#if 0. - Member shapes:
- methods returning
*or&, conversion operators, member templates and nested types; int a, b;, function-pointer fields,union,typedef struct {…} P;andextern "C";- definitions keep their parameters:
int add(int a, char b)was shown asint add().
- methods returning
- Export macros:
class MYLIB_API Foois a class again. - Bases: C++ and Kotlin types record their bases, so
implements,callers <Type>andcontext <Type>see their hierarchy. - Kotlin: properties, constructor
val/vars, enum entries and type aliases are outlined.
| Corpus | 4.9.0 | 4.10.0 |
|---|---|---|
| aws-lc, all 369 C++ files: declarations | 7,578 | 10,008 |
| aws-lc: classes and structs with bases recorded | 0 of 435 | 352 of 620 |
leveldb's 15 public headers, renamed .hpp*: classes and structs, members |
0, 0 | 56, 252 |
* .h files are not parsed as C++ (#235), so the headers were renamed to measure them.
🔗 More calls reach the graph (#179, #130, #180, #87–#89, #85, #185)
- Closures and lambdas: a call inside one belongs to the function around it, in Rust, Java, Kotlin, Scala, C#, C++ and Go.
- Rust standard macros: calls in the arguments of the
format!,print!,write!,panic!andassert!families, plusvec!anddbg!, reach the graph. On ast-bro's own source,callers cache_is_validgoes from 2 callers to 12. - Ruby:
- calls in
-> { }count for the method around them; Job.(1)callscall;Conf.level = 3calls the setterlevel=;class << selfmethods are outlined and in the graph.
- calls in
- C#:
s?.Compute()resolves toCompute, and: Base(arg)is the baseBase.
📦 Deps (#141, #134, #153, #207)
| Case | 4.9.0 | 4.10.0 |
|---|---|---|
ky: direct importers of source/index.ts (they write ./index.js) |
0 | 36 |
const { parse: p } = require('./lib/utils') (deps) |
(no imports) |
lib/utils.js (import) |
… and the call p('x') |
[unresolved] p (Ambiguous) |
lib/utils.js::parse (Exact) |
import m `example.com/shop/model` (deps) |
[external] `example.com/shop/model` |
model/m.go (import) [as m] |
- tsconfig
paths: keys match as tsc matches them. Later targets are tried, the"*"key works, exact keys stay exact, a suffix after*counts, and the longest prefix wins. - nodenext: a TS import of
./x.js,.jsx,.mjsor.cjsresolves to the TypeScript source, as tsc does.
🔎 Search (#195, #112, #200, #119, #202, #118)
-
Bounded excerpts: a hit prints the chunk whole only up to 4 KB with no line over 300 characters. A larger chunk prints an excerpt around the query term and a line saying where the rest is.
--jsonstill carries the whole chunk.Case 4.9.0 4.10.0 search "filter map call" -k 5beside a 1.4 MB minified bundle, stdout1,414,221 bytes 721 bytes -
Oversized files: files left out for being over 2 MB are named at build, under
index --stats, and in a note on every search. -
Concurrent first searches: they build the index once; the others wait and load it.
-
Damaged indexes: an index write that stopped partway, or a cache whose bytes changed, is rebuilt rather than served.
graph.binand the index files now end in a checksum. -
find-related: it leaves out the source's own code, and after an edit reads the new text.
⚡ Performance (#196, #197)
| Case | 4.9.0 | 4.10.0 |
|---|---|---|
map, TypeScript file with 26,000 comment lines above one function (1.2 MB) |
10.58 s | 0.04 s |
map, Rust file with 300 functions under 1,000 doc lines each (13 MB) |
56.12 s | 1.62 s |
cold callers, Go file with 53,000 methods that each call the file's helper |
4.70 s | 1.26 s |
Python's share of #196 is in tree-sitter-python's scanner and stays open.
🛡️ Robustness and output
| Case | 4.9.0 | 4.10.0 |
|---|---|---|
ast-bro map src | head -1, exit code |
101 (panic) | 0 |
callers foo with two linked worktrees of the repository inside it |
3 callers | 1 caller |
- Text encodings (#188): a source file that isn't UTF-8 is read: UTF-16 with a BOM is transcoded, anything else decoded lossily. It used to be dropped silently.
- Unwritable cache (#201): one stderr note says every command rebuilds the graph, instead of silence.
- CRLF (#189): a CRLF conversion is formatting only in
diff, and docs carry no\r. show(#193, #55, #146): every name asked for keeps a match under--limit. Markdown headings holding/or a dot are found by their name.digest(#78): Markdown headings past level 3 are flattened, not dropped.- Go types (#206): a type's range stops at the type, not at its last method.
implements --direct(#80): the header no longer says(incl. transitive).- Hook (#194): a failed Read's map fits Claude Code's 10,000-character cap on added context, so the model gets the map rather than a path and a preview.
4. Impact & Risk Assessment
-
✅ No breaking changes to flags or schemas.
- One flag is added,
context --kind, with the MCP argumentkind. No default changed. - JSON changes are additive, and every schema version is kept. In the 23
--jsonanswers of 4.9.0 and 4.10.0 on this repository, no key was removed. The keys added are:callers/callees:definitionsandmatches[].definition;show:per_symbol;context:candidates,candidates_totalandcandidates_truncated;searchandfind-related:oversized.
- The agent prompt (
ast-bro prompt) gains two sentences, one on per-definition caps and one on--kind.
- One flag is added,
-
⚠️ Behavioural changes worth knowing about:- Rows and counts:
- a
callers/calleesanswer for a shared name groups its rows by definition, in text and in JSON; callers <Class>counts a construction once;- under
--limit, production callers come first.
- a
- MCP:
callersandcalleesreturnisErrorfor a name nothing declares, where they returned an empty answer. MCP text is never coloured. - Outline:
map --no-privateanddigestdropstaticand unnamed-namespace functions in C++ source files;- Rust methods of a generic
implmove under their type, so their qualified names change.
- Resolution:
- some calls that 4.9.0 bound
Exactby a lone name match are now unresolved, by each language's scoping rules (Go, Python builtins, C++static, test helpers); - Python 2-style implicit relative imports (
import utilsfor a sibling) stop resolving; - a TS import of
./x.jsbeside bothx.tsandx.jsgoes tox.ts.
- some calls that 4.9.0 bound
- Search text output shows excerpts for large chunks.
- The first command after upgrading rebuilds the graph cache (schema v15) and the search index, as every release does.
- Rows and counts:
-
📌 Known gaps:
- C++: prototypes at file scope are not outlined (#217), and
.hheaders are not parsed (#235). - C++ internal linkage: a
staticprototype in a header with its definition in the.cppisn't seen, and a typedef that respells a parameter type misses its prototype. - Methods for bare calls: Java, C#, Kotlin, Scala, C++, Ruby and PHP still bind a call without a receiver to a method (#109, #167, #168).
- Python: a parameter's
callback()and locals still bind by name (#166). - Go: a method declared in another file from its type loses the type (#183).
- Search: telling a generated file from its content (#195), and Markdown chunking (#59).
- MCP: hints say
raise --limitwhere the parameter islimit(#191, #58).
- C++: prototypes at file scope are not outlined (#217), and