gitnexus 1.6.6-rc.99 → 1.6.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.
- package/README.md +122 -68
- package/dist/_shared/graph/types.d.ts +17 -1
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +3 -5
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +2 -4
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.d.ts +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/module-scope-index.js +1 -2
- package/dist/_shared/scope-resolution/module-scope-index.js.map +1 -1
- package/dist/_shared/scope-resolution/parsed-file.d.ts +24 -0
- package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts +13 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.d.ts +1 -0
- package/dist/_shared/scope-resolution/registries/context.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/context.js +6 -0
- package/dist/_shared/scope-resolution/registries/context.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.d.ts +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/evidence.js +2 -3
- package/dist/_shared/scope-resolution/registries/evidence.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts +29 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.d.ts.map +1 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js +32 -0
- package/dist/_shared/scope-resolution/registries/macro-registry.js.map +1 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts +9 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +1 -1
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/cli/ai-context.d.ts +35 -1
- package/dist/cli/ai-context.js +111 -12
- package/dist/cli/analyze-config.d.ts +92 -0
- package/dist/cli/analyze-config.js +364 -0
- package/dist/cli/analyze.d.ts +17 -1
- package/dist/cli/analyze.js +224 -71
- package/dist/cli/cli-message.d.ts +1 -1
- package/dist/cli/doctor.d.ts +18 -0
- package/dist/cli/doctor.js +32 -0
- package/dist/cli/i18n/en.d.ts +2 -2
- package/dist/cli/i18n/en.js +2 -2
- package/dist/cli/i18n/resources.d.ts +2 -2
- package/dist/cli/i18n/zh-CN.js +2 -2
- package/dist/cli/index.js +4 -2
- package/dist/cli/resolve-invocation.d.ts +21 -0
- package/dist/cli/resolve-invocation.js +68 -0
- package/dist/cli/setup.d.ts +33 -0
- package/dist/cli/setup.js +96 -35
- package/dist/cli/skill-gen.js +2 -2
- package/dist/cli/wiki.js +20 -4
- package/dist/core/embeddings/embedder.d.ts +1 -1
- package/dist/core/embeddings/embedder.js +14 -1
- package/dist/core/embeddings/runtime-support.d.ts +41 -0
- package/dist/core/embeddings/runtime-support.js +65 -0
- package/dist/core/group/extractors/grpc-patterns/proto.js +2 -1
- package/dist/core/group/extractors/http-patterns/java.js +15 -1
- package/dist/core/ingestion/call-processor.d.ts +57 -227
- package/dist/core/ingestion/call-processor.js +172 -2595
- package/dist/core/ingestion/call-routing.d.ts +6 -5
- package/dist/core/ingestion/call-routing.js +6 -6
- package/dist/core/ingestion/call-types.d.ts +0 -75
- package/dist/core/ingestion/class-extractors/configs/c-cpp.js +26 -1
- package/dist/core/ingestion/class-extractors/configs/ruby.js +3 -0
- package/dist/core/ingestion/class-extractors/generic.js +9 -11
- package/dist/core/ingestion/class-types.d.ts +23 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.d.ts +11 -0
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +227 -73
- package/dist/core/ingestion/cobol-processor.d.ts +1 -0
- package/dist/core/ingestion/cobol-processor.js +51 -2
- package/dist/core/ingestion/emit-references.js +8 -2
- package/dist/core/ingestion/export-detection.d.ts +2 -1
- package/dist/core/ingestion/export-detection.js +2 -6
- package/dist/core/ingestion/field-extractors/configs/dart.d.ts +0 -6
- package/dist/core/ingestion/field-extractors/configs/dart.js +62 -44
- package/dist/core/ingestion/field-extractors/configs/go.d.ts +0 -9
- package/dist/core/ingestion/field-extractors/configs/go.js +40 -1
- package/dist/core/ingestion/field-extractors/configs/jvm.js +43 -4
- package/dist/core/ingestion/field-extractors/configs/php.js +1 -2
- package/dist/core/ingestion/field-extractors/configs/swift.d.ts +12 -1
- package/dist/core/ingestion/field-extractors/configs/swift.js +31 -6
- package/dist/core/ingestion/field-extractors/generic.d.ts +6 -0
- package/dist/core/ingestion/field-extractors/generic.js +5 -4
- package/dist/core/ingestion/field-extractors/typescript.js +0 -29
- package/dist/core/ingestion/filesystem-walker.d.ts +0 -9
- package/dist/core/ingestion/filesystem-walker.js +0 -11
- package/dist/core/ingestion/finalize-orchestrator.js +14 -2
- package/dist/core/ingestion/import-resolvers/configs/swift.d.ts +21 -0
- package/dist/core/ingestion/import-resolvers/configs/swift.js +72 -11
- package/dist/core/ingestion/import-resolvers/python.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/standard.d.ts +2 -2
- package/dist/core/ingestion/import-resolvers/standard.js +6 -5
- package/dist/core/ingestion/import-resolvers/utils.d.ts +2 -5
- package/dist/core/ingestion/import-resolvers/utils.js +1 -9
- package/dist/core/ingestion/language-provider.d.ts +39 -119
- package/dist/core/ingestion/language-provider.js +0 -2
- package/dist/core/ingestion/languages/c/capture-side-channel.d.ts +62 -0
- package/dist/core/ingestion/languages/c/capture-side-channel.js +65 -0
- package/dist/core/ingestion/languages/c/captures.js +41 -23
- package/dist/core/ingestion/languages/c/import-decomposer.d.ts +9 -0
- package/dist/core/ingestion/languages/c/import-decomposer.js +15 -0
- package/dist/core/ingestion/languages/c/import-target.js +52 -9
- package/dist/core/ingestion/languages/c/index.d.ts +2 -1
- package/dist/core/ingestion/languages/c/index.js +2 -1
- package/dist/core/ingestion/languages/c/query.js +15 -0
- package/dist/core/ingestion/languages/c/scope-resolver.js +47 -4
- package/dist/core/ingestion/languages/c/static-linkage.d.ts +8 -0
- package/dist/core/ingestion/languages/c/static-linkage.js +46 -1
- package/dist/core/ingestion/languages/c-cpp.js +16 -7
- package/dist/core/ingestion/languages/cobol/captures.js +25 -2
- package/dist/core/ingestion/languages/cpp/adl.d.ts +88 -4
- package/dist/core/ingestion/languages/cpp/adl.js +380 -160
- package/dist/core/ingestion/languages/cpp/arity-metadata.js +2 -8
- package/dist/core/ingestion/languages/cpp/capture-side-channel.d.ts +65 -0
- package/dist/core/ingestion/languages/cpp/capture-side-channel.js +78 -0
- package/dist/core/ingestion/languages/cpp/captures.js +162 -54
- package/dist/core/ingestion/languages/cpp/file-local-linkage.d.ts +18 -52
- package/dist/core/ingestion/languages/cpp/file-local-linkage.js +49 -1
- package/dist/core/ingestion/languages/cpp/import-decomposer.d.ts +7 -0
- package/dist/core/ingestion/languages/cpp/import-decomposer.js +12 -0
- package/dist/core/ingestion/languages/cpp/index.d.ts +1 -0
- package/dist/core/ingestion/languages/cpp/index.js +1 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.d.ts +8 -0
- package/dist/core/ingestion/languages/cpp/inline-namespaces.js +21 -0
- package/dist/core/ingestion/languages/cpp/query.js +21 -0
- package/dist/core/ingestion/languages/cpp/range-bindings.js +20 -5
- package/dist/core/ingestion/languages/cpp/scope-resolver.js +52 -5
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.d.ts +20 -0
- package/dist/core/ingestion/languages/cpp/two-phase-lookup.js +83 -3
- package/dist/core/ingestion/languages/csharp/captures.js +205 -41
- package/dist/core/ingestion/languages/csharp/index.d.ts +3 -4
- package/dist/core/ingestion/languages/csharp/index.js +3 -4
- package/dist/core/ingestion/languages/csharp/interpret.js +17 -3
- package/dist/core/ingestion/languages/csharp/namespace-siblings.d.ts +17 -7
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +129 -124
- package/dist/core/ingestion/languages/csharp/qualified-type-names.d.ts +14 -0
- package/dist/core/ingestion/languages/csharp/qualified-type-names.js +59 -0
- package/dist/core/ingestion/languages/csharp/query.js +13 -0
- package/dist/core/ingestion/languages/csharp/receiver-binding.js +10 -6
- package/dist/core/ingestion/languages/csharp/scope-resolver.js +8 -1
- package/dist/core/ingestion/languages/csharp.js +0 -5
- package/dist/core/ingestion/languages/dart/arity-metadata.d.ts +25 -0
- package/dist/core/ingestion/languages/dart/arity-metadata.js +35 -0
- package/dist/core/ingestion/languages/dart/arity.d.ts +19 -0
- package/dist/core/ingestion/languages/dart/arity.js +31 -0
- package/dist/core/ingestion/languages/dart/built-ins.d.ts +11 -0
- package/dist/core/ingestion/languages/dart/built-ins.js +34 -0
- package/dist/core/ingestion/languages/dart/cache-stats.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/cache-stats.js +24 -0
- package/dist/core/ingestion/languages/dart/captures.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/captures.js +445 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.d.ts +13 -0
- package/dist/core/ingestion/languages/dart/expand-wildcards.js +31 -0
- package/dist/core/ingestion/languages/dart/import-target.d.ts +15 -0
- package/dist/core/ingestion/languages/dart/import-target.js +65 -0
- package/dist/core/ingestion/languages/dart/index.d.ts +28 -0
- package/dist/core/ingestion/languages/dart/index.js +28 -0
- package/dist/core/ingestion/languages/dart/interpret.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/interpret.js +95 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.d.ts +10 -0
- package/dist/core/ingestion/languages/dart/merge-bindings.js +39 -0
- package/dist/core/ingestion/languages/dart/query.d.ts +26 -0
- package/dist/core/ingestion/languages/dart/query.js +142 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.d.ts +24 -0
- package/dist/core/ingestion/languages/dart/receiver-binding.js +87 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.d.ts +29 -0
- package/dist/core/ingestion/languages/dart/scope-resolver.js +194 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.d.ts +23 -0
- package/dist/core/ingestion/languages/dart/signature-bindings.js +51 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.d.ts +20 -0
- package/dist/core/ingestion/languages/dart/simple-hooks.js +47 -0
- package/dist/core/ingestion/languages/dart.d.ts +0 -1
- package/dist/core/ingestion/languages/dart.js +15 -29
- package/dist/core/ingestion/languages/go/arity-metadata.d.ts +1 -0
- package/dist/core/ingestion/languages/go/arity-metadata.js +31 -1
- package/dist/core/ingestion/languages/go/captures.js +162 -3
- package/dist/core/ingestion/languages/go/interface-impls.js +476 -50
- package/dist/core/ingestion/languages/go/interpret.js +21 -11
- package/dist/core/ingestion/languages/go/method-owners.js +20 -8
- package/dist/core/ingestion/languages/go/query.js +15 -7
- package/dist/core/ingestion/languages/go/range-binding.js +24 -9
- package/dist/core/ingestion/languages/go/receiver-binding.js +1 -1
- package/dist/core/ingestion/languages/go/scope-resolver.js +2 -2
- package/dist/core/ingestion/languages/go/simple-hooks.js +10 -5
- package/dist/core/ingestion/languages/go/type-binding.d.ts +1 -0
- package/dist/core/ingestion/languages/go/type-binding.js +40 -2
- package/dist/core/ingestion/languages/go.d.ts +0 -1
- package/dist/core/ingestion/languages/go.js +0 -5
- package/dist/core/ingestion/languages/index.d.ts +0 -5
- package/dist/core/ingestion/languages/index.js +0 -3
- package/dist/core/ingestion/languages/java/captures.js +252 -23
- package/dist/core/ingestion/languages/java/interpret.js +12 -6
- package/dist/core/ingestion/languages/java/package-siblings.js +18 -5
- package/dist/core/ingestion/languages/java/query.js +16 -1
- package/dist/core/ingestion/languages/java/scope-resolver.d.ts +2 -8
- package/dist/core/ingestion/languages/java/scope-resolver.js +2 -8
- package/dist/core/ingestion/languages/java.js +0 -5
- package/dist/core/ingestion/languages/javascript/captures.js +185 -11
- package/dist/core/ingestion/languages/javascript/query.js +107 -1
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +57 -0
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +60 -0
- package/dist/core/ingestion/languages/kotlin/captures.js +213 -22
- package/dist/core/ingestion/languages/kotlin/companion-scopes.d.ts +7 -0
- package/dist/core/ingestion/languages/kotlin/companion-scopes.js +10 -0
- package/dist/core/ingestion/languages/kotlin/index.d.ts +1 -0
- package/dist/core/ingestion/languages/kotlin/index.js +1 -0
- package/dist/core/ingestion/languages/kotlin/query.js +30 -0
- package/dist/core/ingestion/languages/kotlin/scope-resolver.d.ts +5 -7
- package/dist/core/ingestion/languages/kotlin/scope-resolver.js +22 -7
- package/dist/core/ingestion/languages/kotlin.js +8 -5
- package/dist/core/ingestion/languages/php/captures.js +135 -19
- package/dist/core/ingestion/languages/php/import-decomposer.js +21 -63
- package/dist/core/ingestion/languages/php/index.d.ts +3 -4
- package/dist/core/ingestion/languages/php/index.js +3 -4
- package/dist/core/ingestion/languages/php/query.js +5 -0
- package/dist/core/ingestion/languages/php/receiver-binding.js +8 -4
- package/dist/core/ingestion/languages/php.js +0 -4
- package/dist/core/ingestion/languages/python/captures.js +128 -13
- package/dist/core/ingestion/languages/python/depends-references.js +1 -1
- package/dist/core/ingestion/languages/python/import-target.d.ts +4 -5
- package/dist/core/ingestion/languages/python/import-target.js +108 -16
- package/dist/core/ingestion/languages/python/index-stats.d.ts +18 -0
- package/dist/core/ingestion/languages/python/index-stats.js +25 -0
- package/dist/core/ingestion/languages/python/index.d.ts +3 -4
- package/dist/core/ingestion/languages/python/index.js +3 -4
- package/dist/core/ingestion/languages/python/query.js +17 -0
- package/dist/core/ingestion/languages/python/scope-resolver.js +7 -6
- package/dist/core/ingestion/languages/python.d.ts +0 -2
- package/dist/core/ingestion/languages/python.js +0 -7
- package/dist/core/ingestion/languages/ruby/captures.js +174 -31
- package/dist/core/ingestion/languages/ruby/import-target.js +2 -1
- package/dist/core/ingestion/languages/ruby/interpret.js +2 -1
- package/dist/core/ingestion/languages/ruby/query.js +10 -0
- package/dist/core/ingestion/languages/ruby/scope-resolver.js +61 -11
- package/dist/core/ingestion/languages/ruby.js +4 -53
- package/dist/core/ingestion/languages/rust/captures.js +95 -13
- package/dist/core/ingestion/languages/rust/query.js +64 -1
- package/dist/core/ingestion/languages/rust/range-binding.js +40 -12
- package/dist/core/ingestion/languages/rust/receiver-binding.js +9 -0
- package/dist/core/ingestion/languages/rust/scope-resolver.js +75 -1
- package/dist/core/ingestion/languages/rust.d.ts +0 -2
- package/dist/core/ingestion/languages/rust.js +0 -6
- package/dist/core/ingestion/languages/swift/arity-metadata.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/arity-metadata.js +41 -0
- package/dist/core/ingestion/languages/swift/arity.d.ts +29 -0
- package/dist/core/ingestion/languages/swift/arity.js +42 -0
- package/dist/core/ingestion/languages/swift/base-type.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/base-type.js +27 -0
- package/dist/core/ingestion/languages/swift/cache-stats.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/cache-stats.js +26 -0
- package/dist/core/ingestion/languages/swift/captures.d.ts +35 -0
- package/dist/core/ingestion/languages/swift/captures.js +495 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/implicit-imports.js +57 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.d.ts +24 -0
- package/dist/core/ingestion/languages/swift/import-decomposer.js +84 -0
- package/dist/core/ingestion/languages/swift/import-target.d.ts +33 -0
- package/dist/core/ingestion/languages/swift/import-target.js +81 -0
- package/dist/core/ingestion/languages/swift/index.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/index.js +37 -0
- package/dist/core/ingestion/languages/swift/interpret.d.ts +15 -0
- package/dist/core/ingestion/languages/swift/interpret.js +89 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.d.ts +20 -0
- package/dist/core/ingestion/languages/swift/merge-bindings.js +48 -0
- package/dist/core/ingestion/languages/swift/query.d.ts +46 -0
- package/dist/core/ingestion/languages/swift/query.js +194 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +40 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.js +161 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.d.ts +50 -0
- package/dist/core/ingestion/languages/swift/scope-resolver.js +189 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.d.ts +34 -0
- package/dist/core/ingestion/languages/swift/sibling-type-bindings.js +65 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.d.ts +25 -0
- package/dist/core/ingestion/languages/swift/signature-bindings.js +66 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.d.ts +37 -0
- package/dist/core/ingestion/languages/swift/simple-hooks.js +60 -0
- package/dist/core/ingestion/languages/swift/target-grouping.d.ts +51 -0
- package/dist/core/ingestion/languages/swift/target-grouping.js +93 -0
- package/dist/core/ingestion/languages/swift/target-siblings.d.ts +30 -0
- package/dist/core/ingestion/languages/swift/target-siblings.js +71 -0
- package/dist/core/ingestion/languages/swift.d.ts +0 -5
- package/dist/core/ingestion/languages/swift.js +11 -87
- package/dist/core/ingestion/languages/typescript/array-callback.d.ts +3 -29
- package/dist/core/ingestion/languages/typescript/array-callback.js +4 -43
- package/dist/core/ingestion/languages/typescript/captures.js +147 -17
- package/dist/core/ingestion/languages/typescript/index.d.ts +3 -4
- package/dist/core/ingestion/languages/typescript/index.js +3 -4
- package/dist/core/ingestion/languages/typescript/query.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript/query.js +125 -4
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +0 -1
- package/dist/core/ingestion/languages/typescript.d.ts +2 -3
- package/dist/core/ingestion/languages/typescript.js +46 -23
- package/dist/core/ingestion/languages/vue/captures.d.ts +46 -0
- package/dist/core/ingestion/languages/vue/captures.js +67 -0
- package/dist/core/ingestion/languages/vue/import-target.d.ts +27 -0
- package/dist/core/ingestion/languages/vue/import-target.js +58 -0
- package/dist/core/ingestion/languages/vue/index.d.ts +49 -0
- package/dist/core/ingestion/languages/vue/index.js +49 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.d.ts +55 -0
- package/dist/core/ingestion/languages/vue/scope-resolver.js +292 -0
- package/dist/core/ingestion/languages/vue.js +12 -4
- package/dist/core/ingestion/local-symbol-pruner.d.ts +11 -0
- package/dist/core/ingestion/local-symbol-pruner.js +63 -0
- package/dist/core/ingestion/method-extractors/configs/dart.js +14 -1
- package/dist/core/ingestion/method-extractors/configs/jvm.js +37 -20
- package/dist/core/ingestion/method-extractors/configs/php.js +0 -1
- package/dist/core/ingestion/method-extractors/configs/swift.js +11 -4
- package/dist/core/ingestion/method-types.d.ts +2 -2
- package/dist/core/ingestion/model/index.d.ts +0 -3
- package/dist/core/ingestion/model/index.js +0 -8
- package/dist/core/ingestion/model/resolve.d.ts +7 -43
- package/dist/core/ingestion/model/resolve.js +7 -226
- package/dist/core/ingestion/model/scope-resolution-indexes.d.ts +46 -1
- package/dist/core/ingestion/model/semantic-model.d.ts +4 -6
- package/dist/core/ingestion/model/semantic-model.js +1 -1
- package/dist/core/ingestion/model/symbol-table.d.ts +3 -4
- package/dist/core/ingestion/model/symbol-table.js +3 -4
- package/dist/core/ingestion/parsing-processor.d.ts +30 -24
- package/dist/core/ingestion/parsing-processor.js +76 -640
- package/dist/core/ingestion/pipeline-phases/communities.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/communities.js +5 -2
- package/dist/core/ingestion/pipeline-phases/cross-file.d.ts +9 -8
- package/dist/core/ingestion/pipeline-phases/cross-file.js +16 -12
- package/dist/core/ingestion/pipeline-phases/index.d.ts +1 -0
- package/dist/core/ingestion/pipeline-phases/index.js +1 -0
- package/dist/core/ingestion/pipeline-phases/mro.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/mro.js +2 -2
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +44 -22
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +426 -565
- package/dist/core/ingestion/pipeline-phases/parse.d.ts +13 -33
- package/dist/core/ingestion/pipeline-phases/parse.js +2 -2
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +1 -1
- package/dist/core/ingestion/pipeline-phases/processes.js +5 -3
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.d.ts +14 -0
- package/dist/core/ingestion/pipeline-phases/prune-local-symbols.js +26 -0
- package/dist/core/ingestion/pipeline.d.ts +27 -19
- package/dist/core/ingestion/pipeline.js +4 -2
- package/dist/core/ingestion/resolve-references.js +15 -3
- package/dist/core/ingestion/route-extractors/laravel.d.ts +10 -0
- package/dist/core/ingestion/route-extractors/laravel.js +88 -9
- package/dist/core/ingestion/scope-extractor-bridge.d.ts +2 -1
- package/dist/core/ingestion/scope-extractor-bridge.js +2 -2
- package/dist/core/ingestion/scope-extractor.js +13 -0
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +181 -15
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +21 -10
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +10 -2
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +7 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +58 -6
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +24 -5
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +68 -1
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +189 -29
- package/dist/core/ingestion/scope-resolution/passes/imported-return-types.js +21 -1
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +1 -1
- package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +8 -11
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +171 -50
- package/dist/core/ingestion/scope-resolution/pipeline/registry.d.ts +3 -4
- package/dist/core/ingestion/scope-resolution/pipeline/registry.js +9 -4
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +28 -5
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +191 -24
- package/dist/core/ingestion/scope-resolution/pipeline/validate-bindings-immutability.js +31 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +72 -0
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +440 -39
- package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +18 -2
- package/dist/core/ingestion/scope-resolution/workspace-index.js +94 -7
- package/dist/core/ingestion/tree-sitter-queries.d.ts +14 -14
- package/dist/core/ingestion/tree-sitter-queries.js +380 -158
- package/dist/core/ingestion/ts-js-hoc-utils.d.ts +12 -0
- package/dist/core/ingestion/ts-js-hoc-utils.js +105 -0
- package/dist/core/ingestion/type-env.d.ts +2 -1
- package/dist/core/ingestion/type-env.js +6 -8
- package/dist/core/ingestion/type-extractors/c-cpp.js +8 -10
- package/dist/core/ingestion/type-extractors/csharp.js +18 -34
- package/dist/core/ingestion/type-extractors/go.js +2 -10
- package/dist/core/ingestion/type-extractors/jvm.js +6 -5
- package/dist/core/ingestion/type-extractors/php.js +1 -1
- package/dist/core/ingestion/type-extractors/python.js +1 -1
- package/dist/core/ingestion/type-extractors/ruby.js +2 -2
- package/dist/core/ingestion/type-extractors/rust.js +0 -16
- package/dist/core/ingestion/type-extractors/shared.d.ts +2 -2
- package/dist/core/ingestion/type-extractors/shared.js +25 -11
- package/dist/core/ingestion/type-extractors/swift.js +5 -5
- package/dist/core/ingestion/type-extractors/types.d.ts +1 -1
- package/dist/core/ingestion/type-extractors/typescript.js +1 -1
- package/dist/core/ingestion/utils/ast-helpers.d.ts +119 -1
- package/dist/core/ingestion/utils/ast-helpers.js +260 -13
- package/dist/core/ingestion/utils/callable-labels.d.ts +13 -0
- package/dist/core/ingestion/utils/callable-labels.js +14 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.d.ts +10 -0
- package/dist/core/ingestion/utils/deferred-resolution-profile.js +30 -0
- package/dist/core/ingestion/utils/heap-probe.d.ts +20 -0
- package/dist/core/ingestion/utils/heap-probe.js +39 -0
- package/dist/core/ingestion/utils/heritage-marker.d.ts +33 -0
- package/dist/core/ingestion/utils/heritage-marker.js +41 -0
- package/dist/core/ingestion/utils/qualified-name.d.ts +37 -0
- package/dist/core/ingestion/utils/qualified-name.js +67 -0
- package/dist/core/ingestion/variable-extractors/configs/c-cpp.js +49 -0
- package/dist/core/ingestion/variable-extractors/configs/dart.js +76 -62
- package/dist/core/ingestion/variable-extractors/configs/go.js +74 -7
- package/dist/core/ingestion/variable-extractors/configs/jvm.js +35 -8
- package/dist/core/ingestion/variable-extractors/generic.js +40 -12
- package/dist/core/ingestion/variable-types.d.ts +9 -0
- package/dist/core/ingestion/vue-sfc-extractor.d.ts +97 -7
- package/dist/core/ingestion/vue-sfc-extractor.js +433 -11
- package/dist/core/ingestion/workers/parse-worker.d.ts +0 -11
- package/dist/core/ingestion/workers/parse-worker.js +358 -187
- package/dist/core/ingestion/workers/worker-pool.d.ts +78 -9
- package/dist/core/ingestion/workers/worker-pool.js +346 -49
- package/dist/core/lbug/csv-generator.js +20 -2
- package/dist/core/lbug/lbug-adapter.js +29 -10
- package/dist/core/lbug/native-check.js +17 -5
- package/dist/core/lbug/pool-adapter.d.ts +0 -19
- package/dist/core/lbug/pool-adapter.js +40 -77
- package/dist/core/lbug/query-result-utils.d.ts +19 -0
- package/dist/core/lbug/query-result-utils.js +28 -0
- package/dist/core/run-analyze.d.ts +9 -2
- package/dist/core/run-analyze.js +24 -3
- package/dist/core/tree-sitter/parser-loader.d.ts +13 -0
- package/dist/core/tree-sitter/parser-loader.js +4 -0
- package/dist/core/tree-sitter/safe-parse.d.ts +70 -3
- package/dist/core/tree-sitter/safe-parse.js +214 -11
- package/dist/core/wiki/generator.js +13 -5
- package/dist/core/wiki/graph-queries.d.ts +3 -0
- package/dist/core/wiki/graph-queries.js +9 -1
- package/dist/core/wiki/llm-client.d.ts +1 -1
- package/dist/core/wiki/llm-client.js +7 -2
- package/dist/core/wiki/local-cli-client.d.ts +2 -1
- package/dist/core/wiki/local-cli-client.js +62 -4
- package/dist/mcp/compatible-stdio-transport.d.ts +3 -0
- package/dist/mcp/compatible-stdio-transport.js +22 -0
- package/dist/mcp/core/embedder.d.ts +1 -1
- package/dist/mcp/core/embedder.js +13 -1
- package/dist/mcp/local/local-backend.d.ts +37 -5
- package/dist/mcp/local/local-backend.js +227 -129
- package/dist/mcp/resources.js +3 -3
- package/dist/mcp/server.js +9 -1
- package/dist/storage/git.d.ts +11 -0
- package/dist/storage/git.js +30 -0
- package/dist/storage/parse-cache.d.ts +23 -1
- package/dist/storage/parse-cache.js +138 -32
- package/dist/storage/parsedfile-store.d.ts +142 -0
- package/dist/storage/parsedfile-store.js +367 -0
- package/dist/storage/repo-manager.d.ts +2 -1
- package/dist/storage/scope-index-store.d.ts +114 -0
- package/dist/storage/scope-index-store.js +236 -0
- package/dist/types/pipeline.d.ts +6 -3
- package/hooks/antigravity/gitnexus-antigravity-hook.cjs +2 -1
- package/hooks/claude/gitnexus-hook.cjs +2 -1
- package/hooks/claude/resolve-analyze-cmd.cjs +323 -0
- package/package.json +4 -5
- package/scripts/bench-scope-resolution.ts +1 -3
- package/scripts/cross-platform-tests.ts +4 -1
- package/skills/gitnexus-cli.md +8 -6
- package/skills/gitnexus-debugging.md +15 -15
- package/skills/gitnexus-exploring.md +11 -11
- package/skills/gitnexus-guide.md +1 -1
- package/skills/gitnexus-impact-analysis.md +10 -10
- package/skills/gitnexus-pr-review.md +19 -19
- package/skills/gitnexus-refactoring.md +25 -25
- package/web/assets/{agent-BRX-afm3.js → agent-EkX7webX.js} +156 -131
- package/web/assets/{architectureDiagram-UL44E2DR-B1oYB8-c.js → architectureDiagram-UL44E2DR-BoczH8cv.js} +1 -1
- package/web/assets/{chunk-LCXTWHL2-SPC6pgWI.js → chunk-LCXTWHL2-By5HB3b-.js} +1 -1
- package/web/assets/{chunk-RG4AUYOV-DZXr4Yv3.js → chunk-RG4AUYOV-BQE_DkpL.js} +1 -1
- package/web/assets/{classDiagram-KGZ6W3CR-BqpOj8L9.js → classDiagram-KGZ6W3CR-Dj_02GUH.js} +1 -1
- package/web/assets/{classDiagram-v2-72OJOZXJ-FmElywK2.js → classDiagram-v2-72OJOZXJ-D-NArMpf.js} +1 -1
- package/web/assets/{diagram-3NCE3AQN-BWtJXMDq.js → diagram-3NCE3AQN-VXtXDO95.js} +1 -1
- package/web/assets/{diagram-GF46GFSD-Hh-fChxU.js → diagram-GF46GFSD-B1qab2Ah.js} +1 -1
- package/web/assets/{diagram-QXG6HAR7-DYeQHxGU.js → diagram-QXG6HAR7-BSCHGzzT.js} +1 -1
- package/web/assets/{diagram-WEQXMOUZ-DYGU4T0y.js → diagram-WEQXMOUZ-DHtknmNT.js} +1 -1
- package/web/assets/{erDiagram-L5TCEMPS-bN3wlP2A.js → erDiagram-L5TCEMPS-Db-IYTmm.js} +1 -1
- package/web/assets/{flowDiagram-H6V6AXG4-YACVtF3-.js → flowDiagram-H6V6AXG4-BHDoyVoW.js} +1 -1
- package/web/assets/{index-BhnAdWTt.js → index-BR0IhgbR.js} +10 -10
- package/web/assets/{infoDiagram-3YFTVSEB-BWBzD28-.js → infoDiagram-3YFTVSEB-6h8wbWEe.js} +1 -1
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-B8qYT-j9.js → ishikawaDiagram-BNXS4ZKH-Dx2OkPk1.js} +1 -1
- package/web/assets/{kanban-definition-75IXJCU3-BeoPr5Tl.js → kanban-definition-75IXJCU3-CIIEZfqV.js} +1 -1
- package/web/assets/{mindmap-definition-2TDM6QVE-CdLLN_so.js → mindmap-definition-2TDM6QVE-DUAqydRq.js} +1 -1
- package/web/assets/{pieDiagram-CU6KROY3-DEd2a_k_.js → pieDiagram-CU6KROY3-BntYuYZa.js} +1 -1
- package/web/assets/{requirementDiagram-JXO7QTGE-QNeTo5C_.js → requirementDiagram-JXO7QTGE-QCD6I29n.js} +1 -1
- package/web/assets/{sequenceDiagram-VS2MUI6T-BHC7q7yJ.js → sequenceDiagram-VS2MUI6T-DScFwLz2.js} +1 -1
- package/web/assets/{stateDiagram-7D4R322I-KONnc2Px.js → stateDiagram-7D4R322I-AkRAm6Hl.js} +1 -1
- package/web/assets/{stateDiagram-v2-36443NZ5-C2QfuMlu.js → stateDiagram-v2-36443NZ5-BCK1vigR.js} +1 -1
- package/web/assets/{timeline-definition-O6YCAMPW-D4t4NJx1.js → timeline-definition-O6YCAMPW-BvpIVXjX.js} +1 -1
- package/web/assets/{vennDiagram-MWXL3ELB-6bctC9Yg.js → vennDiagram-MWXL3ELB-BYGWk6dK.js} +1 -1
- package/web/assets/{wardleyDiagram-CUQ6CDDI-BPZYNTvC.js → wardleyDiagram-CUQ6CDDI-Dk1z7H2T.js} +1 -1
- package/web/assets/{xychartDiagram-N2JHSOCM-lBI9O6DW.js → xychartDiagram-N2JHSOCM-2N6NCSWN.js} +1 -1
- package/web/index.html +1 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts +0 -63
- package/dist/_shared/scope-resolution/shadow/aggregate.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/aggregate.js +0 -122
- package/dist/_shared/scope-resolution/shadow/aggregate.js.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.d.ts +0 -59
- package/dist/_shared/scope-resolution/shadow/diff.d.ts.map +0 -1
- package/dist/_shared/scope-resolution/shadow/diff.js +0 -79
- package/dist/_shared/scope-resolution/shadow/diff.js.map +0 -1
- package/dist/core/ingestion/ast-cache.d.ts +0 -26
- package/dist/core/ingestion/ast-cache.js +0 -48
- package/dist/core/ingestion/heritage-extractors/configs/go.d.ts +0 -13
- package/dist/core/ingestion/heritage-extractors/configs/go.js +0 -20
- package/dist/core/ingestion/heritage-extractors/configs/ruby.d.ts +0 -18
- package/dist/core/ingestion/heritage-extractors/configs/ruby.js +0 -65
- package/dist/core/ingestion/heritage-extractors/generic.d.ts +0 -23
- package/dist/core/ingestion/heritage-extractors/generic.js +0 -47
- package/dist/core/ingestion/heritage-processor.d.ts +0 -54
- package/dist/core/ingestion/heritage-processor.js +0 -367
- package/dist/core/ingestion/heritage-types.d.ts +0 -73
- package/dist/core/ingestion/heritage-types.js +0 -2
- package/dist/core/ingestion/import-processor.d.ts +0 -23
- package/dist/core/ingestion/import-processor.js +0 -377
- package/dist/core/ingestion/model/heritage-map.d.ts +0 -105
- package/dist/core/ingestion/model/heritage-map.js +0 -294
- package/dist/core/ingestion/model/resolution-context.d.ts +0 -93
- package/dist/core/ingestion/model/resolution-context.js +0 -337
- package/dist/core/ingestion/named-bindings/csharp.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/csharp.js +0 -37
- package/dist/core/ingestion/named-bindings/java.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/java.js +0 -29
- package/dist/core/ingestion/named-bindings/kotlin.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/kotlin.js +0 -36
- package/dist/core/ingestion/named-bindings/php.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/php.js +0 -61
- package/dist/core/ingestion/named-bindings/python.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/python.js +0 -49
- package/dist/core/ingestion/named-bindings/rust.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/rust.js +0 -66
- package/dist/core/ingestion/named-bindings/types.d.ts +0 -16
- package/dist/core/ingestion/named-bindings/types.js +0 -6
- package/dist/core/ingestion/named-bindings/typescript.d.ts +0 -3
- package/dist/core/ingestion/named-bindings/typescript.js +0 -58
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.d.ts +0 -17
- package/dist/core/ingestion/pipeline-phases/cross-file-impl.js +0 -209
- package/dist/core/ingestion/pipeline-phases/orm-extraction.d.ts +0 -22
- package/dist/core/ingestion/pipeline-phases/orm-extraction.js +0 -92
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.d.ts +0 -70
- package/dist/core/ingestion/pipeline-phases/wildcard-synthesis.js +0 -312
- package/dist/core/ingestion/registry-primary-flag.d.ts +0 -89
- package/dist/core/ingestion/registry-primary-flag.js +0 -122
- package/dist/core/ingestion/shadow-harness.d.ts +0 -113
- package/dist/core/ingestion/shadow-harness.js +0 -148
- package/dist/core/ingestion/utils/ruby-self-call.d.ts +0 -52
- package/dist/core/ingestion/utils/ruby-self-call.js +0 -59
- package/scripts/ci-list-migrated-languages.ts +0 -24
- package/scripts/run-parity.ts +0 -128
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disk-backed `ParsedFile` store (#1983 scope-resolution OOM).
|
|
3
|
+
*
|
|
4
|
+
* ## Why this exists
|
|
5
|
+
*
|
|
6
|
+
* The scope-resolution phase needs a `ParsedFile` (scopes / defs / reference
|
|
7
|
+
* sites) for every file. Historically it re-extracted each file from source on
|
|
8
|
+
* the **main thread** via `extractParsedFile` → `parseSourceSafe`. On a huge
|
|
9
|
+
* repo (Linux kernel, ~64k C files) that re-parse accumulates an unbounded
|
|
10
|
+
* **native** memory leak in `tree-sitter` 0.21.1 (`CallbackInput` retains the
|
|
11
|
+
* input string with no destructor; node-tree-sitter PR #201) — the leaked
|
|
12
|
+
* `TSTree` memory is invisible to V8, never reclaimed by GC, and not freed by
|
|
13
|
+
* worker_thread teardown. The parse phase escapes it only because each parse is
|
|
14
|
+
* relatively cheap there; a second full re-parse of every file on the immortal
|
|
15
|
+
* main thread pushes RSS past the heap cap and the OOM-killer fires.
|
|
16
|
+
*
|
|
17
|
+
* The fix: the parse workers already build a tree-sitter `Tree` per file, so
|
|
18
|
+
* they emit the `ParsedFile` directly (reusing that tree — no second parse).
|
|
19
|
+
* Holding all of them in main-thread heap is what the original #1983 work
|
|
20
|
+
* removed (it cost ~1× the semantic model in RAM during parse), so instead we
|
|
21
|
+
* flush them to this disk store per chunk and stream them back per language in
|
|
22
|
+
* scope-resolution. Net effect: the file is parsed exactly once (in a worker),
|
|
23
|
+
* scope-resolution does ZERO parsing, and peak heap stays bounded.
|
|
24
|
+
*
|
|
25
|
+
* ## Shape
|
|
26
|
+
*
|
|
27
|
+
* `<storagePath>/parsedfile-store/<shardId>.json` — one shard per parse chunk,
|
|
28
|
+
* a JSON array of `ParsedFile` serialized with the same `mapReplacer` the parse
|
|
29
|
+
* cache uses (Scope.bindings / Scope.typeBindings are `Map`s). The store is
|
|
30
|
+
* cleared at the start of each parse and after scope-resolution consumes it, so
|
|
31
|
+
* it never lingers and never goes stale across runs.
|
|
32
|
+
*
|
|
33
|
+
* ## Durable sibling store (`parsedfile-cache/`, warm-cache coverage)
|
|
34
|
+
*
|
|
35
|
+
* The run-scoped store above is only populated when the parse workers actually
|
|
36
|
+
* run. On a warm re-analyze where every chunk is a parse-cache HIT, no worker
|
|
37
|
+
* runs, the run-scoped store was cleared at parse start, and the cached
|
|
38
|
+
* `ParseWorkerResult` carries no `ParsedFile`s (the worker emptied them after
|
|
39
|
+
* its store write) — so scope-resolution would find an empty store and fall
|
|
40
|
+
* back to main-thread `extractParsedFile`, re-opening the #1983 OOM. To close
|
|
41
|
+
* that gap we ALSO write the worker's ParsedFiles to a second, CONTENT-ADDRESSED
|
|
42
|
+
* store keyed by the parse chunk hash (`getDurableParsedFileDir`), which mirrors
|
|
43
|
+
* the parse cache's lifecycle (persists across runs, pruned by `usedKeys`,
|
|
44
|
+
* version-tied via `PARSE_CACHE_VERSION`). On a warm hit the chunk's durable
|
|
45
|
+
* shards are byte-COPIED into the run-scoped store (no re-parse, no
|
|
46
|
+
* re-serialize → byte-identical), so scope-resolution streams them exactly as
|
|
47
|
+
* on a cold run. Content-addressing makes stale reuse impossible: a changed
|
|
48
|
+
* file changes its chunk hash, which misses BOTH stores and re-dispatches.
|
|
49
|
+
*/
|
|
50
|
+
import { promises as fs, mkdirSync, writeFileSync } from 'node:fs';
|
|
51
|
+
import path from 'node:path';
|
|
52
|
+
import v8 from 'node:v8';
|
|
53
|
+
import vm from 'node:vm';
|
|
54
|
+
import { mapReplacer, mapReviver } from './parse-cache.js';
|
|
55
|
+
const STORE_DIRNAME = 'parsedfile-store';
|
|
56
|
+
const DURABLE_DIRNAME = 'parsedfile-cache';
|
|
57
|
+
const DURABLE_INDEX_FILENAME = 'index.json';
|
|
58
|
+
/**
|
|
59
|
+
* Build a JSON.parse reviver that (a) interns every string against a shared
|
|
60
|
+
* pool and (b) applies the parse-cache `mapReviver` (Map/Set reconstruction).
|
|
61
|
+
*
|
|
62
|
+
* `JSON.parse` allocates a DISTINCT string object for every textual token, so a
|
|
63
|
+
* `ParsedFile` graph round-tripped through disk holds millions of duplicate
|
|
64
|
+
* strings — every def repeats its `filePath`, and common type/qualified names
|
|
65
|
+
* (`int`, `void`, `struct …`) recur across the whole repo. On the Linux kernel
|
|
66
|
+
* that roughly DOUBLES the deserialized heap (~15 GB vs ~7.6 GB interned).
|
|
67
|
+
* Interning IN the reviver collapses duplicates as the tree is revived (one
|
|
68
|
+
* pass, no second walk). The pool is per-load; the interned strings stay shared
|
|
69
|
+
* through the retained `ParsedFile` references after the pool is dropped.
|
|
70
|
+
*/
|
|
71
|
+
export const makeInterningReviver = (pool, defPool) => {
|
|
72
|
+
return (key, value) => {
|
|
73
|
+
if (typeof value === 'string') {
|
|
74
|
+
const hit = pool.get(value);
|
|
75
|
+
if (hit !== undefined)
|
|
76
|
+
return hit;
|
|
77
|
+
pool.set(value, value);
|
|
78
|
+
return value;
|
|
79
|
+
}
|
|
80
|
+
const revived = mapReviver(key, value);
|
|
81
|
+
// Collapse the THREE serialized copies of each `SymbolDefinition` back to one
|
|
82
|
+
// shared object, keyed on the def-exclusive `nodeId`. A def is serialized in
|
|
83
|
+
// `localDefs`, in its owning `scope.ownedDefs`, and inside `scope.bindings[].def`;
|
|
84
|
+
// in the live extractor those are ONE object by reference, but `JSON.parse`
|
|
85
|
+
// rebuilds three distinct objects (string interning alone leaves the object
|
|
86
|
+
// duplication intact — ~3× the def-object heap on the disk-backed path).
|
|
87
|
+
// Re-sharing is byte-identical to resolution: every consumer reads defs BY
|
|
88
|
+
// VALUE (`nodeId`/`type`), never by object identity, and the authoritative
|
|
89
|
+
// resolver index is built from `localDefs` only. `nodeId` is def-exclusive in
|
|
90
|
+
// the scope-resolution schema; the `filePath` check guards future shapes.
|
|
91
|
+
if (revived !== null &&
|
|
92
|
+
typeof revived === 'object' &&
|
|
93
|
+
typeof revived.nodeId === 'string' &&
|
|
94
|
+
typeof revived.filePath === 'string') {
|
|
95
|
+
const def = revived;
|
|
96
|
+
const seen = defPool.get(def.nodeId);
|
|
97
|
+
if (seen !== undefined)
|
|
98
|
+
return seen;
|
|
99
|
+
defPool.set(def.nodeId, def);
|
|
100
|
+
return def;
|
|
101
|
+
}
|
|
102
|
+
return revived;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Best-effort forced garbage collection. `JSON.parse` of each shard builds a
|
|
107
|
+
* transient bloated (pre-intern) tree; across hundreds of shards that churn
|
|
108
|
+
* outpaces V8's incremental GC and piles up against the heap limit (measured
|
|
109
|
+
* ~5 GB of avoidable transient on the kernel). A periodic full GC during the
|
|
110
|
+
* load keeps the peak at the retained set rather than retained + churn. Uses
|
|
111
|
+
* the global `gc` when exposed, else the v8/vm trick — and degrades to a no-op
|
|
112
|
+
* if neither is available, so it never throws.
|
|
113
|
+
*/
|
|
114
|
+
let cachedGc;
|
|
115
|
+
/**
|
|
116
|
+
* Best-effort synchronous GC. Uses `globalThis.gc` when `--expose-gc` is set,
|
|
117
|
+
* else lazily wires it via `v8.setFlagsFromString('--expose-gc')` + a fresh
|
|
118
|
+
* `vm` context. Exported so scope-resolution can reclaim a finished language's
|
|
119
|
+
* ParsedFiles at the per-language eviction boundary (#1741 / kernel memory work).
|
|
120
|
+
*/
|
|
121
|
+
export const forceGc = () => {
|
|
122
|
+
const g = globalThis.gc;
|
|
123
|
+
if (typeof g === 'function') {
|
|
124
|
+
g();
|
|
125
|
+
return;
|
|
126
|
+
}
|
|
127
|
+
if (cachedGc === undefined) {
|
|
128
|
+
cachedGc = null;
|
|
129
|
+
try {
|
|
130
|
+
v8.setFlagsFromString('--expose-gc');
|
|
131
|
+
cachedGc = vm.runInNewContext('gc');
|
|
132
|
+
v8.setFlagsFromString('--no-expose-gc');
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
cachedGc = null;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
cachedGc?.();
|
|
139
|
+
};
|
|
140
|
+
export const getParsedFileStoreDir = (storagePath) => path.join(storagePath, STORE_DIRNAME);
|
|
141
|
+
/** Remove any prior run's shards so a fresh parse starts clean. Idempotent. */
|
|
142
|
+
export const clearParsedFileStore = async (storagePath) => {
|
|
143
|
+
await fs.rm(getParsedFileStoreDir(storagePath), { recursive: true, force: true });
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* Single source of truth for a shard's bytes. Returns `null` for an empty
|
|
147
|
+
* chunk (caller writes nothing). Both the async (`persistParsedFileChunk`) and
|
|
148
|
+
* sync (`persistParsedFileShardSync`) writers go through this so the two paths
|
|
149
|
+
* are guaranteed byte-identical — the shards must round-trip through the same
|
|
150
|
+
* `mapReviver`, and matching bytes by having both authors type the same
|
|
151
|
+
* `mapReplacer` call would be a coincidence, not a guarantee.
|
|
152
|
+
*/
|
|
153
|
+
const serializeParsedFileShard = (parsedFiles) => {
|
|
154
|
+
if (parsedFiles.length === 0)
|
|
155
|
+
return null;
|
|
156
|
+
return JSON.stringify(parsedFiles, mapReplacer);
|
|
157
|
+
};
|
|
158
|
+
const shardPath = (storagePath, shardId) => path.join(getParsedFileStoreDir(storagePath), `${shardId}.json`);
|
|
159
|
+
/**
|
|
160
|
+
* Write one parse chunk's `ParsedFile[]` to the store as a single shard (async).
|
|
161
|
+
* No-op for an empty chunk. `shardId` must be unique within a run. Used by the
|
|
162
|
+
* main-thread no-store-disabled fallback and any non-worker writer; the worker
|
|
163
|
+
* store path uses {@link persistParsedFileShardSync}.
|
|
164
|
+
*/
|
|
165
|
+
export const persistParsedFileChunk = async (storagePath, shardId, parsedFiles) => {
|
|
166
|
+
const payload = serializeParsedFileShard(parsedFiles);
|
|
167
|
+
if (payload === null)
|
|
168
|
+
return;
|
|
169
|
+
await fs.mkdir(getParsedFileStoreDir(storagePath), { recursive: true });
|
|
170
|
+
await fs.writeFile(shardPath(storagePath, shardId), payload, 'utf-8');
|
|
171
|
+
};
|
|
172
|
+
// Per-process set of store dirs we've already `mkdir`ed, so the sync worker
|
|
173
|
+
// writer (called once per job, many times into the same dir) doesn't issue a
|
|
174
|
+
// `mkdirSync` syscall on every shard. Mirrors parse-cache.ts's `createdCacheDirs`.
|
|
175
|
+
const createdStoreDirs = new Set();
|
|
176
|
+
/**
|
|
177
|
+
* Synchronous shard writer for use INSIDE a parse worker (#1983 parallel
|
|
178
|
+
* serialization). The worker is a dedicated thread, so a blocking write there
|
|
179
|
+
* protects the main thread, and a sync write avoids threading `async`/`await`
|
|
180
|
+
* through the synchronous per-file extract loop. Produces byte-identical shards
|
|
181
|
+
* to {@link persistParsedFileChunk} via the shared {@link serializeParsedFileShard}.
|
|
182
|
+
* No-op for an empty chunk. `shardId` must be globally unique for the run (the
|
|
183
|
+
* worker uses `w<threadId>-<seq>`); a duplicate would silently overwrite.
|
|
184
|
+
*/
|
|
185
|
+
export const persistParsedFileShardSync = (storagePath, shardId, parsedFiles) => {
|
|
186
|
+
const payload = serializeParsedFileShard(parsedFiles);
|
|
187
|
+
if (payload === null)
|
|
188
|
+
return;
|
|
189
|
+
const dir = getParsedFileStoreDir(storagePath);
|
|
190
|
+
if (!createdStoreDirs.has(dir)) {
|
|
191
|
+
mkdirSync(dir, { recursive: true });
|
|
192
|
+
createdStoreDirs.add(dir);
|
|
193
|
+
}
|
|
194
|
+
writeFileSync(shardPath(storagePath, shardId), payload, 'utf-8');
|
|
195
|
+
};
|
|
196
|
+
/**
|
|
197
|
+
* Stream the store and return the `ParsedFile`s whose `filePath` is in
|
|
198
|
+
* `wantPaths`, keyed by path. Loads one shard at a time and retains only the
|
|
199
|
+
* matching entries, so peak heap is bounded by (matched set) + (one shard)
|
|
200
|
+
* rather than the whole store. Returns an empty map when the store is absent
|
|
201
|
+
* (e.g. tests, or a run with no worker pool) — callers fall back to a fresh
|
|
202
|
+
* extract for the missing files.
|
|
203
|
+
*/
|
|
204
|
+
export const loadParsedFilesForPaths = async (storagePath, wantPaths) => {
|
|
205
|
+
const out = new Map();
|
|
206
|
+
if (wantPaths.size === 0)
|
|
207
|
+
return out;
|
|
208
|
+
const dir = getParsedFileStoreDir(storagePath);
|
|
209
|
+
let shards;
|
|
210
|
+
try {
|
|
211
|
+
shards = (await fs.readdir(dir)).filter((f) => f.endsWith('.json'));
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
return out; // store absent
|
|
215
|
+
}
|
|
216
|
+
// Shared interning pool for this load — deduplicates strings ACROSS shards
|
|
217
|
+
// (one `int` / one repeated filePath for the whole language), which is where
|
|
218
|
+
// most of the saving comes from. Dropped when this function returns.
|
|
219
|
+
const pool = new Map();
|
|
220
|
+
for (let i = 0; i < shards.length; i++) {
|
|
221
|
+
// Per-shard def pool: a SymbolDefinition's three serialized copies live within
|
|
222
|
+
// a single shard (one ParsedFile), so the dedup is shard-local. A cross-shard
|
|
223
|
+
// pool would retain defs of files NOT in `wantPaths` (loaded-but-discarded
|
|
224
|
+
// shards), reintroducing the leak; per-shard drops them with the shard.
|
|
225
|
+
const defPool = new Map();
|
|
226
|
+
const reviver = makeInterningReviver(pool, defPool);
|
|
227
|
+
let parsed;
|
|
228
|
+
try {
|
|
229
|
+
const raw = await fs.readFile(path.join(dir, shards[i]), 'utf-8');
|
|
230
|
+
parsed = JSON.parse(raw, reviver);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
continue; // skip a corrupt shard; missing files fall back to fresh extract
|
|
234
|
+
}
|
|
235
|
+
if (!Array.isArray(parsed))
|
|
236
|
+
continue;
|
|
237
|
+
for (const pf of parsed) {
|
|
238
|
+
if (pf && typeof pf.filePath === 'string' && wantPaths.has(pf.filePath)) {
|
|
239
|
+
out.set(pf.filePath, pf);
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
// Every few shards, reclaim the transient pre-intern parse churn before it
|
|
243
|
+
// piles up against the heap limit (~5 GB avoidable on the kernel), and
|
|
244
|
+
// yield so the GC + any pending I/O can run.
|
|
245
|
+
if ((i & 7) === 7) {
|
|
246
|
+
forceGc();
|
|
247
|
+
await new Promise((resolve) => setImmediate(resolve));
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
return out;
|
|
251
|
+
};
|
|
252
|
+
/** Durable store dir — a sibling of `parsedfile-store/`, NEVER cleared per run. */
|
|
253
|
+
export const getDurableParsedFileDir = (storagePath) => path.join(storagePath, DURABLE_DIRNAME);
|
|
254
|
+
const durableChunkDir = (durableDir, chunkHash) => path.join(durableDir, chunkHash);
|
|
255
|
+
// Per-process set of durable chunk subdirs already `mkdir`ed (mirrors
|
|
256
|
+
// `createdStoreDirs`) so the worker doesn't `mkdirSync` on every shard.
|
|
257
|
+
const createdDurableDirs = new Set();
|
|
258
|
+
/**
|
|
259
|
+
* Synchronous durable-shard writer for use INSIDE a parse worker, alongside
|
|
260
|
+
* {@link persistParsedFileShardSync}. Writes the SAME bytes to a content-addressed
|
|
261
|
+
* durable location keyed by the parse chunk hash so a future warm hit can reuse
|
|
262
|
+
* them. `chunkHash`+`threadId`+`shardSeq` is collision-free across the
|
|
263
|
+
* N-shards-per-chunk fan-out and across worker-death retries — the same
|
|
264
|
+
* uniqueness that makes the run-scoped `w<tid>-<seq>` name safe, prefixed by
|
|
265
|
+
* content. No-op for an empty chunk.
|
|
266
|
+
*/
|
|
267
|
+
export const persistDurableParsedFileShardSync = (durableDir, chunkHash, threadId, shardSeq, parsedFiles) => {
|
|
268
|
+
const payload = serializeParsedFileShard(parsedFiles);
|
|
269
|
+
if (payload === null)
|
|
270
|
+
return;
|
|
271
|
+
const dir = durableChunkDir(durableDir, chunkHash);
|
|
272
|
+
if (!createdDurableDirs.has(dir)) {
|
|
273
|
+
mkdirSync(dir, { recursive: true });
|
|
274
|
+
createdDurableDirs.add(dir);
|
|
275
|
+
}
|
|
276
|
+
writeFileSync(path.join(dir, `${chunkHash}-w${threadId}-${shardSeq}.json`), payload, 'utf-8');
|
|
277
|
+
};
|
|
278
|
+
/**
|
|
279
|
+
* Restore a cached chunk's durable shards into the run-scoped store on a warm
|
|
280
|
+
* hit. A verbatim byte copy (no parse, no re-serialize), so the restored
|
|
281
|
+
* ParsedFiles are byte-identical to a cold run and `loadParsedFilesForPaths`
|
|
282
|
+
* (which keys on `filePath`, not shard name) gives scope-resolution full
|
|
283
|
+
* coverage. The durable shard names already carry the chunk hash, so they never
|
|
284
|
+
* collide with the worker's run-scoped `w<tid>-<seq>` shards. Returns the number
|
|
285
|
+
* of shards restored (0 ⇒ no durable coverage for this chunk; caller treats it
|
|
286
|
+
* as a miss).
|
|
287
|
+
*/
|
|
288
|
+
export const restoreDurableParsedFileShard = async (durableDir, runStoragePath, chunkHash) => {
|
|
289
|
+
const src = durableChunkDir(durableDir, chunkHash);
|
|
290
|
+
let shards;
|
|
291
|
+
try {
|
|
292
|
+
shards = (await fs.readdir(src)).filter((f) => f.endsWith('.json'));
|
|
293
|
+
}
|
|
294
|
+
catch {
|
|
295
|
+
return 0; // no durable shards for this chunk
|
|
296
|
+
}
|
|
297
|
+
if (shards.length === 0)
|
|
298
|
+
return 0;
|
|
299
|
+
const dst = getParsedFileStoreDir(runStoragePath);
|
|
300
|
+
await fs.mkdir(dst, { recursive: true });
|
|
301
|
+
for (const name of shards) {
|
|
302
|
+
await fs.copyFile(path.join(src, name), path.join(dst, name));
|
|
303
|
+
}
|
|
304
|
+
return shards.length;
|
|
305
|
+
};
|
|
306
|
+
/**
|
|
307
|
+
* Read the durable index and return the set of chunk hashes it vouches for,
|
|
308
|
+
* gated on `expectedVersion` (`PARSE_CACHE_VERSION`). A version mismatch or a
|
|
309
|
+
* missing/corrupt index returns the empty set — the caller then treats every
|
|
310
|
+
* chunk as a durable miss and re-dispatches workers (NEVER the main-thread
|
|
311
|
+
* `extractParsedFile` fallback), which rewrites the durable store under the new
|
|
312
|
+
* version. Mirrors `loadParseCache`'s version-invalidation contract.
|
|
313
|
+
*/
|
|
314
|
+
export const loadDurableParsedFileIndex = async (durableDir, expectedVersion) => {
|
|
315
|
+
try {
|
|
316
|
+
const raw = await fs.readFile(path.join(durableDir, DURABLE_INDEX_FILENAME), 'utf-8');
|
|
317
|
+
const idx = JSON.parse(raw);
|
|
318
|
+
if (idx?.version !== expectedVersion || !Array.isArray(idx.keys))
|
|
319
|
+
return new Set();
|
|
320
|
+
return new Set(idx.keys);
|
|
321
|
+
}
|
|
322
|
+
catch {
|
|
323
|
+
return new Set();
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
/**
|
|
327
|
+
* Prune the durable store to `keepKeys` and rewrite its index. `keepKeys` must
|
|
328
|
+
* be the parse cache's surviving on-disk keys (so the two stores stay coherent:
|
|
329
|
+
* a chunk is "cached" iff BOTH its parse-cache shard and its durable shards
|
|
330
|
+
* exist; a quarantined chunk — no parse-cache shard — drops its durable subdir
|
|
331
|
+
* here and re-dispatches next run). Only subdirs with ≥1 shard are indexed
|
|
332
|
+
* (mirrors `saveParseCache`'s written-keys discipline — never vouch for a chunk
|
|
333
|
+
* hash with no backing shard). The index write is tmp+rename atomic.
|
|
334
|
+
*/
|
|
335
|
+
export const pruneAndSaveDurableParsedFileStore = async (durableDir, version, keepKeys) => {
|
|
336
|
+
let entries;
|
|
337
|
+
try {
|
|
338
|
+
entries = await fs.readdir(durableDir);
|
|
339
|
+
}
|
|
340
|
+
catch {
|
|
341
|
+
return; // nothing written this run
|
|
342
|
+
}
|
|
343
|
+
const survivors = [];
|
|
344
|
+
for (const name of entries) {
|
|
345
|
+
if (name === DURABLE_INDEX_FILENAME)
|
|
346
|
+
continue;
|
|
347
|
+
const full = path.join(durableDir, name);
|
|
348
|
+
if (keepKeys.has(name)) {
|
|
349
|
+
try {
|
|
350
|
+
const shards = (await fs.readdir(full)).filter((f) => f.endsWith('.json'));
|
|
351
|
+
if (shards.length > 0) {
|
|
352
|
+
survivors.push(name);
|
|
353
|
+
continue;
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
catch {
|
|
357
|
+
/* not a readable dir → drop below */
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
await fs.rm(full, { recursive: true, force: true });
|
|
361
|
+
}
|
|
362
|
+
const idx = { version, keys: survivors };
|
|
363
|
+
const tmp = path.join(durableDir, `${DURABLE_INDEX_FILENAME}.tmp`);
|
|
364
|
+
await fs.mkdir(durableDir, { recursive: true });
|
|
365
|
+
await fs.writeFile(tmp, JSON.stringify(idx), 'utf-8');
|
|
366
|
+
await fs.rename(tmp, path.join(durableDir, DURABLE_INDEX_FILENAME));
|
|
367
|
+
};
|
|
@@ -413,10 +413,11 @@ export interface CLIConfig {
|
|
|
413
413
|
apiKey?: string;
|
|
414
414
|
model?: string;
|
|
415
415
|
baseUrl?: string;
|
|
416
|
-
provider?: 'openai' | 'openrouter' | 'azure' | 'custom' | 'cursor' | 'claude' | 'codex';
|
|
416
|
+
provider?: 'openai' | 'openrouter' | 'azure' | 'custom' | 'cursor' | 'claude' | 'codex' | 'opencode';
|
|
417
417
|
cursorModel?: string;
|
|
418
418
|
claudeModel?: string;
|
|
419
419
|
codexModel?: string;
|
|
420
|
+
opencodeModel?: string;
|
|
420
421
|
/** Azure api-version query param (e.g. '2024-10-21'). Only used when provider is 'azure'. */
|
|
421
422
|
apiVersion?: string;
|
|
422
423
|
/** Set true when the deployment is a reasoning model (o1, o3, o4-mini). Auto-detected for OpenAI; must be set for Azure deployments. */
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Disk-backed scope store + lazy `ScopeTree` (out-of-core scope index — kernel scope-resolution
|
|
3
|
+
* out-of-core index).
|
|
4
|
+
*
|
|
5
|
+
* ## Why this exists
|
|
6
|
+
*
|
|
7
|
+
* The scope-resolution resident floor is dominated by the per-`Scope` binding
|
|
8
|
+
* payload (`Scope.bindings` / `typeBindings` / `ownedDefs`) — ~17-20 GB for one
|
|
9
|
+
* language on the Linux kernel — held in `preExtractedByPath` AND aliased by the
|
|
10
|
+
* finalize `scopeTree` through the whole emit phase. The emit passes never read
|
|
11
|
+
* `parsed.scopes` directly; they reach scopes EXCLUSIVELY through
|
|
12
|
+
* `scopeTree.getScope(id)` (a point lookup) and `getChildren(id)`. So the heavy
|
|
13
|
+
* scope payload can move to disk behind that point lookup without changing what
|
|
14
|
+
* any consumer observes: every consumer reads a `Scope` BY VALUE (its `bindings`
|
|
15
|
+
* / `ownedDefs` contents, `parent`, `range`), never by object identity.
|
|
16
|
+
*
|
|
17
|
+
* {@link persistScopeShards} writes the scopes to per-file JSON shards (one file
|
|
18
|
+
* = one shard, so a file's whole parent-chain — which never crosses filePath —
|
|
19
|
+
* stays within one shard) using the same `mapReplacer` + def-interning reviver
|
|
20
|
+
* the ParsedFile store proved byte-identical (#1983 / def-object interning). {@link DiskBackedScopeTree}
|
|
21
|
+
* serves `getScope` from a bounded LRU of decoded shards plus a small resident
|
|
22
|
+
* skeleton (`scopeId -> {shard, childIds, parent}`), so only the working set of
|
|
23
|
+
* scopes is resident, not all of them.
|
|
24
|
+
*
|
|
25
|
+
* Default-off: only constructed when `GITNEXUS_DISK_SCOPE_INDEX` is set. The
|
|
26
|
+
* resident `buildScopeTree` path is untouched otherwise.
|
|
27
|
+
*/
|
|
28
|
+
import type { Scope, ScopeId, ScopeTree } from '../_shared/index.js';
|
|
29
|
+
/** Resident per-scope skeleton — everything `ScopeTree` answers WITHOUT the heavy
|
|
30
|
+
* binding payload. `shard` names the on-disk file holding the full `Scope`. */
|
|
31
|
+
interface ScopeSkeletonEntry {
|
|
32
|
+
readonly shard: string;
|
|
33
|
+
readonly parent: ScopeId | null;
|
|
34
|
+
readonly childIds: ScopeId[];
|
|
35
|
+
}
|
|
36
|
+
export declare const getScopeIndexStoreDir: (storagePath: string) => string;
|
|
37
|
+
/**
|
|
38
|
+
* Remove any prior seal's scope shards so a fresh seal starts clean. The shard
|
|
39
|
+
* names are sequential (`s<n>.json`) and the index resets per `persistScopeShards`
|
|
40
|
+
* call, so without this a seal that writes FEWER shards than a previous one (a
|
|
41
|
+
* later language with fewer files, or a later run of a shrunken repo) would leave
|
|
42
|
+
* stale tail shards on disk indefinitely — pure garbage the disk-backed tree
|
|
43
|
+
* never reads, but multi-GB on kernel-scale repos. Idempotent; synchronous to
|
|
44
|
+
* fit the main-thread seal path. Safe to call before each seal: the previously
|
|
45
|
+
* sealed language has finished emit and been released before the next seal runs,
|
|
46
|
+
* so its `DiskBackedScopeTree` never reads these shards again.
|
|
47
|
+
*/
|
|
48
|
+
export declare const clearScopeIndexStore: (storagePath: string) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Persist `scopes` to per-file shards under `<storagePath>/scope-index-store/`
|
|
51
|
+
* and return the resident skeleton the {@link DiskBackedScopeTree} needs. Sharded
|
|
52
|
+
* by `filePath` (sequential `s<n>.json` names — no filePath→filename encoding),
|
|
53
|
+
* so one file's full scope subtree round-trips together. Synchronous: pass-A runs
|
|
54
|
+
* on the main thread and this replaces an in-heap `buildScopeTree`.
|
|
55
|
+
*/
|
|
56
|
+
export declare const persistScopeShards: (storagePath: string, scopes: readonly Scope[]) => ReadonlyMap<ScopeId, ScopeSkeletonEntry>;
|
|
57
|
+
/**
|
|
58
|
+
* A `ScopeTree` that serves `getScope` from disk shards via a bounded LRU,
|
|
59
|
+
* holding only `maxResidentShards` decoded shards + the resident skeleton. Drop-in
|
|
60
|
+
* for the in-heap `buildScopeTree` result for the methods scope-resolution
|
|
61
|
+
* actually calls — `getScope` (the hot one), `getChildren`, `getParent`,
|
|
62
|
+
* `getAncestors`, `has`, `size`. `byId` (a full materialization) is only used by
|
|
63
|
+
* the `INGESTION_EMIT_SCOPES=1` debug path and is unsupported here — the two flags
|
|
64
|
+
* are mutually exclusive.
|
|
65
|
+
*/
|
|
66
|
+
export declare class DiskBackedScopeTree implements ScopeTree {
|
|
67
|
+
private readonly dir;
|
|
68
|
+
private readonly skeleton;
|
|
69
|
+
private readonly maxResidentShards;
|
|
70
|
+
/** Decoded shards, most-recently-used last (Map preserves insertion order). */
|
|
71
|
+
private readonly lru;
|
|
72
|
+
constructor(storagePath: string, skeleton: ReadonlyMap<ScopeId, ScopeSkeletonEntry>, maxResidentShards?: number);
|
|
73
|
+
get size(): number;
|
|
74
|
+
get byId(): ReadonlyMap<ScopeId, Scope>;
|
|
75
|
+
has(id: ScopeId): boolean;
|
|
76
|
+
getChildren(id: ScopeId): readonly ScopeId[];
|
|
77
|
+
getScope(id: ScopeId): Scope | undefined;
|
|
78
|
+
getParent(id: ScopeId): Scope | undefined;
|
|
79
|
+
getAncestors(id: ScopeId): readonly ScopeId[];
|
|
80
|
+
/** Load + decode a shard, touch it as MRU, evict the LRU tail past the cap. */
|
|
81
|
+
private loadShard;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* A `ScopeTree` that starts fully resident (validated by `buildScopeTree`, used
|
|
85
|
+
* by finalize / propagate / resolve, which may mutate `Scope.typeBindings` in
|
|
86
|
+
* place) and then {@link seal}s to a {@link DiskBackedScopeTree} just before emit.
|
|
87
|
+
*
|
|
88
|
+
* Sealing is what actually frees the ~17-20 GB of `Scope.bindings`: the resident
|
|
89
|
+
* tree is held BY THE MODEL'S frozen index bundle, so it cannot be swapped out
|
|
90
|
+
* from the outside. This wrapper IS that held object — `seal()` mutates its own
|
|
91
|
+
* (non-frozen) internal field to null the resident tree from the inside, after
|
|
92
|
+
* persisting it, so the model's reference now points at the disk-backed serving
|
|
93
|
+
* path and the heavy scopes become collectible (once the emit-side ParsedFiles
|
|
94
|
+
* also drop their `scopes`). Idempotent; a no-op before `seal()` keeps today's
|
|
95
|
+
* fully-resident behavior byte-identical.
|
|
96
|
+
*/
|
|
97
|
+
export declare class TransitionalScopeTree implements ScopeTree {
|
|
98
|
+
private resident;
|
|
99
|
+
private disk;
|
|
100
|
+
constructor(scopes: readonly Scope[]);
|
|
101
|
+
/** Persist the resident scopes, switch to disk-backed serving, and drop the
|
|
102
|
+
* resident tree so its scope/binding payload can be reclaimed. Idempotent. */
|
|
103
|
+
seal(storagePath: string, maxResidentShards?: number): void;
|
|
104
|
+
get sealed(): boolean;
|
|
105
|
+
private get active();
|
|
106
|
+
get size(): number;
|
|
107
|
+
get byId(): ReadonlyMap<ScopeId, Scope>;
|
|
108
|
+
has(id: ScopeId): boolean;
|
|
109
|
+
getScope(id: ScopeId): Scope | undefined;
|
|
110
|
+
getParent(id: ScopeId): Scope | undefined;
|
|
111
|
+
getChildren(id: ScopeId): readonly ScopeId[];
|
|
112
|
+
getAncestors(id: ScopeId): readonly ScopeId[];
|
|
113
|
+
}
|
|
114
|
+
export {};
|