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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//! Process-local analysis memos, owned by the analyses layer.
//!
//! These caches are keyed on analyses row/graph types, so they must not live
//! on [`crate::facts::FactsDb`] — that would make the `facts` layer depend on
//! `analyses` types, a genuine module cycle. Instead `FactsDb` holds one
//! type-erased slot map (`analysis_memo::<T>()`); each memo below is a `T`
//! that the analyses layer stores and retrieves through it, keyed per-FactsDb
//! and shared for that connection's lifetime.
//!
//! Every memo stores the FULL, un-row-limited result: callers re-apply their
//! own `rows_limit` after the lookup so a `--rows N` choice never poisons the
//! shared entry. `RefCell` (not a `Mutex`) because the `DuckDB` `Connection`
//! is `!Send + !Sync` and every analysis runs on the single connection-owning
//! thread.
use RefCell;
use HashMap;
use Rc;
use ClonesRow;
use ;
use ImportGraph;
/// Memo for [`crate::analyses::coupling::run_coupling`], which is pure per
/// `(db, coupling-affecting opts)` yet is invoked 2-5× per CLI run on
/// identical inputs (code-health, centrality, communities, clone-coupling,
/// and the SPA dashboard all re-derive the same global coupling graph). The
/// stored value is the full, Fisher-filtered, un-row-limited `Vec`.
pub ;
/// Single-slot memo for the structural import graph
/// ([`crate::analyses::import_graph::build_import_graph`]). The graph is a
/// pure function of the immutable `imports` table, yet a `--format spa` render
/// or a `codelore check` arch-suite rebuilds it (SQL scan + path interning +
/// adjacency) once per arch analysis; a shared `Rc` collapses those into one
/// build.
pub ;
/// Single-slot memo for [`crate::analyses::clones::run_clones_memoised`].
/// `run_clones` walks the working tree and tree-sitter-fingerprints every
/// Tier-1 function — an O(files) filesystem + parse pass with no `changes` /
/// `imports` dependency, so its result is fixed for a given (repo,
/// clone-affecting opts) pair. The agent-loop gate's projected-health engine
/// runs code-health twice on one `FactsDb` (HEAD baseline vs the
/// substituted-complexity projection); both scoped runs re-walk clones over
/// the SAME working tree, so the second walk is pure waste.
pub ;