gitnexus 1.6.3-rc.8 → 1.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. package/README.md +21 -5
  2. package/dist/_shared/graph/types.d.ts +16 -0
  3. package/dist/_shared/graph/types.d.ts.map +1 -1
  4. package/dist/_shared/index.d.ts +20 -2
  5. package/dist/_shared/index.d.ts.map +1 -1
  6. package/dist/_shared/index.js +11 -0
  7. package/dist/_shared/index.js.map +1 -1
  8. package/dist/_shared/scope-resolution/def-index.js +2 -2
  9. package/dist/_shared/scope-resolution/def-index.js.map +1 -1
  10. package/dist/_shared/scope-resolution/method-dispatch-index.d.ts +8 -0
  11. package/dist/_shared/scope-resolution/method-dispatch-index.d.ts.map +1 -1
  12. package/dist/_shared/scope-resolution/method-dispatch-index.js +2 -2
  13. package/dist/_shared/scope-resolution/method-dispatch-index.js.map +1 -1
  14. package/dist/_shared/scope-resolution/module-scope-index.d.ts +8 -0
  15. package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -1
  16. package/dist/_shared/scope-resolution/module-scope-index.js +10 -2
  17. package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -1
  18. package/dist/_shared/scope-resolution/parsed-file.d.ts +76 -0
  19. package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -0
  20. package/dist/_shared/scope-resolution/parsed-file.js +54 -0
  21. package/dist/_shared/scope-resolution/parsed-file.js.map +1 -0
  22. package/dist/_shared/scope-resolution/position-index.d.ts +12 -0
  23. package/dist/_shared/scope-resolution/position-index.d.ts.map +1 -1
  24. package/dist/_shared/scope-resolution/position-index.js +2 -2
  25. package/dist/_shared/scope-resolution/position-index.js.map +1 -1
  26. package/dist/_shared/scope-resolution/qualified-name-index.js +2 -2
  27. package/dist/_shared/scope-resolution/qualified-name-index.js.map +1 -1
  28. package/dist/_shared/scope-resolution/reference-site.d.ts +75 -0
  29. package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -0
  30. package/dist/_shared/scope-resolution/reference-site.js +24 -0
  31. package/dist/_shared/scope-resolution/reference-site.js.map +1 -0
  32. package/dist/_shared/scope-resolution/registries/class-registry.d.ts +27 -0
  33. package/dist/_shared/scope-resolution/registries/class-registry.d.ts.map +1 -0
  34. package/dist/_shared/scope-resolution/registries/class-registry.js +30 -0
  35. package/dist/_shared/scope-resolution/registries/class-registry.js.map +1 -0
  36. package/dist/_shared/scope-resolution/registries/context.d.ts +69 -0
  37. package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -0
  38. package/dist/_shared/scope-resolution/registries/context.js +44 -0
  39. package/dist/_shared/scope-resolution/registries/context.js.map +1 -0
  40. package/dist/_shared/scope-resolution/registries/evidence.d.ts +56 -0
  41. package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -0
  42. package/dist/_shared/scope-resolution/registries/evidence.js +150 -0
  43. package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -0
  44. package/dist/_shared/scope-resolution/registries/field-registry.d.ts +26 -0
  45. package/dist/_shared/scope-resolution/registries/field-registry.d.ts.map +1 -0
  46. package/dist/_shared/scope-resolution/registries/field-registry.js +31 -0
  47. package/dist/_shared/scope-resolution/registries/field-registry.js.map +1 -0
  48. package/dist/_shared/scope-resolution/registries/lookup-core.d.ts +81 -0
  49. package/dist/_shared/scope-resolution/registries/lookup-core.d.ts.map +1 -0
  50. package/dist/_shared/scope-resolution/registries/lookup-core.js +332 -0
  51. package/dist/_shared/scope-resolution/registries/lookup-core.js.map +1 -0
  52. package/dist/_shared/scope-resolution/registries/lookup-qualified.d.ts +33 -0
  53. package/dist/_shared/scope-resolution/registries/lookup-qualified.d.ts.map +1 -0
  54. package/dist/_shared/scope-resolution/registries/lookup-qualified.js +56 -0
  55. package/dist/_shared/scope-resolution/registries/lookup-qualified.js.map +1 -0
  56. package/dist/_shared/scope-resolution/registries/method-registry.d.ts +36 -0
  57. package/dist/_shared/scope-resolution/registries/method-registry.d.ts.map +1 -0
  58. package/dist/_shared/scope-resolution/registries/method-registry.js +32 -0
  59. package/dist/_shared/scope-resolution/registries/method-registry.js.map +1 -0
  60. package/dist/_shared/scope-resolution/registries/tie-breaks.d.ts +43 -0
  61. package/dist/_shared/scope-resolution/registries/tie-breaks.d.ts.map +1 -0
  62. package/dist/_shared/scope-resolution/registries/tie-breaks.js +60 -0
  63. package/dist/_shared/scope-resolution/registries/tie-breaks.js.map +1 -0
  64. package/dist/_shared/scope-resolution/resolve-type-ref.d.ts +1 -10
  65. package/dist/_shared/scope-resolution/resolve-type-ref.d.ts.map +1 -1
  66. package/dist/_shared/scope-resolution/resolve-type-ref.js +6 -0
  67. package/dist/_shared/scope-resolution/resolve-type-ref.js.map +1 -1
  68. package/dist/_shared/scope-resolution/scope-tree.d.ts +4 -4
  69. package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -1
  70. package/dist/_shared/scope-resolution/scope-tree.js +3 -2
  71. package/dist/_shared/scope-resolution/scope-tree.js.map +1 -1
  72. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +6 -2
  73. package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +1 -1
  74. package/dist/_shared/scope-resolution/shadow/aggregate.js +5 -0
  75. package/dist/_shared/scope-resolution/shadow/aggregate.js.map +1 -1
  76. package/dist/_shared/scope-resolution/types.d.ts +11 -0
  77. package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
  78. package/dist/cli/ai-context.js +35 -4
  79. package/dist/cli/analyze.d.ts +27 -0
  80. package/dist/cli/analyze.js +31 -1
  81. package/dist/cli/clean.js +19 -1
  82. package/dist/cli/group.js +73 -0
  83. package/dist/cli/index-repo.js +8 -1
  84. package/dist/cli/index.js +26 -1
  85. package/dist/cli/list.js +11 -1
  86. package/dist/cli/remove.d.ts +30 -0
  87. package/dist/cli/remove.js +99 -0
  88. package/dist/cli/setup.js +185 -57
  89. package/dist/cli/tool.d.ts +5 -0
  90. package/dist/cli/tool.js +42 -0
  91. package/dist/config/ignore-service.d.ts +9 -0
  92. package/dist/config/ignore-service.js +80 -13
  93. package/dist/core/embedding-mode.d.ts +30 -0
  94. package/dist/core/embedding-mode.js +30 -0
  95. package/dist/core/embeddings/ast-utils.js +22 -22
  96. package/dist/core/embeddings/chunker.js +30 -25
  97. package/dist/core/embeddings/embedding-pipeline.d.ts +6 -0
  98. package/dist/core/embeddings/embedding-pipeline.js +15 -6
  99. package/dist/core/embeddings/text-generator.d.ts +1 -1
  100. package/dist/core/embeddings/text-generator.js +33 -24
  101. package/dist/core/embeddings/types.d.ts +43 -1
  102. package/dist/core/embeddings/types.js +101 -29
  103. package/dist/core/git-staleness.d.ts +18 -0
  104. package/dist/core/git-staleness.js +108 -0
  105. package/dist/core/graph/graph.js +115 -20
  106. package/dist/core/graph/types.d.ts +12 -1
  107. package/dist/core/group/config-parser.d.ts +4 -0
  108. package/dist/core/group/config-parser.js +18 -1
  109. package/dist/core/group/cross-impact.d.ts +41 -0
  110. package/dist/core/group/cross-impact.js +441 -0
  111. package/dist/core/group/extractors/http-patterns/php.js +126 -18
  112. package/dist/core/group/group-path-utils.d.ts +17 -0
  113. package/dist/core/group/group-path-utils.js +40 -0
  114. package/dist/core/group/resolve-at-member.d.ts +10 -0
  115. package/dist/core/group/resolve-at-member.js +31 -0
  116. package/dist/core/group/service.d.ts +9 -0
  117. package/dist/core/group/service.js +259 -25
  118. package/dist/core/group/types.d.ts +30 -0
  119. package/dist/core/ingestion/ast-cache.d.ts +16 -1
  120. package/dist/core/ingestion/ast-cache.js +14 -2
  121. package/dist/core/ingestion/call-processor.js +9 -0
  122. package/dist/core/ingestion/emit-references.d.ts +88 -0
  123. package/dist/core/ingestion/emit-references.js +229 -0
  124. package/dist/core/ingestion/filesystem-walker.js +6 -4
  125. package/dist/core/ingestion/finalize-orchestrator.d.ts +63 -0
  126. package/dist/core/ingestion/finalize-orchestrator.js +139 -0
  127. package/dist/core/ingestion/framework-detection.js +6 -2
  128. package/dist/core/ingestion/import-processor.js +4 -0
  129. package/dist/core/ingestion/import-resolvers/python.js +9 -6
  130. package/dist/core/ingestion/import-target-adapter.d.ts +73 -0
  131. package/dist/core/ingestion/import-target-adapter.js +95 -0
  132. package/dist/core/ingestion/language-provider.d.ts +36 -33
  133. package/dist/core/ingestion/languages/csharp/accessor-unwrap.d.ts +21 -0
  134. package/dist/core/ingestion/languages/csharp/accessor-unwrap.js +56 -0
  135. package/dist/core/ingestion/languages/csharp/arity-metadata.d.ts +26 -0
  136. package/dist/core/ingestion/languages/csharp/arity-metadata.js +46 -0
  137. package/dist/core/ingestion/languages/csharp/arity.d.ts +23 -0
  138. package/dist/core/ingestion/languages/csharp/arity.js +37 -0
  139. package/dist/core/ingestion/languages/csharp/cache-stats.d.ts +15 -0
  140. package/dist/core/ingestion/languages/csharp/cache-stats.js +26 -0
  141. package/dist/core/ingestion/languages/csharp/captures.d.ts +19 -0
  142. package/dist/core/ingestion/languages/csharp/captures.js +249 -0
  143. package/dist/core/ingestion/languages/csharp/import-decomposer.d.ts +19 -0
  144. package/dist/core/ingestion/languages/csharp/import-decomposer.js +93 -0
  145. package/dist/core/ingestion/languages/csharp/import-target.d.ts +25 -0
  146. package/dist/core/ingestion/languages/csharp/import-target.js +123 -0
  147. package/dist/core/ingestion/languages/csharp/index.d.ts +82 -0
  148. package/dist/core/ingestion/languages/csharp/index.js +82 -0
  149. package/dist/core/ingestion/languages/csharp/interpret.d.ts +15 -0
  150. package/dist/core/ingestion/languages/csharp/interpret.js +132 -0
  151. package/dist/core/ingestion/languages/csharp/merge-bindings.d.ts +27 -0
  152. package/dist/core/ingestion/languages/csharp/merge-bindings.js +55 -0
  153. package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +50 -0
  154. package/dist/core/ingestion/languages/csharp/namespace-siblings.js +374 -0
  155. package/dist/core/ingestion/languages/csharp/query.d.ts +35 -0
  156. package/dist/core/ingestion/languages/csharp/query.js +515 -0
  157. package/dist/core/ingestion/languages/csharp/receiver-binding.d.ts +31 -0
  158. package/dist/core/ingestion/languages/csharp/receiver-binding.js +135 -0
  159. package/dist/core/ingestion/languages/csharp/scope-resolver.d.ts +10 -0
  160. package/dist/core/ingestion/languages/csharp/scope-resolver.js +63 -0
  161. package/dist/core/ingestion/languages/csharp/simple-hooks.d.ts +53 -0
  162. package/dist/core/ingestion/languages/csharp/simple-hooks.js +76 -0
  163. package/dist/core/ingestion/languages/csharp.js +14 -0
  164. package/dist/core/ingestion/languages/python/arity-metadata.d.ts +24 -0
  165. package/dist/core/ingestion/languages/python/arity-metadata.js +45 -0
  166. package/dist/core/ingestion/languages/python/arity.d.ts +22 -0
  167. package/dist/core/ingestion/languages/python/arity.js +38 -0
  168. package/dist/core/ingestion/languages/python/cache-stats.d.ts +17 -0
  169. package/dist/core/ingestion/languages/python/cache-stats.js +28 -0
  170. package/dist/core/ingestion/languages/python/captures.d.ts +19 -0
  171. package/dist/core/ingestion/languages/python/captures.js +106 -0
  172. package/dist/core/ingestion/languages/python/import-decomposer.d.ts +15 -0
  173. package/dist/core/ingestion/languages/python/import-decomposer.js +112 -0
  174. package/dist/core/ingestion/languages/python/import-target.d.ts +21 -0
  175. package/dist/core/ingestion/languages/python/import-target.js +99 -0
  176. package/dist/core/ingestion/languages/python/index.d.ts +80 -0
  177. package/dist/core/ingestion/languages/python/index.js +80 -0
  178. package/dist/core/ingestion/languages/python/interpret.d.ts +15 -0
  179. package/dist/core/ingestion/languages/python/interpret.js +191 -0
  180. package/dist/core/ingestion/languages/python/merge-bindings.d.ts +16 -0
  181. package/dist/core/ingestion/languages/python/merge-bindings.js +44 -0
  182. package/dist/core/ingestion/languages/python/query.d.ts +9 -0
  183. package/dist/core/ingestion/languages/python/query.js +267 -0
  184. package/dist/core/ingestion/languages/python/receiver-binding.d.ts +21 -0
  185. package/dist/core/ingestion/languages/python/receiver-binding.js +116 -0
  186. package/dist/core/ingestion/languages/python/scope-resolver.d.ts +16 -0
  187. package/dist/core/ingestion/languages/python/scope-resolver.js +53 -0
  188. package/dist/core/ingestion/languages/python/simple-hooks.d.ts +23 -0
  189. package/dist/core/ingestion/languages/python/simple-hooks.js +35 -0
  190. package/dist/core/ingestion/languages/python.js +14 -0
  191. package/dist/core/ingestion/model/method-registry.d.ts +9 -0
  192. package/dist/core/ingestion/model/method-registry.js +4 -0
  193. package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +59 -0
  194. package/dist/core/ingestion/model/scope-resolution-indexes.js +42 -0
  195. package/dist/core/ingestion/model/semantic-model.d.ts +64 -0
  196. package/dist/core/ingestion/model/semantic-model.js +55 -0
  197. package/dist/core/ingestion/mro-processor.js +38 -22
  198. package/dist/core/ingestion/parsing-processor.d.ts +18 -1
  199. package/dist/core/ingestion/parsing-processor.js +45 -11
  200. package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
  201. package/dist/core/ingestion/pipeline-phases/index.js +1 -0
  202. package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +10 -0
  203. package/dist/core/ingestion/pipeline-phases/parse-impl.js +17 -2
  204. package/dist/core/ingestion/pipeline-phases/parse.d.ts +18 -0
  205. package/dist/core/ingestion/pipeline.js +2 -1
  206. package/dist/core/ingestion/registry-primary-flag.d.ts +86 -0
  207. package/dist/core/ingestion/registry-primary-flag.js +111 -0
  208. package/dist/core/ingestion/resolve-references.d.ts +63 -0
  209. package/dist/core/ingestion/resolve-references.js +175 -0
  210. package/dist/core/ingestion/scope-extractor-bridge.d.ts +32 -0
  211. package/dist/core/ingestion/scope-extractor-bridge.js +44 -0
  212. package/dist/core/ingestion/scope-extractor.d.ts +86 -0
  213. package/dist/core/ingestion/scope-extractor.js +758 -0
  214. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +372 -0
  215. package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +212 -0
  216. package/dist/core/ingestion/scope-resolution/graph-bridge/edges.d.ts +43 -0
  217. package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +79 -0
  218. package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +57 -0
  219. package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +112 -0
  220. package/dist/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.d.ts +17 -0
  221. package/dist/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.js +46 -0
  222. package/dist/core/ingestion/scope-resolution/graph-bridge/method-dispatch.d.ts +19 -0
  223. package/dist/core/ingestion/scope-resolution/graph-bridge/method-dispatch.js +30 -0
  224. package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.d.ts +37 -0
  225. package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +113 -0
  226. package/dist/core/ingestion/scope-resolution/graph-bridge/references-to-edges.d.ts +38 -0
  227. package/dist/core/ingestion/scope-resolution/graph-bridge/references-to-edges.js +73 -0
  228. package/dist/core/ingestion/scope-resolution/passes/compound-receiver.d.ts +42 -0
  229. package/dist/core/ingestion/scope-resolution/passes/compound-receiver.js +198 -0
  230. package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +27 -0
  231. package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +131 -0
  232. package/dist/core/ingestion/scope-resolution/passes/imported-return-types.d.ts +48 -0
  233. package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +130 -0
  234. package/dist/core/ingestion/scope-resolution/passes/mro.d.ts +42 -0
  235. package/dist/core/ingestion/scope-resolution/passes/mro.js +99 -0
  236. package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.d.ts +26 -0
  237. package/dist/core/ingestion/scope-resolution/passes/overload-narrowing.js +61 -0
  238. package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.d.ts +46 -0
  239. package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +327 -0
  240. package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +47 -0
  241. package/dist/core/ingestion/scope-resolution/pipeline/phase.js +130 -0
  242. package/dist/core/ingestion/scope-resolution/pipeline/reconcile-ownership.d.ts +68 -0
  243. package/dist/core/ingestion/scope-resolution/pipeline/reconcile-ownership.js +125 -0
  244. package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +17 -0
  245. package/dist/core/ingestion/scope-resolution/pipeline/registry.js +21 -0
  246. package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +66 -0
  247. package/dist/core/ingestion/scope-resolution/pipeline/run.js +157 -0
  248. package/dist/core/ingestion/scope-resolution/scope/namespace-targets.d.ts +36 -0
  249. package/dist/core/ingestion/scope-resolution/scope/namespace-targets.js +52 -0
  250. package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +127 -0
  251. package/dist/core/ingestion/scope-resolution/scope/walkers.js +349 -0
  252. package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +52 -0
  253. package/dist/core/ingestion/scope-resolution/workspace-index.js +61 -0
  254. package/dist/core/ingestion/shadow-harness.d.ts +113 -0
  255. package/dist/core/ingestion/shadow-harness.js +148 -0
  256. package/dist/core/ingestion/utils/ast-helpers.d.ts +19 -1
  257. package/dist/core/ingestion/utils/ast-helpers.js +70 -0
  258. package/dist/core/ingestion/utils/max-file-size.d.ts +20 -0
  259. package/dist/core/ingestion/utils/max-file-size.js +52 -0
  260. package/dist/core/ingestion/workers/parse-worker.d.ts +9 -0
  261. package/dist/core/ingestion/workers/parse-worker.js +57 -21
  262. package/dist/core/lbug/lbug-adapter.d.ts +22 -2
  263. package/dist/core/lbug/lbug-adapter.js +58 -14
  264. package/dist/core/lbug/pool-adapter.d.ts +17 -0
  265. package/dist/core/lbug/pool-adapter.js +24 -14
  266. package/dist/core/run-analyze.d.ts +32 -0
  267. package/dist/core/run-analyze.js +74 -19
  268. package/dist/core/search/bm25-index.d.ts +18 -0
  269. package/dist/core/search/bm25-index.js +125 -12
  270. package/dist/core/tree-sitter/parser-loader.js +6 -1
  271. package/dist/mcp/local/local-backend.d.ts +67 -3
  272. package/dist/mcp/local/local-backend.js +296 -34
  273. package/dist/mcp/resources.d.ts +31 -0
  274. package/dist/mcp/resources.js +100 -17
  275. package/dist/mcp/tools.d.ts +4 -1
  276. package/dist/mcp/tools.js +75 -54
  277. package/dist/server/api.js +6 -2
  278. package/dist/storage/git.d.ts +49 -0
  279. package/dist/storage/git.js +111 -0
  280. package/dist/storage/repo-manager.d.ts +246 -1
  281. package/dist/storage/repo-manager.js +391 -9
  282. package/package.json +7 -6
  283. package/scripts/bench-scope-resolution.ts +134 -0
  284. package/scripts/ci-list-migrated-languages.ts +24 -0
  285. package/skills/gitnexus-cli.md +1 -0
@@ -0,0 +1,332 @@
1
+ /**
2
+ * `lookupCore` — the shared 7-step canonical resolution algorithm
3
+ * (RFC §4.2; Ring 2 SHARED #917).
4
+ *
5
+ * Pure function. Given a name, a starting scope, and per-kind parameters,
6
+ * walks lexical scopes + optional type-binding MRO + optional owner
7
+ * contributor + global qualified-name fallback, and returns a ranked
8
+ * `Resolution[]` with per-candidate evidence.
9
+ *
10
+ * All three public registries (`ClassRegistry` / `MethodRegistry` /
11
+ * `FieldRegistry`) dispatch into this function, differing only in the
12
+ * parameters they pass. The CHOICE of which steps fire is expressed
13
+ * through `LookupParams`, not through different algorithms per kind.
14
+ *
15
+ * ## Algorithm (RFC §4.2, verbatim names)
16
+ *
17
+ * **Step 1 — Lexical scope-chain walk.** From `startScope`, walk
18
+ * parent-ward. At each scope, consult `scope.bindings.get(name)`:
19
+ * - Filter candidates whose `def.type ∈ acceptedKinds`.
20
+ * - For each surviving candidate, record a raw signal with the
21
+ * binding's origin + the current scope-chain depth.
22
+ * - **Hard shadow.** If `bindings.get(name)` is non-empty (including
23
+ * non-kind-matching candidates), stop walking. The name is
24
+ * lexically bound here; outer scopes are not consulted.
25
+ *
26
+ * **Step 2 — Type-binding resolution.** When `useReceiverTypeBinding`
27
+ * is true, resolve the receiver's type at `startScope` (from
28
+ * `scope.typeBindings`), then walk the MRO via
29
+ * `MethodDispatchIndex.mroFor(ownerDefId)`. Membership per owner comes
30
+ * through `RegistryContext.methodDispatch` + owner lookups into
31
+ * `scope.ownedDefs`; each hit records a raw signal with the owner's
32
+ * MRO depth.
33
+ *
34
+ * **Step 3 — Owner-scoped contributor.** When
35
+ * `params.ownerScopedContributor` is present, merge its `byName(name)`
36
+ * hits with `origin: 'local'` (they are declared directly on the
37
+ * receiver). Distinct from Step 2 — Step 2 walks the MRO; Step 3 only
38
+ * looks at the directly-declared owner members.
39
+ *
40
+ * **Step 4 — Kind filter (emit `kind-match` evidence).** Already
41
+ * applied during Steps 1-3; this step just adds a `kind-match` signal
42
+ * at weight 0 to every candidate for debuggability (so the evidence
43
+ * array is self-describing).
44
+ *
45
+ * **Step 5 — Arity filter.** Call `providers.arityCompatibility(callsite,
46
+ * def)` per surviving candidate. Verdicts: `compatible` / `unknown` /
47
+ * `incompatible`. If at least one candidate is `compatible`, drop
48
+ * `incompatible` ones. Otherwise keep all (the penalty weight alone
49
+ * will rank them lower but they remain in the result).
50
+ *
51
+ * **Step 6 — Global fallback.** When Steps 1-3 produced **no**
52
+ * candidates and the name contains a `.`, consult the
53
+ * `QualifiedNameIndex` via `lookupQualified` — see §4.5. The `scope`
54
+ * argument is NOT passed here because global lookup is scope-agnostic.
55
+ *
56
+ * **Step 7 — Rank + tie-break.** Compose evidence, compute confidence
57
+ * (sum capped at 1.0), sort by the RFC Appendix B cascade.
58
+ *
59
+ * ## What this module does NOT do
60
+ *
61
+ * - No AST reads (pure data in, pure data out).
62
+ * - No `gitnexus/` imports.
63
+ * - No language switches. Language-specific behavior flows exclusively
64
+ * through `providers.*` and the `params` object.
65
+ * - No caching. Callers that want memoization can wrap this function.
66
+ */
67
+ import { composeEvidence, confidenceFromEvidence } from './evidence.js';
68
+ import { compareByConfidenceWithTiebreaks } from './tie-breaks.js';
69
+ import { lookupQualified } from './lookup-qualified.js';
70
+ /**
71
+ * Run the 7-step lookup. Returns a non-empty `Resolution[]` when any
72
+ * candidate was found; an empty array otherwise. Callers consume `[0]`
73
+ * for the best answer and optionally inspect the rest for alternates.
74
+ */
75
+ export function lookupCore(name, startScope, params, ctx) {
76
+ const acceptedKinds = new Set(params.acceptedKinds);
77
+ const perCandidate = new Map();
78
+ // ── Step 1: lexical scope-chain walk ──────────────────────────────────
79
+ const lexicalShadowed = walkLexicalChain(name, startScope, acceptedKinds, ctx, perCandidate);
80
+ // ── Step 2: type-binding / MRO walk (methods/fields) ──────────────────
81
+ if (params.useReceiverTypeBinding && ctx.methodDispatch !== undefined) {
82
+ walkReceiverTypeBinding(name, startScope, acceptedKinds, params, ctx, perCandidate);
83
+ }
84
+ // ── Step 3: owner-scoped contributor ──────────────────────────────────
85
+ if (params.ownerScopedContributor !== null) {
86
+ seedFromOwnerScopedContributor(name, params.ownerScopedContributor, acceptedKinds, perCandidate);
87
+ }
88
+ // ── Step 4: kind-match evidence (emitted by composeEvidence directly) ──
89
+ // Handled inside `composeEvidence`.
90
+ // ── Step 5: arity filter ──────────────────────────────────────────────
91
+ if (params.callsite !== undefined) {
92
+ applyArityFilter(params.callsite, perCandidate, ctx);
93
+ }
94
+ // ── Step 6: global fallback (only when Steps 1-3 produced nothing) ──
95
+ if (perCandidate.size === 0 && !lexicalShadowed && name.includes('.')) {
96
+ const globals = lookupQualified(name, { acceptedKinds: params.acceptedKinds }, ctx);
97
+ if (globals.length > 0)
98
+ return globals;
99
+ }
100
+ if (perCandidate.size === 0)
101
+ return EMPTY;
102
+ // ── Step 7: compose evidence + rank ──────────────────────────────────
103
+ return rankCandidates(perCandidate);
104
+ }
105
+ function ensureCandidate(perCandidate, def) {
106
+ const existing = perCandidate.get(def.nodeId);
107
+ if (existing !== undefined)
108
+ return existing;
109
+ const fresh = {
110
+ def,
111
+ signals: { kindMatch: true },
112
+ tieBreakKey: { scopeDepth: 0, mroDepth: 0, origin: 'local' },
113
+ };
114
+ perCandidate.set(def.nodeId, fresh);
115
+ return fresh;
116
+ }
117
+ // ─── Step 1 implementation ─────────────────────────────────────────────────
118
+ /**
119
+ * Walk the lexical scope chain from `startScope` upward. Returns `true`
120
+ * iff a scope with any `bindings.get(name)` entries was found — the
121
+ * caller uses this to decide whether to run the global fallback.
122
+ */
123
+ function walkLexicalChain(name, startScope, acceptedKinds, ctx, perCandidate) {
124
+ let currentId = startScope;
125
+ let depth = 0;
126
+ const visited = new Set();
127
+ while (currentId !== null) {
128
+ if (visited.has(currentId))
129
+ return false;
130
+ visited.add(currentId);
131
+ const scope = ctx.scopes.getScope(currentId);
132
+ if (scope === undefined)
133
+ return false;
134
+ const bindings = scope.bindings.get(name);
135
+ if (bindings !== undefined && bindings.length > 0) {
136
+ for (const binding of bindings) {
137
+ if (!acceptedKinds.has(binding.def.type))
138
+ continue;
139
+ recordLexicalHit(perCandidate, binding, depth);
140
+ }
141
+ return true; // hard shadow regardless of kind-filter survivorship
142
+ }
143
+ currentId = scope.parent;
144
+ depth++;
145
+ }
146
+ return false;
147
+ }
148
+ function recordLexicalHit(perCandidate, binding, scopeChainDepth) {
149
+ const state = ensureCandidate(perCandidate, binding.def);
150
+ state.signals.origin = binding.origin;
151
+ state.signals.scopeChainDepth = scopeChainDepth;
152
+ if (binding.via?.linkStatus === 'unresolved') {
153
+ state.signals.viaUnlinkedImport = true;
154
+ }
155
+ if (binding.via?.kind === 'dynamic-unresolved') {
156
+ state.signals.dynamicUnresolved = true;
157
+ }
158
+ state.tieBreakKey.scopeDepth = scopeChainDepth;
159
+ state.tieBreakKey.origin = binding.origin;
160
+ }
161
+ // ─── Step 2 implementation ─────────────────────────────────────────────────
162
+ function walkReceiverTypeBinding(name, startScope, acceptedKinds, params, ctx, perCandidate) {
163
+ const ownerDefId = resolveReceiverOwner(startScope, params, ctx);
164
+ if (ownerDefId === undefined)
165
+ return;
166
+ if (ctx.methodDispatch === undefined)
167
+ return;
168
+ const ownerDef = ctx.defs.get(ownerDefId);
169
+ if (ownerDef === undefined)
170
+ return;
171
+ // Walk the owner itself at depth 0, then its MRO chain.
172
+ const walk = [ownerDefId, ...ctx.methodDispatch.mroFor(ownerDefId)];
173
+ for (let mroDepth = 0; mroDepth < walk.length; mroDepth++) {
174
+ const currentOwnerId = walk[mroDepth];
175
+ const members = collectOwnedMembers(currentOwnerId, name, ctx);
176
+ for (const def of members) {
177
+ if (!acceptedKinds.has(def.type))
178
+ continue;
179
+ recordTypeBindingHit(perCandidate, def, mroDepth, ownerDefId);
180
+ }
181
+ }
182
+ }
183
+ function resolveReceiverOwner(startScope, params, ctx) {
184
+ // Explicit receiver: consult the callsite scope's typeBindings for the
185
+ // named receiver; the attached TypeRef identifies the owner. Without a
186
+ // ready resolveTypeRef call (that module is separate), we do a direct
187
+ // lookup and trust the caller to have populated the binding.
188
+ if (params.explicitReceiver !== undefined) {
189
+ return lookupReceiverType(startScope, params.explicitReceiver.name, ctx);
190
+ }
191
+ // Implicit `self` / `this` — the scope's typeBindings should carry it.
192
+ for (const implicitName of IMPLICIT_RECEIVERS) {
193
+ const owner = lookupReceiverType(startScope, implicitName, ctx);
194
+ if (owner !== undefined)
195
+ return owner;
196
+ }
197
+ return undefined;
198
+ }
199
+ const IMPLICIT_RECEIVERS = Object.freeze(['self', 'this']);
200
+ function lookupReceiverType(startScope, receiverName, ctx) {
201
+ let currentId = startScope;
202
+ const visited = new Set();
203
+ while (currentId !== null) {
204
+ if (visited.has(currentId))
205
+ return undefined;
206
+ visited.add(currentId);
207
+ const scope = ctx.scopes.getScope(currentId);
208
+ if (scope === undefined)
209
+ return undefined;
210
+ const typeRef = scope.typeBindings.get(receiverName);
211
+ if (typeRef !== undefined) {
212
+ // rawName must resolve to a def via qualifiedNames; if it doesn't, we
213
+ // can't claim the receiver type. No fallback — that's what
214
+ // `resolveTypeRef` would do, but we keep this path lean and let
215
+ // callers pre-resolve if they want the richer semantics.
216
+ const candidateIds = ctx.qualifiedNames.get(typeRef.rawName);
217
+ if (candidateIds.length === 1)
218
+ return candidateIds[0];
219
+ // Ambiguous (≥ 2) or missing (0) — caller must pre-resolve via
220
+ // `resolveTypeRef` (#916) if they want the richer semantics. We
221
+ // intentionally do NOT re-implement a simple-name fallback here.
222
+ return undefined;
223
+ }
224
+ currentId = scope.parent;
225
+ }
226
+ return undefined;
227
+ }
228
+ function collectOwnedMembers(ownerDefId, memberName, ctx) {
229
+ // An owner's members are defs whose `ownerId === ownerDefId` and whose
230
+ // simple name matches `memberName`. We iterate `defs.byId` — O(D) per
231
+ // call today. A future by-owner index would make this O(K); tracked as
232
+ // a follow-up optimization before Ring 3 flips go production.
233
+ const out = [];
234
+ for (const def of ctx.defs.byId.values()) {
235
+ if (def.ownerId !== ownerDefId)
236
+ continue;
237
+ if (simpleNameOf(def) !== memberName)
238
+ continue;
239
+ out.push(def);
240
+ }
241
+ return out;
242
+ }
243
+ function simpleNameOf(def) {
244
+ if (def.qualifiedName === undefined || def.qualifiedName.length === 0)
245
+ return undefined;
246
+ const dot = def.qualifiedName.lastIndexOf('.');
247
+ return dot === -1 ? def.qualifiedName : def.qualifiedName.slice(dot + 1);
248
+ }
249
+ function recordTypeBindingHit(perCandidate, def, mroDepth, receiverOwner) {
250
+ const state = ensureCandidate(perCandidate, def);
251
+ const existingMroDepth = state.signals.typeBindingMroDepth;
252
+ const firstHit = existingMroDepth === undefined;
253
+ // Only replace if this hit is shallower (smaller MRO depth). The local
254
+ // const lets TS narrow to `number` in the `else` branch so no `!`
255
+ // assertion is needed.
256
+ if (firstHit || mroDepth < existingMroDepth) {
257
+ state.signals.typeBindingMroDepth = mroDepth;
258
+ state.tieBreakKey.mroDepth = mroDepth;
259
+ }
260
+ if (def.ownerId === receiverOwner) {
261
+ state.signals.ownerMatch = true;
262
+ }
263
+ // Pure type-binding candidates (no lexical hit) would otherwise keep the
264
+ // `ensureCandidate` default `tieBreakKey.origin === 'local'`, making the
265
+ // Appendix B cascade lump them with local-origin candidates. Demote them
266
+ // to `'import'` — the strongest non-local origin — only when no earlier
267
+ // phase set an origin for this candidate. Lexical hits from Step 1 set
268
+ // `signals.origin` before Step 2 runs, so the guard skips them; Step 3
269
+ // (`seedFromOwnerScopedContributor`) runs AFTER Step 2 and unconditionally
270
+ // overrides `tieBreakKey.origin` back to `'local'` for direct-owner
271
+ // members, so any same-def overlap still ends up ranked correctly.
272
+ if (firstHit && state.signals.origin === undefined) {
273
+ state.tieBreakKey.origin = 'import';
274
+ }
275
+ }
276
+ // ─── Step 3 implementation ─────────────────────────────────────────────────
277
+ function seedFromOwnerScopedContributor(name, contributor, acceptedKinds, perCandidate) {
278
+ for (const def of contributor.byName(name)) {
279
+ if (!acceptedKinds.has(def.type))
280
+ continue;
281
+ const state = ensureCandidate(perCandidate, def);
282
+ // Treat the contributor's direct membership as `origin: 'local'` —
283
+ // strongest visibility, no scope-chain penalty.
284
+ state.signals.origin = 'local';
285
+ state.signals.scopeChainDepth = 0;
286
+ state.signals.ownerMatch = def.ownerId === contributor.ownerDefId;
287
+ state.tieBreakKey.origin = 'local';
288
+ }
289
+ }
290
+ // ─── Step 5 implementation ─────────────────────────────────────────────────
291
+ function applyArityFilter(callsite, perCandidate, ctx) {
292
+ const arityFn = ctx.providers.arityCompatibility;
293
+ if (arityFn === undefined) {
294
+ // No provider → record 'unknown' for every candidate; keeps signal
295
+ // shape uniform for composeEvidence.
296
+ for (const state of perCandidate.values()) {
297
+ state.signals.arityVerdict = 'unknown';
298
+ }
299
+ return;
300
+ }
301
+ let anyCompatible = false;
302
+ for (const state of perCandidate.values()) {
303
+ const verdict = arityFn(callsite, state.def);
304
+ state.signals.arityVerdict = verdict;
305
+ if (verdict === 'compatible')
306
+ anyCompatible = true;
307
+ }
308
+ if (!anyCompatible)
309
+ return;
310
+ // Filter: when at least one compatible candidate exists, drop incompatibles.
311
+ for (const [defId, state] of perCandidate) {
312
+ if (state.signals.arityVerdict === 'incompatible') {
313
+ perCandidate.delete(defId);
314
+ }
315
+ }
316
+ }
317
+ // ─── Step 7 implementation ─────────────────────────────────────────────────
318
+ function rankCandidates(perCandidate) {
319
+ const resolutions = [];
320
+ const tieKeys = new Map();
321
+ for (const state of perCandidate.values()) {
322
+ const evidence = composeEvidence(state.signals);
323
+ const confidence = confidenceFromEvidence(evidence);
324
+ resolutions.push({ def: state.def, confidence, evidence });
325
+ tieKeys.set(state.def.nodeId, { ...state.tieBreakKey });
326
+ }
327
+ resolutions.sort((a, b) => compareByConfidenceWithTiebreaks(a, b, tieKeys));
328
+ return Object.freeze(resolutions);
329
+ }
330
+ // ─── Constants ──────────────────────────────────────────────────────────────
331
+ const EMPTY = Object.freeze([]);
332
+ //# sourceMappingURL=lookup-core.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-core.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/lookup-core.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAiEG;AAcH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAmB,MAAM,eAAe,CAAC;AACzF,OAAO,EAAE,gCAAgC,EAAoB,MAAM,iBAAiB,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAYxD;;;;GAIG;AACH,MAAM,UAAU,UAAU,CACxB,IAAY,EACZ,UAAmB,EACnB,MAAwB,EACxB,GAAoB;IAEpB,MAAM,aAAa,GAAG,IAAI,GAAG,CAAY,MAAM,CAAC,aAAa,CAAC,CAAC;IAC/D,MAAM,YAAY,GAAG,IAAI,GAAG,EAAyB,CAAC;IAEtD,yEAAyE;IACzE,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IAE7F,yEAAyE;IACzE,IAAI,MAAM,CAAC,sBAAsB,IAAI,GAAG,CAAC,cAAc,KAAK,SAAS,EAAE,CAAC;QACtE,uBAAuB,CAAC,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,YAAY,CAAC,CAAC;IACtF,CAAC;IAED,yEAAyE;IACzE,IAAI,MAAM,CAAC,sBAAsB,KAAK,IAAI,EAAE,CAAC;QAC3C,8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+ * Consults `QualifiedNameIndex` directly, filters by `acceptedKinds`, and
5
+ * returns `Resolution[]` with `origin: 'global-qualified'` evidence. Used by:
6
+ *
7
+ * - `resolveTypeRef` dotted fallback (#916)
8
+ * - `Registry.lookup` Step 6 when no lexical candidate survived
9
+ * - Explicit dotted identifiers in Cypher / MCP tools where the caller
10
+ * knows the target's canonical qualified name
11
+ *
12
+ * **Strict + deterministic.** No receiver-type resolution, no scope walk.
13
+ * Every surviving candidate gets the same base confidence (from
14
+ * `EvidenceWeights.globalQualified`), then the tie-break cascade
15
+ * disambiguates.
16
+ */
17
+ import type { NodeLabel } from '../../graph/types.js';
18
+ import type { Resolution } from '../types.js';
19
+ import type { RegistryContext } from './context.js';
20
+ export interface LookupQualifiedParams {
21
+ readonly acceptedKinds: readonly NodeLabel[];
22
+ }
23
+ /**
24
+ * Look up a canonical qualified name (e.g., `app.models.User`) across all
25
+ * defs, filtered by `acceptedKinds`. Returns an empty array when the name
26
+ * is not indexed or no candidate matches the kind filter.
27
+ *
28
+ * Callers consume `[0]` for the strict single-return answer; the remainder
29
+ * carries alternate candidates (partial classes, overloads, accidental
30
+ * cross-kind hits) ordered by the tie-break cascade.
31
+ */
32
+ export declare function lookupQualified(qualifiedName: string, params: LookupQualifiedParams, ctx: RegistryContext): readonly Resolution[];
33
+ //# sourceMappingURL=lookup-qualified.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-qualified.d.ts","sourceRoot":"","sources":["../../../src/scope-resolution/registries/lookup-qualified.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAG9C,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAEpD,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,aAAa,EAAE,SAAS,SAAS,EAAE,CAAC;CAC9C;AAED;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,aAAa,EAAE,MAAM,EACrB,MAAM,EAAE,qBAAqB,EAC7B,GAAG,EAAE,eAAe,GACnB,SAAS,UAAU,EAAE,CA4BvB"}
@@ -0,0 +1,56 @@
1
+ /**
2
+ * `lookupQualified` — qualified-name fast path (RFC §4.5; Ring 2 SHARED #917).
3
+ *
4
+ * Consults `QualifiedNameIndex` directly, filters by `acceptedKinds`, and
5
+ * returns `Resolution[]` with `origin: 'global-qualified'` evidence. Used by:
6
+ *
7
+ * - `resolveTypeRef` dotted fallback (#916)
8
+ * - `Registry.lookup` Step 6 when no lexical candidate survived
9
+ * - Explicit dotted identifiers in Cypher / MCP tools where the caller
10
+ * knows the target's canonical qualified name
11
+ *
12
+ * **Strict + deterministic.** No receiver-type resolution, no scope walk.
13
+ * Every surviving candidate gets the same base confidence (from
14
+ * `EvidenceWeights.globalQualified`), then the tie-break cascade
15
+ * disambiguates.
16
+ */
17
+ import { composeEvidence, confidenceFromEvidence } from './evidence.js';
18
+ import { compareByConfidenceWithTiebreaks } from './tie-breaks.js';
19
+ /**
20
+ * Look up a canonical qualified name (e.g., `app.models.User`) across all
21
+ * defs, filtered by `acceptedKinds`. Returns an empty array when the name
22
+ * is not indexed or no candidate matches the kind filter.
23
+ *
24
+ * Callers consume `[0]` for the strict single-return answer; the remainder
25
+ * carries alternate candidates (partial classes, overloads, accidental
26
+ * cross-kind hits) ordered by the tie-break cascade.
27
+ */
28
+ export function lookupQualified(qualifiedName, params, ctx) {
29
+ const defIds = ctx.qualifiedNames.get(qualifiedName);
30
+ if (defIds.length === 0)
31
+ return EMPTY;
32
+ const acceptedKinds = new Set(params.acceptedKinds);
33
+ const resolutions = [];
34
+ const tieKeys = new Map();
35
+ for (const defId of defIds) {
36
+ const def = ctx.defs.get(defId);
37
+ if (def === undefined)
38
+ continue;
39
+ if (!acceptedKinds.has(def.type))
40
+ continue;
41
+ const evidence = composeEvidence({ origin: 'global-qualified', kindMatch: true });
42
+ const confidence = confidenceFromEvidence(evidence);
43
+ resolutions.push({ def, confidence, evidence });
44
+ tieKeys.set(def.nodeId, {
45
+ scopeDepth: 0,
46
+ mroDepth: 0,
47
+ origin: 'global-qualified',
48
+ });
49
+ }
50
+ if (resolutions.length === 0)
51
+ return EMPTY;
52
+ resolutions.sort((a, b) => compareByConfidenceWithTiebreaks(a, b, tieKeys));
53
+ return Object.freeze(resolutions);
54
+ }
55
+ const EMPTY = Object.freeze([]);
56
+ //# sourceMappingURL=lookup-qualified.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup-qualified.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/lookup-qualified.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AAIH,OAAO,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AACxE,OAAO,EAAE,gCAAgC,EAAoB,MAAM,iBAAiB,CAAC;AAOrF;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,aAAqB,EACrB,MAA6B,EAC7B,GAAoB;IAEpB,MAAM,MAAM,GAAG,GAAG,CAAC,cAAc,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC;IACrD,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAEtC,MAAM,aAAa,GAAG,IAAI,GAAG,CAAY,MAAM,CAAC,aAAa,CAAC,CAAC;IAE/D,MAAM,WAAW,GAAiB,EAAE,CAAC;IACrC,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAE/C,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;QAC3B,MAAM,GAAG,GAAG,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,GAAG,KAAK,SAAS;YAAE,SAAS;QAChC,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;YAAE,SAAS;QAE3C,MAAM,QAAQ,GAAG,eAAe,CAAC,EAAE,MAAM,EAAE,kBAAkB,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAClF,MAAM,UAAU,GAAG,sBAAsB,CAAC,QAAQ,CAAC,CAAC;QACpD,WAAW,CAAC,IAAI,CAAC,EAAE,GAAG,EAAE,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC;QAChD,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,MAAM,EAAE;YACtB,UAAU,EAAE,CAAC;YACb,QAAQ,EAAE,CAAC;YACX,MAAM,EAAE,kBAAkB;SAC3B,CAAC,CAAC;IACL,CAAC;IAED,IAAI,WAAW,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC;IAE3C,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,gCAAgC,CAAC,CAAC,EAAE,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,KAAK,GAA0B,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * `MethodRegistry` — scope-aware lookup for method / function / constructor
3
+ * dispatch (RFC §4.4; Ring 2 SHARED #917).
4
+ *
5
+ * Thin wrapper over `lookupCore`, specialized for callable kinds:
6
+ *
7
+ * - `acceptedKinds` = Method / Function / Constructor.
8
+ * - `useReceiverTypeBinding` is **true** — the type-binding + MRO walk
9
+ * (Step 2) is the primary evidence path for receiver-dispatched calls.
10
+ * - `callsite.arity` flows through to `provider.arityCompatibility`
11
+ * when provided. When the provider is absent, arity evidence is
12
+ * `unknown` (neutral signal).
13
+ */
14
+ import type { Callsite, Resolution, ScopeId } from '../types.js';
15
+ import type { OwnerScopedContributor, RegistryContext } from './context.js';
16
+ /**
17
+ * Extra per-call parameters that vary across call sites but NOT across
18
+ * registries. Kept as a separate shape so `MethodRegistry.lookup` stays
19
+ * concise while still exposing the explicit-receiver + owner-contributor +
20
+ * arity knobs the RFC algorithm needs.
21
+ */
22
+ export interface MethodLookupOptions {
23
+ /** Call-site arity for `provider.arityCompatibility`. */
24
+ readonly callsite?: Callsite;
25
+ /** Explicit receiver (e.g., `user` in `user.save()`). See §4.1. */
26
+ readonly explicitReceiver?: {
27
+ readonly name: string;
28
+ };
29
+ /** Optional per-owner contributor (Step 3). */
30
+ readonly ownerScopedContributor?: OwnerScopedContributor;
31
+ }
32
+ export interface MethodRegistry {
33
+ lookup(name: string, scope: ScopeId, options?: MethodLookupOptions): readonly Resolution[];
34
+ }
35
+ export declare function buildMethodRegistry(ctx: RegistryContext): MethodRegistry;
36
+ //# sourceMappingURL=method-registry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-registry.d.ts","sourceRoot":"","sources":["../../../src/scope-resolution/registries/method-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAEjE,OAAO,KAAK,EAAE,sBAAsB,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAG5E;;;;;GAKG;AACH,MAAM,WAAW,mBAAmB;IAClC,yDAAyD;IACzD,QAAQ,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC;IAC7B,mEAAmE;IACnE,QAAQ,CAAC,gBAAgB,CAAC,EAAE;QAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IACtD,+CAA+C;IAC/C,QAAQ,CAAC,sBAAsB,CAAC,EAAE,sBAAsB,CAAC;CAC1D;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,mBAAmB,GAAG,SAAS,UAAU,EAAE,CAAC;CAC5F;AAED,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,eAAe,GAAG,cAAc,CAexE"}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * `MethodRegistry` — scope-aware lookup for method / function / constructor
3
+ * dispatch (RFC §4.4; Ring 2 SHARED #917).
4
+ *
5
+ * Thin wrapper over `lookupCore`, specialized for callable kinds:
6
+ *
7
+ * - `acceptedKinds` = Method / Function / Constructor.
8
+ * - `useReceiverTypeBinding` is **true** — the type-binding + MRO walk
9
+ * (Step 2) is the primary evidence path for receiver-dispatched calls.
10
+ * - `callsite.arity` flows through to `provider.arityCompatibility`
11
+ * when provided. When the provider is absent, arity evidence is
12
+ * `unknown` (neutral signal).
13
+ */
14
+ import { lookupCore } from './lookup-core.js';
15
+ import { METHOD_KINDS } from './context.js';
16
+ export function buildMethodRegistry(ctx) {
17
+ return {
18
+ lookup(name, scope, options = {}) {
19
+ const params = {
20
+ acceptedKinds: METHOD_KINDS,
21
+ useReceiverTypeBinding: true,
22
+ ownerScopedContributor: options.ownerScopedContributor ?? null,
23
+ ...(options.callsite !== undefined ? { callsite: options.callsite } : {}),
24
+ ...(options.explicitReceiver !== undefined
25
+ ? { explicitReceiver: options.explicitReceiver }
26
+ : {}),
27
+ };
28
+ return lookupCore(name, scope, params, ctx);
29
+ },
30
+ };
31
+ }
32
+ //# sourceMappingURL=method-registry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-registry.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/method-registry.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAGH,OAAO,EAAE,UAAU,EAAyB,MAAM,kBAAkB,CAAC;AAErE,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAqB5C,MAAM,UAAU,mBAAmB,CAAC,GAAoB;IACtD,OAAO;QACL,MAAM,CAAC,IAAY,EAAE,KAAc,EAAE,UAA+B,EAAE;YACpE,MAAM,MAAM,GAAqB;gBAC/B,aAAa,EAAE,YAAY;gBAC3B,sBAAsB,EAAE,IAAI;gBAC5B,sBAAsB,EAAE,OAAO,CAAC,sBAAsB,IAAI,IAAI;gBAC9D,GAAG,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,OAAO,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACzE,GAAG,CAAC,OAAO,CAAC,gBAAgB,KAAK,SAAS;oBACxC,CAAC,CAAC,EAAE,gBAAgB,EAAE,OAAO,CAAC,gBAAgB,EAAE;oBAChD,CAAC,CAAC,EAAE,CAAC;aACR,CAAC;YACF,OAAO,UAAU,CAAC,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC;QAC9C,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ /**
2
+ * `compareByConfidenceWithTiebreaks` — the RFC §4.2 Step 7 total order
3
+ * over `Resolution` candidates (Ring 2 SHARED #917).
4
+ *
5
+ * Primary key is confidence (DESC). Remaining ties within `CONFIDENCE_EPSILON`
6
+ * fall through a deterministic cascade so the same inputs always produce
7
+ * the same winner, independent of insertion order.
8
+ *
9
+ * Tie-break cascade (per RFC Appendix B):
10
+ *
11
+ * 1. confidence DESC (primary)
12
+ * 2. scope depth ASC (nearer lexical scope wins)
13
+ * 3. MRO depth ASC (nearer class in hierarchy wins)
14
+ * 4. `ORIGIN_PRIORITY` ASC (local > import > … > global-name)
15
+ * 5. DefId.localeCompare (final deterministic tiebreaker)
16
+ *
17
+ * The per-candidate inputs needed beyond `Resolution.confidence` —
18
+ * `scopeDepth`, `mroDepth`, `origin` — are supplied via a sidecar
19
+ * `TieBreakKey` so the comparator stays pure and `Resolution` itself
20
+ * doesn't need to carry book-keeping fields.
21
+ */
22
+ import { type OriginForTieBreak } from '../origin-priority.js';
23
+ import type { Resolution } from '../types.js';
24
+ export declare const CONFIDENCE_EPSILON = 0.001;
25
+ /** Side-information per candidate used for secondary tie-breaks. */
26
+ export interface TieBreakKey {
27
+ readonly scopeDepth: number;
28
+ readonly mroDepth: number;
29
+ readonly origin: OriginForTieBreak;
30
+ }
31
+ /**
32
+ * Pure comparator suitable for `Array.prototype.sort`. Return value follows
33
+ * the JavaScript convention: negative → `a` wins, positive → `b` wins.
34
+ *
35
+ * **Important:** `keys` is keyed by `Resolution.def.nodeId`, not by array
36
+ * index — stable across reorderings. Missing keys fall back to neutral
37
+ * values (`scopeDepth: 0`, `mroDepth: 0`, `origin: 'local'`), which means
38
+ * the tie-break degrades gracefully to defId-lexicographic ordering when
39
+ * side-info is unavailable. That keeps the total order deterministic
40
+ * even on malformed inputs.
41
+ */
42
+ export declare function compareByConfidenceWithTiebreaks(a: Resolution, b: Resolution, keys: ReadonlyMap<string, TieBreakKey>): number;
43
+ //# sourceMappingURL=tie-breaks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tie-breaks.d.ts","sourceRoot":"","sources":["../../../src/scope-resolution/registries/tie-breaks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAmB,KAAK,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAChF,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C,eAAO,MAAM,kBAAkB,QAAQ,CAAC;AAExC,oEAAoE;AACpE,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;CACpC;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,gCAAgC,CAC9C,CAAC,EAAE,UAAU,EACb,CAAC,EAAE,UAAU,EACb,IAAI,EAAE,WAAW,CAAC,MAAM,EAAE,WAAW,CAAC,GACrC,MAAM,CAoBR"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * `compareByConfidenceWithTiebreaks` — the RFC §4.2 Step 7 total order
3
+ * over `Resolution` candidates (Ring 2 SHARED #917).
4
+ *
5
+ * Primary key is confidence (DESC). Remaining ties within `CONFIDENCE_EPSILON`
6
+ * fall through a deterministic cascade so the same inputs always produce
7
+ * the same winner, independent of insertion order.
8
+ *
9
+ * Tie-break cascade (per RFC Appendix B):
10
+ *
11
+ * 1. confidence DESC (primary)
12
+ * 2. scope depth ASC (nearer lexical scope wins)
13
+ * 3. MRO depth ASC (nearer class in hierarchy wins)
14
+ * 4. `ORIGIN_PRIORITY` ASC (local > import > … > global-name)
15
+ * 5. DefId.localeCompare (final deterministic tiebreaker)
16
+ *
17
+ * The per-candidate inputs needed beyond `Resolution.confidence` —
18
+ * `scopeDepth`, `mroDepth`, `origin` — are supplied via a sidecar
19
+ * `TieBreakKey` so the comparator stays pure and `Resolution` itself
20
+ * doesn't need to carry book-keeping fields.
21
+ */
22
+ import { ORIGIN_PRIORITY } from '../origin-priority.js';
23
+ export const CONFIDENCE_EPSILON = 0.001;
24
+ /**
25
+ * Pure comparator suitable for `Array.prototype.sort`. Return value follows
26
+ * the JavaScript convention: negative → `a` wins, positive → `b` wins.
27
+ *
28
+ * **Important:** `keys` is keyed by `Resolution.def.nodeId`, not by array
29
+ * index — stable across reorderings. Missing keys fall back to neutral
30
+ * values (`scopeDepth: 0`, `mroDepth: 0`, `origin: 'local'`), which means
31
+ * the tie-break degrades gracefully to defId-lexicographic ordering when
32
+ * side-info is unavailable. That keeps the total order deterministic
33
+ * even on malformed inputs.
34
+ */
35
+ export function compareByConfidenceWithTiebreaks(a, b, keys) {
36
+ // Primary: confidence DESC, treating values within epsilon as equal.
37
+ const delta = b.confidence - a.confidence;
38
+ if (Math.abs(delta) >= CONFIDENCE_EPSILON)
39
+ return delta < 0 ? -1 : 1;
40
+ const ka = keys.get(a.def.nodeId) ?? DEFAULT_KEY;
41
+ const kb = keys.get(b.def.nodeId) ?? DEFAULT_KEY;
42
+ // Secondary: scope depth ASC.
43
+ if (ka.scopeDepth !== kb.scopeDepth)
44
+ return ka.scopeDepth - kb.scopeDepth;
45
+ // Tertiary: MRO depth ASC.
46
+ if (ka.mroDepth !== kb.mroDepth)
47
+ return ka.mroDepth - kb.mroDepth;
48
+ // Quaternary: ORIGIN_PRIORITY ASC.
49
+ const po = ORIGIN_PRIORITY[ka.origin] - ORIGIN_PRIORITY[kb.origin];
50
+ if (po !== 0)
51
+ return po;
52
+ // Final: DefId lexicographic, locale-aware for deterministic cross-platform output.
53
+ return a.def.nodeId.localeCompare(b.def.nodeId);
54
+ }
55
+ const DEFAULT_KEY = Object.freeze({
56
+ scopeDepth: 0,
57
+ mroDepth: 0,
58
+ origin: 'local',
59
+ });
60
+ //# sourceMappingURL=tie-breaks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tie-breaks.js","sourceRoot":"","sources":["../../../src/scope-resolution/registries/tie-breaks.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,eAAe,EAA0B,MAAM,uBAAuB,CAAC;AAGhF,MAAM,CAAC,MAAM,kBAAkB,GAAG,KAAK,CAAC;AASxC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,gCAAgC,CAC9C,CAAa,EACb,CAAa,EACb,IAAsC;IAEtC,qEAAqE;IACrE,MAAM,KAAK,GAAG,CAAC,CAAC,UAAU,GAAG,CAAC,CAAC,UAAU,CAAC;IAC1C,IAAI,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,IAAI,kBAAkB;QAAE,OAAO,KAAK,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAErE,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,WAAW,CAAC;IACjD,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,WAAW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