Commit 2a07fa5
feat(cha): layered base-class resolution recovers cross-file override edges
Measuring the prior ambiguity-skip on real repos showed it was far too conservative: it
dropped a cross-file override edge whenever the base class name was reused ANYWHERE —
~37% of all base-references on Laravel (1034/2810), a large recall loss on exactly the big
namespaced codebases CHA targets.
Replaced the bare same-file-then-skip logic in buildClassNodes with layered,
most-specific-evidence-first resolution:
1. a class of that name in the child's own file;
2. the file the child imports the name from (existing importMap, now threaded in —
covers Java/TS/JS/Python/Go/Rust/Ruby);
3. a class of that name unique within the child's directory (same package);
4. a globally-unique class of that name;
5. otherwise skip (genuinely ambiguous across dirs, no import).
Layers 1-4 each carry real evidence; only truly unresolvable bases are skipped, keeping the
false-negatives-over-false-positives bias.
Dogfooded:
- DesignPatternsPHP 71 -> 87 override edges: recovered the real FactoryMethod/Logger,
StaticFactory/Formatter, and Bridge/Formatter hierarchies the skip had dropped (each
implementer resolves to its OWN directory's base); cross-namespace false edges stay gone;
zero cross-top-directory edges.
- Laravel (1640 files): 1758 override edges / 512 cross-package; an adversarial agent audit
of all reused-name families (Builder/Grammar/Connection/Driver/Guard/Loader/... incl. all 6
globally-ambiguous base names) found ZERO false positives — import resolves cross-package
Contracts/* bases, directory-locality resolves same-namespace siblings (Query vs Schema),
never cross-wiring. ~100% precision with a large recall gain.
Residual: a globally-duplicated base name neither same-dir-unique nor import-disambiguated is
still skipped (rare). Full FQCN extraction for non-importMap languages (PHP/Kotlin/Swift/Scala/
C#) is the further future enhancement. Tests +1; full suite green (3763). Decision: 320bf215.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 03eb4f4 commit 2a07fa5
4 files changed
Lines changed: 81 additions & 7 deletions
File tree
- openspec
- changes/archive/add-type-hierarchy-resolved-dispatch
- specs/analyzer
- src/core/analyzer
Lines changed: 25 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
98 | 123 | | |
99 | 124 | | |
100 | 125 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
5571 | 5571 | | |
5572 | 5572 | | |
5573 | 5573 | | |
| 5574 | + | |
| 5575 | + | |
| 5576 | + | |
| 5577 | + | |
| 5578 | + | |
| 5579 | + | |
5574 | 5580 | | |
5575 | 5581 | | |
5576 | 5582 | | |
| |||
6068 | 6074 | | |
6069 | 6075 | | |
6070 | 6076 | | |
| 6077 | + | |
| 6078 | + | |
| 6079 | + | |
| 6080 | + | |
| 6081 | + | |
| 6082 | + | |
| 6083 | + | |
| 6084 | + | |
| 6085 | + | |
| 6086 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2905 | 2905 | | |
2906 | 2906 | | |
2907 | 2907 | | |
| 2908 | + | |
2908 | 2909 | | |
2909 | 2910 | | |
2910 | 2911 | | |
| |||
2964 | 2965 | | |
2965 | 2966 | | |
2966 | 2967 | | |
| 2968 | + | |
| 2969 | + | |
2967 | 2970 | | |
2968 | 2971 | | |
2969 | 2972 | | |
| 2973 | + | |
| 2974 | + | |
| 2975 | + | |
2970 | 2976 | | |
| 2977 | + | |
| 2978 | + | |
| 2979 | + | |
| 2980 | + | |
| 2981 | + | |
| 2982 | + | |
| 2983 | + | |
2971 | 2984 | | |
2972 | 2985 | | |
2973 | 2986 | | |
2974 | | - | |
2975 | | - | |
2976 | | - | |
2977 | | - | |
2978 | | - | |
2979 | | - | |
| 2987 | + | |
| 2988 | + | |
| 2989 | + | |
| 2990 | + | |
| 2991 | + | |
| 2992 | + | |
| 2993 | + | |
| 2994 | + | |
2980 | 2995 | | |
2981 | 2996 | | |
2982 | 2997 | | |
| |||
4764 | 4779 | | |
4765 | 4780 | | |
4766 | 4781 | | |
4767 | | - | |
| 4782 | + | |
4768 | 4783 | | |
4769 | 4784 | | |
4770 | 4785 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
245 | 245 | | |
246 | 246 | | |
247 | 247 | | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
248 | 266 | | |
249 | 267 | | |
250 | 268 | | |
| |||
0 commit comments