gitnexus 1.6.3-rc.5 → 1.6.3-rc.6

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.
@@ -18,6 +18,10 @@ export { buildModuleScopeIndex } from './scope-resolution/module-scope-index.js'
18
18
  export type { ModuleScopeIndex, ModuleScopeEntry } from './scope-resolution/module-scope-index.js';
19
19
  export { buildQualifiedNameIndex } from './scope-resolution/qualified-name-index.js';
20
20
  export type { QualifiedNameIndex } from './scope-resolution/qualified-name-index.js';
21
+ export { resolveTypeRef } from './scope-resolution/resolve-type-ref.js';
22
+ export type { ResolveTypeRefContext, ScopeLookup } from './scope-resolution/resolve-type-ref.js';
23
+ export { buildMethodDispatchIndex } from './scope-resolution/method-dispatch-index.js';
24
+ export type { MethodDispatchIndex, MethodDispatchInput, } from './scope-resolution/method-dispatch-index.js';
21
25
  export { diffResolutions } from './scope-resolution/shadow/diff.js';
22
26
  export type { ShadowAgreement, ShadowCallsite, ShadowDiff, } from './scope-resolution/shadow/diff.js';
23
27
  export { aggregateDiffs } from './scope-resolution/shadow/aggregate.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,SAAS,EACT,iBAAiB,GAClB,MAAM,kBAAkB,CAAC;AAG1B,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AACpC,YAAY,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAGzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AACjG,YAAY,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAGrD,YAAY,EAAE,aAAa,EAAE,gBAAgB,EAAE,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AAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AACjF,YAAY,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,0CAA0C,CAAC;AACnG,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AACrF,YAAY,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAGrF,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,YAAY,EAAE,qBAAqB,EAAE,WAAW,EAAE,MAAM,wCAAwC,CAAC;AAGjG,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AACvF,YAAY,EACV,mBAAmB,EACnB,mBAAmB,GACpB,MAAM,6CAA6C,CAAC;AAGrD,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AACpE,YAAY,EACV,eAAe,EACf,cAAc,EACd,UAAU,GACX,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACxE,YAAY,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,wCAAwC,CAAC"}
@@ -12,6 +12,10 @@ export { LanguageClassifications, isProductionLanguage, } from './scope-resoluti
12
12
  export { buildDefIndex } from './scope-resolution/def-index.js';
13
13
  export { buildModuleScopeIndex } from './scope-resolution/module-scope-index.js';
14
14
  export { buildQualifiedNameIndex } from './scope-resolution/qualified-name-index.js';
15
+ // Strict type-reference resolver (RFC §4.6; Ring 2 SHARED #916)
16
+ export { resolveTypeRef } from './scope-resolution/resolve-type-ref.js';
17
+ // Method-dispatch materialized view over HeritageMap (RFC §3.1; Ring 2 SHARED #914)
18
+ export { buildMethodDispatchIndex } from './scope-resolution/method-dispatch-index.js';
15
19
  // Shadow-mode diff + aggregation (RFC §6.3; Ring 2 SHARED #918)
16
20
  export { diffResolutions } from './scope-resolution/shadow/diff.js';
17
21
  export { aggregateDiffs } from './scope-resolution/shadow/aggregate.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,mBAAmB;AACnB,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,mBAAmB;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAiCjG,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,yDAAyD;AACzD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,+CAA+C,CAAC;AAGvD,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAGrF,gEAAgE;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAMpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AASA,mBAAmB;AACnB,OAAO,EACL,WAAW,EACX,cAAc,EACd,SAAS,EACT,oBAAoB,GACrB,MAAM,4BAA4B,CAAC;AAGpC,mBAAmB;AACnB,OAAO,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AACpD,OAAO,EAAE,uBAAuB,EAAE,6BAA6B,EAAE,MAAM,yBAAyB,CAAC;AAiCjG,8DAA8D;AAC9D,OAAO,EAAE,eAAe,EAAE,wBAAwB,EAAE,MAAM,wCAAwC,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,MAAM,uCAAuC,CAAC;AAGxE,yDAAyD;AACzD,OAAO,EACL,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,+CAA+C,CAAC;AAGvD,sEAAsE;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAEhE,OAAO,EAAE,qBAAqB,EAAE,MAAM,0CAA0C,CAAC;AAEjF,OAAO,EAAE,uBAAuB,EAAE,MAAM,4CAA4C,CAAC;AAGrF,gEAAgE;AAChE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC;AAGxE,oFAAoF;AACpF,OAAO,EAAE,wBAAwB,EAAE,MAAM,6CAA6C,CAAC;AAMvF,gEAAgE;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,mCAAmC,CAAC;AAMpE,OAAO,EAAE,cAAc,EAAE,MAAM,wCAAwC,CAAC"}
@@ -0,0 +1,72 @@
1
+ /**
2
+ * `MethodDispatchIndex` — materialized view of class hierarchies keyed by
3
+ * `DefId` (RFC §3.1; Ring 2 SHARED #914).
4
+ *
5
+ * Two O(1)-access maps used by `Registry.lookupMethod` and interface-
6
+ * dispatch callers:
7
+ *
8
+ * - `mroByOwnerDefId` : owner class → full MRO ancestor chain
9
+ * (excludes the owner itself, in per-language
10
+ * strategy order).
11
+ * - `implsByInterfaceDefId` : interface/trait → classes that implement it.
12
+ *
13
+ * **Not an MRO implementation.** The build function is a pure aggregator: it
14
+ * asks the caller (via `computeMro` and `implementsOf` callbacks) for the
15
+ * per-language answers and materializes the two-way index. MRO strategies
16
+ * live where they already do today (`model/resolve.ts § c3Linearize`,
17
+ * `languages/ruby.ts § selectDispatch`, etc.) — this index does not
18
+ * reimplement them.
19
+ *
20
+ * Why callbacks and not a shared strategy registry: the five strategies
21
+ * (Python C3, Ruby kind-aware, Java/Kotlin linear, Rust qualified-syntax,
22
+ * COBOL none) already exist in the CLI package and depend on the CLI's
23
+ * `HeritageMap` + `SemanticModel`. Pulling them into `gitnexus-shared` would
24
+ * require migrating both — out of scope for #914. Callbacks let the shared
25
+ * build stay pure while honoring existing strategies verbatim.
26
+ *
27
+ * Consumed by: #917 (`Registry.lookupMethod` MRO fast path, interface
28
+ * dispatch resolver).
29
+ */
30
+ import type { DefId } from './types.js';
31
+ export interface MethodDispatchIndex {
32
+ /**
33
+ * Full MRO ancestor chain per owner class (excludes the owner itself).
34
+ * Order reflects the per-language strategy used by `computeMro`.
35
+ */
36
+ readonly mroByOwnerDefId: ReadonlyMap<DefId, readonly DefId[]>;
37
+ /** Interfaces / traits → classes that implement them. */
38
+ readonly implsByInterfaceDefId: ReadonlyMap<DefId, readonly DefId[]>;
39
+ /** `mroByOwnerDefId.get`, with an empty frozen array on miss. */
40
+ mroFor(ownerDefId: DefId): readonly DefId[];
41
+ /** `implsByInterfaceDefId.get`, with an empty frozen array on miss. */
42
+ implementorsOf(interfaceDefId: DefId): readonly DefId[];
43
+ }
44
+ export interface MethodDispatchInput {
45
+ /**
46
+ * Owner defs to index (classes, structs, traits, interfaces — any kind
47
+ * that can appear on the owner side of a method-dispatch graph).
48
+ */
49
+ readonly owners: readonly DefId[];
50
+ /**
51
+ * Return the full MRO ancestor chain for `ownerDefId`, **excluding the
52
+ * owner itself**, in the order dictated by the owner's language-specific
53
+ * MRO strategy.
54
+ *
55
+ * Contract:
56
+ * - Pure (no side effects).
57
+ * - Deterministic per input.
58
+ * - `undefined` not allowed — return `[]` when the owner has no parents.
59
+ */
60
+ readonly computeMro: (ownerDefId: DefId) => readonly DefId[];
61
+ /**
62
+ * Return the set of interface/trait defs that `ownerDefId` implements.
63
+ * Transitive inclusion (e.g., `implements` on a parent class) is the
64
+ * caller's choice — the build function simply inverts whatever is
65
+ * returned.
66
+ *
67
+ * Repeated IDs in the output are deduplicated automatically.
68
+ */
69
+ readonly implementsOf: (ownerDefId: DefId) => readonly DefId[];
70
+ }
71
+ export declare function buildMethodDispatchIndex(input: MethodDispatchInput): MethodDispatchIndex;
72
+ //# sourceMappingURL=method-dispatch-index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-dispatch-index.d.ts","sourceRoot":"","sources":["../../src/scope-resolution/method-dispatch-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAIxC,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,eAAe,EAAE,WAAW,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC,CAAC;IAC/D,yDAAyD;IACzD,QAAQ,CAAC,qBAAqB,EAAE,WAAW,CAAC,KAAK,EAAE,SAAS,KAAK,EAAE,CAAC,CAAC;IAErE,iEAAiE;IACjE,MAAM,CAAC,UAAU,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,CAAC;IAC5C,uEAAuE;IACvE,cAAc,CAAC,cAAc,EAAE,KAAK,GAAG,SAAS,KAAK,EAAE,CAAC;CACzD;AAED,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,SAAS,KAAK,EAAE,CAAC;IAClC;;;;;;;;;OASG;IACH,QAAQ,CAAC,UAAU,EAAE,CAAC,UAAU,EAAE,KAAK,KAAK,SAAS,KAAK,EAAE,CAAC;IAC7D;;;;;;;OAOG;IACH,QAAQ,CAAC,YAAY,EAAE,CAAC,UAAU,EAAE,KAAK,KAAK,SAAS,KAAK,EAAE,CAAC;CAChE;AAID,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,mBAAmB,GAAG,mBAAmB,CAqCxF"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * `MethodDispatchIndex` — materialized view of class hierarchies keyed by
3
+ * `DefId` (RFC §3.1; Ring 2 SHARED #914).
4
+ *
5
+ * Two O(1)-access maps used by `Registry.lookupMethod` and interface-
6
+ * dispatch callers:
7
+ *
8
+ * - `mroByOwnerDefId` : owner class → full MRO ancestor chain
9
+ * (excludes the owner itself, in per-language
10
+ * strategy order).
11
+ * - `implsByInterfaceDefId` : interface/trait → classes that implement it.
12
+ *
13
+ * **Not an MRO implementation.** The build function is a pure aggregator: it
14
+ * asks the caller (via `computeMro` and `implementsOf` callbacks) for the
15
+ * per-language answers and materializes the two-way index. MRO strategies
16
+ * live where they already do today (`model/resolve.ts § c3Linearize`,
17
+ * `languages/ruby.ts § selectDispatch`, etc.) — this index does not
18
+ * reimplement them.
19
+ *
20
+ * Why callbacks and not a shared strategy registry: the five strategies
21
+ * (Python C3, Ruby kind-aware, Java/Kotlin linear, Rust qualified-syntax,
22
+ * COBOL none) already exist in the CLI package and depend on the CLI's
23
+ * `HeritageMap` + `SemanticModel`. Pulling them into `gitnexus-shared` would
24
+ * require migrating both — out of scope for #914. Callbacks let the shared
25
+ * build stay pure while honoring existing strategies verbatim.
26
+ *
27
+ * Consumed by: #917 (`Registry.lookupMethod` MRO fast path, interface
28
+ * dispatch resolver).
29
+ */
30
+ // ─── Builder ────────────────────────────────────────────────────────────────
31
+ export function buildMethodDispatchIndex(input) {
32
+ const mroByOwnerDefId = new Map();
33
+ const implsBuilding = new Map();
34
+ const implsSeen = new Map();
35
+ for (const ownerId of input.owners) {
36
+ // First-write-wins on duplicate owner ids: a stable policy consistent
37
+ // with sibling indexes (#913 DefIndex / ModuleScopeIndex).
38
+ if (!mroByOwnerDefId.has(ownerId)) {
39
+ const chain = input.computeMro(ownerId);
40
+ mroByOwnerDefId.set(ownerId, Object.freeze(chain.slice()));
41
+ }
42
+ for (const ifaceId of input.implementsOf(ownerId)) {
43
+ let seen = implsSeen.get(ifaceId);
44
+ if (seen === undefined) {
45
+ seen = new Set();
46
+ implsSeen.set(ifaceId, seen);
47
+ }
48
+ if (seen.has(ownerId))
49
+ continue;
50
+ seen.add(ownerId);
51
+ let bucket = implsBuilding.get(ifaceId);
52
+ if (bucket === undefined) {
53
+ bucket = [];
54
+ implsBuilding.set(ifaceId, bucket);
55
+ }
56
+ bucket.push(ownerId);
57
+ }
58
+ }
59
+ const implsByInterfaceDefId = new Map();
60
+ for (const [ifaceId, owners] of implsBuilding) {
61
+ implsByInterfaceDefId.set(ifaceId, Object.freeze(owners.slice()));
62
+ }
63
+ return freezeIndex(mroByOwnerDefId, implsByInterfaceDefId);
64
+ }
65
+ // ─── Internal ───────────────────────────────────────────────────────────────
66
+ const EMPTY = Object.freeze([]);
67
+ function freezeIndex(mroByOwnerDefId, implsByInterfaceDefId) {
68
+ return {
69
+ mroByOwnerDefId,
70
+ implsByInterfaceDefId,
71
+ mroFor(ownerDefId) {
72
+ return mroByOwnerDefId.get(ownerDefId) ?? EMPTY;
73
+ },
74
+ implementorsOf(interfaceDefId) {
75
+ return implsByInterfaceDefId.get(interfaceDefId) ?? EMPTY;
76
+ },
77
+ };
78
+ }
79
+ //# sourceMappingURL=method-dispatch-index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"method-dispatch-index.js","sourceRoot":"","sources":["../../src/scope-resolution/method-dispatch-index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAiDH,+EAA+E;AAE/E,MAAM,UAAU,wBAAwB,CAAC,KAA0B;IACjE,MAAM,eAAe,GAAG,IAAI,GAAG,EAA2B,CAAC;IAC3D,MAAM,aAAa,GAAG,IAAI,GAAG,EAAkB,CAAC;IAChD,MAAM,SAAS,GAAG,IAAI,GAAG,EAAqB,CAAC;IAE/C,KAAK,MAAM,OAAO,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC;QACnC,sEAAsE;QACtE,2DAA2D;QAC3D,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,MAAM,KAAK,GAAG,KAAK,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;YACxC,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;QAC7D,CAAC;QAED,KA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AU,CAAC,IAAI,KAAK,CAAC;QAClD,CAAC;QACD,cAAc,CAAC,cAAqB;YAClC,OAAO,qBAAqB,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,KAAK,CAAC;QAC5D,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,62 @@
1
+ /**
2
+ * `resolveTypeRef` — strict single-return resolver for `TypeRef`s
3
+ * (RFC §4.6; Ring 2 SHARED #916).
4
+ *
5
+ * Narrower contract than `Registry.lookup`: no name-only global fallback, no
6
+ * confidence ranking, no arity check. Used by `Registry.lookup` Step 2 (type-
7
+ * binding propagation) and by any caller that wants the single best type-
8
+ * target for an annotation without paying for the full evidence pipeline.
9
+ *
10
+ * **Algorithm (strict).** Walk the scope chain from `ref.declaredAtScope`:
11
+ *
12
+ * 1. At each scope, inspect `bindings.get(ref.rawName)`:
13
+ * - If one of the bindings is a **type-kind** def with a **strict origin**
14
+ * (`'local' | 'import' | 'namespace' | 'reexport'`), return it.
15
+ * - If any binding for this name exists at this scope but none qualifies
16
+ * (e.g., a local variable named `User` shadows an outer import of class
17
+ * `User`), return `null`. The nearer binding shadows; we do NOT fall
18
+ * through to the global qualified-name index.
19
+ * - Otherwise continue to the parent scope.
20
+ * 2. If the raw name is a dotted path (e.g., `'models.User'`) and the scope
21
+ * walk produced no match, consult `QualifiedNameIndex.byQualifiedName`.
22
+ * Only accept **exactly one** type-kind hit — anything ambiguous returns
23
+ * `null` rather than a guess.
24
+ * 3. Return `null`.
25
+ *
26
+ * **What `'strict' origins' means.** `'wildcard'` is intentionally excluded.
27
+ * A wildcard-expanded name (`from x import *`) is too loose to use as an
28
+ * anchor for type resolution — it gives no signal about whether the name was
29
+ * actually imported. `Registry.lookup` may accept wildcard bindings at its
30
+ * own discretion (with lower evidence weight); `resolveTypeRef` does not.
31
+ *
32
+ * **What 'type-kind' means.** The subset of `NodeLabel` that a type annotation
33
+ * may legitimately reference: class-like, interface-like, enum-like, and
34
+ * alias-like kinds. See `TYPE_KINDS` below.
35
+ *
36
+ * Pure function — safe to call repeatedly; no side effects.
37
+ */
38
+ import type { SymbolDefinition } from './symbol-definition.js';
39
+ import type { Scope, ScopeId, TypeRef } from './types.js';
40
+ import type { DefIndex } from './def-index.js';
41
+ import type { QualifiedNameIndex } from './qualified-name-index.js';
42
+ /**
43
+ * Minimal scope-lookup contract required by `resolveTypeRef`. Implemented by
44
+ * the `ScopeTree` from #912; declared here so #916 can ship as a standalone
45
+ * piece without a hard dependency on the full scope-tree implementation. Any
46
+ * structure that hands back a `Scope` by `ScopeId` satisfies this contract.
47
+ */
48
+ export interface ScopeLookup {
49
+ getScope(id: ScopeId): Scope | undefined;
50
+ }
51
+ /**
52
+ * All inputs `resolveTypeRef` needs from the semantic model. Bundled into a
53
+ * context object so the call site stays short and the interface is stable as
54
+ * additional indexes get threaded through in later rings.
55
+ */
56
+ export interface ResolveTypeRefContext {
57
+ readonly scopes: ScopeLookup;
58
+ readonly defIndex: DefIndex;
59
+ readonly qualifiedNameIndex: QualifiedNameIndex;
60
+ }
61
+ export declare function resolveTypeRef(ref: TypeRef, ctx: ResolveTypeRefContext): SymbolDefinition | null;
62
+ //# sourceMappingURL=resolve-type-ref.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-type-ref.d.ts","sourceRoot":"","sources":["../../src/scope-resolution/resolve-type-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AAGH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC/D,OAAO,KAAK,EAAc,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AACtE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAIpE;;;;;GAKG;AACH,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,EAAE,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAAC;CAC1C;AAED;;;;GAIG;AACH,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC5B,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,CAAC;CACjD;AAsCD,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,qBAAqB,GAAG,gBAAgB,GAAG,IAAI,CAgDhG"}
@@ -0,0 +1,120 @@
1
+ /**
2
+ * `resolveTypeRef` — strict single-return resolver for `TypeRef`s
3
+ * (RFC §4.6; Ring 2 SHARED #916).
4
+ *
5
+ * Narrower contract than `Registry.lookup`: no name-only global fallback, no
6
+ * confidence ranking, no arity check. Used by `Registry.lookup` Step 2 (type-
7
+ * binding propagation) and by any caller that wants the single best type-
8
+ * target for an annotation without paying for the full evidence pipeline.
9
+ *
10
+ * **Algorithm (strict).** Walk the scope chain from `ref.declaredAtScope`:
11
+ *
12
+ * 1. At each scope, inspect `bindings.get(ref.rawName)`:
13
+ * - If one of the bindings is a **type-kind** def with a **strict origin**
14
+ * (`'local' | 'import' | 'namespace' | 'reexport'`), return it.
15
+ * - If any binding for this name exists at this scope but none qualifies
16
+ * (e.g., a local variable named `User` shadows an outer import of class
17
+ * `User`), return `null`. The nearer binding shadows; we do NOT fall
18
+ * through to the global qualified-name index.
19
+ * - Otherwise continue to the parent scope.
20
+ * 2. If the raw name is a dotted path (e.g., `'models.User'`) and the scope
21
+ * walk produced no match, consult `QualifiedNameIndex.byQualifiedName`.
22
+ * Only accept **exactly one** type-kind hit — anything ambiguous returns
23
+ * `null` rather than a guess.
24
+ * 3. Return `null`.
25
+ *
26
+ * **What `'strict' origins' means.** `'wildcard'` is intentionally excluded.
27
+ * A wildcard-expanded name (`from x import *`) is too loose to use as an
28
+ * anchor for type resolution — it gives no signal about whether the name was
29
+ * actually imported. `Registry.lookup` may accept wildcard bindings at its
30
+ * own discretion (with lower evidence weight); `resolveTypeRef` does not.
31
+ *
32
+ * **What 'type-kind' means.** The subset of `NodeLabel` that a type annotation
33
+ * may legitimately reference: class-like, interface-like, enum-like, and
34
+ * alias-like kinds. See `TYPE_KINDS` below.
35
+ *
36
+ * Pure function — safe to call repeatedly; no side effects.
37
+ */
38
+ // ─── Strict policy constants ────────────────────────────────────────────────
39
+ /** `'wildcard'` is deliberately absent. See file header. */
40
+ const STRICT_ORIGINS = new Set([
41
+ 'local',
42
+ 'import',
43
+ 'namespace',
44
+ 'reexport',
45
+ ]);
46
+ /**
47
+ * `NodeLabel` values that may appear on the RHS of a type annotation.
48
+ *
49
+ * Includes the usual class-like and interface-like kinds plus the alias-like
50
+ * ones (`TypeAlias`, `Typedef`). `Namespace` is excluded — it is a scope
51
+ * container, not a value type. `Function` / `Method` / `Variable` are
52
+ * excluded by design: a `rawName` bound to them at a strict origin is a
53
+ * *shadowing* binding, which the algorithm short-circuits to `null`.
54
+ */
55
+ const TYPE_KINDS = new Set([
56
+ 'Class',
57
+ 'Interface',
58
+ 'Enum',
59
+ 'Struct',
60
+ 'Union',
61
+ 'Trait',
62
+ 'TypeAlias',
63
+ 'Typedef',
64
+ 'Record',
65
+ 'Delegate',
66
+ 'Annotation',
67
+ 'Template',
68
+ ]);
69
+ // ─── Main entry point ──────────────────────────────────────────────────────
70
+ export function resolveTypeRef(ref, ctx) {
71
+ // Phase 1: scope-chain walk anchored at the declaration site.
72
+ let currentId = ref.declaredAtScope;
73
+ const visited = new Set();
74
+ while (currentId !== null) {
75
+ // Cycle guard — a well-formed scope tree never loops, but a bug in the
76
+ // construction path should fail fast here rather than hanging.
77
+ if (visited.has(currentId))
78
+ return null;
79
+ visited.add(currentId);
80
+ const scope = ctx.scopes.getScope(currentId);
81
+ if (scope === undefined)
82
+ return null; // broken chain = unresolvable
83
+ const bindings = scope.bindings.get(ref.rawName);
84
+ if (bindings !== undefined && bindings.length > 0) {
85
+ // At least one binding exists at this scope → it is the shadowing site.
86
+ // Either one of them qualifies, or the name is shadowed by a non-type.
87
+ for (const binding of bindings) {
88
+ if (!STRICT_ORIGINS.has(binding.origin))
89
+ continue;
90
+ if (TYPE_KINDS.has(binding.def.type)) {
91
+ return binding.def;
92
+ }
93
+ }
94
+ // Shadowed by a non-type / non-strict-origin binding. Fail fast — no
95
+ // global fallback, no walk to the parent.
96
+ return null;
97
+ }
98
+ currentId = scope.parent;
99
+ }
100
+ // Phase 2: dotted fallback via `QualifiedNameIndex`. Only accept a unique
101
+ // type-kind hit; anything ambiguous returns null (strict: no guesses).
102
+ if (ref.rawName.includes('.')) {
103
+ const candidates = ctx.qualifiedNameIndex.get(ref.rawName);
104
+ let onlyTypeDef = null;
105
+ for (const defId of candidates) {
106
+ const def = ctx.defIndex.get(defId);
107
+ if (def === undefined)
108
+ continue;
109
+ if (!TYPE_KINDS.has(def.type))
110
+ continue;
111
+ if (onlyTypeDef !== null)
112
+ return null; // ambiguous
113
+ onlyTypeDef = def;
114
+ }
115
+ if (onlyTypeDef !== null)
116
+ return onlyTypeDef;
117
+ }
118
+ return null;
119
+ }
120
+ //# sourceMappingURL=resolve-type-ref.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resolve-type-ref.js","sourceRoot":"","sources":["../../src/scope-resolution/resolve-type-ref.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AA+BH,+EAA+E;AAE/E,4DAA4D;AAC5D,MAAM,cAAc,GAAsC,IAAI,GAAG,CAAuB;IACtF,OAAO;IACP,QAAQ;IACR,WAAW;IACX,UAAU;CACX,CAAC,CAAC;AAEH;;;;;;;;GAQG;AACH,MAAM,UAAU,GAA2B,IAAI,GAAG,CAAY;IAC5D,OAAO;IACP,WAAW;IACX,MAAM;IACN,QAAQ;IACR,OAAO;IACP,OAAO;IACP,WAAW;IACX,SAAS;IACT,QAAQ;IACR,UAAU;IACV,YAAY;IACZ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CAAC,EAAE,CAAC;QAC9B,MAAM,UAAU,GAAG,GAAG,CAAC,kBAAkB,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QAC3D,IAAI,WAAW,GAA4B,IAAI,CAAC;QAChD,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;YAC/B,MAAM,GAAG,GAAG,GAAG,CAAC,QAAQ,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;YACpC,IAAI,GAAG,KAAK,SAAS;gBAAE,SAAS;YAChC,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC;gBAAE,SAAS;YACxC,IAAI,WAAW,KAAK,IAAI;gBAAE,OAAO,IAAI,CAAC,CAAC,YAAY;YACnD,WAAW,GAAG,GAAG,CAAC;QACpB,CAAC;QACD,IAAI,WAAW,KAAK,IAAI;YAAE,OAAO,WAAW,CAAC;IAC/C,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitnexus",
3
- "version": "1.6.3-rc.5",
3
+ "version": "1.6.3-rc.6",
4
4
  "description": "Graph-powered code intelligence for AI agents. Index any codebase, query via MCP or CLI.",
5
5
  "author": "Abhigyan Patwari",
6
6
  "license": "PolyForm-Noncommercial-1.0.0",