1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//! Unified on-disk + in-memory graph cache shared by `src/deps/` (file-level
//! import graph) and `src/calls/` (symbol-level call graph).
//!
//! One cache file at `.ast-bro/deps/graph.bin`, one fingerprint table,
//! one advisory lock. The deps half is built eagerly on first access; the
//! calls half lives behind `Option<CallGraph>` and only materialises when a
//! `callers`/`callees` query asks for it. Within a process — most importantly
//! `ast-bro mcp` — every consumer reads through `shared::get_or_init`,
//! which holds an `Arc<RwLock<Arc<UnifiedGraph>>>` so multiple tool calls
//! share one in-memory graph and pay the parse cost exactly once per session.
//!
//! Why keep the `deps/` directory name even though it now holds the call
//! graph too: renaming would force every existing user to rebuild from a new
//! path. The schema bump (`deps-index.v1` → `graph-index.v1`) already forces
//! a rebuild; further moving the file is unnecessary churn.
pub use ;
use crateCallGraph;
use crateDepGraph;
use ;
/// In-memory state held inside the shared `Arc`. Cheap to clone (the `Arc`
/// indirection means consumers share storage); a fresh `Arc` is swapped in
/// when the call graph is promoted from `None` to `Some`.
/// Fetch the unified graph with its call-graph half guaranteed present,
/// promoting (building) the call graph on first access if it hasn't
/// materialised yet. Shared by `impact` and `context`, which both need the
/// call graph and would otherwise each carry an identical copy of this logic.