gitnexus 1.6.10-rc.21 → 1.6.10-rc.210
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 +212 -22
- package/dist/_shared/graph/types.d.ts +27 -8
- package/dist/_shared/graph/types.d.ts.map +1 -1
- package/dist/_shared/index.d.ts +4 -3
- package/dist/_shared/index.d.ts.map +1 -1
- package/dist/_shared/index.js +1 -1
- package/dist/_shared/index.js.map +1 -1
- package/dist/_shared/integrations/circuit-breaker.d.ts.map +1 -1
- package/dist/_shared/integrations/circuit-breaker.js.map +1 -1
- package/dist/_shared/integrations/resilient-fetch.d.ts +19 -1
- package/dist/_shared/integrations/resilient-fetch.d.ts.map +1 -1
- package/dist/_shared/integrations/resilient-fetch.js +23 -10
- package/dist/_shared/integrations/resilient-fetch.js.map +1 -1
- package/dist/_shared/language-detection.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.d.ts +2 -2
- package/dist/_shared/lbug/schema-constants.d.ts.map +1 -1
- package/dist/_shared/lbug/schema-constants.js +3 -0
- package/dist/_shared/lbug/schema-constants.js.map +1 -1
- package/dist/_shared/scope-resolution/callable-flow-site.d.ts +110 -0
- package/dist/_shared/scope-resolution/callable-flow-site.d.ts.map +1 -0
- package/dist/_shared/scope-resolution/callable-flow-site.js +11 -0
- package/dist/_shared/scope-resolution/callable-flow-site.js.map +1 -0
- package/dist/_shared/scope-resolution/evidence-weights.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts +6 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/finalize-algorithm.js +316 -37
- package/dist/_shared/scope-resolution/finalize-algorithm.js.map +1 -1
- package/dist/_shared/scope-resolution/parsed-file.d.ts +7 -0
- package/dist/_shared/scope-resolution/parsed-file.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts +124 -1
- package/dist/_shared/scope-resolution/reference-site.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/field-registry.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/lookup-core.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/registries/lookup-core.js +58 -2
- package/dist/_shared/scope-resolution/registries/lookup-core.js.map +1 -1
- package/dist/_shared/scope-resolution/registries/method-registry.js.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/scope-tree.js.map +1 -1
- package/dist/_shared/scope-resolution/symbol-definition.d.ts +47 -0
- package/dist/_shared/scope-resolution/symbol-definition.d.ts.map +1 -1
- package/dist/_shared/scope-resolution/types.d.ts +297 -5
- package/dist/_shared/scope-resolution/types.d.ts.map +1 -1
- package/dist/cli/ai-context.d.ts +10 -2
- package/dist/cli/ai-context.js +128 -61
- package/dist/cli/analyze-config.d.ts +1 -1
- package/dist/cli/analyze-options.d.ts +131 -0
- package/dist/cli/analyze-options.js +1 -0
- package/dist/cli/analyze.d.ts +25 -114
- package/dist/cli/analyze.js +194 -36
- package/dist/cli/cli-message.d.ts +1 -1
- package/dist/cli/detect-changes-format.js +19 -2
- package/dist/cli/doctor.d.ts +23 -0
- package/dist/cli/doctor.js +72 -9
- package/dist/cli/editor-targets.js +6 -0
- package/dist/cli/eval-server.d.ts +23 -1
- package/dist/cli/eval-server.js +128 -9
- package/dist/cli/format-symbol.d.ts +15 -0
- package/dist/cli/format-symbol.js +17 -0
- package/dist/cli/generated-skill.d.ts +17 -0
- package/dist/cli/generated-skill.js +1 -0
- package/dist/cli/group.js +23 -2
- package/dist/cli/help-i18n.js +3 -0
- package/dist/cli/i18n/en.d.ts +17 -8
- package/dist/cli/i18n/en.js +19 -8
- package/dist/cli/i18n/resources.d.ts +26 -8
- package/dist/cli/i18n/zh-CN.d.ts +9 -0
- package/dist/cli/i18n/zh-CN.js +17 -8
- package/dist/cli/index.js +16 -9
- package/dist/cli/lazy-action.d.ts +7 -0
- package/dist/cli/lazy-action.js +27 -0
- package/dist/cli/mcp.js +6 -3
- package/dist/cli/resolve-invocation.d.ts +7 -3
- package/dist/cli/resolve-invocation.js +7 -3
- package/dist/cli/setup.d.ts +8 -0
- package/dist/cli/setup.js +30 -7
- package/dist/cli/skill-gen.d.ts +1 -6
- package/dist/cli/skill-gen.js +88 -18
- package/dist/cli/standard-skills.d.ts +76 -0
- package/dist/cli/standard-skills.js +45 -0
- package/dist/cli/status.d.ts +4 -1
- package/dist/cli/status.js +57 -4
- package/dist/cli/tool.d.ts +1 -0
- package/dist/cli/tool.js +75 -7
- package/dist/cli/uninstall.js +7 -2
- package/dist/cli/wiki.d.ts +1 -0
- package/dist/cli/wiki.js +59 -10
- package/dist/config/ignore-service.d.ts +2 -0
- package/dist/config/ignore-service.js +31 -4
- package/dist/core/analysis-features.d.ts +21 -0
- package/dist/core/analysis-features.js +59 -0
- package/dist/core/analyzer-identity.d.ts +154 -0
- package/dist/core/analyzer-identity.js +2158 -0
- package/dist/core/augmentation/engine.js +95 -76
- package/dist/core/embedding-checkpoint.d.ts +143 -0
- package/dist/core/embedding-checkpoint.js +221 -0
- package/dist/core/embedding-count.d.ts +61 -0
- package/dist/core/embedding-count.js +69 -0
- package/dist/core/embeddings/ast-utils.js +9 -1
- package/dist/core/embeddings/embedder.d.ts +3 -2
- package/dist/core/embeddings/embedder.js +8 -5
- package/dist/core/embeddings/embedding-identity.d.ts +11 -0
- package/dist/core/embeddings/embedding-identity.js +24 -0
- package/dist/core/embeddings/embedding-pipeline.d.ts +24 -1
- package/dist/core/embeddings/embedding-pipeline.js +341 -19
- package/dist/core/embeddings/http-client.d.ts +10 -2
- package/dist/core/embeddings/http-client.js +282 -47
- package/dist/core/embeddings/node-module-compat.d.ts +4 -2
- package/dist/core/embeddings/node-module-compat.js +4 -2
- package/dist/core/embeddings/onnxruntime-common-resolver.js +5 -5
- package/dist/core/embeddings/onnxruntime-node-resolver.js +2 -2
- package/dist/core/embeddings/runtime-install.js +1 -1
- package/dist/core/git-staleness.js +1 -1
- package/dist/core/graph/graph.js +3 -0
- package/dist/core/graph/import-cycles.d.ts +194 -3
- package/dist/core/graph/import-cycles.js +522 -73
- package/dist/core/graph/types.d.ts +18 -0
- package/dist/core/group/bridge-db.js +5 -27
- package/dist/core/group/cross-impact.d.ts +21 -0
- package/dist/core/group/cross-impact.js +128 -15
- package/dist/core/group/cross-trace.js +27 -16
- package/dist/core/group/extractors/http-patterns/java.js +91 -14
- package/dist/core/group/extractors/http-patterns/node.js +19 -0
- package/dist/core/group/extractors/http-patterns/types.d.ts +8 -0
- package/dist/core/group/extractors/http-route-extractor.d.ts +1 -0
- package/dist/core/group/extractors/http-route-extractor.js +122 -48
- package/dist/core/group/extractors/include-extractor.js +20 -2
- package/dist/core/group/extractors/manifest-extractor.d.ts +1 -1
- package/dist/core/group/extractors/manifest-extractor.js +7 -7
- package/dist/core/group/service.js +10 -1
- package/dist/core/group/storage.js +2 -33
- package/dist/core/group/types.d.ts +18 -0
- package/dist/core/incremental/subgraph-extract.d.ts +9 -6
- package/dist/core/incremental/subgraph-extract.js +33 -10
- package/dist/core/index-freshness.d.ts +80 -0
- package/dist/core/index-freshness.js +120 -0
- package/dist/core/ingestion/call-processor.d.ts +13 -1
- package/dist/core/ingestion/call-processor.js +110 -3
- package/dist/core/ingestion/cfg/callee-cell-format.d.ts +42 -0
- package/dist/core/ingestion/cfg/callee-cell-format.js +42 -0
- package/dist/core/ingestion/cfg/emit.d.ts +8 -23
- package/dist/core/ingestion/cfg/emit.js +9 -23
- package/dist/core/ingestion/class-extractors/configs/go.js +10 -5
- package/dist/core/ingestion/class-extractors/configs/jvm.js +29 -0
- package/dist/core/ingestion/cluster-enricher.js +8 -4
- package/dist/core/ingestion/cobol/cobol-preprocessor.js +1 -1
- package/dist/core/ingestion/community-processor.d.ts +21 -3
- package/dist/core/ingestion/community-processor.js +88 -83
- package/dist/core/ingestion/di-extractors/index.d.ts +22 -34
- package/dist/core/ingestion/di-extractors/index.js +17 -18
- package/dist/core/ingestion/di-extractors/spring.d.ts +27 -5
- package/dist/core/ingestion/di-extractors/spring.js +87 -3
- package/dist/core/ingestion/di-extractors/types.d.ts +60 -0
- package/dist/core/ingestion/di-extractors/types.js +15 -0
- package/dist/core/ingestion/emit-references.js +4 -0
- package/dist/core/ingestion/filesystem-walker.js +16 -12
- package/dist/core/ingestion/finalize-orchestrator.js +1 -0
- package/dist/core/ingestion/frameworks/spring/analysis-features.d.ts +9 -0
- package/dist/core/ingestion/frameworks/spring/analysis-features.js +41 -0
- package/dist/core/ingestion/frameworks/spring/annotation-arguments.d.ts +13 -0
- package/dist/core/ingestion/frameworks/spring/annotation-arguments.js +227 -0
- package/dist/core/ingestion/frameworks/spring/aop-candidates.d.ts +15 -0
- package/dist/core/ingestion/frameworks/spring/aop-candidates.js +85 -0
- package/dist/core/ingestion/frameworks/spring/aop.d.ts +118 -0
- package/dist/core/ingestion/frameworks/spring/aop.js +476 -0
- package/dist/core/ingestion/frameworks/spring/auto-configuration.d.ts +8 -0
- package/dist/core/ingestion/frameworks/spring/auto-configuration.js +16 -0
- package/dist/core/ingestion/frameworks/spring/bean-candidates.d.ts +30 -0
- package/dist/core/ingestion/frameworks/spring/bean-candidates.js +182 -0
- package/dist/core/ingestion/frameworks/spring/bean-catalog.d.ts +12 -0
- package/dist/core/ingestion/frameworks/spring/bean-catalog.js +27 -0
- package/dist/core/ingestion/frameworks/spring/bean-factories.d.ts +33 -0
- package/dist/core/ingestion/frameworks/spring/bean-factories.js +65 -0
- package/dist/core/ingestion/frameworks/spring/conditionals.d.ts +25 -0
- package/dist/core/ingestion/frameworks/spring/conditionals.js +319 -0
- package/dist/core/ingestion/frameworks/spring/config-bindings.d.ts +24 -0
- package/dist/core/ingestion/frameworks/spring/config-bindings.js +115 -0
- package/dist/core/ingestion/frameworks/spring/di-metadata.d.ts +48 -0
- package/dist/core/ingestion/frameworks/spring/di-metadata.js +379 -0
- package/dist/core/ingestion/frameworks/spring/non-http-handlers.d.ts +28 -0
- package/dist/core/ingestion/frameworks/spring/non-http-handlers.js +152 -0
- package/dist/core/ingestion/frameworks/spring/resource-injection.d.ts +5 -0
- package/dist/core/ingestion/frameworks/spring/resource-injection.js +91 -0
- package/dist/core/ingestion/import-resolvers/configs/csharp.js +5 -1
- package/dist/core/ingestion/import-resolvers/configs/swift.js +13 -0
- package/dist/core/ingestion/import-resolvers/csharp.d.ts +9 -1
- package/dist/core/ingestion/import-resolvers/csharp.js +234 -27
- package/dist/core/ingestion/import-resolvers/go.d.ts +11 -1
- package/dist/core/ingestion/import-resolvers/go.js +44 -17
- package/dist/core/ingestion/import-resolvers/jvm.d.ts +2 -2
- package/dist/core/ingestion/import-resolvers/node-workspace-packages.d.ts +90 -0
- package/dist/core/ingestion/import-resolvers/node-workspace-packages.js +428 -0
- package/dist/core/ingestion/import-resolvers/package-dir-index.d.ts +124 -0
- package/dist/core/ingestion/import-resolvers/package-dir-index.js +223 -0
- package/dist/core/ingestion/import-resolvers/pass-cache.d.ts +50 -0
- package/dist/core/ingestion/import-resolvers/pass-cache.js +60 -0
- package/dist/core/ingestion/import-resolvers/per-file-set.d.ts +71 -0
- package/dist/core/ingestion/import-resolvers/per-file-set.js +11 -0
- package/dist/core/ingestion/import-resolvers/php.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/php.js +27 -8
- package/dist/core/ingestion/import-resolvers/python-file-index.d.ts +201 -0
- package/dist/core/ingestion/import-resolvers/python-file-index.js +302 -0
- package/dist/core/ingestion/import-resolvers/python.js +25 -6
- package/dist/core/ingestion/import-resolvers/ruby.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/rust.d.ts +2 -2
- package/dist/core/ingestion/import-resolvers/standard.d.ts +1 -1
- package/dist/core/ingestion/import-resolvers/types.d.ts +1 -12
- package/dist/core/ingestion/import-resolvers/utils.d.ts +65 -6
- package/dist/core/ingestion/import-resolvers/utils.js +215 -36
- package/dist/core/ingestion/import-resolvers/workspace-file-index.d.ts +72 -0
- package/dist/core/ingestion/import-resolvers/workspace-file-index.js +58 -0
- package/dist/core/ingestion/language-config.d.ts +20 -1
- package/dist/core/ingestion/language-config.js +18 -23
- package/dist/core/ingestion/language-provider.d.ts +133 -7
- package/dist/core/ingestion/languages/c/captures.js +63 -0
- package/dist/core/ingestion/languages/c/import-target.js +12 -16
- package/dist/core/ingestion/languages/c/query.js +17 -0
- package/dist/core/ingestion/languages/c/scope-resolver.js +26 -19
- package/dist/core/ingestion/languages/c/static-linkage.js +12 -16
- package/dist/core/ingestion/languages/c-cpp.js +13 -0
- package/dist/core/ingestion/languages/cobol/captures.js +93 -0
- package/dist/core/ingestion/languages/cobol/scope-resolver.js +34 -20
- package/dist/core/ingestion/languages/cobol.js +13 -0
- package/dist/core/ingestion/languages/cpp/adl.d.ts +2 -2
- package/dist/core/ingestion/languages/cpp/adl.js +67 -44
- package/dist/core/ingestion/languages/cpp/captures.js +222 -3
- package/dist/core/ingestion/languages/cpp/file-local-linkage.js +11 -15
- package/dist/core/ingestion/languages/cpp/inline-namespaces.d.ts +28 -8
- package/dist/core/ingestion/languages/cpp/inline-namespaces.js +242 -68
- package/dist/core/ingestion/languages/cpp/interpret.d.ts +2 -0
- package/dist/core/ingestion/languages/cpp/interpret.js +126 -6
- package/dist/core/ingestion/languages/cpp/query.js +106 -0
- package/dist/core/ingestion/languages/cpp/scope-resolver.js +62 -20
- package/dist/core/ingestion/languages/csharp/accessor-unwrap.d.ts +2 -15
- package/dist/core/ingestion/languages/csharp/accessor-unwrap.js +18 -10
- package/dist/core/ingestion/languages/csharp/captures.js +44 -0
- package/dist/core/ingestion/languages/csharp/import-target.js +46 -72
- package/dist/core/ingestion/languages/csharp/namespace-siblings.js +5 -1
- package/dist/core/ingestion/languages/csharp/query.js +25 -5
- package/dist/core/ingestion/languages/csharp/scope-resolver.js +75 -2
- package/dist/core/ingestion/languages/dart/captures.d.ts +10 -0
- package/dist/core/ingestion/languages/dart/captures.js +686 -16
- package/dist/core/ingestion/languages/dart/extension-type-preprocess.d.ts +7 -0
- package/dist/core/ingestion/languages/dart/extension-type-preprocess.js +30 -0
- package/dist/core/ingestion/languages/dart/import-target.js +32 -9
- package/dist/core/ingestion/languages/dart/index.d.ts +1 -1
- package/dist/core/ingestion/languages/dart/index.js +1 -1
- package/dist/core/ingestion/languages/dart/query.js +98 -1
- package/dist/core/ingestion/languages/dart/scope-resolver.js +14 -3
- package/dist/core/ingestion/languages/dart/simple-hooks.js +9 -0
- package/dist/core/ingestion/languages/dart.js +8 -1
- package/dist/core/ingestion/languages/go/captures.js +142 -3
- package/dist/core/ingestion/languages/go/generic-type-parameters.d.ts +31 -0
- package/dist/core/ingestion/languages/go/generic-type-parameters.js +140 -0
- package/dist/core/ingestion/languages/go/import-target.d.ts +3 -10
- package/dist/core/ingestion/languages/go/import-target.js +34 -30
- package/dist/core/ingestion/languages/go/index.d.ts +1 -1
- package/dist/core/ingestion/languages/go/interface-impls.d.ts +9 -1
- package/dist/core/ingestion/languages/go/interface-impls.js +693 -87
- package/dist/core/ingestion/languages/go/interpret.d.ts +2 -0
- package/dist/core/ingestion/languages/go/interpret.js +22 -8
- package/dist/core/ingestion/languages/go/method-owners.js +31 -12
- package/dist/core/ingestion/languages/go/package-clause.d.ts +46 -0
- package/dist/core/ingestion/languages/go/package-clause.js +75 -0
- package/dist/core/ingestion/languages/go/package-siblings.js +7 -11
- package/dist/core/ingestion/languages/go/query.js +56 -3
- package/dist/core/ingestion/languages/go/scope-resolver.js +39 -0
- package/dist/core/ingestion/languages/go.js +9 -0
- package/dist/core/ingestion/languages/java/analysis-features.d.ts +7 -0
- package/dist/core/ingestion/languages/java/analysis-features.js +25 -0
- package/dist/core/ingestion/languages/java/capture-side-channel.d.ts +38 -0
- package/dist/core/ingestion/languages/java/capture-side-channel.js +124 -0
- package/dist/core/ingestion/languages/java/captures.d.ts +4 -3
- package/dist/core/ingestion/languages/java/captures.js +321 -49
- package/dist/core/ingestion/languages/java/import-target.d.ts +49 -9
- package/dist/core/ingestion/languages/java/import-target.js +68 -88
- package/dist/core/ingestion/languages/java/interpret.js +3 -2
- package/dist/core/ingestion/languages/java/module-resolution.d.ts +62 -0
- package/dist/core/ingestion/languages/java/module-resolution.js +142 -0
- package/dist/core/ingestion/languages/java/package-facts.d.ts +5 -0
- package/dist/core/ingestion/languages/java/package-facts.js +9 -0
- package/dist/core/ingestion/languages/java/package-siblings.d.ts +3 -16
- package/dist/core/ingestion/languages/java/package-siblings.js +8 -147
- package/dist/core/ingestion/languages/java/query.js +39 -3
- package/dist/core/ingestion/languages/java/record-components.d.ts +14 -0
- package/dist/core/ingestion/languages/java/record-components.js +185 -0
- package/dist/core/ingestion/languages/java/scope-resolver.js +35 -2
- package/dist/core/ingestion/languages/java/spring-aop.d.ts +12 -0
- package/dist/core/ingestion/languages/java/spring-aop.js +49 -0
- package/dist/core/ingestion/languages/java/spring-bean-metadata.d.ts +2 -0
- package/dist/core/ingestion/languages/java/spring-bean-metadata.js +8 -0
- package/dist/core/ingestion/languages/java/spring-conditionals.d.ts +11 -0
- package/dist/core/ingestion/languages/java/spring-conditionals.js +48 -0
- package/dist/core/ingestion/languages/java/spring-config-bindings.d.ts +23 -0
- package/dist/core/ingestion/languages/java/spring-config-bindings.js +215 -0
- package/dist/core/ingestion/languages/java/spring-di.d.ts +20 -0
- package/dist/core/ingestion/languages/java/spring-di.js +160 -0
- package/dist/core/ingestion/languages/java/spring-non-http-handlers.d.ts +7 -0
- package/dist/core/ingestion/languages/java/spring-non-http-handlers.js +32 -0
- package/dist/core/ingestion/languages/java.js +76 -3
- package/dist/core/ingestion/languages/javascript/captures.d.ts +6 -1
- package/dist/core/ingestion/languages/javascript/captures.js +278 -4
- package/dist/core/ingestion/languages/javascript/import-target.d.ts +17 -21
- package/dist/core/ingestion/languages/javascript/import-target.js +24 -41
- package/dist/core/ingestion/languages/javascript/index.d.ts +54 -5
- package/dist/core/ingestion/languages/javascript/index.js +54 -5
- package/dist/core/ingestion/languages/javascript/query.d.ts +1 -0
- package/dist/core/ingestion/languages/javascript/query.js +232 -5
- package/dist/core/ingestion/languages/javascript/scope-resolver.js +12 -0
- package/dist/core/ingestion/languages/javascript/simple-hooks.js +2 -1
- package/dist/core/ingestion/languages/jvm/package-facts.d.ts +35 -0
- package/dist/core/ingestion/languages/jvm/package-facts.js +40 -0
- package/dist/core/ingestion/languages/jvm/package-siblings.d.ts +14 -0
- package/dist/core/ingestion/languages/jvm/package-siblings.js +197 -0
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.d.ts +40 -3
- package/dist/core/ingestion/languages/kotlin/capture-side-channel.js +111 -8
- package/dist/core/ingestion/languages/kotlin/captures.js +112 -0
- package/dist/core/ingestion/languages/kotlin/import-target.d.ts +8 -1
- package/dist/core/ingestion/languages/kotlin/import-target.js +20 -123
- 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/module-resolution.d.ts +22 -0
- package/dist/core/ingestion/languages/kotlin/module-resolution.js +108 -0
- package/dist/core/ingestion/languages/kotlin/package-facts.d.ts +5 -0
- package/dist/core/ingestion/languages/kotlin/package-facts.js +9 -0
- package/dist/core/ingestion/languages/kotlin/package-siblings.d.ts +4 -0
- package/dist/core/ingestion/languages/kotlin/package-siblings.js +8 -0
- package/dist/core/ingestion/languages/kotlin/query.js +47 -2
- package/dist/core/ingestion/languages/kotlin/scope-resolver.js +36 -3
- package/dist/core/ingestion/languages/kotlin/spring-aop.d.ts +12 -0
- package/dist/core/ingestion/languages/kotlin/spring-aop.js +64 -0
- package/dist/core/ingestion/languages/kotlin/spring-bean-metadata.d.ts +2 -0
- package/dist/core/ingestion/languages/kotlin/spring-bean-metadata.js +8 -0
- package/dist/core/ingestion/languages/kotlin/spring-conditionals.d.ts +12 -0
- package/dist/core/ingestion/languages/kotlin/spring-conditionals.js +49 -0
- package/dist/core/ingestion/languages/kotlin/spring-di.d.ts +20 -0
- package/dist/core/ingestion/languages/kotlin/spring-di.js +299 -0
- package/dist/core/ingestion/languages/kotlin/spring-non-http-handlers.d.ts +10 -0
- package/dist/core/ingestion/languages/kotlin/spring-non-http-handlers.js +41 -0
- package/dist/core/ingestion/languages/kotlin.js +5 -6
- package/dist/core/ingestion/languages/php/captures.d.ts +5 -0
- package/dist/core/ingestion/languages/php/captures.js +359 -51
- package/dist/core/ingestion/languages/php/import-decomposer.js +12 -0
- package/dist/core/ingestion/languages/php/import-target.d.ts +2 -1
- package/dist/core/ingestion/languages/php/import-target.js +229 -7
- package/dist/core/ingestion/languages/php/interpret.js +10 -0
- package/dist/core/ingestion/languages/php/query.js +31 -0
- package/dist/core/ingestion/languages/php/scope-resolver.js +1 -1
- package/dist/core/ingestion/languages/python/arity-metadata.d.ts +1 -0
- package/dist/core/ingestion/languages/python/arity-metadata.js +1 -0
- package/dist/core/ingestion/languages/python/captures.d.ts +3 -4
- package/dist/core/ingestion/languages/python/captures.js +53 -5
- package/dist/core/ingestion/languages/python/import-decomposer.js +22 -1
- package/dist/core/ingestion/languages/python/import-target.d.ts +42 -1
- package/dist/core/ingestion/languages/python/import-target.js +277 -91
- package/dist/core/ingestion/languages/python/index.d.ts +1 -1
- package/dist/core/ingestion/languages/python/index.js +1 -1
- package/dist/core/ingestion/languages/python/interpret.d.ts +52 -0
- package/dist/core/ingestion/languages/python/interpret.js +249 -3
- package/dist/core/ingestion/languages/python/query.js +9 -0
- package/dist/core/ingestion/languages/python/receiver-binding.d.ts +17 -2
- package/dist/core/ingestion/languages/python/receiver-binding.js +192 -2
- package/dist/core/ingestion/languages/python/scope-resolver.js +27 -4
- package/dist/core/ingestion/languages/python/simple-hooks.d.ts +5 -5
- package/dist/core/ingestion/languages/python/simple-hooks.js +9 -5
- package/dist/core/ingestion/languages/ruby/captures.js +200 -0
- package/dist/core/ingestion/languages/ruby/import-target.js +7 -5
- package/dist/core/ingestion/languages/ruby/query.js +93 -0
- package/dist/core/ingestion/languages/ruby/scope-resolver.js +2 -0
- package/dist/core/ingestion/languages/ruby/simple-hooks.d.ts +1 -1
- package/dist/core/ingestion/languages/ruby/simple-hooks.js +22 -1
- package/dist/core/ingestion/languages/rust/captures.js +52 -1
- package/dist/core/ingestion/languages/rust/interpret.js +18 -0
- package/dist/core/ingestion/languages/rust/method-owners.js +11 -1
- package/dist/core/ingestion/languages/rust/module-path.d.ts +126 -0
- package/dist/core/ingestion/languages/rust/module-path.js +214 -0
- package/dist/core/ingestion/languages/rust/qualified-call.d.ts +41 -0
- package/dist/core/ingestion/languages/rust/qualified-call.js +481 -0
- package/dist/core/ingestion/languages/rust/query.js +48 -6
- package/dist/core/ingestion/languages/rust/range-binding.d.ts +1 -11
- package/dist/core/ingestion/languages/rust/range-binding.js +149 -63
- package/dist/core/ingestion/languages/rust/scope-resolver.js +21 -2
- package/dist/core/ingestion/languages/rust.js +17 -0
- package/dist/core/ingestion/languages/swift/captures.js +99 -3
- package/dist/core/ingestion/languages/swift/conditional-directive-preprocess.d.ts +48 -0
- package/dist/core/ingestion/languages/swift/conditional-directive-preprocess.js +253 -0
- package/dist/core/ingestion/languages/swift/import-target.js +4 -9
- package/dist/core/ingestion/languages/swift/query.js +17 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.d.ts +8 -0
- package/dist/core/ingestion/languages/swift/receiver-binding.js +6 -2
- package/dist/core/ingestion/languages/swift.js +2 -0
- package/dist/core/ingestion/languages/typescript/captures.d.ts +90 -1
- package/dist/core/ingestion/languages/typescript/captures.js +288 -5
- package/dist/core/ingestion/languages/typescript/cjs-export-assignment.d.ts +134 -0
- package/dist/core/ingestion/languages/typescript/cjs-export-assignment.js +523 -0
- package/dist/core/ingestion/languages/typescript/cjs-module-exports.d.ts +54 -0
- package/dist/core/ingestion/languages/typescript/cjs-module-exports.js +191 -0
- package/dist/core/ingestion/languages/typescript/file-candidates.d.ts +29 -0
- package/dist/core/ingestion/languages/typescript/file-candidates.js +70 -0
- package/dist/core/ingestion/languages/typescript/import-decomposer.d.ts +28 -1
- package/dist/core/ingestion/languages/typescript/import-decomposer.js +125 -10
- package/dist/core/ingestion/languages/typescript/import-target.d.ts +25 -37
- package/dist/core/ingestion/languages/typescript/import-target.js +24 -26
- package/dist/core/ingestion/languages/typescript/interpret.d.ts +21 -1
- package/dist/core/ingestion/languages/typescript/interpret.js +45 -5
- package/dist/core/ingestion/languages/typescript/module-resolution.d.ts +48 -0
- package/dist/core/ingestion/languages/typescript/module-resolution.js +171 -0
- package/dist/core/ingestion/languages/typescript/nuxt-auto-imports.js +2 -1
- package/dist/core/ingestion/languages/typescript/query.d.ts +1 -0
- package/dist/core/ingestion/languages/typescript/query.js +340 -14
- package/dist/core/ingestion/languages/typescript/receiver-binding.d.ts +17 -0
- package/dist/core/ingestion/languages/typescript/receiver-binding.js +27 -0
- package/dist/core/ingestion/languages/typescript/scope-resolver.js +27 -40
- package/dist/core/ingestion/languages/typescript/simple-hooks.d.ts +0 -10
- package/dist/core/ingestion/languages/typescript/simple-hooks.js +22 -22
- package/dist/core/ingestion/languages/typescript/tsconfig.d.ts +59 -0
- package/dist/core/ingestion/languages/typescript/tsconfig.js +291 -0
- package/dist/core/ingestion/languages/typescript.js +87 -1
- package/dist/core/ingestion/languages/vue/import-target.d.ts +6 -22
- package/dist/core/ingestion/languages/vue/import-target.js +11 -47
- package/dist/core/ingestion/languages/vue/scope-resolver.js +4 -2
- package/dist/core/ingestion/local-symbol-pruner.js +11 -11
- package/dist/core/ingestion/method-extractors/configs/csharp.js +1 -0
- package/dist/core/ingestion/method-extractors/generic.js +1 -0
- package/dist/core/ingestion/method-types.d.ts +16 -0
- package/dist/core/ingestion/parsing-processor.js +32 -1
- package/dist/core/ingestion/pipeline-phases/di.d.ts +8 -33
- package/dist/core/ingestion/pipeline-phases/di.js +275 -157
- package/dist/core/ingestion/pipeline-phases/index.d.ts +3 -0
- package/dist/core/ingestion/pipeline-phases/index.js +3 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.d.ts +15 -0
- package/dist/core/ingestion/pipeline-phases/parse-impl.js +158 -3
- package/dist/core/ingestion/pipeline-phases/parse.js +5 -0
- package/dist/core/ingestion/pipeline-phases/processes.d.ts +11 -2
- package/dist/core/ingestion/pipeline-phases/processes.js +102 -7
- package/dist/core/ingestion/pipeline-phases/routes.js +56 -10
- package/dist/core/ingestion/pipeline-phases/spring-aop.d.ts +34 -0
- package/dist/core/ingestion/pipeline-phases/spring-aop.js +439 -0
- package/dist/core/ingestion/pipeline-phases/spring-auto-configuration.d.ts +34 -0
- package/dist/core/ingestion/pipeline-phases/spring-auto-configuration.js +255 -0
- package/dist/core/ingestion/pipeline-phases/spring-config.d.ts +37 -0
- package/dist/core/ingestion/pipeline-phases/spring-config.js +433 -0
- package/dist/core/ingestion/pipeline-phases/types.d.ts +7 -0
- package/dist/core/ingestion/pipeline.d.ts +27 -3
- package/dist/core/ingestion/pipeline.js +62 -12
- package/dist/core/ingestion/process-processor.d.ts +109 -2
- package/dist/core/ingestion/process-processor.js +464 -52
- package/dist/core/ingestion/resolve-references.d.ts +6 -1
- package/dist/core/ingestion/resolve-references.js +78 -6
- package/dist/core/ingestion/route-extractors/data-route-table.d.ts +25 -0
- package/dist/core/ingestion/route-extractors/data-route-table.js +864 -0
- package/dist/core/ingestion/route-extractors/dispatch-guard.d.ts +96 -0
- package/dist/core/ingestion/route-extractors/dispatch-guard.js +1184 -0
- package/dist/core/ingestion/route-extractors/spring-shared.d.ts +11 -0
- package/dist/core/ingestion/route-extractors/spring-shared.js +89 -0
- package/dist/core/ingestion/route-extractors/spring.js +109 -24
- package/dist/core/ingestion/scope-extractor-bridge.js +9 -1
- package/dist/core/ingestion/scope-extractor.d.ts +22 -7
- package/dist/core/ingestion/scope-extractor.js +617 -59
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.d.ts +381 -22
- package/dist/core/ingestion/scope-resolution/contract/scope-resolver.js +16 -5
- package/dist/core/ingestion/scope-resolution/graph-bridge/callee-id-sink.d.ts +7 -7
- package/dist/core/ingestion/scope-resolution/graph-bridge/callee-id-sink.js +8 -7
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.d.ts +15 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/edges.js +53 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.d.ts +20 -15
- package/dist/core/ingestion/scope-resolution/graph-bridge/ids.js +275 -41
- package/dist/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.d.ts +123 -0
- package/dist/core/ingestion/scope-resolution/graph-bridge/imports-to-edges.js +171 -17
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.d.ts +56 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/node-lookup.js +130 -32
- package/dist/core/ingestion/scope-resolution/graph-bridge/references-to-edges.d.ts +30 -1
- package/dist/core/ingestion/scope-resolution/graph-bridge/references-to-edges.js +46 -3
- package/dist/core/ingestion/scope-resolution/passes/callable-value-flow.d.ts +64 -0
- package/dist/core/ingestion/scope-resolution/passes/callable-value-flow.js +1233 -0
- package/dist/core/ingestion/scope-resolution/passes/compound-receiver.d.ts +107 -5
- package/dist/core/ingestion/scope-resolution/passes/compound-receiver.js +590 -33
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.d.ts +19 -4
- package/dist/core/ingestion/scope-resolution/passes/free-call-fallback.js +160 -4
- package/dist/core/ingestion/scope-resolution/passes/imported-value-refs.d.ts +34 -0
- package/dist/core/ingestion/scope-resolution/passes/imported-value-refs.js +62 -0
- package/dist/core/ingestion/scope-resolution/passes/property-dispatch.d.ts +64 -0
- package/dist/core/ingestion/scope-resolution/passes/property-dispatch.js +118 -0
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.d.ts +109 -8
- package/dist/core/ingestion/scope-resolution/passes/receiver-bound-calls.js +931 -92
- package/dist/core/ingestion/scope-resolution/passes/return-shape-members.d.ts +58 -0
- package/dist/core/ingestion/scope-resolution/passes/return-shape-members.js +458 -0
- package/dist/core/ingestion/scope-resolution/passes/unique-name-properties.d.ts +180 -0
- package/dist/core/ingestion/scope-resolution/passes/unique-name-properties.js +418 -0
- package/dist/core/ingestion/scope-resolution/pipeline/phase.d.ts +34 -0
- package/dist/core/ingestion/scope-resolution/pipeline/phase.js +82 -38
- package/dist/core/ingestion/scope-resolution/pipeline/run.d.ts +61 -1
- package/dist/core/ingestion/scope-resolution/pipeline/run.js +384 -48
- package/dist/core/ingestion/scope-resolution/resolution-outcome.d.ts +112 -2
- package/dist/core/ingestion/scope-resolution/resolution-outcome.js +38 -1
- package/dist/core/ingestion/scope-resolution/scope/namespace-targets.d.ts +25 -3
- package/dist/core/ingestion/scope-resolution/scope/namespace-targets.js +36 -16
- package/dist/core/ingestion/scope-resolution/scope/walkers.d.ts +210 -9
- package/dist/core/ingestion/scope-resolution/scope/walkers.js +968 -56
- package/dist/core/ingestion/scope-resolution/summary-maps.d.ts +28 -0
- package/dist/core/ingestion/scope-resolution/summary-maps.js +50 -0
- package/dist/core/ingestion/scope-resolution/undecided-satisfaction.d.ts +55 -0
- package/dist/core/ingestion/scope-resolution/undecided-satisfaction.js +37 -0
- package/dist/core/ingestion/scope-resolution/unresolved-receivers.d.ts +109 -0
- package/dist/core/ingestion/scope-resolution/unresolved-receivers.js +204 -0
- package/dist/core/ingestion/scope-resolution/utils/definition-id.d.ts +13 -0
- package/dist/core/ingestion/scope-resolution/utils/definition-id.js +19 -0
- package/dist/core/ingestion/scope-resolution/utils/generic-instantiation.d.ts +171 -0
- package/dist/core/ingestion/scope-resolution/utils/generic-instantiation.js +218 -0
- package/dist/core/ingestion/scope-resolution/workspace-index-types.d.ts +34 -0
- package/dist/core/ingestion/scope-resolution/workspace-index-types.js +15 -0
- package/dist/core/ingestion/scope-resolution/workspace-index.d.ts +7 -20
- package/dist/core/ingestion/taint/typescript-model.js +34 -2
- package/dist/core/ingestion/tree-sitter-queries.d.ts +11 -11
- package/dist/core/ingestion/tree-sitter-queries.js +688 -5
- package/dist/core/ingestion/type-env.js +11 -7
- package/dist/core/ingestion/type-extractors/jvm.js +17 -2
- package/dist/core/ingestion/type-extractors/shared.d.ts +17 -0
- package/dist/core/ingestion/type-extractors/shared.js +16 -0
- package/dist/core/ingestion/type-extractors/types.d.ts +12 -0
- package/dist/core/ingestion/type-extractors/typescript.d.ts +20 -0
- package/dist/core/ingestion/type-extractors/typescript.js +26 -0
- package/dist/core/ingestion/utils/ast-helpers.d.ts +311 -14
- package/dist/core/ingestion/utils/ast-helpers.js +745 -48
- package/dist/core/ingestion/utils/call-analysis.d.ts +27 -22
- package/dist/core/ingestion/utils/call-analysis.js +202 -7
- package/dist/core/ingestion/utils/callable-flow-captures.d.ts +153 -0
- package/dist/core/ingestion/utils/callable-flow-captures.js +928 -0
- package/dist/core/ingestion/utils/callable-labels.d.ts +25 -0
- package/dist/core/ingestion/utils/callable-labels.js +31 -0
- package/dist/core/ingestion/utils/effective-ram.d.ts +40 -0
- package/dist/core/ingestion/utils/effective-ram.js +58 -0
- package/dist/core/ingestion/utils/line-base.d.ts +14 -0
- package/dist/core/ingestion/utils/line-base.js +14 -0
- package/dist/core/ingestion/utils/method-props.d.ts +27 -4
- package/dist/core/ingestion/utils/method-props.js +29 -4
- package/dist/core/ingestion/utils/receiver-chain-captures.d.ts +31 -0
- package/dist/core/ingestion/utils/receiver-chain-captures.js +57 -0
- package/dist/core/ingestion/utils/receiver-chain-codec.d.ts +89 -0
- package/dist/core/ingestion/utils/receiver-chain-codec.js +182 -0
- package/dist/core/ingestion/utils/scope-tree-walk.d.ts +22 -0
- package/dist/core/ingestion/utils/scope-tree-walk.js +33 -0
- package/dist/core/ingestion/utils/template-arguments.d.ts +96 -0
- package/dist/core/ingestion/utils/template-arguments.js +196 -0
- package/dist/core/ingestion/utils/type-parameters.d.ts +49 -0
- package/dist/core/ingestion/utils/type-parameters.js +206 -0
- package/dist/core/ingestion/workers/callable-id.d.ts +72 -0
- package/dist/core/ingestion/workers/callable-id.js +116 -0
- package/dist/core/ingestion/workers/parse-worker.d.ts +14 -1
- package/dist/core/ingestion/workers/parse-worker.js +409 -39
- package/dist/core/ingestion/workers/worker-pool.d.ts +34 -27
- package/dist/core/ingestion/workers/worker-pool.js +133 -25
- package/dist/core/lbug/csv-generator.d.ts +27 -0
- package/dist/core/lbug/csv-generator.js +80 -17
- package/dist/core/lbug/extension-load-error.d.ts +2 -2
- package/dist/core/lbug/extension-load-error.js +44 -27
- package/dist/core/lbug/extension-loader.d.ts +29 -0
- package/dist/core/lbug/extension-loader.js +32 -7
- package/dist/core/lbug/graph-emit-sink.d.ts +264 -0
- package/dist/core/lbug/graph-emit-sink.js +581 -0
- package/dist/core/lbug/lbug-adapter.d.ts +337 -3
- package/dist/core/lbug/lbug-adapter.js +772 -67
- package/dist/core/lbug/lbug-config.d.ts +93 -6
- package/dist/core/lbug/lbug-config.js +269 -9
- package/dist/core/lbug/native-check.d.ts +39 -0
- package/dist/core/lbug/native-check.js +323 -46
- package/dist/core/lbug/pdg-emit-sink.d.ts +13 -4
- package/dist/core/lbug/pdg-emit-sink.js +21 -111
- package/dist/core/lbug/pool-adapter.d.ts +23 -1
- package/dist/core/lbug/pool-adapter.js +115 -7
- package/dist/core/lbug/query-batch.d.ts +75 -0
- package/dist/core/lbug/query-batch.js +102 -0
- package/dist/core/lbug/rel-pair-routing.d.ts +160 -2
- package/dist/core/lbug/rel-pair-routing.js +228 -10
- package/dist/core/lbug/schema.d.ts +162 -3
- package/dist/core/lbug/schema.js +392 -157
- package/dist/core/lbug/sidecar-recovery.d.ts +1 -0
- package/dist/core/lbug/sidecar-recovery.js +1 -1
- package/dist/core/lbug/sync-csv-writer.d.ts +47 -0
- package/dist/core/lbug/sync-csv-writer.js +108 -0
- package/dist/core/lbug/wal-checkpoint-driver.js +3 -0
- package/dist/core/platform/capabilities.d.ts +0 -1
- package/dist/core/platform/capabilities.js +12 -7
- package/dist/core/run-analyze.d.ts +150 -3
- package/dist/core/run-analyze.js +1562 -151
- package/dist/core/search/bm25-index.d.ts +11 -0
- package/dist/core/search/bm25-index.js +60 -26
- package/dist/core/search/fts-indexes.d.ts +167 -2
- package/dist/core/search/fts-indexes.js +264 -10
- package/dist/core/wiki/graph-queries.js +145 -112
- package/dist/core/wiki/llm-client.d.ts +37 -5
- package/dist/core/wiki/llm-client.js +88 -17
- package/dist/core/wiki/prompts.d.ts +19 -0
- package/dist/core/wiki/prompts.js +20 -1
- package/dist/lib/utils.d.ts +113 -0
- package/dist/lib/utils.js +185 -0
- package/dist/mcp/http-transport.d.ts +5 -0
- package/dist/mcp/http-transport.js +19 -5
- package/dist/mcp/local/aop-metadata.d.ts +77 -0
- package/dist/mcp/local/aop-metadata.js +227 -0
- package/dist/mcp/local/bean-metadata.d.ts +3 -0
- package/dist/mcp/local/bean-metadata.js +46 -0
- package/dist/mcp/local/local-backend.d.ts +167 -6
- package/dist/mcp/local/local-backend.js +1756 -405
- package/dist/mcp/local/path-predicate.d.ts +19 -0
- package/dist/mcp/local/path-predicate.js +21 -0
- package/dist/mcp/local/pdg-impact.d.ts +132 -10
- package/dist/mcp/local/pdg-impact.js +391 -98
- package/dist/mcp/output-budget.d.ts +5 -0
- package/dist/mcp/output-budget.js +52 -0
- package/dist/mcp/read-only-policy.d.ts +12 -0
- package/dist/mcp/read-only-policy.js +102 -0
- package/dist/mcp/repository-policy.d.ts +35 -0
- package/dist/mcp/repository-policy.js +333 -0
- package/dist/mcp/resources.js +34 -7
- package/dist/mcp/server.d.ts +5 -2
- package/dist/mcp/server.js +48 -18
- package/dist/mcp/tools.d.ts +8 -8
- package/dist/mcp/tools.js +91 -20
- package/dist/server/analyze-job.d.ts +40 -2
- package/dist/server/analyze-job.js +30 -2
- package/dist/server/analyze-launch.d.ts +1 -1
- package/dist/server/analyze-launch.js +79 -10
- package/dist/server/analyze-worker-core.d.ts +3 -2
- package/dist/server/analyze-worker-core.js +15 -3
- package/dist/server/analyze-worker-ipc.d.ts +1 -1
- package/dist/server/analyze-worker-ipc.js +4 -0
- package/dist/server/analyze-worker-protocol.d.ts +59 -0
- package/dist/server/analyze-worker-protocol.js +1 -0
- package/dist/server/analyze-worker.d.ts +1 -17
- package/dist/server/analyze-worker.js +29 -6
- package/dist/server/api.d.ts +2 -11
- package/dist/server/api.js +200 -155
- package/dist/server/embed-run-outcome.d.ts +89 -0
- package/dist/server/embed-run-outcome.js +88 -0
- package/dist/server/git-clone.js +6 -2
- package/dist/server/mcp-http.d.ts +1 -1
- package/dist/server/mcp-http.js +4 -2
- package/dist/server/middleware.d.ts +116 -9
- package/dist/server/middleware.js +291 -22
- package/dist/server/sse-progress.d.ts +41 -0
- package/dist/server/sse-progress.js +125 -0
- package/dist/server/upload-ingest.js +2 -1
- package/dist/server/validation.js +2 -1
- package/dist/storage/branch-index.d.ts +11 -6
- package/dist/storage/branch-index.js +15 -7
- package/dist/storage/file-hash.js +2 -2
- package/dist/storage/fs-atomic.d.ts +25 -0
- package/dist/storage/fs-atomic.js +42 -0
- package/dist/storage/git.d.ts +165 -0
- package/dist/storage/git.js +352 -3
- package/dist/storage/index-lock.d.ts +83 -0
- package/dist/storage/index-lock.js +654 -0
- package/dist/storage/parse-cache.js +482 -1
- package/dist/storage/parsedfile-store.d.ts +8 -0
- package/dist/storage/parsedfile-store.js +235 -1
- package/dist/storage/repo-manager.d.ts +29 -309
- package/dist/storage/repo-manager.js +187 -165
- package/dist/storage/repo-meta.d.ts +530 -0
- package/dist/storage/repo-meta.js +100 -0
- package/dist/types/pipeline.d.ts +37 -0
- package/hooks/antigravity/gitnexus-antigravity-hook.cjs +1 -1
- package/hooks/claude/gitnexus-hook.cjs +1 -1
- package/hooks/claude/resolve-analyze-cmd.cjs +80 -13
- package/package.json +19 -12
- package/scripts/cross-platform-shard.ts +143 -0
- package/scripts/cross-platform-tests.ts +94 -0
- package/scripts/ensure-fts.ts +14 -3
- package/scripts/run-cross-platform.ts +36 -10
- package/scripts/sync-plugin-manifests.mjs +192 -0
- package/skills/gitnexus-cli.md +3 -3
- package/skills/gitnexus-debugging.md +37 -7
- package/skills/gitnexus-exploring.md +26 -4
- package/skills/gitnexus-impact-analysis.md +71 -10
- package/skills/gitnexus-lfg/README.md +55 -0
- package/skills/gitnexus-lfg/SKILL.md +86 -0
- package/skills/gitnexus-plan/README.md +147 -0
- package/skills/gitnexus-plan/SKILL.md +348 -0
- package/skills/gitnexus-plan/references/context-ledger.md +137 -0
- package/skills/gitnexus-plan/references/context-pack.md +126 -0
- package/skills/gitnexus-plan/references/evidence-provenance.md +309 -0
- package/skills/gitnexus-plan/references/pdg-slice.md +109 -0
- package/skills/gitnexus-plan/references/plan-template.md +201 -0
- package/skills/gitnexus-plan/scripts/evidence-provenance.mjs +2366 -0
- package/skills/gitnexus-refactoring.md +48 -5
- package/skills/gitnexus-review/SKILL.md +279 -0
- package/skills/gitnexus-review/ci-personas/ci-adversarial-lens.md +42 -0
- package/skills/gitnexus-review/ci-personas/ci-blast-radius-lens.md +39 -0
- package/skills/gitnexus-review/ci-personas/ci-correctness-lens.md +37 -0
- package/skills/gitnexus-review/ci-personas/ci-coverage-lens.md +40 -0
- package/skills/gitnexus-review/ci-personas/ci-critic-lens.md +42 -0
- package/skills/gitnexus-review/ci-personas/ci-security-lens.md +39 -0
- package/skills/gitnexus-taint-analysis.md +13 -7
- package/skills/gitnexus-work/README.md +71 -0
- package/skills/gitnexus-work/SKILL.md +272 -0
- package/skills/gitnexus-work/references/evidence-provenance.md +309 -0
- package/skills/gitnexus-work/scripts/evidence-provenance.mjs +2366 -0
- package/vendor/leiden/utils.cjs +28 -1
- package/web/assets/ProcessFlowModal-Badh2Pbg.js +24 -0
- package/web/assets/__vite-browser-external-bMKyYQkO.js +1 -0
- package/web/assets/abnfDiagram-QNN2D4NM-Cq2djWWe.js +1 -0
- package/web/assets/agent-DIzEQ1JJ.js +626 -0
- package/web/assets/architecture-TIHT7OUA-V6N4J3SY-fTePvLoe.js +1 -0
- package/web/assets/architectureDiagram-OT7VKSJ7-mKEXxkeF.js +36 -0
- package/web/assets/blockDiagram-54WLDVWM-Dg_hrRWE.js +132 -0
- package/web/assets/{c4Diagram-Y2BXMSZH-DOXVs7-C.js → c4Diagram-X2LASM7V-CnhoT4aV.js} +6 -6
- package/web/assets/chunk-224SPVON-B8gxtXpy.js +1 -0
- package/web/assets/chunk-2AEHWXPW-CV4r6-1I.js +127 -0
- package/web/assets/chunk-2SREHG4O-Dip42xOq.js +1 -0
- package/web/assets/chunk-4RFN2BYJ-DHHWuC-n.js +1 -0
- package/web/assets/chunk-66DQ2XMT-CM0xjFAN.js +1 -0
- package/web/assets/chunk-6BELYETK-ChsYtfHW.js +1 -0
- package/web/assets/chunk-6L755F7B-CMhLBxi2.js +1 -0
- package/web/assets/chunk-7CWYLC5S-DRgGkkpF.js +2 -0
- package/web/assets/chunk-A7VWPJGB-B4O3oQdQ.js +1 -0
- package/web/assets/chunk-BI6VK774-D0oaWk8V.js +1 -0
- package/web/assets/chunk-D6VWDJW2-BxcBdZ9c.js +2 -0
- package/web/assets/chunk-DMV4VAQV-Bn6WXDSX.js +4 -0
- package/web/assets/chunk-E5QJAATJ-dh-5CtIV.js +2 -0
- package/web/assets/chunk-EQFTRU2I-1ix7TzW9.js +2 -0
- package/web/assets/chunk-FWYVLQTC-BgDItRzJ.js +1 -0
- package/web/assets/chunk-HNC4WDU7-DoU3KnA7.js +1 -0
- package/web/assets/chunk-L5GCOVLC-CE2w8Nm_.js +161 -0
- package/web/assets/chunk-LAHSG3N2-Bz4hcn0N.js +321 -0
- package/web/assets/chunk-LORZLZWG-B57uGw2N.js +88 -0
- package/web/assets/chunk-NLANEA3F-XpH_NPA5.js +62 -0
- package/web/assets/chunk-NV3KIAZN-5yvcpMiu.js +1 -0
- package/web/assets/chunk-OIYT25JQ-CQ6KOZGX.js +1 -0
- package/web/assets/chunk-PE7DX7ZZ-CCvRVj43.js +10 -0
- package/web/assets/chunk-Q67WD55A-BWCH2SVz.js +156 -0
- package/web/assets/chunk-RRFMTAIC-CMN0wcYA.js +1 -0
- package/web/assets/{chunk-RLI5ZMPA-CkXZ0y0U.js → chunk-SATU7PGQ-B1zhgOvc.js} +1 -1
- package/web/assets/chunk-STOV2HOB-GnExfzIX.js +1 -0
- package/web/assets/chunk-SZD42YQK-ijyKKVr1.js +70 -0
- package/web/assets/chunk-TFPGFQPA-Dj6a-0pC.js +231 -0
- package/web/assets/chunk-TGVD4F4B-BMc31Gj2.js +2 -0
- package/web/assets/chunk-TZUXEDM2-B7p9AcTw.js +1 -0
- package/web/assets/chunk-UAT7B5JY-DW-A_fpI.js +1 -0
- package/web/assets/{chunk-6764PJDD-C7xxk063.js → chunk-VE5CLXGZ-C1vB7wpY.js} +1 -1
- package/web/assets/chunk-VJFVEZTB-CX66F2ep.js +206 -0
- package/web/assets/chunk-VY5UBI4V-yxPQAWxw.js +1 -0
- package/web/assets/chunk-WJBAP47W-BckNkuEN.js +1 -0
- package/web/assets/chunk-XNMVGMAZ-Cg_LnPtj.js +1 -0
- package/web/assets/classDiagram-VPOSVPXH-BjOiXA_C.js +1 -0
- package/web/assets/classDiagram-v2-5VFNUXQA-BjOiXA_C.js +1 -0
- package/web/assets/{cose-bilkent-UX7MHV2Q-BmnZ7Mvj.js → cose-bilkent-RZA4XIPR-BHpK4Crp.js} +1 -1
- package/web/assets/cynefin-VYW2F7L2-2VAHYKR6-DAsF6GZv.js +1 -0
- package/web/assets/cynefinDiagram-TR7LZUCG-C3Iar9lZ.js +62 -0
- package/web/assets/dagre-K64A6Z3X-CUwi79mA.js +4 -0
- package/web/assets/diagram-2TLGJV2N-C2F5Nfym.js +30 -0
- package/web/assets/diagram-JCD7PQ7C-DC5-9FRr.js +24 -0
- package/web/assets/diagram-KFBZAVDW-Dfmf_4ti.js +3 -0
- package/web/assets/diagram-L7DVE3PN-GIRyVUtt.js +41 -0
- package/web/assets/diagram-YP3FGXHI-CyNFYtkd.js +24 -0
- package/web/assets/ebnfDiagram-DRHRQJWO-D8_CI4ZF.js +1 -0
- package/web/assets/erDiagram-SZLJLQMB-CohQjznC.js +85 -0
- package/web/assets/eventmodeling-45OFAUF4-AOUJWSLX-BvTc6iQi.js +1 -0
- package/web/assets/flowDiagram-BWE6NHOH-B6RnEvD9.js +1 -0
- package/web/assets/ganttDiagram-2QTCJSNI-Cks_mEcF.js +292 -0
- package/web/assets/gitGraph-TEB2WS4Q-U5VWYIBC-Dy7CCSZ5.js +1 -0
- package/web/assets/gitGraphDiagram-VVZAVV5G-CG41cIVc.js +106 -0
- package/web/assets/{index-B4eB4dNZ.js → index-BBNl0qfX.js} +51 -51
- package/web/assets/index-CJDpyH-n.css +2 -0
- package/web/assets/info-DKCQHKI2-DX6KST54-BLJg1ikX.js +1 -0
- package/web/assets/infoDiagram-FY4PZKRE-BJ3vPVwW.js +2 -0
- package/web/assets/{ishikawaDiagram-BNXS4ZKH-BLjivjXL.js → ishikawaDiagram-4JDSWWDM-DmqWtjkl.js} +6 -6
- package/web/assets/{journeyDiagram-M6C3CM3L-Cetgs3NH.js → journeyDiagram-QUS3FAKT-XAzVzrQW.js} +6 -6
- package/web/assets/{kanban-definition-75IXJCU3-DMlCaIpf.js → kanban-definition-D4L7SQKK-YurRnmYn.js} +27 -27
- package/web/assets/katex-C5OPUE3Q-Bnbavtmu.js +257 -0
- package/web/assets/{mindmap-definition-2TDM6QVE-B4GbXQBc.js → mindmap-definition-66QP5TD6-ChrWWnil.js} +29 -29
- package/web/assets/node-Ct_zna8U.js +8 -0
- package/web/assets/packet-7NZHBO7P-5WG45QPS-KUxcuvaA.js +1 -0
- package/web/assets/pegDiagram-YKIO5C6U-QGeQLEq2.js +1 -0
- package/web/assets/pie-RZYD4A2V-2OCZ2VTD-DPs08kJY.js +1 -0
- package/web/assets/pieDiagram-YPY3TKG5-BuT3MYzm.js +39 -0
- package/web/assets/preload-helper-Czpn1I53.js +1 -0
- package/web/assets/{quadrantDiagram-VICAPDV7-B1TQnlm0.js → quadrantDiagram-VO5QLCXA-B7098wSc.js} +6 -6
- package/web/assets/radar-I7S5WNFK-EPLSA35B-w5F0K3a7.js +1 -0
- package/web/assets/railroad-3IZDKUUU-PWFQV6Y6-Bu668yqY.js +1 -0
- package/web/assets/railroad-abnf-AHOZXSZD-JYYJX3BS-B6ghpETS.js +1 -0
- package/web/assets/railroad-ebnf-EBAXGLYW-RBZ4ONAP-D-XmHh3M.js +1 -0
- package/web/assets/railroad-peg-LSFZ7HO6-KHNPXGPG-mhkrhzEn.js +1 -0
- package/web/assets/railroadDiagram-M77LTMSB-AXu4vxk_.js +1 -0
- package/web/assets/requirementDiagram-RASO5HTO-B-l8InpK.js +84 -0
- package/web/assets/sankeyDiagram-F32LOJ6L-Kd7zjJgX.js +40 -0
- package/web/assets/sdk-CzHHH8tD.js +37 -0
- package/web/assets/sequenceDiagram-URATNSBD-BlcdY9DS.js +162 -0
- package/web/assets/sizeCapture-5GORAGP4-BEqQzsxs.js +1 -0
- package/web/assets/src-C5sx_gMp.js +1 -0
- package/web/assets/stateDiagram-DODFXNG5-DTdHc-fF.js +1 -0
- package/web/assets/stateDiagram-v2-JNMM5JRA-DioNLDDo.js +1 -0
- package/web/assets/swimlanes-OSWOYLSK-CA0ofdwY.js +2 -0
- package/web/assets/swimlanesDiagram-RHGX2RDE-PkwUdckC.js +8 -0
- package/web/assets/timeline-definition-WJXWRH4I-DUfp1R3E.js +120 -0
- package/web/assets/treeView-QDETBFTQ-EHYTSQNO-C5lpBgPm.js +1 -0
- package/web/assets/treemap-6X3UGDF4-CCWCF7EK-BB0ZyO-B.js +1 -0
- package/web/assets/vennDiagram-K3VCMQLI-Bj-FN-XS.js +34 -0
- package/web/assets/wardley-OPB4EBWU-6OWERDVT-CEA3Nq0j.js +1 -0
- package/web/assets/wardleyDiagram-XK6FUAWV-CVV0dHFr.js +78 -0
- package/web/assets/xychartDiagram-5VRUVLCW-CK_rbSWE.js +7 -0
- package/web/index.html +17 -15
- package/dist/core/ingestion/languages/python/index-stats.d.ts +0 -18
- package/dist/core/ingestion/languages/python/index-stats.js +0 -25
- package/skills/gitnexus-pr-review.md +0 -163
- package/web/assets/ProcessFlowModal-Dna7GkwO.js +0 -22
- package/web/assets/agent-DNYDy-KA.js +0 -660
- package/web/assets/architecture-7EHR7CIX-6QZW5X65-BVWFvYz2.js +0 -1
- package/web/assets/architectureDiagram-UL44E2DR-BU5ZRITg.js +0 -36
- package/web/assets/blockDiagram-7IZFK4PR-Dut1BpTV.js +0 -132
- package/web/assets/chunk-2T2R6R2M-pkw2oXHH.js +0 -4
- package/web/assets/chunk-2UTLFMKG-CXlhF3Pt.js +0 -1
- package/web/assets/chunk-3SSMPTDK-rPsRM1x0.js +0 -321
- package/web/assets/chunk-4R4BOZG6-Be_F0JoX.js +0 -159
- package/web/assets/chunk-67TQ5CYL-zxhDWgyF.js +0 -124
- package/web/assets/chunk-7J6CGLKN-AmkN8jJN.js +0 -10
- package/web/assets/chunk-C62D2QBJ-3gdL8EKc.js +0 -1
- package/web/assets/chunk-CEXFNPSA-CjwtMDkc.js +0 -1
- package/web/assets/chunk-INKRHTLW-D9BM9HWZ.js +0 -70
- package/web/assets/chunk-J5EP6P6S-L19oz55R.js +0 -1
- package/web/assets/chunk-KGFNY3KK-tD2F6wxK.js +0 -62
- package/web/assets/chunk-KGYTTC2M-zm6n242I.js +0 -1
- package/web/assets/chunk-KNLZD3CH-BGlP6X9R.js +0 -1
- package/web/assets/chunk-LCXTWHL2-Ba9JK-6F.js +0 -231
- package/web/assets/chunk-LII3EMHJ-EGx-eBIu.js +0 -1
- package/web/assets/chunk-LRIF4GLE-C3_PqUBq.js +0 -1
- package/web/assets/chunk-QA3QBVWF-D4cSJBf6.js +0 -2
- package/web/assets/chunk-RERM46MO-B5dAdWpP.js +0 -1
- package/web/assets/chunk-RG4AUYOV-OqBBMwuQ.js +0 -206
- package/web/assets/chunk-RKZBBQEN-MyIQbGgD.js +0 -1
- package/web/assets/chunk-T2UQINTJ-BJusEiGe.js +0 -1
- package/web/assets/chunk-UP6H54XL-BG-n7qDp.js +0 -1
- package/web/assets/chunk-UXSXWOXI-CW1_r5cS.js +0 -1
- package/web/assets/chunk-UY5QBCOK-BCpUlARQ.js +0 -1
- package/web/assets/chunk-VU6ZFW4Y-BeXVk45_.js +0 -2
- package/web/assets/chunk-ZXARS5L4-BI_qR2Nm.js +0 -1
- package/web/assets/classDiagram-KGZ6W3CR-D9zSIg0x.js +0 -1
- package/web/assets/classDiagram-v2-72OJOZXJ-D9zSIg0x.js +0 -1
- package/web/assets/dagre-ND4H6XIP-CpcV5kbl.js +0 -4
- package/web/assets/diagram-3NCE3AQN-6SMxBRpj.js +0 -43
- package/web/assets/diagram-GF46GFSD-BZEdNcRZ.js +0 -24
- package/web/assets/diagram-HNR7UZ2L-DxKW2a2Y.js +0 -3
- package/web/assets/diagram-QXG6HAR7-HfTHcXX_.js +0 -24
- package/web/assets/diagram-WEQXMOUZ-CyijUS8r.js +0 -10
- package/web/assets/erDiagram-L5TCEMPS-D0fvpWEX.js +0 -85
- package/web/assets/eventmodeling-FCH6USID-MREXMVOE-CgFBM7e-.js +0 -1
- package/web/assets/flowDiagram-H6V6AXG4-Bvr9bbhk.js +0 -162
- package/web/assets/ganttDiagram-JCBTUEKG-TzODrLzv.js +0 -292
- package/web/assets/gitGraph-WXDBUCRP-R675I2BI-DCJv7SII.js +0 -1
- package/web/assets/gitGraphDiagram-S2ZK5IYY-ONQSwJIY.js +0 -106
- package/web/assets/index-CX_fADmQ.css +0 -2
- package/web/assets/info-J43DQDTF-KCYPFFUO-BfNy-9Nd.js +0 -1
- package/web/assets/infoDiagram-3YFTVSEB-DIPVUIQ6.js +0 -2
- package/web/assets/katex-K3KEBU37-qRQBy-EZ.js +0 -261
- package/web/assets/packet-YPE3B663-LP52Z2RK-D4qkeG9k.js +0 -1
- package/web/assets/pie-LRSECV5Y-TCRJHUBD-B_yMKyQa.js +0 -1
- package/web/assets/pieDiagram-CU6KROY3-D3YC_xyg.js +0 -30
- package/web/assets/radar-GUYGQ44K-RDLRG3WG-DeD6yN_0.js +0 -1
- package/web/assets/requirementDiagram-JXO7QTGE-f8wczLQf.js +0 -84
- package/web/assets/sankeyDiagram-URQDO5SZ-BTxzG5j0.js +0 -40
- package/web/assets/sequenceDiagram-VS2MUI6T-DuamM-IR.js +0 -162
- package/web/assets/src-BNCXICdA.js +0 -1
- package/web/assets/stateDiagram-7D4R322I-Ch2pEUcw.js +0 -1
- package/web/assets/stateDiagram-v2-36443NZ5-7ANuoZLL.js +0 -1
- package/web/assets/timeline-definition-O6YCAMPW-07BR8R8G.js +0 -120
- package/web/assets/treeView-BLDUP644-QA4HXRO3-CDuSYnd4.js +0 -1
- package/web/assets/treemap-LRROVOQU-LLAWBHMP-imazucyJ.js +0 -1
- package/web/assets/vennDiagram-MWXL3ELB-BQX2ossk.js +0 -34
- package/web/assets/wardley-L42UT6IY-5TKZOOLJ-DqrT9tB8.js +0 -1
- package/web/assets/wardleyDiagram-CUQ6CDDI-CGIJBBiK.js +0 -78
- package/web/assets/xychartDiagram-N2JHSOCM-B3HNMuWp.js +0 -7
- /package/web/assets/{chunk-7W6UQGC5-pyKGssV3.js → chunk-LIEV3EAG-pyKGssV3.js} +0 -0
package/dist/core/run-analyze.js
CHANGED
|
@@ -8,20 +8,28 @@
|
|
|
8
8
|
* IMPORTANT: This module must NEVER call process.exit(). The caller (CLI
|
|
9
9
|
* wrapper or server worker) is responsible for process lifecycle.
|
|
10
10
|
*/
|
|
11
|
+
import { detectGraphWriteCollapse } from './index-freshness.js';
|
|
12
|
+
import { PDG_EDGE_TYPES } from './lbug/pdg-emit-sink.js';
|
|
11
13
|
import path from 'path';
|
|
12
14
|
import fs from 'fs/promises';
|
|
13
|
-
import {
|
|
15
|
+
import { randomUUID } from 'node:crypto';
|
|
16
|
+
import { retryRename } from '../storage/fs-atomic.js';
|
|
17
|
+
import { acquireIndexLock } from '../storage/index-lock.js';
|
|
14
18
|
import { runPipelineFromRepo } from './ingestion/pipeline.js';
|
|
19
|
+
import { logUnresolvedReceiverFiles, summarizeUnresolvedReceivers, } from './ingestion/scope-resolution/unresolved-receivers.js';
|
|
20
|
+
import { summarizeUndecidedSatisfaction } from './ingestion/scope-resolution/undecided-satisfaction.js';
|
|
15
21
|
import { resetDegradedParseCounter } from './tree-sitter/safe-parse.js';
|
|
16
|
-
import { initLbug, loadGraphToLbug, getLbugStats, executeQuery, executeWithReusedStatement, closeLbug, closeLbugBeforeExit, loadCachedEmbeddings, deleteNodesForFiles, deleteAllCommunitiesAndProcesses, deleteAllInterprocTaintPaths, deleteAllCallSummaries, deleteAllInjects, queryImportersBatch, loadFTSExtension, wipeLbugDbFiles, LbugWipeError, DELETE_FILES_CHUNK_SIZE, } from './lbug/lbug-adapter.js';
|
|
22
|
+
import { initLbug, loadGraphToLbug, getLbugStats, executeQuery, executeWithReusedStatement, closeLbug, closeLbugBeforeExit, loadCachedEmbeddings, deleteNodesForFiles, ensureEmbeddingRowDmlSafe, ensureFtsRowDmlSafe, readIndexCatalogSnapshot, INDEX_CATALOG_UNREADABLE, deleteAllCommunitiesAndProcesses, deleteAllInterprocTaintPaths, deleteAllCallSummaries, deleteAllInjects, deleteAllAdvisedBy, deleteSpringAopEvidenceNodes, deleteSpringAutoConfigurationDeclarations, deleteSpringAutoConfigurationSyntheticClasses, queryImportersBatch, loadFTSExtension, wipeLbugDbFiles, LbugWipeError, DELETE_FILES_CHUNK_SIZE, } from './lbug/lbug-adapter.js';
|
|
23
|
+
import { estimateBufferPool, setBufferPoolSizeHint, resolveNativeSafeStorageDir, } from './lbug/lbug-config.js';
|
|
17
24
|
import { escapeCypherString } from './lbug/cypher-escape.js';
|
|
18
|
-
import {
|
|
25
|
+
import { chunk } from '../lib/utils.js';
|
|
26
|
+
import { buildSearchIndexesOrDegrade, ftsFailureIsFatal, createSearchFTSIndexes, summarizeFtsIndexBuildFailures, dropSearchFTSIndexes, initialiseSearchFTSStemmer, verifySearchFTSIndexes, } from './search/fts-indexes.js';
|
|
19
27
|
import { cjkSegmentationModeMismatch, getSearchFTSCjkSegmentation, initialiseSearchFTSCjkSegmentation, } from './search/cjk-segmentation.js';
|
|
20
|
-
import { getExtensionCapabilities, resolveAnalyzeInstallPolicy } from './lbug/extension-loader.js';
|
|
28
|
+
import { getExtensionCapability, getExtensionCapabilities, getFtsCapability, resolveAnalyzeInstallPolicy, } from './lbug/extension-loader.js';
|
|
21
29
|
import { diagnoseExtensionLoad } from './lbug/extension-load-error.js';
|
|
22
30
|
import { startWalCheckpointDriver, checkpointOnce, } from './lbug/wal-checkpoint-driver.js';
|
|
23
|
-
import { quarantineSidecarsForDirtyRecovery } from './lbug/sidecar-recovery.js';
|
|
24
|
-
import { getStoragePaths, resolveBranchPlacement, saveMeta, loadMeta, ensureGitNexusIgnored, registerRepo, adoptFlatBranchLabel, isReadOnlyFilesystemError, isRepoRegistered, cleanupOldKuzuFiles, reconcileMetadataFiles, isMissingFilesystemError, INDEX_METADATA_FILE,
|
|
31
|
+
import { quarantineSidecarsForDirtyRecovery, inspectLbugSidecars, } from './lbug/sidecar-recovery.js';
|
|
32
|
+
import { getStoragePaths, resolveBranchPlacement, saveMeta, loadMeta, ensureGitNexusIgnored, registerRepo, adoptFlatBranchLabel, isReadOnlyFilesystemError, isRepoRegistered, cleanupOldKuzuFiles, reconcileMetadataFiles, isMissingFilesystemError, INDEX_METADATA_FILE, } from '../storage/repo-manager.js';
|
|
25
33
|
import { DEFAULT_PDG_MAX_FUNCTION_LINES } from './ingestion/cfg/collect.js';
|
|
26
34
|
import { DEFAULT_MAX_CFG_EDGES_PER_FUNCTION, DEFAULT_PDG_MAX_REACHING_DEF_EDGES_PER_FUNCTION, DEFAULT_PDG_MAX_CDG_EDGES_PER_FUNCTION, } from './ingestion/cfg/emit.js';
|
|
27
35
|
import { DEFAULT_PDG_MAX_TAINT_FINDINGS_PER_FUNCTION, DEFAULT_PDG_MAX_TAINT_HOPS, } from './ingestion/taint/propagate.js';
|
|
@@ -35,11 +43,111 @@ import { shadowCandidatesFor } from './incremental/shadow-candidates.js';
|
|
|
35
43
|
import { shouldEscalateIncrementalWrite } from './incremental/escalation-gate.js';
|
|
36
44
|
import { loadParseCache, saveParseCache, pruneCache, PARSE_CACHE_VERSION, } from '../storage/parse-cache.js';
|
|
37
45
|
import { getDurableParsedFileDir, pruneAndSaveDurableParsedFileStore, } from '../storage/parsedfile-store.js';
|
|
38
|
-
import { getCurrentCommit, getCurrentBranch, getRemoteUrl, hasGitDir, getInferredRepoName, resolveRepoIdentityRoot, } from '../storage/git.js';
|
|
46
|
+
import { getCurrentCommit, getCurrentBranch, getRemoteUrl, hasGitDir, getInferredRepoName, isWorkingTreeDirty, resolveRepoIdentityRoot, } from '../storage/git.js';
|
|
39
47
|
import { generateAIContextFiles } from '../cli/ai-context.js';
|
|
40
48
|
import { sanitizeDetectedBranch } from '../cli/analyze-config.js';
|
|
41
|
-
import { EMBEDDING_TABLE_NAME } from './lbug/schema.js';
|
|
42
|
-
import {
|
|
49
|
+
import { EMBEDDING_TABLE_NAME, EMBEDDING_DIMS, STALE_HASH_SENTINEL, SCHEMA_FINGERPRINT, schemaFingerprintMismatch, isSchemaFingerprintShaped, embeddingDimsMismatch, } from './lbug/schema.js';
|
|
50
|
+
import { isSpringBeanCandidateSourceFile } from './ingestion/frameworks/spring/bean-catalog.js';
|
|
51
|
+
import { isSpringBeanFactoryDeclaration } from './ingestion/frameworks/spring/bean-factories.js';
|
|
52
|
+
import { SPRING_AOP_FEATURE, SPRING_BEAN_INVENTORY_FEATURE, SPRING_CONDITIONALS_FEATURE, SPRING_NON_HTTP_HANDLERS_FEATURE, } from './ingestion/frameworks/spring/analysis-features.js';
|
|
53
|
+
import { JAVA_ENUM_INTERFACE_HERITAGE_FEATURE, JAVA_RECORD_COMPONENT_ACCESSORS_FEATURE, SPRING_CONFIG_BINDINGS_FEATURE, } from './ingestion/languages/java/analysis-features.js';
|
|
54
|
+
import { CLASS_FRAMEWORK_ANNOTATIONS_FEATURE, findAnalysisFeatureMismatches, resolveAnalysisFeatureVersions, } from './analysis-features.js';
|
|
55
|
+
import { analyzerRunnerIdentitiesEqual, finalizeAnalyzerRunnerIdentity, resolveAnalyzerRunnerIdentity, } from './analyzer-identity.js';
|
|
56
|
+
// Static, and deliberately so: `embedding-count.ts` and `embedding-checkpoint.ts`
|
|
57
|
+
// live outside `core/embeddings/` precisely because the lazy-embeddings
|
|
58
|
+
// convention (#2370 — no embeddings module loads unless a run needs one) must
|
|
59
|
+
// keep holding while this counter and the checkpoint rules run on the ORDINARY
|
|
60
|
+
// path of every analyze. Neither imports anything native.
|
|
61
|
+
import { measurePersistedEmbeddingCount, persistedEmbeddingCountOrUndefined, resolvePersistedEmbeddingCount, } from './embedding-count.js';
|
|
62
|
+
import { EMBEDDING_RESUME_MAX_ATTEMPTS, decideEmbeddingResume, mintInterruptedCheckpoint, mintPartialCheckpoint, mintUnverifiedCountCheckpoint, } from './embedding-checkpoint.js';
|
|
63
|
+
/**
|
|
64
|
+
* Strip C0/C1 control characters from a progress/diagnostic message.
|
|
65
|
+
*
|
|
66
|
+
* Several guard notices below interpolate values read straight out of
|
|
67
|
+
* `.gitnexus/gitnexus.json`, which is parsed with no runtime shape validation
|
|
68
|
+
* (`loadMeta` does a bare `JSON.parse(...) as RepoMeta`) — the stamped schema
|
|
69
|
+
* fingerprint, the runner-identity schema, the CJK mode. On the CLI path these
|
|
70
|
+
* reach `console.log` and therefore the user's terminal, so a crafted value
|
|
71
|
+
* carrying ANSI escapes (`\x1b[2J`, `\x1b]0;…`) would be replayed verbatim.
|
|
72
|
+
*
|
|
73
|
+
* Sanitizing at the funnel rather than per field: every message that ever
|
|
74
|
+
* interpolates untrusted metadata is covered, including ones not written yet.
|
|
75
|
+
* Newline and tab are preserved — multi-line notices are intentional.
|
|
76
|
+
*/
|
|
77
|
+
const stripControlCharacters = (msg) => msg.replace(/[\x00-\x08\x0b\x0c\x0e-\x1f\x7f-\x9f]/g, '');
|
|
78
|
+
const ANALYSIS_FEATURES = [
|
|
79
|
+
CLASS_FRAMEWORK_ANNOTATIONS_FEATURE,
|
|
80
|
+
SPRING_AOP_FEATURE,
|
|
81
|
+
SPRING_BEAN_INVENTORY_FEATURE,
|
|
82
|
+
SPRING_CONDITIONALS_FEATURE,
|
|
83
|
+
SPRING_NON_HTTP_HANDLERS_FEATURE,
|
|
84
|
+
SPRING_CONFIG_BINDINGS_FEATURE,
|
|
85
|
+
JAVA_ENUM_INTERFACE_HERITAGE_FEATURE,
|
|
86
|
+
JAVA_RECORD_COMPONENT_ACCESSORS_FEATURE,
|
|
87
|
+
];
|
|
88
|
+
function stringList(value) {
|
|
89
|
+
return Array.isArray(value)
|
|
90
|
+
? value.filter((item) => typeof item === 'string')
|
|
91
|
+
: [];
|
|
92
|
+
}
|
|
93
|
+
function collectFrameworkAnnotationDriftFiles(graph, persistedRows) {
|
|
94
|
+
const persistedById = new Map();
|
|
95
|
+
for (const row of persistedRows) {
|
|
96
|
+
if (typeof row.id === 'string') {
|
|
97
|
+
persistedById.set(row.id, stringList(row.frameworkAnnotations));
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
const driftFiles = new Set();
|
|
101
|
+
graph.forEachNode((node) => {
|
|
102
|
+
if (node.label !== 'Class')
|
|
103
|
+
return;
|
|
104
|
+
const current = stringList(node.properties.frameworkAnnotations);
|
|
105
|
+
const persisted = persistedById.get(node.id) ?? [];
|
|
106
|
+
if (current.length !== persisted.length ||
|
|
107
|
+
current.some((annotation, index) => annotation !== persisted[index])) {
|
|
108
|
+
const filePath = node.properties.filePath;
|
|
109
|
+
if (typeof filePath === 'string')
|
|
110
|
+
driftFiles.add(filePath);
|
|
111
|
+
}
|
|
112
|
+
});
|
|
113
|
+
return driftFiles;
|
|
114
|
+
}
|
|
115
|
+
function collectSpringBeanDeclarationDriftFiles(graph, persistedRows) {
|
|
116
|
+
const persisted = new Map();
|
|
117
|
+
for (const row of persistedRows) {
|
|
118
|
+
if (typeof row.id === 'string' &&
|
|
119
|
+
typeof row.filePath === 'string' &&
|
|
120
|
+
typeof row.reason === 'string' &&
|
|
121
|
+
isSpringBeanFactoryDeclaration({ type: 'DECLARES', reason: row.reason })) {
|
|
122
|
+
persisted.set(row.id, { filePath: row.filePath, reason: row.reason });
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
const current = new Map();
|
|
126
|
+
for (const relationship of graph.relationships) {
|
|
127
|
+
if (relationship.type !== 'DECLARES')
|
|
128
|
+
continue;
|
|
129
|
+
if (!isSpringBeanFactoryDeclaration(relationship))
|
|
130
|
+
continue;
|
|
131
|
+
const declaration = graph.getNode(relationship.targetId);
|
|
132
|
+
if (declaration === undefined || typeof declaration.properties.filePath !== 'string')
|
|
133
|
+
continue;
|
|
134
|
+
current.set(declaration.id, {
|
|
135
|
+
filePath: declaration.properties.filePath,
|
|
136
|
+
reason: relationship.reason,
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
const driftFiles = new Set();
|
|
140
|
+
for (const [id, value] of current) {
|
|
141
|
+
const prior = persisted.get(id);
|
|
142
|
+
if (prior === undefined || prior.reason !== value.reason)
|
|
143
|
+
driftFiles.add(value.filePath);
|
|
144
|
+
}
|
|
145
|
+
for (const [id, value] of persisted) {
|
|
146
|
+
if (!current.has(id))
|
|
147
|
+
driftFiles.add(value.filePath);
|
|
148
|
+
}
|
|
149
|
+
return driftFiles;
|
|
150
|
+
}
|
|
43
151
|
/**
|
|
44
152
|
* Logged when the optional FTS extension cannot be loaded or installed during
|
|
45
153
|
* a full analyze. Kept as a named constant so the env-var/command guidance
|
|
@@ -57,6 +165,106 @@ const FTS_UNAVAILABLE_MESSAGE = `${FTS_UNAVAILABLE_LEAD} ` +
|
|
|
57
165
|
// keep importing from this module's stable surface.
|
|
58
166
|
export { deriveEmbeddingMode, DEFAULT_EMBEDDING_NODE_LIMIT } from './embedding-mode.js';
|
|
59
167
|
import { deriveEmbeddingMode as _deriveEmbeddingMode, deriveEmbeddingCap, DEFAULT_EMBEDDING_NODE_LIMIT, } from './embedding-mode.js';
|
|
168
|
+
/**
|
|
169
|
+
* Relationships RESIDENT in the in-memory graph, excluding the PDG layers —
|
|
170
|
+
* the heap-side counterpart of the sink's `structuralRows` subtotal and of
|
|
171
|
+
* `getLbugStats().structuralEdges`, counted by the same `PDG_EDGE_TYPES`
|
|
172
|
+
* predicate so all three measure one population.
|
|
173
|
+
*
|
|
174
|
+
* A type-aware scan rather than `graph.relationshipCount`, because that count is
|
|
175
|
+
* PDG-INCLUSIVE on every run that does not stream. `resolveStreamPdgEmit` and
|
|
176
|
+
* `resolveStreamGraphEmit` BOTH require `force === true`, so with no `--force`
|
|
177
|
+
* there is no sink at all and `scope-resolution/pipeline/run.ts` writes the PDG
|
|
178
|
+
* layers into the ordinary graph (`input.pdgEmitSink ?? graph`). Measured
|
|
179
|
+
* directly: one `runScopeResolution({ pdg: true })` with no sink leaves
|
|
180
|
+
* `relationshipCount = 1`, all of it `CFG`. A first-time `analyze --pdg` on a
|
|
181
|
+
* fresh repo is a FULL write (so the collapse check runs) and a non-streaming
|
|
182
|
+
* one, so `relationshipCount` there compares structural-plus-PDG against a
|
|
183
|
+
* structural-only measurement — the same false collapse the streamed path
|
|
184
|
+
* already fixed, on the default configuration rather than the `--force` one.
|
|
185
|
+
*
|
|
186
|
+
* `forEachRelationshipFields` is the zero-allocation columnar scan (~90 ms per
|
|
187
|
+
* million edges) and `pipelineResult.graph` is always the RAW graph, never the
|
|
188
|
+
* sink, so this never has to recall an offloaded edge.
|
|
189
|
+
*
|
|
190
|
+
* `NaN` when the graph cannot be scanned at all, which is the SAME fact the
|
|
191
|
+
* previous `graph.relationshipCount` read produced for such a graph (`undefined
|
|
192
|
+
* + streamedRows`), and which `detectGraphWriteCollapse` maps to an explicit
|
|
193
|
+
* `'unmeasurable'`. Its docstring already names "a graph implementation that
|
|
194
|
+
* reports no total, a lightweight pipeline result" as an expected input, so
|
|
195
|
+
* calling an absent method here would convert a documented no-verdict into a
|
|
196
|
+
* crashed analyze.
|
|
197
|
+
*/
|
|
198
|
+
export function countStructuralRelationships(graph) {
|
|
199
|
+
if (typeof graph?.forEachRelationshipFields !== 'function')
|
|
200
|
+
return Number.NaN;
|
|
201
|
+
let structural = 0;
|
|
202
|
+
graph.forEachRelationshipFields((_sourceId, _targetId, type) => {
|
|
203
|
+
if (!PDG_EDGE_TYPES.has(type))
|
|
204
|
+
structural++;
|
|
205
|
+
});
|
|
206
|
+
return structural;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The STRUCTURAL relationship count a healthy write is expected to persist.
|
|
210
|
+
*
|
|
211
|
+
* Exported and called by production rather than mirrored in a test. That is the
|
|
212
|
+
* point: the wiring test kept a LOCAL COPY of this expression "because the
|
|
213
|
+
* production expression is inline in a 3000-line function", and a copy cannot
|
|
214
|
+
* catch a term the original got wrong. It did not catch this one.
|
|
215
|
+
*
|
|
216
|
+
* BOTH terms are objects, not pre-selected numbers, and for the same reason:
|
|
217
|
+
* every defect this expression has had was a wrong FIELD chosen at a call site
|
|
218
|
+
* no unit test can reach — first `totalRows` over `structuralRows`, then
|
|
219
|
+
* `relationshipCount` over the structural subtotal. Taking the graph and the
|
|
220
|
+
* manifest puts both choices inside the tested function.
|
|
221
|
+
*/
|
|
222
|
+
export function computeExpectedStructuralRelationships(
|
|
223
|
+
/**
|
|
224
|
+
* The in-memory graph, NOT its `relationshipCount`. That count includes the
|
|
225
|
+
* PDG layers whenever they did not stream — which is every run without
|
|
226
|
+
* `--force`, i.e. the default configuration. A graph that cannot be scanned
|
|
227
|
+
* yields `NaN`, i.e. an explicit no-verdict, exactly as an absent
|
|
228
|
+
* `relationshipCount` did.
|
|
229
|
+
*/
|
|
230
|
+
graph,
|
|
231
|
+
/**
|
|
232
|
+
* The MANIFEST, not a pre-selected number. Taking the whole object puts the
|
|
233
|
+
* `structuralRows` / `totalRows` choice INSIDE the tested function — the
|
|
234
|
+
* choice that was wrong before, and that a numeric parameter leaves at an
|
|
235
|
+
* untestable call site.
|
|
236
|
+
*/
|
|
237
|
+
graphEmitManifest) {
|
|
238
|
+
return countStructuralRelationships(graph) + (graphEmitManifest?.structuralRows ?? 0);
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Which `graphWriteCollapsed` stamp a finished run should PERSIST.
|
|
242
|
+
*
|
|
243
|
+
* Split on the VERDICT, never on the write mode. `saveMeta` overwrites
|
|
244
|
+
* meta.json atomically rather than merging, so returning `undefined` DELETES
|
|
245
|
+
* the stamp — and the stamp is what marks the index incomplete and forces the
|
|
246
|
+
* rebuild that repairs it. Only a positive `'healthy'` measurement earns that
|
|
247
|
+
* deletion; `'unmeasurable'` means this run compared nothing, and a run that
|
|
248
|
+
* measured nothing has repaired nothing.
|
|
249
|
+
*
|
|
250
|
+
* Exported and called by production for the same reason
|
|
251
|
+
* {@link computeExpectedStructuralRelationships} is: the previous version of
|
|
252
|
+
* this decision lived inline in a 3000-line function, where no unit test could
|
|
253
|
+
* reach it, and it shipped implementing a documented three-way taxonomy as a
|
|
254
|
+
* two-way branch on `wroteChangedSubgraphOnly`.
|
|
255
|
+
*/
|
|
256
|
+
export function selectPersistedCollapseStamp(verdict,
|
|
257
|
+
/** The stamp already on disk. Survives every non-`'healthy'` verdict. */
|
|
258
|
+
previousStamp) {
|
|
259
|
+
switch (verdict.verdict) {
|
|
260
|
+
case 'collapsed':
|
|
261
|
+
return { expected: verdict.expected, persisted: verdict.persisted };
|
|
262
|
+
case 'healthy':
|
|
263
|
+
return undefined;
|
|
264
|
+
case 'unmeasurable':
|
|
265
|
+
return previousStamp;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
60
268
|
export const PHASE_LABELS = {
|
|
61
269
|
extracting: 'Scanning files',
|
|
62
270
|
structure: 'Building structure',
|
|
@@ -207,6 +415,36 @@ export const resolvePdgConfig = (options) => options.pdg === true
|
|
|
207
415
|
export const resolveStreamPdgEmit = (options) => options.pdg === true &&
|
|
208
416
|
options.force === true &&
|
|
209
417
|
(options.streamPdgEmit === true || parseTruthyEnv(process.env.GITNEXUS_STREAM_PDG_EMIT));
|
|
418
|
+
/**
|
|
419
|
+
* Resolve whether streamed structural graph emit is on for this run (#2680).
|
|
420
|
+
*
|
|
421
|
+
* **On by default.** It costs nothing observable: the sink answers a complete
|
|
422
|
+
* relationship read, so community detection, process extraction, the taint
|
|
423
|
+
* fixpoint and the local-symbol pruner all behave exactly as they do without it
|
|
424
|
+
* — the edges simply live in columns and on disk instead of as objects. There is
|
|
425
|
+
* no reason to make a user opt in to using less memory.
|
|
426
|
+
*
|
|
427
|
+
* Two conditions still bound it:
|
|
428
|
+
*
|
|
429
|
+
* - `force === true`. Sound only on a full rebuild, because the incremental
|
|
430
|
+
* writeback (`extractChangedSubgraph`) reads relationships back out of the
|
|
431
|
+
* in-memory graph. Same gate, and same reason, as {@link resolveStreamPdgEmit}.
|
|
432
|
+
* - `GITNEXUS_STREAM_GRAPH_EMIT=0` (or an explicit `streamGraphEmit: false`)
|
|
433
|
+
* turns it off. The escape hatch exists for bisecting a suspected
|
|
434
|
+
* streaming-related fault, not as a routine choice.
|
|
435
|
+
*
|
|
436
|
+
* Memory-only: not part of {@link resolvePdgConfig}, so toggling never trips
|
|
437
|
+
* `pdgModeMismatch`. Read every call (not memoized) so `vi.stubEnv` works.
|
|
438
|
+
*/
|
|
439
|
+
export const resolveStreamGraphEmit = (options) => {
|
|
440
|
+
if (options.force !== true)
|
|
441
|
+
return false;
|
|
442
|
+
if (options.streamGraphEmit !== undefined)
|
|
443
|
+
return options.streamGraphEmit;
|
|
444
|
+
// Unset ⇒ on. Set ⇒ honour it, so `=0` / `=false` is the escape hatch.
|
|
445
|
+
const raw = process.env.GITNEXUS_STREAM_GRAPH_EMIT;
|
|
446
|
+
return raw === undefined || raw === '' ? true : parseTruthyEnv(raw);
|
|
447
|
+
};
|
|
210
448
|
/**
|
|
211
449
|
* Resolve the streamed PDG-emit write-buffer size (#2202). Explicit option wins
|
|
212
450
|
* over `GITNEXUS_PDG_EMIT_CHUNK_SIZE`; `undefined` ⇒ the sink's
|
|
@@ -251,62 +489,40 @@ export const pdgModeMismatch = (recorded, options) => {
|
|
|
251
489
|
// different runs would always be `!==`, tripping pdgModeMismatch on every
|
|
252
490
|
// re-analyze and forcing a needless full writeback. e.g. do NOT change
|
|
253
491
|
// `hasCallSummary: true` to a per-language object like `{ ts: true, ... }`; keep
|
|
254
|
-
//
|
|
255
|
-
//
|
|
492
|
+
// any diagnostic refinement in the impact CONSUMER (see pdg-impact.ts
|
|
493
|
+
// assemblePdgImpactResult, which reports empty ascent from the persisted
|
|
494
|
+
// CALL_SUMMARY data), not in this version discriminator.
|
|
256
495
|
for (const key of new Set([...Object.keys(reqRecord), ...Object.keys(recRecord)])) {
|
|
257
496
|
if (reqRecord[key] !== recRecord[key])
|
|
258
497
|
return true;
|
|
259
498
|
}
|
|
260
499
|
return false;
|
|
261
500
|
};
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
// Scope the degraded-parse log throttle to this run. On a reused process
|
|
271
|
-
// (e.g. tests, or any host that calls runFullAnalysis more than once) the
|
|
272
|
-
// module-level counter would otherwise stay saturated and suppress every
|
|
273
|
-
// degraded-parse log after the first run. The per-parse worker holds its own
|
|
274
|
-
// counter in its own module instance and is process-scoped, so no separate
|
|
275
|
-
// worker-side reset is needed (see safe-parse.ts ParseTimeoutError contract).
|
|
276
|
-
resetDegradedParseCounter();
|
|
501
|
+
/**
|
|
502
|
+
* Resolve which storage slot this analyze writes to, including branch
|
|
503
|
+
* placement (#2106/#2354). Extracted from the top of the pipeline so the lock
|
|
504
|
+
* scope (`metaDir`) is known before the lock is acquired. Throws the same
|
|
505
|
+
* `--branch` / checked-out mismatch error the pipeline used to throw inline, so
|
|
506
|
+
* that failure still surfaces before any lock is taken.
|
|
507
|
+
*/
|
|
508
|
+
async function resolveWriteTarget(repoPath, options) {
|
|
277
509
|
// `storagePath` is ALWAYS the flat `.gitnexus` — content-addressed caches
|
|
278
|
-
// (parse-cache, parsedfile-store) and
|
|
279
|
-
//
|
|
510
|
+
// (parse-cache, parsedfile-store) and kuzu-migration cleanup live there and
|
|
511
|
+
// are shared across branches (#2106 KTD7).
|
|
280
512
|
const { storagePath } = getStoragePaths(repoPath);
|
|
281
|
-
// Clean up stale KuzuDB files from before the LadybugDB migration.
|
|
282
|
-
const kuzuResult = await cleanupOldKuzuFiles(storagePath);
|
|
283
|
-
if (kuzuResult.found && kuzuResult.needsReindex) {
|
|
284
|
-
log('Migrating from KuzuDB to LadybugDB — rebuilding index...');
|
|
285
|
-
}
|
|
286
513
|
const repoHasGit = hasGitDir(repoPath);
|
|
287
514
|
const currentCommit = repoHasGit ? getCurrentCommit(repoPath) : '';
|
|
288
|
-
// ── #2106/#2354: resolve which branch slot this run writes to ─────────
|
|
289
|
-
// `branchLabel` is the branch identity recorded in meta.json (incl. the
|
|
290
|
-
// flat workspace slot). `placement.branch` is undefined for the flat slot
|
|
291
|
-
// (the lbug/meta paths stay byte-identical to single-branch behavior) and
|
|
292
|
-
// set for a `branches/<slug>/` sub-directory. Only an explicit `--branch`
|
|
293
|
-
// can route to a sub-directory; a plain analyze ALWAYS targets the flat
|
|
294
|
-
// slot, which follows the checked-out working tree (#2354) — the
|
|
295
|
-
// auto-detected branch (null for detached HEAD / non-git) is recorded as
|
|
296
|
-
// the slot's informational label only.
|
|
297
515
|
// Normalize the auto-detected branch the same way an explicit `--branch` is
|
|
298
|
-
// validated (#2106 R1): a git ref the branch-name rules forbid
|
|
299
|
-
//
|
|
300
|
-
//
|
|
301
|
-
// ref passes through unchanged so index-time and query-time labels round-trip.
|
|
516
|
+
// validated (#2106 R1): a git ref the branch-name rules forbid becomes `null`
|
|
517
|
+
// → the flat slot, matching that a later `--branch <that-ref>` query would
|
|
518
|
+
// also be rejected. A normal ref round-trips index-time/query-time labels.
|
|
302
519
|
const checkedOutBranch = repoHasGit
|
|
303
520
|
? (sanitizeDetectedBranch(getCurrentBranch(repoPath)) ?? null)
|
|
304
521
|
: null;
|
|
305
522
|
// Analyze indexes the working tree, not an arbitrary ref. An explicit
|
|
306
523
|
// `--branch X` while a DIFFERENT branch Y is checked out would write Y's
|
|
307
|
-
// content
|
|
308
|
-
//
|
|
309
|
-
// allow an explicit label so CI checkouts can name their snapshot.
|
|
524
|
+
// content into X's slot, corrupting X (#2106). Refuse the mismatch. Detached
|
|
525
|
+
// HEAD / non-git (checkedOutBranch === null) still allow an explicit label.
|
|
310
526
|
if (options.branch && checkedOutBranch && options.branch !== checkedOutBranch) {
|
|
311
527
|
throw new Error(`--branch "${options.branch}" does not match the checked-out branch "${checkedOutBranch}". ` +
|
|
312
528
|
`Check out "${options.branch}" before indexing it, or omit --branch to index the current branch.`);
|
|
@@ -314,9 +530,104 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
314
530
|
const branchLabel = options.branch ?? checkedOutBranch;
|
|
315
531
|
const placement = options.branch ? await resolveBranchPlacement(repoPath, branchLabel) : {};
|
|
316
532
|
const { lbugPath, metaPath } = getStoragePaths(repoPath, placement.branch);
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
533
|
+
return {
|
|
534
|
+
storagePath,
|
|
535
|
+
repoHasGit,
|
|
536
|
+
currentCommit,
|
|
537
|
+
checkedOutBranch,
|
|
538
|
+
branchLabel,
|
|
539
|
+
placement,
|
|
540
|
+
lbugPath,
|
|
541
|
+
metaPath,
|
|
542
|
+
metaDir: path.dirname(metaPath),
|
|
543
|
+
};
|
|
544
|
+
}
|
|
545
|
+
/**
|
|
546
|
+
* Run the full analysis under an exclusive, index-directory-scoped write lock
|
|
547
|
+
* (#2658). A second concurrent `analyze` on the same slot waits here for the
|
|
548
|
+
* first to finish, then falls through to the normal freshness check inside —
|
|
549
|
+
* so a run whose work the holder already did returns `alreadyUpToDate` in
|
|
550
|
+
* seconds instead of rebuilding (single-flight coalescing), while a run for a
|
|
551
|
+
* genuinely-changed tree does one follow-up incremental. No new flag: waiting
|
|
552
|
+
* is the default, which is what hook-driven re-index wants.
|
|
553
|
+
*
|
|
554
|
+
* The lock is held by whichever process runs the pipeline (the heap-respawn
|
|
555
|
+
* child, or the original) — see index-lock.ts for why ownership lives with the
|
|
556
|
+
* writer, not a supervising parent. Released as soon as the write completes or
|
|
557
|
+
* throws; the post-analysis steps in the CLI (skills, registry) run lock-free.
|
|
558
|
+
*/
|
|
559
|
+
export async function runFullAnalysis(repoPath, options, callbacks, runnerIdentityAtBootstrap) {
|
|
560
|
+
// Validate operator-provided FTS config before anything else — a typo fails
|
|
561
|
+
// here in ms, without taking the lock. (createSearchFTSIndexes reuses the
|
|
562
|
+
// cached value via getSearchFTSStemmer.)
|
|
563
|
+
initialiseSearchFTSStemmer();
|
|
564
|
+
initialiseSearchFTSCjkSegmentation();
|
|
565
|
+
// Scope the degraded-parse log throttle to this run (module-level counter
|
|
566
|
+
// would otherwise stay saturated on a reused process).
|
|
567
|
+
resetDegradedParseCounter();
|
|
568
|
+
const log = (msg) => callbacks.onLog?.(stripControlCharacters(msg));
|
|
569
|
+
const acquireOpts = {
|
|
570
|
+
log,
|
|
571
|
+
onWaitStart: () => callbacks.onProgress('lock', 0, 'Waiting for another analyze to finish on this index…'),
|
|
572
|
+
};
|
|
573
|
+
let writeTarget = await resolveWriteTarget(repoPath, options);
|
|
574
|
+
let lock = await acquireIndexLock(writeTarget.metaDir, acquireOpts);
|
|
575
|
+
try {
|
|
576
|
+
// #2658 review H2: acquireIndexLock can wait up to the timeout ceiling,
|
|
577
|
+
// during which git HEAD/branch — and thus the resolved write slot — may
|
|
578
|
+
// change (a commit lands, a branch is switched, or another writer adopts the
|
|
579
|
+
// flat slot). The pre-wait snapshot must NOT be reused: re-resolve UNDER the
|
|
580
|
+
// lock so the freshness check (`existingMeta.lastCommit === currentCommit`)
|
|
581
|
+
// and the meta stamps see current git state, honoring the module's "re-check
|
|
582
|
+
// freshness after acquiring" contract. If the slot itself moved we hold the
|
|
583
|
+
// WRONG lock — release and re-acquire the correct one. Bounded so a
|
|
584
|
+
// pathologically churning checkout can't loop forever; after the cap we
|
|
585
|
+
// proceed on the current lock. The loop is INSIDE the try so a re-resolve
|
|
586
|
+
// that throws (e.g. a `--branch` that stopped matching the now-switched
|
|
587
|
+
// checkout) still releases the held lock via `finally` (no leak).
|
|
588
|
+
const MAX_RELOCK = 3;
|
|
589
|
+
for (let attempt = 0; attempt < MAX_RELOCK; attempt++) {
|
|
590
|
+
const fresh = await resolveWriteTarget(repoPath, options);
|
|
591
|
+
if (fresh.metaDir === writeTarget.metaDir) {
|
|
592
|
+
writeTarget = fresh; // same slot — adopt the freshly-read commit/branch/placement
|
|
593
|
+
break;
|
|
594
|
+
}
|
|
595
|
+
log(`Index write target moved while waiting for the lock ` +
|
|
596
|
+
`(${writeTarget.metaDir} → ${fresh.metaDir}); re-acquiring the correct slot.`);
|
|
597
|
+
lock.release();
|
|
598
|
+
writeTarget = fresh;
|
|
599
|
+
lock = await acquireIndexLock(fresh.metaDir, acquireOpts);
|
|
600
|
+
if (attempt === MAX_RELOCK - 1) {
|
|
601
|
+
log('Index write target still moving after repeated re-acquire; proceeding on this lock.');
|
|
602
|
+
}
|
|
603
|
+
}
|
|
604
|
+
return await runFullAnalysisInner(repoPath, options, callbacks, writeTarget, runnerIdentityAtBootstrap);
|
|
605
|
+
}
|
|
606
|
+
finally {
|
|
607
|
+
lock.release();
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
async function runFullAnalysisInner(repoPath, options, callbacks, writeTarget, runnerIdentityAtBootstrap) {
|
|
611
|
+
const log = (msg) => callbacks.onLog?.(stripControlCharacters(msg));
|
|
612
|
+
const progress = (phase, percent, message) => callbacks.onProgress(phase, percent, message);
|
|
613
|
+
// FTS-config validation and the degraded-parse counter reset happen in the
|
|
614
|
+
// `runFullAnalysis` wrapper (before the lock is taken).
|
|
615
|
+
// Write target (storage paths + resolved branch placement) was computed by
|
|
616
|
+
// the `runFullAnalysis` wrapper — which needs `metaDir` up front to acquire
|
|
617
|
+
// the exclusive index lock BEFORE any of the freshness/write work below
|
|
618
|
+
// (#2658). `storagePath` is ALWAYS the flat `.gitnexus`; `placement.branch`
|
|
619
|
+
// selects a `branches/<slug>/` sub-slot only for an explicit `--branch` that
|
|
620
|
+
// does not own the flat slot. See resolveWriteTarget for the full contract.
|
|
621
|
+
const { storagePath, repoHasGit, currentCommit, branchLabel, placement, lbugPath, metaDir } = writeTarget;
|
|
622
|
+
// Start each analyze with a clean buffer-pool hint: any pre-pipeline DB open
|
|
623
|
+
// (e.g. the embeddings-cache open) falls back to the default until the hint is
|
|
624
|
+
// set from the built graph below, so a prior run's size can't leak in.
|
|
625
|
+
setBufferPoolSizeHint(undefined);
|
|
626
|
+
// Clean up stale KuzuDB files from before the LadybugDB migration.
|
|
627
|
+
const kuzuResult = await cleanupOldKuzuFiles(storagePath);
|
|
628
|
+
if (kuzuResult.found && kuzuResult.needsReindex) {
|
|
629
|
+
log('Migrating from KuzuDB to LadybugDB — rebuilding index...');
|
|
630
|
+
}
|
|
320
631
|
// Keep gitnexus.json and the legacy meta.json mirror in sync (fresher
|
|
321
632
|
// indexedAt wins; nothing is deleted). Best-effort: loadMeta has its own
|
|
322
633
|
// legacy fallback, so a reconciliation failure (read-only mount, full disk)
|
|
@@ -388,6 +699,12 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
388
699
|
// Surface the load-side reason (#2374): "not pre-installed" was wrong
|
|
389
700
|
// and doctor never installed anything, so the old message trapped
|
|
390
701
|
// users in a query → repair-fts → doctor loop with no way out.
|
|
702
|
+
// NOTE: deliberately the exported `getExtensionCapabilities()` rather
|
|
703
|
+
// than `getFtsCapability()`. The #2383 regression tests stub that
|
|
704
|
+
// export to inject a classified load failure; routing through the
|
|
705
|
+
// helper bypasses the stub (ESM internal calls do not see a module
|
|
706
|
+
// mock), and the classified VC++/ELF remedy silently degrades to
|
|
707
|
+
// generic text — which is exactly the contradiction #2383 fixed.
|
|
391
708
|
const rawFtsReason = getExtensionCapabilities().find((c) => c.name === 'fts')?.reason;
|
|
392
709
|
const ftsReason = rawFtsReason?.replace(/\.$/, '');
|
|
393
710
|
// A missing runtime dependency (Windows error 126, #2374) is not healed
|
|
@@ -404,7 +721,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
404
721
|
remedyTail);
|
|
405
722
|
}
|
|
406
723
|
progress('fts', 85, 'Repairing search indexes...');
|
|
407
|
-
await createSearchFTSIndexes({
|
|
724
|
+
const repairFailures = await createSearchFTSIndexes({
|
|
408
725
|
onIndexStart: options.verbose
|
|
409
726
|
? (table, indexName) => log(`FTS: creating ${table}.${indexName}`)
|
|
410
727
|
: undefined,
|
|
@@ -414,11 +731,56 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
414
731
|
});
|
|
415
732
|
const missing = await verifySearchFTSIndexes(executeQuery);
|
|
416
733
|
if (missing.length > 0) {
|
|
417
|
-
|
|
734
|
+
// #2889: name WHY each index is missing when the build itself said so.
|
|
735
|
+
// Repair now rebuilds every table it can before reporting, so the tables
|
|
736
|
+
// absent from this list were genuinely repaired even on a failed run —
|
|
737
|
+
// previously the first failure aborted the sweep and the message could
|
|
738
|
+
// only ever list "missing", never a reason. Same sentence the analyze
|
|
739
|
+
// degrade path prints, so one failure does not read two ways.
|
|
740
|
+
const reasons = repairFailures.length > 0 ? ` ${summarizeFtsIndexBuildFailures(repairFailures)}.` : '';
|
|
741
|
+
throw new Error(`FTS repair failed - missing indexes after rebuild: ${missing.join(', ')}.${reasons} ` +
|
|
418
742
|
'Run `gitnexus analyze --force` to perform a full graph+FTS rebuild; ' +
|
|
419
743
|
'if that also fails, verify FTS extension availability via `gitnexus doctor`.');
|
|
420
744
|
}
|
|
421
745
|
await ensureGitNexusIgnored(repoPath);
|
|
746
|
+
// #2767: stamp ONLY capabilities.fts so a long-lived MCP session's
|
|
747
|
+
// ensureInitialized() has an explicit, correctly-scoped signal that FTS
|
|
748
|
+
// changed — indexedAt/lastCommit/runnerIdentity/stats are copied through
|
|
749
|
+
// untouched (see the "must not claim a new analyzer identity" comment
|
|
750
|
+
// below). capabilities is forensic/no-programmatic-readers-until-now, so
|
|
751
|
+
// graph/vectorSearch are backfilled with conservative, honest defaults
|
|
752
|
+
// when a legacy meta.json predates this field entirely — repair-fts
|
|
753
|
+
// never touched them and cannot claim a capability it did not verify.
|
|
754
|
+
// Best-effort: a write failure must not turn an already-successful FTS
|
|
755
|
+
// rebuild into a reported repair failure.
|
|
756
|
+
try {
|
|
757
|
+
// Re-read the on-disk meta immediately before writing, rather than
|
|
758
|
+
// reusing `existingMeta` (captured before the FTS rebuild ran, which
|
|
759
|
+
// can span real wall-clock time). Another writer to this same
|
|
760
|
+
// gitnexus.json in the interim — e.g. the HTTP server's background
|
|
761
|
+
// embedding-checkpoint job — must not have its update silently
|
|
762
|
+
// reverted by this stamp overwriting a stale snapshot. Falls back to
|
|
763
|
+
// `existingMeta` only if the file became unreadable in that window.
|
|
764
|
+
const latestMeta = (await loadMeta(metaDir)) ?? existingMeta;
|
|
765
|
+
await saveMeta(metaDir, {
|
|
766
|
+
...latestMeta,
|
|
767
|
+
capabilities: {
|
|
768
|
+
graph: latestMeta.capabilities?.graph ?? {
|
|
769
|
+
provider: 'ladybugdb',
|
|
770
|
+
status: 'available',
|
|
771
|
+
},
|
|
772
|
+
fts: { provider: 'ladybugdb-fts', status: 'available' },
|
|
773
|
+
vectorSearch: latestMeta.capabilities?.vectorSearch ?? {
|
|
774
|
+
provider: 'exact-scan',
|
|
775
|
+
status: 'unavailable',
|
|
776
|
+
exactScanLimit: 0,
|
|
777
|
+
},
|
|
778
|
+
},
|
|
779
|
+
});
|
|
780
|
+
}
|
|
781
|
+
catch (err) {
|
|
782
|
+
log(`FTS capability stamp write failed (non-critical, repair itself succeeded${err instanceof Error ? `: ${err.message}` : ''}); continuing.`);
|
|
783
|
+
}
|
|
422
784
|
progress('fts', 90, 'Search indexes ready');
|
|
423
785
|
progress('done', 100, 'Done');
|
|
424
786
|
return {
|
|
@@ -434,6 +796,52 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
434
796
|
await closeLbug().catch(() => { });
|
|
435
797
|
}
|
|
436
798
|
}
|
|
799
|
+
// Resolve once per real analysis run so every successful metadata write
|
|
800
|
+
// carries one coherent receipt. The FTS-only repair path above intentionally
|
|
801
|
+
// returns without restamping: it does not regenerate the graph represented by
|
|
802
|
+
// RepoMeta and therefore must not claim a new analyzer identity.
|
|
803
|
+
const runnerIdentity = runnerIdentityAtBootstrap ?? resolveAnalyzerRunnerIdentity(import.meta.url);
|
|
804
|
+
if (!analyzerRunnerIdentitiesEqual(runnerIdentity, runnerIdentity)) {
|
|
805
|
+
throw new Error('Analyzer bootstrap supplied a malformed runner identity receipt');
|
|
806
|
+
}
|
|
807
|
+
let resumeEmbeddingCheckpoint = false;
|
|
808
|
+
let pendingEmbeddingNodeIds = new Set();
|
|
809
|
+
let embeddingIdentityForRun;
|
|
810
|
+
// The marker this run resumed, so Phase 5 can tell "the retry cleared the
|
|
811
|
+
// set" from "the retry failed the same way again" and bound the latter — see
|
|
812
|
+
// `nextAttemptCount` in embedding-checkpoint.ts (#2790).
|
|
813
|
+
let resumedEmbeddingCheckpoint;
|
|
814
|
+
if (existingMeta?.embeddingCheckpoint) {
|
|
815
|
+
const checkpoint = existingMeta.embeddingCheckpoint;
|
|
816
|
+
// The verdict itself lives in embedding-checkpoint.ts, shared with
|
|
817
|
+
// `POST /api/embed` — two readers of one marker must not be able to
|
|
818
|
+
// disagree about what it means.
|
|
819
|
+
//
|
|
820
|
+
// The identity stays LAZY, as it has to: the flag and retry-budget verdicts
|
|
821
|
+
// short-circuit before one is needed, and resolving it means importing an
|
|
822
|
+
// embeddings module (#2370 — none loads unless a run actually needs one).
|
|
823
|
+
// `decideEmbeddingResume` asks for it by aborting on `undefined`, which is
|
|
824
|
+
// the only abort it can reach without one.
|
|
825
|
+
let decision = decideEmbeddingResume(checkpoint, undefined, options);
|
|
826
|
+
if (decision.action === 'abort') {
|
|
827
|
+
const { resolveEmbeddingIdentity } = await import('./embeddings/embedding-identity.js');
|
|
828
|
+
embeddingIdentityForRun = resolveEmbeddingIdentity();
|
|
829
|
+
decision = decideEmbeddingResume(checkpoint, embeddingIdentityForRun, options);
|
|
830
|
+
}
|
|
831
|
+
if (decision.action === 'abort')
|
|
832
|
+
throw new Error(decision.error);
|
|
833
|
+
log(decision.log);
|
|
834
|
+
if (options.dropEmbeddings) {
|
|
835
|
+
// --drop-embeddings has always implied a rebuild here; the decision only
|
|
836
|
+
// covers the marker.
|
|
837
|
+
options = { ...options, force: true };
|
|
838
|
+
}
|
|
839
|
+
if (decision.action === 'resume') {
|
|
840
|
+
resumeEmbeddingCheckpoint = true;
|
|
841
|
+
pendingEmbeddingNodeIds = new Set(decision.pendingNodeIds);
|
|
842
|
+
resumedEmbeddingCheckpoint = decision.resumedFrom;
|
|
843
|
+
}
|
|
844
|
+
}
|
|
437
845
|
// ── Crash recovery: dirty flag forces full rebuild ────────────────
|
|
438
846
|
// If the previous incremental run set incrementalInProgress and didn't
|
|
439
847
|
// clear it, the on-disk index may be in a half-state. Cheapest path
|
|
@@ -526,25 +934,95 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
526
934
|
`Tip: set \`pdg: ${pdgOn}\` in .gitnexusrc to pin the mode across runs.`);
|
|
527
935
|
options = { ...options, force: true };
|
|
528
936
|
}
|
|
529
|
-
// ── schema
|
|
530
|
-
// Mirrors the pdg-mode block above:
|
|
531
|
-
//
|
|
532
|
-
//
|
|
533
|
-
//
|
|
937
|
+
// ── schema mismatch forces full rebuild (#2289 P1, #2798) ─────────
|
|
938
|
+
// Mirrors the pdg-mode block above: an index whose tables were created from
|
|
939
|
+
// a different DDL cannot be reconciled by an incremental top-up — a
|
|
940
|
+
// same-commit re-analyze would strand stale rows next to new-schema writes,
|
|
941
|
+
// and LadybugDB fixes a relation table's endpoint pairs at CREATE time, so
|
|
942
|
+
// edges the old shape cannot hold are simply dropped. MUST sit before the
|
|
534
943
|
// alreadyUpToDate fast path below: an unchanged-commit clean tree would
|
|
535
|
-
// otherwise early-return without ever reaching the `isIncremental` gate
|
|
536
|
-
// that consults `schemaVersion`, defeating the bump's whole point.
|
|
944
|
+
// otherwise early-return without ever reaching the `isIncremental` gate.
|
|
537
945
|
//
|
|
538
|
-
//
|
|
539
|
-
//
|
|
540
|
-
//
|
|
541
|
-
//
|
|
542
|
-
//
|
|
543
|
-
//
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
946
|
+
// Forcing here is what recreates the schema: `force` makes the run a full
|
|
947
|
+
// rebuild, which wipes the database file and re-runs the DDL against an
|
|
948
|
+
// empty one. Re-running `CREATE … TABLE` over the EXISTING database would
|
|
949
|
+
// not help — runSchemaCreationQueries suppresses "already exists", so the
|
|
950
|
+
// new shape would never be applied.
|
|
951
|
+
//
|
|
952
|
+
// ABSENT covers two cases and forces in both: an index from a GitNexus
|
|
953
|
+
// older than this field (the backward-compatibility path — one rebuild, then
|
|
954
|
+
// it is stamped), and a non-git repo, which never stamps it (see the meta
|
|
955
|
+
// literal below) and takes the `currentCommit === ''` rebuild branch below
|
|
956
|
+
// regardless.
|
|
957
|
+
//
|
|
958
|
+
// The two cases must not be told the same story. Blaming "an older GitNexus
|
|
959
|
+
// version" is FALSE for a non-git repo — the field is absent by design there,
|
|
960
|
+
// so this build would keep saying it about an index this exact build just
|
|
961
|
+
// wrote, on every run, forever. A stamp is only named when it has the shape
|
|
962
|
+
// SCHEMA_FINGERPRINT produces; anything else degrades to a neutral
|
|
963
|
+
// placeholder, and a non-git repo is additionally told WHY it has no stamp.
|
|
964
|
+
if (existingMeta && schemaFingerprintMismatch(existingMeta.schemaFingerprint)) {
|
|
965
|
+
const stamped = existingMeta.schemaFingerprint;
|
|
966
|
+
const origin = isSchemaFingerprintShaped(stamped) ? stamped : 'an unidentified GitNexus build';
|
|
967
|
+
const nonGitNote = stamped === undefined && !repoHasGit
|
|
968
|
+
? ' Non-git repositories never record a schema fingerprint, so this run rebuilds regardless.'
|
|
969
|
+
: '';
|
|
970
|
+
log(`index schema changed (built by ${origin}, this build is ${SCHEMA_FINGERPRINT}); forcing a ` +
|
|
971
|
+
`full re-analyze so the database is recreated from the current schema.${nonGitNote}`);
|
|
972
|
+
options = { ...options, force: true };
|
|
973
|
+
}
|
|
974
|
+
// ── a recorded graph-write collapse forces a full rebuild ────────
|
|
975
|
+
//
|
|
976
|
+
// Every other meta-driven trigger above and below gets a block here;
|
|
977
|
+
// `graphWriteCollapsed` was recorded and then never read by anything
|
|
978
|
+
// (`grep -rn graphWriteCollapsed src/` showed writes only). The consequence is
|
|
979
|
+
// the worst available: a collapsed index whose commit has not changed takes
|
|
980
|
+
// the `alreadyUpToDate` fast path, prints "Already up to date", exits 0, and
|
|
981
|
+
// keeps doing so forever. The one state that means "most of your edges are
|
|
982
|
+
// gone" was the one state that repaired itself only if the user happened to
|
|
983
|
+
// pass `--force`.
|
|
984
|
+
//
|
|
985
|
+
// Forcing is the correct remedy rather than merely re-running: the collapse
|
|
986
|
+
// means the persisted graph disagrees with what the pipeline produced, and an
|
|
987
|
+
// incremental pass over unchanged files would write nothing and re-stamp the
|
|
988
|
+
// same broken index as fresh.
|
|
989
|
+
if (existingMeta?.graphWriteCollapsed) {
|
|
990
|
+
const { expected, persisted } = existingMeta.graphWriteCollapsed;
|
|
991
|
+
log(`previous run persisted ${persisted} of ${expected} expected relationships ` +
|
|
992
|
+
`(recorded as a graph-write collapse); forcing a full re-analyze rather than ` +
|
|
993
|
+
`reporting an index this build already knows is incomplete.`);
|
|
994
|
+
options = { ...options, force: true };
|
|
995
|
+
}
|
|
996
|
+
// ── independently-versioned analysis capabilities ────────────────
|
|
997
|
+
// `schemaFingerprint` is reserved for graph-wide incremental invariants. Some
|
|
998
|
+
// persisted semantics apply only to repositories containing relevant source
|
|
999
|
+
// files, so they carry exact feature versions instead. This guard must also
|
|
1000
|
+
// run before alreadyUpToDate: a feature can change what is EXTRACTED without
|
|
1001
|
+
// changing the DDL, so an index whose `schemaFingerprint` matches this build
|
|
1002
|
+
// can still be missing that feature's evidence (e.g. the Class
|
|
1003
|
+
// frameworkAnnotations values, or Java/Kotlin Bean evidence) — the fingerprint
|
|
1004
|
+
// guard above would wave it through.
|
|
1005
|
+
const persistedFilePaths = Object.keys(existingMeta?.fileHashes ?? {});
|
|
1006
|
+
const expectedPersistedAnalysisFeatures = resolveAnalysisFeatureVersions(ANALYSIS_FEATURES, persistedFilePaths);
|
|
1007
|
+
const persistedAnalysisFeatureMismatches = existingMeta
|
|
1008
|
+
? findAnalysisFeatureMismatches(existingMeta.analysisFeatures, expectedPersistedAnalysisFeatures)
|
|
1009
|
+
: [];
|
|
1010
|
+
let analysisFeatureMismatchLogged = false;
|
|
1011
|
+
if (existingMeta && persistedAnalysisFeatureMismatches.length > 0) {
|
|
1012
|
+
log(`analysis capabilities changed (${persistedAnalysisFeatureMismatches.join(', ')}); ` +
|
|
1013
|
+
`forcing a full rebuild so persisted feature evidence is complete.`);
|
|
1014
|
+
options = { ...options, force: true };
|
|
1015
|
+
analysisFeatureMismatchLogged = true;
|
|
1016
|
+
}
|
|
1017
|
+
// Analyzer provenance is part of freshness, not merely diagnostics. A
|
|
1018
|
+
// same-commit fast path must not preserve metadata produced by an older,
|
|
1019
|
+
// malformed, or dependency/native-different runner. Force a real rebuild so
|
|
1020
|
+
// the graph and its schema-v4 receipt are finalized atomically together.
|
|
1021
|
+
if (existingMeta && !analyzerRunnerIdentitiesEqual(existingMeta.runnerIdentity, runnerIdentity)) {
|
|
1022
|
+
const stampedRunnerSchema = existingMeta.runnerIdentity?.schemaVersion;
|
|
1023
|
+
log(`analyzer runner identity changed (stamped schema ${String(stampedRunnerSchema ?? 'missing')}, ` +
|
|
1024
|
+
`this build uses schema ${runnerIdentity.schemaVersion}); forcing a full rebuild so the ` +
|
|
1025
|
+
'index provenance matches the analyzer and dependency/native runtime that produced it.');
|
|
548
1026
|
options = { ...options, force: true };
|
|
549
1027
|
}
|
|
550
1028
|
if (existingMeta &&
|
|
@@ -554,8 +1032,47 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
554
1032
|
`text and query-time segmentation stay in sync.`);
|
|
555
1033
|
options = { ...options, force: true };
|
|
556
1034
|
}
|
|
1035
|
+
// ── embedding width mismatch forces full rebuild (#2798) ──────────
|
|
1036
|
+
// The half of the schema `SCHEMA_FINGERPRINT` deliberately cannot cover:
|
|
1037
|
+
// `CodeEmbedding.embedding` is declared `FLOAT[EMBEDDING_DIMS]`, and that
|
|
1038
|
+
// width comes from `GITNEXUS_EMBEDDING_DIMS` at module load, so folding it
|
|
1039
|
+
// into a digest of CODE would make the same build disagree with itself under
|
|
1040
|
+
// two envs. Without this block a dims flip on a same-commit clean tree fired
|
|
1041
|
+
// NO guard: the fast path below returned over a FLOAT[384] table while this
|
|
1042
|
+
// process embedded at 768. The one older reaction (in the embedding-restore
|
|
1043
|
+
// block further down) discards the CACHE and re-embeds — into a column whose
|
|
1044
|
+
// width it never revisits.
|
|
1045
|
+
//
|
|
1046
|
+
// Forcing is again what repairs it, and for the same reason as the
|
|
1047
|
+
// fingerprint guard: only a full rebuild wipes the database and re-runs the
|
|
1048
|
+
// DDL, and `runSchemaCreationQueries` suppresses "already exists", so
|
|
1049
|
+
// re-running CREATE over the existing DB would silently keep the old width.
|
|
1050
|
+
// Not conditioned on the index actually holding vectors — the table is
|
|
1051
|
+
// created for every index either way, and nothing but a rebuild can retype it.
|
|
1052
|
+
//
|
|
1053
|
+
// ABSENT is NOT a mismatch here (see embeddingDimsMismatch for the argument):
|
|
1054
|
+
// it means an index predating the field, whose width is unknown but was
|
|
1055
|
+
// consistent with the env that wrote it, and which the fingerprint guard
|
|
1056
|
+
// above already rebuilds — that rebuild is where the stamp lands.
|
|
1057
|
+
if (existingMeta && embeddingDimsMismatch(existingMeta.embeddingDims, EMBEDDING_DIMS)) {
|
|
1058
|
+
// Only NAME a recorded width that could be one, for the reason the
|
|
1059
|
+
// fingerprint guard gates its stamp on `isSchemaFingerprintShaped`:
|
|
1060
|
+
// meta.json is a schema-less JSON.parse of on-disk state, so a value that
|
|
1061
|
+
// is not a positive integer is not worth quoting back at the user.
|
|
1062
|
+
const recordedDims = existingMeta.embeddingDims;
|
|
1063
|
+
const built = typeof recordedDims === 'number' && Number.isInteger(recordedDims) && recordedDims > 0
|
|
1064
|
+
? `FLOAT[${recordedDims}]`
|
|
1065
|
+
: 'an unrecognized width';
|
|
1066
|
+
log(`embedding dimensions changed (index built with ${built}, this run embeds at ` +
|
|
1067
|
+
`${EMBEDDING_DIMS}); forcing a full rebuild so the vector column is recreated at the ` +
|
|
1068
|
+
`new width. Tip: set GITNEXUS_EMBEDDING_DIMS (or --embedding-dims) to pin it across runs.`);
|
|
1069
|
+
options = { ...options, force: true };
|
|
1070
|
+
}
|
|
557
1071
|
// ── Early-return: already up to date ──────────────────────────────
|
|
558
|
-
if (existingMeta &&
|
|
1072
|
+
if (existingMeta &&
|
|
1073
|
+
!existingMeta.embeddingCheckpoint &&
|
|
1074
|
+
!options.force &&
|
|
1075
|
+
existingMeta.lastCommit === currentCommit) {
|
|
559
1076
|
// Non-git folders have currentCommit = '' — always rebuild since we can't detect changes
|
|
560
1077
|
if (currentCommit !== '') {
|
|
561
1078
|
// For git repos, even if HEAD matches lastCommit, the working tree
|
|
@@ -570,33 +1087,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
570
1087
|
// Counting them as dirty would perpetually defeat the up-to-date
|
|
571
1088
|
// fast path because the previous analyze just wrote them
|
|
572
1089
|
// (regression vs PR #1233 behavior).
|
|
573
|
-
const dirty = (
|
|
574
|
-
try {
|
|
575
|
-
const out = execFileSync('git', [
|
|
576
|
-
'status',
|
|
577
|
-
'--porcelain',
|
|
578
|
-
'--',
|
|
579
|
-
'.',
|
|
580
|
-
':(exclude).gitnexus',
|
|
581
|
-
':(exclude).gitnexus/**',
|
|
582
|
-
':(exclude).claude',
|
|
583
|
-
':(exclude).claude/**',
|
|
584
|
-
':(exclude).cursor',
|
|
585
|
-
':(exclude).cursor/**',
|
|
586
|
-
':(exclude)AGENTS.md',
|
|
587
|
-
':(exclude)CLAUDE.md',
|
|
588
|
-
], {
|
|
589
|
-
cwd: repoPath,
|
|
590
|
-
stdio: ['ignore', 'pipe', 'ignore'],
|
|
591
|
-
windowsHide: true,
|
|
592
|
-
encoding: 'utf8',
|
|
593
|
-
});
|
|
594
|
-
return out.trim().length > 0;
|
|
595
|
-
}
|
|
596
|
-
catch {
|
|
597
|
-
return true; // conservative on git failure
|
|
598
|
-
}
|
|
599
|
-
})();
|
|
1090
|
+
const dirty = isWorkingTreeDirty(repoPath);
|
|
600
1091
|
// Registration wrinkle around the fast path (#2264). A prior
|
|
601
1092
|
// `analyze --name X` that hit a name collision writes meta.json (meta-save
|
|
602
1093
|
// runs before registerRepo) then fails before registering, leaving the
|
|
@@ -610,6 +1101,21 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
610
1101
|
// possibly half-finalized index. `isRepoRegistered` is only read on the
|
|
611
1102
|
// opt-in branch so the common fast path keeps its single-stat cost.
|
|
612
1103
|
const healUnregistered = options.allowDuplicateName === true && !(await isRepoRegistered(repoPath));
|
|
1104
|
+
// §5.C is deliberately NOT self-healed here. An #2841 FTS-forced rebuild
|
|
1105
|
+
// stamps `lastCommit`, so a plain rerun lands on this fast path and the
|
|
1106
|
+
// search indexes stay missing until the next content change. The fix for
|
|
1107
|
+
// that is the ADVICE, not a probe: the degraded-search warning now points
|
|
1108
|
+
// at `gitnexus analyze --repair-fts` (which rebuilds the indexes without
|
|
1109
|
+
// re-parsing anything) instead of "then rerun".
|
|
1110
|
+
//
|
|
1111
|
+
// An auto-heal probe was tried and reverted. It could not distinguish
|
|
1112
|
+
// "extension was missing" from "index build failed" without a stamped
|
|
1113
|
+
// discriminator, so a deterministic build failure (#2544/#2546) re-analyzed
|
|
1114
|
+
// the whole repo on every invocation forever; it opened the live index on
|
|
1115
|
+
// the millisecond fast path; and it turned this early return into a full
|
|
1116
|
+
// re-analysis whenever an index authored where FTS was unavailable was
|
|
1117
|
+
// later read on a host where it loads — which is a legitimate, common
|
|
1118
|
+
// state, and the invariant `analyzer-identity-cli.test.ts` pins.
|
|
613
1119
|
if (!dirty && !healUnregistered) {
|
|
614
1120
|
// ── #2354: restamp the workspace label on a same-commit branch flip ──
|
|
615
1121
|
// The flat slot follows the checked-out working tree; a branch switch
|
|
@@ -677,7 +1183,9 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
677
1183
|
let cachedEmbeddingNodeIds = new Set();
|
|
678
1184
|
let cachedEmbeddings = [];
|
|
679
1185
|
const existingEmbeddingCount = existingMeta?.stats?.embeddings ?? 0;
|
|
680
|
-
const { forceRegenerateEmbeddings, preserveExistingEmbeddings, shouldGenerateEmbeddings, shouldLoadCache, } = _deriveEmbeddingMode(options, existingEmbeddingCount);
|
|
1186
|
+
const { forceRegenerateEmbeddings, preserveExistingEmbeddings, shouldGenerateEmbeddings: derivedShouldGenerateEmbeddings, shouldLoadCache: derivedShouldLoadCache, } = _deriveEmbeddingMode(options, existingEmbeddingCount);
|
|
1187
|
+
const shouldGenerateEmbeddings = derivedShouldGenerateEmbeddings || resumeEmbeddingCheckpoint;
|
|
1188
|
+
const shouldLoadCache = derivedShouldLoadCache || resumeEmbeddingCheckpoint;
|
|
681
1189
|
if (options.dropEmbeddings && existingEmbeddingCount > 0) {
|
|
682
1190
|
log(`Dropping ${existingEmbeddingCount} existing embeddings (--drop-embeddings). ` +
|
|
683
1191
|
`Re-run with --embeddings to regenerate.`);
|
|
@@ -738,6 +1246,21 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
738
1246
|
// Loaded into a single ParseCache object that the pipeline mutates
|
|
739
1247
|
// in-place (cache hits leave entries unchanged; misses add new ones).
|
|
740
1248
|
const parseCache = await loadParseCache(storagePath);
|
|
1249
|
+
// Streamed structural emit (#2680). Resolved ONCE, so the pipeline flag and
|
|
1250
|
+
// the CSV-dir resolution below cannot disagree — and resolved HERE, not at
|
|
1251
|
+
// function entry, because the POSITION is load-bearing: the gate is
|
|
1252
|
+
// `options.force`, and every freshness guard above REBINDS `options` with
|
|
1253
|
+
// `force: true` (embedding-checkpoint drop, dirty-flag recovery, pdg-mode
|
|
1254
|
+
// flip, schema-fingerprint change, analysis-feature drift, runner-identity change,
|
|
1255
|
+
// CJK-mode change). Resolving before them froze the answer at `false` for
|
|
1256
|
+
// every rebuild they trigger — including the whole-fleet rebuild an
|
|
1257
|
+
// schema-fingerprint change forces on every existing index at once,
|
|
1258
|
+
// which is exactly when the #2649 memory relief matters most. So this MUST
|
|
1259
|
+
// stay below the last guard that can set `force` and above its first use.
|
|
1260
|
+
// (The post-pipeline analysis-feature re-check can also set `force`, but the
|
|
1261
|
+
// pipeline has already run by then; that run emits non-streamed, precisely as
|
|
1262
|
+
// `resolveStreamPdgEmit` — read fresh at the same point — behaves.)
|
|
1263
|
+
const streamGraphEmitActive = resolveStreamGraphEmit(options);
|
|
741
1264
|
// ── Phase 1: Full Pipeline (0–60%) ────────────────────────────────
|
|
742
1265
|
const pipelineResult = await runPipelineFromRepo(repoPath, (p) => {
|
|
743
1266
|
const phaseLabel = PHASE_LABELS[p.phase] || p.phase;
|
|
@@ -766,6 +1289,16 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
766
1289
|
// offloaded BasicBlock layer. Memory-only; byte-identical output.
|
|
767
1290
|
streamPdgEmit: resolveStreamPdgEmit(options),
|
|
768
1291
|
pdgEmitChunkSize: resolvePdgEmitChunkSize(options),
|
|
1292
|
+
// Streamed structural emit (#2680) — same full-rebuild gate as the PDG
|
|
1293
|
+
// toggle above, for the same incremental-writeback reason.
|
|
1294
|
+
streamGraphEmit: streamGraphEmitActive,
|
|
1295
|
+
// Resolved ONLY when streaming is active: on a Windows non-ASCII storage
|
|
1296
|
+
// path this helper mkdtempSyncs a real directory, so evaluating it
|
|
1297
|
+
// unconditionally would leak one temp dir per analyze even with the flag
|
|
1298
|
+
// off. The PDG sibling resolves inside its guard for the same reason.
|
|
1299
|
+
graphEmitCsvDir: streamGraphEmitActive
|
|
1300
|
+
? resolveNativeSafeStorageDir(storagePath, 'graph-csv')
|
|
1301
|
+
: undefined,
|
|
769
1302
|
fetchWrappers: options.fetchWrappers,
|
|
770
1303
|
});
|
|
771
1304
|
// ── Phase 2: LadybugDB (60–85%) ──────────────────────────────────
|
|
@@ -782,6 +1315,20 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
782
1315
|
}
|
|
783
1316
|
});
|
|
784
1317
|
const newFileHashes = await computeFileHashes(repoPath, allFilePaths);
|
|
1318
|
+
const currentAnalysisFeatures = resolveAnalysisFeatureVersions(ANALYSIS_FEATURES, allFilePaths);
|
|
1319
|
+
const currentAnalysisFeatureMismatches = existingMeta
|
|
1320
|
+
? findAnalysisFeatureMismatches(existingMeta.analysisFeatures, currentAnalysisFeatures)
|
|
1321
|
+
: [];
|
|
1322
|
+
if (existingMeta &&
|
|
1323
|
+
currentAnalysisFeatureMismatches.length > 0 &&
|
|
1324
|
+
!analysisFeatureMismatchLogged) {
|
|
1325
|
+
// Covers a repository gaining or losing its first applicable source file:
|
|
1326
|
+
// the persisted file list cannot predict that transition before the
|
|
1327
|
+
// pipeline, but an incremental top-up would leave unchanged rows incomplete.
|
|
1328
|
+
log(`analysis capabilities changed (${currentAnalysisFeatureMismatches.join(', ')}); ` +
|
|
1329
|
+
`forcing a full rebuild so persisted feature evidence is complete.`);
|
|
1330
|
+
options = { ...options, force: true };
|
|
1331
|
+
}
|
|
785
1332
|
// Decide incremental vs full at THIS point (post-pipeline, pre-DB).
|
|
786
1333
|
// All eligibility conditions are checked here against the actual
|
|
787
1334
|
// pipeline output — no separate pre-pipeline prediction to desync from
|
|
@@ -790,7 +1337,11 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
790
1337
|
// path, silently losing embeddings).
|
|
791
1338
|
const isIncremental = !options.force &&
|
|
792
1339
|
!!existingMeta &&
|
|
793
|
-
|
|
1340
|
+
// Belt and braces, not a second gate: the guard above already set `force`
|
|
1341
|
+
// on exactly this condition, and `!options.force` short-circuits before
|
|
1342
|
+
// this conjunct is reached. Kept so the eligibility contract reads whole.
|
|
1343
|
+
!schemaFingerprintMismatch(existingMeta.schemaFingerprint) &&
|
|
1344
|
+
currentAnalysisFeatureMismatches.length === 0 &&
|
|
794
1345
|
!!existingMeta.fileHashes &&
|
|
795
1346
|
Object.keys(existingMeta.fileHashes).length > 0 &&
|
|
796
1347
|
repoHasGit &&
|
|
@@ -798,6 +1349,61 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
798
1349
|
const hashDiff = isIncremental
|
|
799
1350
|
? diffFileHashes(newFileHashes, existingMeta.fileHashes)
|
|
800
1351
|
: undefined;
|
|
1352
|
+
// #2 atomic index publish: on a full rebuild, build the fresh DB at a temp
|
|
1353
|
+
// path and swap it over the live index in one rename at the very end, so a
|
|
1354
|
+
// concurrent MCP reader opening mid-build only ever sees the previous
|
|
1355
|
+
// complete index (never a wiped/half-built file) and a crash leaves the old
|
|
1356
|
+
// index intact. The whole build flows through the singleton connection, so
|
|
1357
|
+
// only initLbug/wipeLbugDbFiles below take the temp target.
|
|
1358
|
+
//
|
|
1359
|
+
// POSIX only: the common CLI/serve-worker analyze paths skip the native close
|
|
1360
|
+
// (closeLbugBeforeExit, #2264) and leave the build handle open at swap time.
|
|
1361
|
+
// POSIX renames an open file cleanly; a same-process open handle blocks the
|
|
1362
|
+
// rename on Windows. Windows keeps the current in-place behavior
|
|
1363
|
+
// (buildPath === lbugPath, no swap) until that is resolved (see §12/follow-up).
|
|
1364
|
+
const isFullRebuild = !(isIncremental && hashDiff);
|
|
1365
|
+
// Where the swap is allowed:
|
|
1366
|
+
// - POSIX renames an open file, so the usual skip-native-close (#2264) is
|
|
1367
|
+
// fine and the swap always applies.
|
|
1368
|
+
// - Windows can swap only when a real close is safe to release the build
|
|
1369
|
+
// handle before the rename — i.e. NOT a --pdg run (the #2264 destructor
|
|
1370
|
+
// crash). Unverified on Windows CI; falls back to in-place otherwise.
|
|
1371
|
+
const posixSwap = process.platform !== 'win32';
|
|
1372
|
+
// #2614 Windows: the forced real-close before the rename re-bets that #2264 is
|
|
1373
|
+
// --pdg-only, which is unproven (the CLI/worker skip the native close
|
|
1374
|
+
// UNCONDITIONALLY) and unverifiable without a Windows runner. Keep it opt-in
|
|
1375
|
+
// (GITNEXUS_ATOMIC_WINDOWS_SWAP=1) so the default Windows analyze stays on the
|
|
1376
|
+
// proven in-place path; enable it only to test the Windows swap.
|
|
1377
|
+
const windowsSwapOk = process.platform === 'win32' &&
|
|
1378
|
+
options.pdg !== true &&
|
|
1379
|
+
process.env.GITNEXUS_ATOMIC_WINDOWS_SWAP === '1';
|
|
1380
|
+
// Incremental atomicity copies the whole index into the temp before mutating
|
|
1381
|
+
// it, which negates incremental's speed premise — so it is opt-in
|
|
1382
|
+
// (GITNEXUS_ATOMIC_INCREMENTAL=1) pending a benchmark. Full rebuilds always
|
|
1383
|
+
// swap where the platform allows.
|
|
1384
|
+
const wantAtomicIncremental = isIncremental && !!hashDiff && process.env.GITNEXUS_ATOMIC_INCREMENTAL === '1';
|
|
1385
|
+
// #2614 F3: the copy-then-swap stages ONLY the main lbug file, so a live index
|
|
1386
|
+
// carrying an orphan .wal/.shadow (a silently-failed prior checkpoint) would
|
|
1387
|
+
// be copied incompletely and lose that delta. Only take the atomic path when
|
|
1388
|
+
// the live index is a consolidated single file; otherwise fall back to the
|
|
1389
|
+
// in-place writeback, which the next open replays correctly.
|
|
1390
|
+
const atomicIncremental = wantAtomicIncremental && (await inspectLbugSidecars(lbugPath)).kind === 'clean';
|
|
1391
|
+
if (wantAtomicIncremental && !atomicIncremental) {
|
|
1392
|
+
log('atomic-incremental: live index carries orphan sidecars — using in-place writeback');
|
|
1393
|
+
}
|
|
1394
|
+
// `let` (#2841 review H2): an escalation discovered ~440 lines below — from
|
|
1395
|
+
// EITHER cause, a blocked extension or an oversized write set — can upgrade
|
|
1396
|
+
// an in-place incremental write to a staged one, because that valve's plan is
|
|
1397
|
+
// wipe-then-COPY over this very path. See the upgrade at the escalation
|
|
1398
|
+
// valve. Nothing between here and there reads either binding except
|
|
1399
|
+
// `initLbug(buildPath)`, which the upgrade re-runs against the staging path.
|
|
1400
|
+
let useAtomicSwap = (isFullRebuild || atomicIncremental) && (posixSwap || windowsSwapOk);
|
|
1401
|
+
// #2658: a per-run staging name (was the fixed `lbug.new`). Even under the
|
|
1402
|
+
// single-writer lock, a unique name means a crashed run's half-built staging
|
|
1403
|
+
// file can never be mistaken for — or clobber — a live run's; the lock's
|
|
1404
|
+
// orphan sweep (sweepStagingArtifacts) reclaims stragglers on the next
|
|
1405
|
+
// acquire. The `.staging.` prefix is what that sweep matches.
|
|
1406
|
+
let buildPath = useAtomicSwap ? `${lbugPath}.staging.${randomUUID()}` : lbugPath;
|
|
801
1407
|
if (isIncremental && hashDiff) {
|
|
802
1408
|
log(`Incremental: changed=${hashDiff.changed.length}, ` +
|
|
803
1409
|
`added=${hashDiff.added.length}, ` +
|
|
@@ -816,6 +1422,14 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
816
1422
|
directWriteCount: hashDiff.toWrite.length,
|
|
817
1423
|
},
|
|
818
1424
|
});
|
|
1425
|
+
if (atomicIncremental) {
|
|
1426
|
+
// Stage the live index into the temp so the in-place delete/writeback
|
|
1427
|
+
// below mutates the COPY, and the end-of-run swap publishes it atomically.
|
|
1428
|
+
// Clear any stale temp first (a crashed run), then copy the (consolidated,
|
|
1429
|
+
// single-file) live index. Whole-file copy — hence opt-in.
|
|
1430
|
+
await wipeLbugDbFiles(buildPath);
|
|
1431
|
+
await fs.copyFile(lbugPath, buildPath);
|
|
1432
|
+
}
|
|
819
1433
|
}
|
|
820
1434
|
else {
|
|
821
1435
|
// Full rebuild path: wipe DB files first.
|
|
@@ -846,9 +1460,29 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
846
1460
|
// valve below can never drift. Failures now throw a typed LbugWipeError
|
|
847
1461
|
// (ENOENT-verified removal) instead of silently letting initLbug reopen
|
|
848
1462
|
// a still-populated DB this run believes it wiped.
|
|
849
|
-
|
|
1463
|
+
//
|
|
1464
|
+
// With the atomic swap (POSIX), this wipes the TEMP build target
|
|
1465
|
+
// (`buildPath` = `<lbugPath>.new`, clearing any stragglers from a crashed
|
|
1466
|
+
// run) and leaves the live index untouched until the end-of-run swap. On
|
|
1467
|
+
// Windows buildPath === lbugPath, so this is the original in-place wipe.
|
|
1468
|
+
await wipeLbugDbFiles(buildPath);
|
|
850
1469
|
}
|
|
851
|
-
|
|
1470
|
+
// Size the buffer pool to the graph just built by the pipeline (a page cache
|
|
1471
|
+
// over the on-disk index, which scales with node/edge count) instead of the
|
|
1472
|
+
// fixed 2 GiB default, whose eager commit dominates large-repo analyze. The
|
|
1473
|
+
// size is clamped to [COPY-safety floor, default], so it only ever shrinks
|
|
1474
|
+
// the pool; env override / no-hint paths are unchanged. See
|
|
1475
|
+
// resolveBufferManagerSize / estimateBufferPool.
|
|
1476
|
+
setBufferPoolSizeHint(estimateBufferPool(pipelineResult.graph.nodeCount +
|
|
1477
|
+
pipelineResult.graph.relationshipCount +
|
|
1478
|
+
// Streamed edges left the heap but still get COPYed, so they are part of
|
|
1479
|
+
// the real load volume (#2680). The hint only ever SHRINKS the pool, so
|
|
1480
|
+
// omitting them would starve the COPY at exactly the scale streaming
|
|
1481
|
+
// exists to serve.
|
|
1482
|
+
(pipelineResult.graphEmitManifest?.totalRows ?? 0)));
|
|
1483
|
+
// Full rebuild (POSIX) builds into the temp `buildPath`; incremental and
|
|
1484
|
+
// Windows use `buildPath === lbugPath` in place.
|
|
1485
|
+
await initLbug(buildPath);
|
|
852
1486
|
// Manual WAL checkpoint driver (#1741): periodically drain the WAL
|
|
853
1487
|
// from JS so the un-retriable native auto-checkpoint almost never
|
|
854
1488
|
// has work left to do. Failures of the manual CHECKPOINT are absorbed
|
|
@@ -882,6 +1516,10 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
882
1516
|
// process already holds and — worse — ran a read against the DB between
|
|
883
1517
|
// writeback and finalize for no recovery benefit.
|
|
884
1518
|
let deletedFilePathsForRestore = null;
|
|
1519
|
+
// True once this run has persisted only a CHANGED SUBGRAPH. The post-write
|
|
1520
|
+
// collapse check compares the whole in-memory graph against the whole DB,
|
|
1521
|
+
// which is only a like-for-like comparison on a full rebuild.
|
|
1522
|
+
let wroteChangedSubgraphOnly = false;
|
|
885
1523
|
if (isIncremental && hashDiff) {
|
|
886
1524
|
// ── Incremental DB writeback ───────────────────────────────────
|
|
887
1525
|
// 0. Expand the writable set with transitive importers of
|
|
@@ -1010,6 +1648,39 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1010
1648
|
// and extractChangedSubgraph — asymmetry between the two would
|
|
1011
1649
|
// leave stale rows or PK-conflict at COPY time.
|
|
1012
1650
|
const effectiveWriteSet = computeEffectiveWriteSet(pipelineResult.graph, writableFiles);
|
|
1651
|
+
// `frameworkAnnotations` is derived from cross-file JVM visibility, so
|
|
1652
|
+
// an unchanged Class row can change when a same-package declaration is
|
|
1653
|
+
// added or removed without producing an IMPORTS edge. Compare the fresh
|
|
1654
|
+
// graph against the pre-write DB and rewrite only files whose persisted
|
|
1655
|
+
// value drifted. Add them after edge-boundary expansion: relationships
|
|
1656
|
+
// touching these files are already included by extractChangedSubgraph,
|
|
1657
|
+
// while pulling every unchanged neighbor would add no correctness.
|
|
1658
|
+
// Only supported Spring Bean source changes can alter this property;
|
|
1659
|
+
// avoid materializing every persisted Class row for unrelated language
|
|
1660
|
+
// updates. Check deleted paths too so removing/renaming a Java shadowing
|
|
1661
|
+
// declaration still refreshes unchanged Spring candidates.
|
|
1662
|
+
const beanSourceChanged = hashDiff.toWrite.some(isSpringBeanCandidateSourceFile) ||
|
|
1663
|
+
hashDiff.deleted.some(isSpringBeanCandidateSourceFile);
|
|
1664
|
+
if (beanSourceChanged) {
|
|
1665
|
+
const persistedFrameworkAnnotations = (await executeQuery('MATCH (c:Class) ' + 'RETURN c.id AS id, c.frameworkAnnotations AS frameworkAnnotations'));
|
|
1666
|
+
const frameworkAnnotationDriftFiles = collectFrameworkAnnotationDriftFiles(pipelineResult.graph, persistedFrameworkAnnotations);
|
|
1667
|
+
for (const filePath of frameworkAnnotationDriftFiles)
|
|
1668
|
+
effectiveWriteSet.add(filePath);
|
|
1669
|
+
if (frameworkAnnotationDriftFiles.size > 0) {
|
|
1670
|
+
log(`Incremental: +${frameworkAnnotationDriftFiles.size} file(s) added for ` +
|
|
1671
|
+
'framework annotation property drift');
|
|
1672
|
+
}
|
|
1673
|
+
const persistedSpringBeanDeclarations = (await executeQuery('MATCH (m:Method)-[r:CodeRelation]->(b:CodeElement) ' +
|
|
1674
|
+
"WHERE r.type = 'DECLARES' AND r.reason STARTS WITH 'spring-bean-factory:' " +
|
|
1675
|
+
'RETURN b.id AS id, b.filePath AS filePath, r.reason AS reason'));
|
|
1676
|
+
const springBeanDeclarationDriftFiles = collectSpringBeanDeclarationDriftFiles(pipelineResult.graph, persistedSpringBeanDeclarations);
|
|
1677
|
+
for (const filePath of springBeanDeclarationDriftFiles)
|
|
1678
|
+
effectiveWriteSet.add(filePath);
|
|
1679
|
+
if (springBeanDeclarationDriftFiles.size > 0) {
|
|
1680
|
+
log(`Incremental: +${springBeanDeclarationDriftFiles.size} file(s) added for ` +
|
|
1681
|
+
'Spring Bean factory declaration drift');
|
|
1682
|
+
}
|
|
1683
|
+
}
|
|
1013
1684
|
// Deduped: deleted entries may already appear via importer-BFS
|
|
1014
1685
|
// expansion (the importer BFS can return a now-deleted path), which
|
|
1015
1686
|
// would otherwise hand deleteNodesForFiles the same path twice in one
|
|
@@ -1030,15 +1701,182 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1030
1701
|
// DB write plan changes here; fileHashes/meta bookkeeping is identical.
|
|
1031
1702
|
// Thresholds + the AND-gate live in incremental/escalation-gate.ts.
|
|
1032
1703
|
const writeFraction = effectiveWriteSet.size / Math.max(1, allFilePaths.length);
|
|
1033
|
-
|
|
1704
|
+
// VECTOR gate (#2623) — load the extension BEFORE a single embedding row
|
|
1705
|
+
// is touched. `deleteNodesForFiles` below opens with the CodeEmbedding
|
|
1706
|
+
// join-delete, and LadybugDB refuses all DML on a table carrying its HNSW
|
|
1707
|
+
// index unless VECTOR is loaded on this connection; nothing else on this
|
|
1708
|
+
// path loads it until Phase 4, so every incremental run over a DB that
|
|
1709
|
+
// already built `code_embedding_idx` died here. Same seam the FTS drop
|
|
1710
|
+
// occupies at the head of this branch (#2589): index lifecycle first,
|
|
1711
|
+
// then rows. UNCONDITIONAL — not gated on `shouldGenerateEmbeddings` —
|
|
1712
|
+
// because a DB carrying the index from an earlier `--embeddings` run hits
|
|
1713
|
+
// the identical wall on a plain incremental run.
|
|
1714
|
+
//
|
|
1715
|
+
// When VECTOR genuinely cannot load, the table is immutable (the index
|
|
1716
|
+
// cannot be dropped without the extension either), so surgery is
|
|
1717
|
+
// impossible: fall through to the escalation valve's wipe-and-COPY plan,
|
|
1718
|
+
// which rebuilds the DB files outright and needs no embedding-row DML.
|
|
1719
|
+
//
|
|
1720
|
+
// FTS twin (#2841): the identical wall exists for every table carrying an
|
|
1721
|
+
// FTS index — LadybugDB refuses the DML at BIND time, so even a zero-row
|
|
1722
|
+
// DETACH DELETE fails, and `DROP_FTS_INDEX` is itself an FTS-extension
|
|
1723
|
+
// function (there is no SQL `DROP INDEX` at all), so the indexes cannot be
|
|
1724
|
+
// cleared in place either. Same verdict, same remedy: escalate. Both gates
|
|
1725
|
+
// share ONE `SHOW_INDEXES` read — they answer different questions about the
|
|
1726
|
+
// same catalog snapshot, and nothing between here and the write plan
|
|
1727
|
+
// creates or drops an index.
|
|
1728
|
+
const indexCatalogRows = await readIndexCatalogSnapshot();
|
|
1729
|
+
const embeddingRowDmlSafe = await ensureEmbeddingRowDmlSafe(indexCatalogRows);
|
|
1730
|
+
const ftsRowDmlSafe = await ensureFtsRowDmlSafe(indexCatalogRows);
|
|
1731
|
+
const extensionForcedRebuild = !embeddingRowDmlSafe || !ftsRowDmlSafe;
|
|
1732
|
+
// `!options.dropEmbeddings` (H1): this rescue reads the rows back OUT of
|
|
1733
|
+
// the DB, so it must never fire on the one path whose entire purpose is to
|
|
1734
|
+
// destroy them. `--drop-embeddings` deliberately leaves `cachedEmbeddings`
|
|
1735
|
+
// empty (`deriveEmbeddingMode` returns `shouldLoadCache: false` for it by
|
|
1736
|
+
// construction — see the four-mode comment at the cache-load site), and its
|
|
1737
|
+
// `options.force = true` conversion sits INSIDE
|
|
1738
|
+
// `if (existingMeta?.embeddingCheckpoint)`, so a repo without a checkpoint
|
|
1739
|
+
// stays incremental and arrives here holding exactly the state the rescue
|
|
1740
|
+
// reads as "the index metadata did not account for them" — restoring the N
|
|
1741
|
+
// rows the operator just asked to wipe, printing `Preserving N` on top of
|
|
1742
|
+
// this run's own `Dropping N` line, and exiting 0.
|
|
1743
|
+
//
|
|
1744
|
+
// The predicate has to be the FLAG, not `shouldLoadCache`: that would also
|
|
1745
|
+
// disable the rescue in the case it exists for (meta says 0 embeddings
|
|
1746
|
+
// while rows survive ⇒ `hasExisting` false ⇒ `shouldLoadCache` false), i.e.
|
|
1747
|
+
// it would fix the wipe by deleting the safeguard. Covers
|
|
1748
|
+
// `--drop-embeddings --embeddings` too — the rescue repopulates
|
|
1749
|
+
// `cachedEmbeddingNodeIds`, which Phase 4 hands `runEmbeddingPipeline` as
|
|
1750
|
+
// the already-embedded set, so the very nodes the user asked to REGENERATE
|
|
1751
|
+
// would be skipped.
|
|
1752
|
+
if (extensionForcedRebuild && !options.dropEmbeddings && cachedEmbeddings.length === 0) {
|
|
1753
|
+
// The escalation below WIPES the DB files, and Phase 3.5 restores
|
|
1754
|
+
// embedding rows from `cachedEmbeddings` — which is only populated when
|
|
1755
|
+
// `deriveEmbeddingMode` saw `meta.stats.embeddings > 0`. A DB whose meta
|
|
1756
|
+
// under-reports its embeddings (meta restored from an older run, or a
|
|
1757
|
+
// count that never got stamped) would therefore have every vector
|
|
1758
|
+
// silently destroyed by a rebuild it did not ask for. Read them now,
|
|
1759
|
+
// while the DB is still intact — a plain MATCH, which needs no VECTOR
|
|
1760
|
+
// extension. Rows whose owning node is gone are dropped by Phase 3.5's
|
|
1761
|
+
// live-graph filter, exactly as on any other wiped path.
|
|
1762
|
+
const rescued = await loadCachedEmbeddings();
|
|
1763
|
+
if (rescued.embeddings.length > 0) {
|
|
1764
|
+
cachedEmbeddings = rescued.embeddings;
|
|
1765
|
+
cachedEmbeddingNodeIds = rescued.embeddingNodeIds;
|
|
1766
|
+
log(`Preserving ${rescued.embeddings.length} embedding row(s) across the forced rebuild ` +
|
|
1767
|
+
`(the index metadata did not account for them).`);
|
|
1768
|
+
}
|
|
1769
|
+
}
|
|
1770
|
+
// Hoisted out of the `||` below (§5.D): the size verdict has to be KNOWN
|
|
1771
|
+
// even when a blocked extension already forced the rebuild, or the message
|
|
1772
|
+
// cannot report both. Pure predicate over three numbers
|
|
1773
|
+
// (incremental/escalation-gate.ts), so evaluating it unconditionally costs
|
|
1774
|
+
// nothing and has no side effects.
|
|
1775
|
+
const sizeForcedRebuild = shouldEscalateIncrementalWrite(filesToDelete.length, effectiveWriteSet.size, allFilePaths.length);
|
|
1776
|
+
if (extensionForcedRebuild || sizeForcedRebuild) {
|
|
1034
1777
|
escalatedFullWrite = true;
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1778
|
+
// Every live cause is named, not just the first: a DB can carry BOTH a
|
|
1779
|
+
// vector index and FTS indexes, and reporting one cause while the other
|
|
1780
|
+
// is equally fatal is how #2841 stayed mis-diagnosed for so long. §5.D:
|
|
1781
|
+
// that argument crosses the extension/size boundary too, so the size
|
|
1782
|
+
// cause is APPENDED here rather than selected between — the old either/or
|
|
1783
|
+
// ternary dropped the write-set line whenever an extension also blocked.
|
|
1784
|
+
const escalationCauses = [];
|
|
1785
|
+
const degradedEffects = [];
|
|
1786
|
+
// H5: `readIndexCatalogRows()` returning nothing means "could not prove
|
|
1787
|
+
// anything", and both gates correctly fail CLOSED on it — but a
|
|
1788
|
+
// fail-closed sentinel is not evidence. Asserting "the CodeEmbedding
|
|
1789
|
+
// vector index exists" from it is affirmatively FALSE on a repo that
|
|
1790
|
+
// never enabled embeddings, and the only truthful signal (the adapter's
|
|
1791
|
+
// `Could not read the LadybugDB index catalog` warning) goes to the pino
|
|
1792
|
+
// stderr stream, NOT this `onLog` callback — so `gitnexus serve` and the
|
|
1793
|
+
// analyze worker UI would show the invented claim alone. Emit one honest
|
|
1794
|
+
// cause naming the unsettled read instead of two fabricated ones.
|
|
1795
|
+
// Tested against the explicit sentinel, NOT truthiness: §5.A made the
|
|
1796
|
+
// failed read representable (`INDEX_CATALOG_UNREADABLE`) precisely so
|
|
1797
|
+
// "the caller passed nothing" and "the caller tried and could not prove
|
|
1798
|
+
// anything" stop sharing one value — and the sentinel is a Symbol, so a
|
|
1799
|
+
// `!indexCatalogRows` test would silently never fire here.
|
|
1800
|
+
const indexCatalogUnreadable = indexCatalogRows === INDEX_CATALOG_UNREADABLE;
|
|
1801
|
+
// `extensionForcedRebuild &&`: an unreadable catalog is only a CAUSE
|
|
1802
|
+
// when it actually blocked something. A size-only escalation whose
|
|
1803
|
+
// catalog read happened to fail still had both gates answer "safe"
|
|
1804
|
+
// (both extensions loaded), and claiming otherwise would trade one
|
|
1805
|
+
// invented cause for another.
|
|
1806
|
+
if (extensionForcedRebuild && indexCatalogUnreadable) {
|
|
1807
|
+
const blockedExtensions = [
|
|
1808
|
+
!embeddingRowDmlSafe ? 'VECTOR' : undefined,
|
|
1809
|
+
!ftsRowDmlSafe ? 'FTS' : undefined,
|
|
1810
|
+
].filter((name) => name !== undefined);
|
|
1811
|
+
escalationCauses.push(`the LadybugDB index catalog could not be read (the read error is on the analyzer's ` +
|
|
1812
|
+
`warning stream), so neither a live ${EMBEDDING_TABLE_NAME} vector index nor a live ` +
|
|
1813
|
+
`FTS search index could be ruled out, and the ${blockedExtensions.join(' and ')} ` +
|
|
1814
|
+
`extension${blockedExtensions.length > 1 ? 's' : ''} could not be loaded to rewrite ` +
|
|
1815
|
+
`indexed rows in place either`);
|
|
1816
|
+
}
|
|
1817
|
+
if (!embeddingRowDmlSafe) {
|
|
1818
|
+
if (!indexCatalogUnreadable) {
|
|
1819
|
+
escalationCauses.push(`the ${EMBEDDING_TABLE_NAME} vector index exists but the VECTOR extension could not be ` +
|
|
1820
|
+
`loaded, so embedding rows cannot be rewritten in place`);
|
|
1821
|
+
}
|
|
1822
|
+
degradedEffects.push('Semantic search falls back to exact scan until VECTOR is available.');
|
|
1823
|
+
}
|
|
1824
|
+
if (!ftsRowDmlSafe) {
|
|
1825
|
+
if (!indexCatalogUnreadable) {
|
|
1826
|
+
// Self-contained subject (H5): `join('; and ')` used to render "…the
|
|
1827
|
+
// CodeEmbedding vector index exists … and THIS INDEX carries FTS
|
|
1828
|
+
// search indexes…", pointing "this index" at the vector index just
|
|
1829
|
+
// named — and an index does not carry indexes.
|
|
1830
|
+
escalationCauses.push(`the graph store carries one or more FTS search indexes but the FTS extension could ` +
|
|
1831
|
+
`not be loaded, so no indexed table can be written in place (LadybugDB refuses the ` +
|
|
1832
|
+
`write at bind time, and the indexes cannot be dropped without the extension either)`);
|
|
1833
|
+
}
|
|
1834
|
+
degradedEffects.push('Full-text/BM25 search stays degraded until FTS is available.');
|
|
1835
|
+
}
|
|
1836
|
+
if (sizeForcedRebuild) {
|
|
1837
|
+
escalationCauses.push(`the effective write set covers ${effectiveWriteSet.size}/${allFilePaths.length} ` +
|
|
1838
|
+
// Display clamp only (predicate unchanged): BFS-found deleted
|
|
1839
|
+
// importers can push the numerator past the CURRENT file list, so
|
|
1840
|
+
// the raw fraction can exceed 1 — see the population-mismatch note
|
|
1841
|
+
// on shouldEscalateIncrementalWrite (tri-review 4669518496).
|
|
1842
|
+
`files (${Math.min(100, Math.round(writeFraction * 100))}%)`);
|
|
1843
|
+
}
|
|
1844
|
+
// Remedy by CLASSIFICATION, never hand-written (#2841 review H3). The
|
|
1845
|
+
// old tail always said "run `gitnexus doctor` … or set
|
|
1846
|
+
// GITNEXUS_LBUG_EXTENSION_INSTALL=auto", which is affirmatively WRONG
|
|
1847
|
+
// for the `missing_dependency` class (Windows error 126 / absent
|
|
1848
|
+
// OpenSSL 3, #2374/#2669): its own remedy states that reinstalling will
|
|
1849
|
+
// not help, and that class is precisely the environment this escalation
|
|
1850
|
+
// path was registered for on the Windows matrix. Every other rendering
|
|
1851
|
+
// in this file already routes through `diagnoseExtensionLoad` — the
|
|
1852
|
+
// FTS_UNAVAILABLE_LEAD degrade log and the `--repair-fts` failure tail
|
|
1853
|
+
// — so this one does too, once per BLOCKED extension and with that
|
|
1854
|
+
// extension's own label, because the FTS-specific advice the classifier
|
|
1855
|
+
// emits (`gitnexus analyze --repair-fts`) must never be dispensed for
|
|
1856
|
+
// VECTOR. Emitted verbatim and alone: only the classified remedy
|
|
1857
|
+
// reaches the user, never the raw load `reason`, so the message stays
|
|
1858
|
+
// path-free (#2374/#2375 redaction contract). Reached exactly when an
|
|
1859
|
+
// extension blocked the write — `degradedEffects` is pushed by the two
|
|
1860
|
+
// `!…RowDmlSafe` branches above and by nothing else, and each of those
|
|
1861
|
+
// gates only answers `false` after its own load attempt failed, so the
|
|
1862
|
+
// capability record it reads is always populated. Looked up through the
|
|
1863
|
+
// shared `getExtensionCapability`/`getFtsCapability` accessors rather
|
|
1864
|
+
// than a sixth hand-spelled `.find((c) => c.name === …)`: the extension
|
|
1865
|
+
// NAME is the one string the lookup is keyed on, and it belongs in
|
|
1866
|
+
// extension-loader.ts.
|
|
1867
|
+
const extensionRemedies = [
|
|
1868
|
+
!embeddingRowDmlSafe
|
|
1869
|
+
? { reason: getExtensionCapability('VECTOR')?.reason, label: 'VECTOR' }
|
|
1870
|
+
: undefined,
|
|
1871
|
+
!ftsRowDmlSafe ? { reason: getFtsCapability()?.reason, label: 'FTS' } : undefined,
|
|
1872
|
+
]
|
|
1873
|
+
.filter((e) => e !== undefined)
|
|
1874
|
+
.map(({ reason, label }) => diagnoseExtensionLoad(reason, label).remedy);
|
|
1875
|
+
log(`Incremental: ${escalationCauses.join('; and ')} — switching to a full DB write ` +
|
|
1876
|
+
`(wipe + bulk COPY) for this run; file-level incremental bookkeeping is unaffected.` +
|
|
1877
|
+
(degradedEffects.length > 0
|
|
1878
|
+
? ` ${degradedEffects.join(' ')} ${extensionRemedies.join(' ')}`
|
|
1879
|
+
: ''));
|
|
1042
1880
|
// toWriteCount: 0 is the established full-path dirty-flag sentinel;
|
|
1043
1881
|
// the real counters ride along for crash diagnostics.
|
|
1044
1882
|
await saveIncrementalDirtyState('escalated-full-write', {
|
|
@@ -1056,10 +1894,59 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1056
1894
|
// surviving family member throws a typed LbugWipeError here instead
|
|
1057
1895
|
// of letting the reopen below resurrect the rows this run just chose
|
|
1058
1896
|
// to replace wholesale.
|
|
1897
|
+
// #2841 review H2 — never destroy the only complete index before its
|
|
1898
|
+
// replacement is durable. `buildPath` was frozen ~440 lines above, while
|
|
1899
|
+
// this run was still classified incremental, so it still points AT the
|
|
1900
|
+
// live index: escalating without this upgrade means
|
|
1901
|
+
// `wipeLbugDbFiles(lbugPath)` followed by a bulk COPY in place, and an
|
|
1902
|
+
// interrupt, ENOSPC, or COPY failure anywhere in that window leaves NO
|
|
1903
|
+
// complete index at all.
|
|
1904
|
+
//
|
|
1905
|
+
// That invariant is about RECOVERABILITY, which does not depend on why
|
|
1906
|
+
// the run escalated — the wipe-then-COPY plan below is identical for
|
|
1907
|
+
// both causes, so a size-forced escalation loses the index to a Ctrl-C
|
|
1908
|
+
// exactly as an extension-forced one does. Both stage. The escalation
|
|
1909
|
+
// rebuilds from the in-memory graph the pipeline already produced, so
|
|
1910
|
+
// staging costs no `fs.copyFile` of the old DB: it is peak disk plus a
|
|
1911
|
+
// rename — precisely what a plain `--force` full rebuild already pays
|
|
1912
|
+
// unconditionally on POSIX.
|
|
1913
|
+
//
|
|
1914
|
+
// Safe because the gate runs BEFORE any row DML: the DB open at
|
|
1915
|
+
// `buildPath` is unmutated, so switching targets loses nothing. The
|
|
1916
|
+
// end-of-run swap publishes the staging file atomically, and a failure
|
|
1917
|
+
// anywhere before it leaves the previous index live (its own comment
|
|
1918
|
+
// says so) with the dirty flag already stamped above for recovery.
|
|
1919
|
+
//
|
|
1920
|
+
// Knock-on effects of flipping `useAtomicSwap` here, both intended:
|
|
1921
|
+
// `ftsFailureIsFatal(..., useAtomicSwap)` now aborts instead of
|
|
1922
|
+
// degrading on an FTS *integrity* error — which is exactly that
|
|
1923
|
+
// predicate's documented staging contract (throwing abandons a
|
|
1924
|
+
// throwaway file and keeps the live index) — and `forceRealCloseForSwap`
|
|
1925
|
+
// engages on Windows, which is why the upgrade is gated on the same
|
|
1926
|
+
// `posixSwap || windowsSwapOk` policy that governs every other swap.
|
|
1927
|
+
// …but NOT when we are escalating out of ignorance. An unreadable
|
|
1928
|
+
// catalog means `CALL SHOW_INDEXES()` itself failed, which on a real
|
|
1929
|
+
// index means the store is damaged — e.g. a stray directory sitting at
|
|
1930
|
+
// `lbug.wal.checkpoint` makes every open of that path an IO exception.
|
|
1931
|
+
// Staging would then quietly write a fresh index NEXT to the damage,
|
|
1932
|
+
// swap it in, and exit 0: the run "succeeds", the broken sidecar
|
|
1933
|
+
// survives untouched, and the next in-place writeback trips over it
|
|
1934
|
+
// again. Building in place keeps the underlying IO fault on the failure
|
|
1935
|
+
// path where the operator gets a diagnosis (this is what
|
|
1936
|
+
// `analyze-wal-checkpoint-failure.test.ts` pins). Staging protects a
|
|
1937
|
+
// HEALTHY live index from a machine-level cause; it must not be used to
|
|
1938
|
+
// route around a damaged one.
|
|
1939
|
+
const catalogWasReadable = indexCatalogRows !== INDEX_CATALOG_UNREADABLE;
|
|
1940
|
+
if (catalogWasReadable && !useAtomicSwap && (posixSwap || windowsSwapOk)) {
|
|
1941
|
+
useAtomicSwap = true;
|
|
1942
|
+
buildPath = `${lbugPath}.staging.${randomUUID()}`;
|
|
1943
|
+
log('Incremental: building the replacement index alongside the live one and swapping it in ' +
|
|
1944
|
+
'at the end, so an interrupted rebuild leaves the current index intact.');
|
|
1945
|
+
}
|
|
1059
1946
|
await walCheckpointDriver.stop();
|
|
1060
1947
|
await closeLbug();
|
|
1061
|
-
await wipeLbugDbFiles(
|
|
1062
|
-
await initLbug(
|
|
1948
|
+
await wipeLbugDbFiles(buildPath);
|
|
1949
|
+
await initLbug(buildPath);
|
|
1063
1950
|
walCheckpointDriver = startWalCheckpointDriver();
|
|
1064
1951
|
await loadGraphToLbug(pipelineResult.graph, pipelineResult.repoPath, storagePath, (msg) => {
|
|
1065
1952
|
lbugMsgCount++;
|
|
@@ -1068,7 +1955,24 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1068
1955
|
});
|
|
1069
1956
|
}
|
|
1070
1957
|
else {
|
|
1071
|
-
// 1a.
|
|
1958
|
+
// 1a. Drop every FTS index before touching a single row (#2589).
|
|
1959
|
+
// `deleteNodesForFiles` below DETACH DELETEs rows out of tables
|
|
1960
|
+
// that otherwise still carry the FTS index built at the end of
|
|
1961
|
+
// the PREVIOUS analyze run — Phase 3 doesn't drop+rebuild it
|
|
1962
|
+
// until well after this delete completes. LadybugDB's FTS
|
|
1963
|
+
// extension is not proven to survive DML against an indexed
|
|
1964
|
+
// table (its own docs never demonstrate it), and that ordering
|
|
1965
|
+
// is exactly what produced "FTS index 'file_fts' is
|
|
1966
|
+
// inconsistent: term is missing during delete". Dropping first
|
|
1967
|
+
// removes the hazard outright; Phase 3's createSearchFTSIndexes
|
|
1968
|
+
// rebuilds every index from the final row set regardless, so
|
|
1969
|
+
// this is a no-op on its own drop step there.
|
|
1970
|
+
// Reuse the snapshot read at the gate above (#2841 cleanup): same run,
|
|
1971
|
+
// same connection, and nothing on this branch creates or drops an index
|
|
1972
|
+
// in between — so re-reading would only weaken the one-read invariant
|
|
1973
|
+
// the snapshot type exists to enforce.
|
|
1974
|
+
await dropSearchFTSIndexes(indexCatalogRows);
|
|
1975
|
+
// 1b. Remove the write set's existing rows — batched (#2409): one
|
|
1072
1976
|
// DETACH DELETE per table per 200-file chunk. The former per-file
|
|
1073
1977
|
// loop issued a count + delete per table per FILE — ~13k
|
|
1074
1978
|
// single-row write transactions on a ~700-file write set — which
|
|
@@ -1105,7 +2009,21 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1105
2009
|
// deleting on every non-pdg incremental run (N runs = N copies of
|
|
1106
2010
|
// every INJECTS row; CodeRelation has no PK and no read-side dedup).
|
|
1107
2011
|
await deleteAllInjects();
|
|
1108
|
-
// 2b.
|
|
2012
|
+
// 2b. Spring AOP pointcuts are matched against the full resolved graph;
|
|
2013
|
+
// a third-file change can invalidate an edge between unchanged files.
|
|
2014
|
+
// Rebuild the complete ADVISED_BY set on every incremental writeback.
|
|
2015
|
+
await deleteAllAdvisedBy();
|
|
2016
|
+
await deleteSpringAopEvidenceNodes();
|
|
2017
|
+
// 2c. Drop Spring-owned DECLARES edges (#2415). The
|
|
2018
|
+
// auto-configuration phase scans every metadata file and recomputes
|
|
2019
|
+
// the full set each run; exact reason filtering leaves declarations
|
|
2020
|
+
// owned by other metadata systems untouched.
|
|
2021
|
+
await deleteSpringAutoConfigurationDeclarations();
|
|
2022
|
+
// 2d. Drop source-unavailable auto-configuration placeholders. Fresh
|
|
2023
|
+
// synthetic nodes are graph-wide in extractChangedSubgraph, so this
|
|
2024
|
+
// also removes an orphan when a newly-added real class takes over.
|
|
2025
|
+
await deleteSpringAutoConfigurationSyntheticClasses();
|
|
2026
|
+
// 2e. Drop interprocedural TAINT_PATH edges (#2084 M4 U6) when pdg is on
|
|
1109
2027
|
// — their validity is a whole-program property (an A→C flow can be
|
|
1110
2028
|
// invalidated by a change to an intermediate function on a third
|
|
1111
2029
|
// file), so endpoint-writability extraction can't refresh them.
|
|
@@ -1113,7 +2031,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1113
2031
|
// graph (isGraphWideRelType), mirroring Community/Process.
|
|
1114
2032
|
if (options.pdg === true) {
|
|
1115
2033
|
await deleteAllInterprocTaintPaths();
|
|
1116
|
-
//
|
|
2034
|
+
// 2f. Drop CALL_SUMMARY edges (PDG FU-C) on an incremental `--pdg`
|
|
1117
2035
|
// writeback. They are re-included from the FULL fresh graph
|
|
1118
2036
|
// (isGraphWideRelType) and the callSummaries phase recomputes every
|
|
1119
2037
|
// summary each run, so delete-all-then-rebuild keeps an unchanged
|
|
@@ -1125,6 +2043,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1125
2043
|
// the SAME effectiveWriteSet so the subgraph and the deletes
|
|
1126
2044
|
// cover identical files (asymmetry would silently corrupt).
|
|
1127
2045
|
const subgraph = extractChangedSubgraph(pipelineResult.graph, effectiveWriteSet);
|
|
2046
|
+
wroteChangedSubgraphOnly = true;
|
|
1128
2047
|
await saveIncrementalDirtyState('load-graph', {
|
|
1129
2048
|
importerExpansion,
|
|
1130
2049
|
shadowSeedCount: shadowSeed.length,
|
|
@@ -1154,7 +2073,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1154
2073
|
lbugMsgCount++;
|
|
1155
2074
|
const pct = Math.min(84, 60 + Math.round((lbugMsgCount / (lbugMsgCount + 10)) * 24));
|
|
1156
2075
|
progress('lbug', pct, msg);
|
|
1157
|
-
}, pipelineResult.pdgEmitManifest);
|
|
2076
|
+
}, pipelineResult.pdgEmitManifest, pipelineResult.graphEmitManifest);
|
|
1158
2077
|
}
|
|
1159
2078
|
// ── Phase 3: FTS (85–90%) ─────────────────────────────────────────
|
|
1160
2079
|
// The analyze (write) path owns building the search indexes, so it uses
|
|
@@ -1171,8 +2090,22 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1171
2090
|
const ftsAvailable = await loadFTSExtension(undefined, {
|
|
1172
2091
|
policy: resolveAnalyzeInstallPolicy(),
|
|
1173
2092
|
});
|
|
2093
|
+
// Tracks whether search indexes actually ended up usable this run — starts
|
|
2094
|
+
// as ftsAvailable (extension loaded) but flips to false below when the
|
|
2095
|
+
// build/verify step itself fails, so capabilities.fts.status / ftsSkipped
|
|
2096
|
+
// stay honest even though that failure no longer aborts the whole analyze.
|
|
2097
|
+
let ftsReady = ftsAvailable;
|
|
2098
|
+
// Why FTS ended up skipped (#2658 review L2): extension-unavailable up front,
|
|
2099
|
+
// or build-failed in the degrade branch below.
|
|
2100
|
+
let ftsSkipReason = ftsAvailable
|
|
2101
|
+
? undefined
|
|
2102
|
+
: 'extension-unavailable';
|
|
1174
2103
|
if (ftsAvailable) {
|
|
1175
|
-
|
|
2104
|
+
// Degrade rather than throw: createSearchFTSIndexes re-tokenizes every
|
|
2105
|
+
// stored row on every run, so a native tokenizer error on a single
|
|
2106
|
+
// pre-existing row (#2544/#2546) must not discard this run's otherwise-
|
|
2107
|
+
// successful graph/embeddings work — only keyword search degrades.
|
|
2108
|
+
const ftsResult = await buildSearchIndexesOrDegrade(executeQuery, {
|
|
1176
2109
|
onIndexStart: options.verbose
|
|
1177
2110
|
? (table, indexName) => log(`FTS: creating ${table}.${indexName}`)
|
|
1178
2111
|
: undefined,
|
|
@@ -1180,18 +2113,38 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1180
2113
|
? (table, indexName) => log(`FTS: ready ${table}.${indexName}`)
|
|
1181
2114
|
: undefined,
|
|
1182
2115
|
});
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
2116
|
+
if (ftsResult.ok) {
|
|
2117
|
+
progress('fts', 90, 'Search indexes ready');
|
|
2118
|
+
}
|
|
2119
|
+
else if (ftsFailureIsFatal(ftsResult.failureClass, useAtomicSwap)) {
|
|
2120
|
+
// #2658: an IO/rename/checkpoint/corruption failure while building FTS
|
|
2121
|
+
// is a genuinely broken build on this disk — not a concurrent writer
|
|
2122
|
+
// (the single-writer lock rules that out). ONLY fatal on the atomic-swap
|
|
2123
|
+
// path: the graph was built into a throwaway staging DB, so throwing
|
|
2124
|
+
// before the swap abandons the staging file and leaves the previous live
|
|
2125
|
+
// index intact. On an in-place build the live DB is already mutated and
|
|
2126
|
+
// cannot be rolled back by throwing (see ftsFailureIsFatal) — those
|
|
2127
|
+
// degrade in the branch below instead.
|
|
2128
|
+
throw new Error(`Search index build failed with an integrity error and the analysis was aborted ` +
|
|
2129
|
+
`to avoid publishing a broken index: ${ftsResult.error}. The previous index is ` +
|
|
2130
|
+
`left intact. Re-run \`gitnexus analyze\`; if it persists, check the disk for space ` +
|
|
2131
|
+
`or corruption.`);
|
|
2132
|
+
}
|
|
2133
|
+
else {
|
|
2134
|
+
ftsReady = false;
|
|
2135
|
+
ftsSkipReason = 'build-failed';
|
|
2136
|
+
log(`FTS index build failed (${ftsResult.error}) — keyword search degraded this run. ` +
|
|
2137
|
+
'Graph and embeddings analysis completed successfully. Run `gitnexus analyze --repair-fts` to retry.');
|
|
2138
|
+
progress('fts', 90, 'Search indexes skipped (build failed)');
|
|
1187
2139
|
}
|
|
1188
|
-
progress('fts', 90, 'Search indexes ready');
|
|
1189
2140
|
}
|
|
1190
2141
|
else {
|
|
1191
2142
|
// For a missing runtime dependency (#2374) the file is present, so the
|
|
1192
2143
|
// generic "install it with network access" tail in FTS_UNAVAILABLE_MESSAGE
|
|
1193
2144
|
// contradicts the remedy's own "reinstalling will NOT help" (#2383 F2). Lead
|
|
1194
2145
|
// with the class-neutral sentence and append only the classified remedy.
|
|
2146
|
+
// Same #2383 mock seam as the repair path above — keep the exported
|
|
2147
|
+
// `getExtensionCapabilities()` lookup here.
|
|
1195
2148
|
const ftsReason = getExtensionCapabilities().find((c) => c.name === 'fts')?.reason;
|
|
1196
2149
|
const { kind, remedy } = diagnoseExtensionLoad(ftsReason);
|
|
1197
2150
|
log(kind === 'missing_dependency'
|
|
@@ -1256,8 +2209,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1256
2209
|
});
|
|
1257
2210
|
progress('embeddings', 88, `Restoring ${rowsToRestore.length} cached embeddings...`);
|
|
1258
2211
|
const EMBED_BATCH = 200;
|
|
1259
|
-
for (
|
|
1260
|
-
const batch = rowsToRestore.slice(i, i + EMBED_BATCH);
|
|
2212
|
+
for (const batch of chunk(rowsToRestore, EMBED_BATCH)) {
|
|
1261
2213
|
try {
|
|
1262
2214
|
await batchInsert(executeWithReusedStatement, batch);
|
|
1263
2215
|
restoredEmbeddingCount += batch.length;
|
|
@@ -1285,9 +2237,8 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1285
2237
|
.map((e) => `${e.nodeId}:${e.chunkIndex}`);
|
|
1286
2238
|
if (orphanRowIds.length > 0) {
|
|
1287
2239
|
try {
|
|
1288
|
-
for (
|
|
1289
|
-
const
|
|
1290
|
-
const listLiteral = `[${chunk
|
|
2240
|
+
for (const batch of chunk(orphanRowIds, DELETE_FILES_CHUNK_SIZE)) {
|
|
2241
|
+
const listLiteral = `[${batch
|
|
1291
2242
|
.map((id) => `'${escapeCypherString(id)}'`)
|
|
1292
2243
|
.join(', ')}]`;
|
|
1293
2244
|
await executeQuery(`MATCH (e:${EMBEDDING_TABLE_NAME}) WHERE e.id IN ${listLiteral} DELETE e`);
|
|
@@ -1307,10 +2258,161 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1307
2258
|
}
|
|
1308
2259
|
// ── Phase 4: Embeddings (90–98%) ──────────────────────────────────
|
|
1309
2260
|
const stats = await getLbugStats();
|
|
2261
|
+
// Post-write integrity: the pipeline knows exactly how many relationships
|
|
2262
|
+
// it produced, and `stats` is what the DB hands back after the write, so a
|
|
2263
|
+
// large shortfall is provable rather than inferred — no comparison against
|
|
2264
|
+
// the previous index needed. This is the guard for a refresh that reports
|
|
2265
|
+
// SUCCESS while leaving the index unusable: edges collapsing to a fraction
|
|
2266
|
+
// of what was built, or a `CodeRelation` table that never materialized
|
|
2267
|
+
// (which surfaces here as a persisted count of zero).
|
|
2268
|
+
//
|
|
2269
|
+
// A RATIO, not equality: some relationship types legitimately do not round
|
|
2270
|
+
// -trip one-for-one, and `--pdg` writes MORE rows into the same table than
|
|
2271
|
+
// the call-graph produced, so demanding equality would fire on healthy
|
|
2272
|
+
// runs. Only a collapse is a defect.
|
|
2273
|
+
//
|
|
2274
|
+
// Fail-safe when `expected` reads 0: an implementation that offloads
|
|
2275
|
+
// relationships out of memory may no longer be able to report a total, and
|
|
2276
|
+
// a false "your index is broken" is worse than a missed one.
|
|
2277
|
+
//
|
|
2278
|
+
// STREAMED EDGES COUNT. When `GraphEmitSink` streaming is active the bulk
|
|
2279
|
+
// types (CALLS/IMPORTS/REFERENCES/ACCESSES) leave the heap at parse time and
|
|
2280
|
+
// never enter `relationshipCount`, so a bare count understates `expected` by
|
|
2281
|
+
// most of the edge volume and the ratio passes trivially. Streaming is on for
|
|
2282
|
+
// any `force === true` run — which includes the crash/schema-mismatch
|
|
2283
|
+
// recovery paths AND the `analyze --force` retry this check's own warning
|
|
2284
|
+
// tells the operator to run. Same correction, and for the same reason, as
|
|
2285
|
+
// the buffer-pool hint earlier in this file.
|
|
2286
|
+
//
|
|
2287
|
+
// `structuralRows`, NOT `totalRows`. The manifest's `totalRows` is a
|
|
2288
|
+
// buffer-pool size hint and counts EVERY streamed row; PDG edges stream
|
|
2289
|
+
// through this same sink (measured: `pdgEmitManifest` absent, zero PDG
|
|
2290
|
+
// resident in the graph, 179,676 streamed rows of which ~110k were PDG), so
|
|
2291
|
+
// using it compared a structural-plus-PDG expectation against the
|
|
2292
|
+
// structural-only measurement below and declared a healthy `--pdg` index
|
|
2293
|
+
// INCOMPLETE — 200,501 against 64,764 on a real repo, with every row
|
|
2294
|
+
// present. The stamp then forced a rebuild on the next run, which repeated
|
|
2295
|
+
// it: a permanent loop on an undamaged index.
|
|
2296
|
+
//
|
|
2297
|
+
// A pair key cannot separate them — it is `From|To` NODE LABELS, and a PDG
|
|
2298
|
+
// edge shares `Function|Function` with `CALLS` — so the sink counts the
|
|
2299
|
+
// split at the point it writes, where `relationship.type` is in hand.
|
|
2300
|
+
//
|
|
2301
|
+
// The GRAPH, not `graph.relationshipCount`. That count is PDG-inclusive on
|
|
2302
|
+
// every run that does NOT stream, and streaming needs `force === true`
|
|
2303
|
+
// (`resolveStreamGraphEmit` opens with `if (options.force !== true) return
|
|
2304
|
+
// false`, `resolveStreamPdgEmit` the same), so plain `analyze --pdg` has no
|
|
2305
|
+
// sink and `run.ts` writes the PDG layers into the ordinary graph. A first
|
|
2306
|
+
// run on a fresh repo has no `existingMeta`, so it is not incremental and
|
|
2307
|
+
// this check RUNS — comparing structural-plus-PDG against structural-only
|
|
2308
|
+
// and failing a healthy index. `computeExpectedStructuralRelationships`
|
|
2309
|
+
// therefore counts the heap side type-aware too, so both sides measure the
|
|
2310
|
+
// same population in every configuration rather than only under `--force`.
|
|
2311
|
+
const expectedRelationships = computeExpectedStructuralRelationships(pipelineResult.graph, pipelineResult.graphEmitManifest);
|
|
2312
|
+
// `getLbugStats` returns `edges: undefined` when the count could not be
|
|
2313
|
+
// taken, which is a different fact from zero — an edge query that throws
|
|
2314
|
+
// must not read as a measured collapse. `nodes > 0` is independent evidence
|
|
2315
|
+
// the DB was readable at all, but it says nothing about whether the EDGE
|
|
2316
|
+
// query threw, so both conditions are required.
|
|
2317
|
+
//
|
|
2318
|
+
// STRUCTURAL ONLY, and that is the whole correction. `expected` above counts
|
|
2319
|
+
// the in-memory graph plus the streamed STRUCTURAL manifest; the streamed
|
|
2320
|
+
// PDG layers never enter `graph.relationshipCount`. But `stats.edges` counts
|
|
2321
|
+
// EVERY `CodeRelation` row, and PDG writes into that same table — so on a
|
|
2322
|
+
// `--pdg` run the two sides measured different populations and the surplus
|
|
2323
|
+
// masked real loss. With 1,000 structural edges expected and 4,000 PDG rows
|
|
2324
|
+
// persisted, losing EVERY structural edge still read `persisted = 4000` and
|
|
2325
|
+
// cleared the ratio: a total wipeout, reported healthy, on exactly the large
|
|
2326
|
+
// repos `--pdg` is used for.
|
|
2327
|
+
//
|
|
2328
|
+
// Padding `expected` with the PDG rows instead does NOT fix it — it makes
|
|
2329
|
+
// the universes match but leaves the ratio judging a minority population:
|
|
2330
|
+
// 4,000 of 5,000 still clears 0.5. Only comparing structural against
|
|
2331
|
+
// structural asks the question the check exists to ask.
|
|
2332
|
+
//
|
|
2333
|
+
// FALLBACK when the structural query alone failed. `structuralEdges` is the
|
|
2334
|
+
// newer, filtered, `IN`-predicate query; before it existed only `edges` had
|
|
2335
|
+
// to succeed, and routing the whole check through the newer one made a
|
|
2336
|
+
// single throw disable the guard AND — since the stamp now triggers the
|
|
2337
|
+
// automatic rebuild — the repair it drives. When this run had no PDG layer
|
|
2338
|
+
// the two counts are equal by construction (nothing writes a PDG row), so
|
|
2339
|
+
// `edges` answers the same question and the guard keeps working. With
|
|
2340
|
+
// `--pdg` on there is no substitute and the absence stands: it becomes an
|
|
2341
|
+
// explicit `'unmeasurable'` verdict below, which preserves rather than
|
|
2342
|
+
// erases the previous stamp.
|
|
2343
|
+
const structuralCountMissed = stats.nodes > 0 && stats.structuralEdges === undefined;
|
|
2344
|
+
const persistedRelationships = stats.nodes > 0
|
|
2345
|
+
? (stats.structuralEdges ?? (options.pdg === true ? undefined : stats.edges))
|
|
2346
|
+
: undefined;
|
|
2347
|
+
// Never swallowed. The count is taken inside a `catch {}` in `getLbugStats`,
|
|
2348
|
+
// so without this line a failed measurement is indistinguishable from a
|
|
2349
|
+
// healthy one in the logs — and "measured nothing" reading as "measured
|
|
2350
|
+
// fine" is the whole class of defect this area keeps producing.
|
|
2351
|
+
if (structuralCountMissed) {
|
|
2352
|
+
log(`Warning: the structural relationship count could not be read` +
|
|
2353
|
+
`${stats.structuralEdgesError ? ` (${stats.structuralEdgesError})` : ''}` +
|
|
2354
|
+
`${persistedRelationships === undefined
|
|
2355
|
+
? '; the graph-write-collapse check produced no verdict this run and any ' +
|
|
2356
|
+
'previously recorded collapse is kept rather than cleared.'
|
|
2357
|
+
: `; falling back to the unfiltered edge count (${stats.edges}), which is ` +
|
|
2358
|
+
'equal to it on this run because no PDG layer was written.'}`);
|
|
2359
|
+
}
|
|
2360
|
+
// NOT COMPARABLE ON AN INCREMENTAL WRITE. That path persists only
|
|
2361
|
+
// `extractChangedSubgraph(...)` while both counts here are whole-scope: the
|
|
2362
|
+
// full in-memory graph against the entire DB. A 10,000-edge index whose
|
|
2363
|
+
// incremental rewrite lost 200 replacements reads 9,800 against 10,000 —
|
|
2364
|
+
// comfortably above the ratio — so a corrupt index would be certified
|
|
2365
|
+
// complete, and the reverse (a small change to a large index) would report
|
|
2366
|
+
// a collapse that did not happen. Producing no verdict is the honest answer
|
|
2367
|
+
// until the check is given the write-set delta to compare against; that is
|
|
2368
|
+
// the same fail-safe the `expected === 0` case already takes.
|
|
2369
|
+
const collapseVerdict = wroteChangedSubgraphOnly
|
|
2370
|
+
? { verdict: 'unmeasurable', reason: 'incremental-write' }
|
|
2371
|
+
: detectGraphWriteCollapse(expectedRelationships, persistedRelationships);
|
|
2372
|
+
const graphWriteCollapsed = collapseVerdict.verdict === 'collapsed'
|
|
2373
|
+
? { expected: collapseVerdict.expected, persisted: collapseVerdict.persisted }
|
|
2374
|
+
: undefined;
|
|
2375
|
+
// SPLIT ON THE VERDICT, NOT THE WRITE MODE. `saveMeta` is a full atomic
|
|
2376
|
+
// overwrite, not a merge, so whichever branch omits the field DELETES the
|
|
2377
|
+
// stamp from meta.json — and the stamp is what marks the index incomplete
|
|
2378
|
+
// and forces the repairing rebuild.
|
|
2379
|
+
//
|
|
2380
|
+
// Three-way, explicitly:
|
|
2381
|
+
// collapse detected -> stamp it
|
|
2382
|
+
// healthy -> CLEAR it (the index really is healthy now)
|
|
2383
|
+
// no verdict -> carry the previous stamp forward
|
|
2384
|
+
//
|
|
2385
|
+
// Keying on `wroteChangedSubgraphOnly` implemented that as a TWO-way and got
|
|
2386
|
+
// the third case wrong wherever it arose on a FULL run: a run whose
|
|
2387
|
+
// structural count could not be READ (the `catch {}` in `getLbugStats`,
|
|
2388
|
+
// reachable through the `withConnLock` contention the comment on that call
|
|
2389
|
+
// warns about) reaches no verdict, but took the "full run ⇒ clear it"
|
|
2390
|
+
// branch and erased a stamp recording real, unrepaired loss. The next run
|
|
2391
|
+
// then found nothing forcing a rebuild, took `alreadyUpToDate`, printed
|
|
2392
|
+
// "Already up to date" and exited 0 — permanently, which is exactly the
|
|
2393
|
+
// failure the stamp exists to prevent.
|
|
2394
|
+
//
|
|
2395
|
+
// Mirrors `branch: branchLabel ?? existingMeta?.branch` a few lines down in
|
|
2396
|
+
// the meta write, which had the preserve-on-absence shape all along.
|
|
2397
|
+
const persistedCollapseStamp = selectPersistedCollapseStamp(collapseVerdict, existingMeta?.graphWriteCollapsed);
|
|
2398
|
+
if (graphWriteCollapsed) {
|
|
2399
|
+
log(`Warning: graph write incomplete — the pipeline produced ${expectedRelationships} ` +
|
|
2400
|
+
`relationships but only ${persistedRelationships} are readable from the index. Recording the ` +
|
|
2401
|
+
`index as INCOMPLETE (graph-write-collapsed) rather than fresh; re-run ` +
|
|
2402
|
+
`\`gitnexus analyze --force\`.`);
|
|
2403
|
+
}
|
|
1310
2404
|
let embeddingSkipped = true;
|
|
1311
2405
|
let semanticMode;
|
|
2406
|
+
// Hoisted out of the Phase 4 block so the Phase 5 gate can tell "the
|
|
2407
|
+
// pipeline attempted work and produced nothing" apart from "the pipeline
|
|
2408
|
+
// had nothing to attempt" (#2790). `undefined` ≡ the pipeline never ran.
|
|
2409
|
+
let embeddingResult;
|
|
2410
|
+
// What Phase 5 stamps as `embeddingCheckpoint`. `undefined` ≡ clear it
|
|
2411
|
+
// (the clean-run contract). Built inside Phase 4 so it carries the identity
|
|
2412
|
+
// of the run that actually wrote it — see the assignment below (#2790).
|
|
2413
|
+
let pendingEmbeddingCheckpoint;
|
|
1312
2414
|
if (shouldGenerateEmbeddings) {
|
|
1313
|
-
const { skipForCap, capDisabled, nodeLimit } = deriveEmbeddingCap(stats.nodes, options.embeddingsNodeLimit);
|
|
2415
|
+
const { skipForCap, capDisabled, nodeLimit } = deriveEmbeddingCap(stats.nodes, resumeEmbeddingCheckpoint ? 0 : options.embeddingsNodeLimit);
|
|
1314
2416
|
if (!skipForCap) {
|
|
1315
2417
|
embeddingSkipped = false;
|
|
1316
2418
|
if (capDisabled && stats.nodes > DEFAULT_EMBEDDING_NODE_LIMIT) {
|
|
@@ -1347,8 +2449,8 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1347
2449
|
// the case a naive gate would leave index-less again.
|
|
1348
2450
|
// buildVectorIndex carries its own extension-policy gate and
|
|
1349
2451
|
// warn-on-failure; the boolean feeds semanticMode so the finalize stamp
|
|
1350
|
-
// reflects the DB's ACTUAL state even when recreation fails (
|
|
1351
|
-
//
|
|
2452
|
+
// reflects the DB's ACTUAL state even when recreation fails (extension
|
|
2453
|
+
// unavailable → 'exact-scan').
|
|
1352
2454
|
const dbWasWiped = !isIncremental || escalatedFullWrite;
|
|
1353
2455
|
if (restoredEmbeddingCount > 0 && dbWasWiped && embeddingSkipped) {
|
|
1354
2456
|
// Re-import at the seam rather than thread a mutable capture from
|
|
@@ -1366,6 +2468,11 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1366
2468
|
const httpMode = isHttpMode();
|
|
1367
2469
|
progress('embeddings', 90, httpMode ? 'Connecting to embedding endpoint...' : 'Loading embedding model...');
|
|
1368
2470
|
const { runEmbeddingPipeline } = await import('./embeddings/embedding-pipeline.js');
|
|
2471
|
+
if (!embeddingIdentityForRun) {
|
|
2472
|
+
const { resolveEmbeddingIdentity } = await import('./embeddings/embedding-identity.js');
|
|
2473
|
+
embeddingIdentityForRun = resolveEmbeddingIdentity();
|
|
2474
|
+
}
|
|
2475
|
+
const embeddingIdentity = embeddingIdentityForRun;
|
|
1369
2476
|
// Build a Map<nodeId, contentHash> from cached embeddings for incremental mode
|
|
1370
2477
|
let existingEmbeddings;
|
|
1371
2478
|
if (cachedEmbeddingNodeIds.size > 0) {
|
|
@@ -1374,7 +2481,52 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1374
2481
|
existingEmbeddings.set(e.nodeId, e.contentHash ?? STALE_HASH_SENTINEL);
|
|
1375
2482
|
}
|
|
1376
2483
|
}
|
|
1377
|
-
|
|
2484
|
+
// ── A checkpoint save writes ONLY the checkpoint (#2790) ──────────
|
|
2485
|
+
// This used to write a full, SUCCESS-shaped meta: new `lastCommit`, new
|
|
2486
|
+
// `fileHashes`, `incrementalInProgress: undefined`. All three are lies at
|
|
2487
|
+
// this point in the run. The first `onCheckpointWindowStart` fires at
|
|
2488
|
+
// batchIndex 0 — before a single embedding row exists — and on a full
|
|
2489
|
+
// rebuild the graph is still in the unpublished staging DB
|
|
2490
|
+
// (`${lbugPath}.staging.<uuid>`), which the atomic swap only renames into
|
|
2491
|
+
// place AFTER Phase 5. A Phase 4 crash therefore threw the whole staging
|
|
2492
|
+
// build away while leaving a meta claiming the new commit and the new
|
|
2493
|
+
// file hashes: the next run diffed those advanced hashes, got
|
|
2494
|
+
// changed=0/added=0/deleted=0, took the incremental path and "preserved"
|
|
2495
|
+
// the OLD graph forever — the exact log line reported in #2790 — with the
|
|
2496
|
+
// `incrementalInProgress` crash-recovery contract (repo-manager.ts) also
|
|
2497
|
+
// cleared mid-run, so nothing could force the rebuild that would heal it.
|
|
2498
|
+
//
|
|
2499
|
+
// Freshness fields may only advance once the index is published. So:
|
|
2500
|
+
// re-read the on-disk meta immediately before writing (the shape the
|
|
2501
|
+
// /api/embed checkpoint writer in server/api.ts already uses, which also
|
|
2502
|
+
// keeps a concurrent writer's update from being reverted by a stale
|
|
2503
|
+
// snapshot) and replace ONLY `embeddingCheckpoint` — plus
|
|
2504
|
+
// `stats.embeddings` when the caller actually MEASURED the live count
|
|
2505
|
+
// (the post-window `onCheckpoint`). The window-start callback passes
|
|
2506
|
+
// nothing: restating the previous run's count there both re-published a
|
|
2507
|
+
// stale number and clobbered the live count a preceding `onCheckpoint`
|
|
2508
|
+
// had just written.
|
|
2509
|
+
const saveEmbeddingCheckpoint = async (checkpoint, pendingNodeIds, embeddings) => {
|
|
2510
|
+
const latestMeta = (await loadMeta(metaDir)) ?? existingMeta;
|
|
2511
|
+
// First-ever analyze of this repo: no meta exists on disk yet (the
|
|
2512
|
+
// pre-wipe dirty stamp only fires when one does). Mint the minimum
|
|
2513
|
+
// RepoMeta requires, with `lastCommit: ''` — never `currentCommit` —
|
|
2514
|
+
// so a crash here cannot make the next run mistake the discarded
|
|
2515
|
+
// staging build for an indexed commit.
|
|
2516
|
+
const base = latestMeta ?? {
|
|
2517
|
+
repoPath,
|
|
2518
|
+
lastCommit: '',
|
|
2519
|
+
indexedAt: new Date().toISOString(),
|
|
2520
|
+
};
|
|
2521
|
+
await saveMeta(metaDir, {
|
|
2522
|
+
...base,
|
|
2523
|
+
...(embeddings === undefined ? {} : { stats: { ...base.stats, embeddings } }),
|
|
2524
|
+
// Written by a run that is still IN FLIGHT — see the `kind` doc in
|
|
2525
|
+
// repo-manager.ts.
|
|
2526
|
+
embeddingCheckpoint: mintInterruptedCheckpoint(embeddingIdentity, checkpoint, pendingNodeIds),
|
|
2527
|
+
});
|
|
2528
|
+
};
|
|
2529
|
+
embeddingResult = await runEmbeddingPipeline(executeQuery, executeWithReusedStatement, (p) => {
|
|
1378
2530
|
const scaled = 90 + Math.round((p.percent / 100) * 8);
|
|
1379
2531
|
const label = p.phase === 'loading-model'
|
|
1380
2532
|
? httpMode
|
|
@@ -1382,7 +2534,48 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1382
2534
|
: 'Loading embedding model...'
|
|
1383
2535
|
: `Embedding ${p.nodesProcessed || 0}/${p.totalNodes || '?'}`;
|
|
1384
2536
|
progress('embeddings', scaled, label);
|
|
1385
|
-
}, {}, cachedEmbeddingNodeIds.size > 0 ? cachedEmbeddingNodeIds : undefined, existingEmbeddings
|
|
2537
|
+
}, {}, cachedEmbeddingNodeIds.size > 0 ? cachedEmbeddingNodeIds : undefined, existingEmbeddings, {
|
|
2538
|
+
forceReembedNodeIds: pendingEmbeddingNodeIds,
|
|
2539
|
+
onCheckpointWindowStart: async ({ nodeIds, ...checkpoint }) => {
|
|
2540
|
+
await saveEmbeddingCheckpoint(checkpoint, nodeIds);
|
|
2541
|
+
},
|
|
2542
|
+
// ── The mid-run count is a DIAGNOSTIC, not a gate (#2790) ──────
|
|
2543
|
+
// This used to run the count query bare. THIS callback's rejection
|
|
2544
|
+
// propagates out of `runEmbeddingPipeline` and kills the whole
|
|
2545
|
+
// analyze, so an unavailable count took the run down BEFORE Phase 5
|
|
2546
|
+
// ran at all — meaning the tri-state Phase 5 added for exactly this
|
|
2547
|
+
// case could never execute.
|
|
2548
|
+
//
|
|
2549
|
+
// The shared counter (embedding-count.ts) answers `unknown` instead,
|
|
2550
|
+
// and `undefined` is already `saveEmbeddingCheckpoint`'s "do not
|
|
2551
|
+
// touch stats.embeddings" signal — so the checkpoint still lands,
|
|
2552
|
+
// with whatever count is already on disk left alone.
|
|
2553
|
+
onCheckpoint: async (checkpoint) => {
|
|
2554
|
+
await checkpointOnce();
|
|
2555
|
+
const measured = await measurePersistedEmbeddingCount(executeQuery);
|
|
2556
|
+
if (measured.kind === 'unknown') {
|
|
2557
|
+
log(`Warning: could not measure persisted embeddings at the embedding checkpoint ` +
|
|
2558
|
+
`(${measured.reason}); the checkpoint is saved with the last known count.`);
|
|
2559
|
+
}
|
|
2560
|
+
await saveEmbeddingCheckpoint(checkpoint, [], persistedEmbeddingCountOrUndefined(measured));
|
|
2561
|
+
},
|
|
2562
|
+
});
|
|
2563
|
+
// ── A partial run must NOT clear the checkpoint (#2790) ───────────
|
|
2564
|
+
// Dropped nodes hold zero embedding rows, but "zero rows" alone heals
|
|
2565
|
+
// nothing: a plain `gitnexus analyze` derives shouldGenerateEmbeddings
|
|
2566
|
+
// = false whenever the index already has embeddings, so the pipeline is
|
|
2567
|
+
// never called and the nodes stay missing until someone passes
|
|
2568
|
+
// --embeddings/--force/--drop-embeddings. Retaining the checkpoint is
|
|
2569
|
+
// what restores the pre-#2790 heal: the resume path above forces
|
|
2570
|
+
// shouldGenerateEmbeddings regardless of flags and feeds
|
|
2571
|
+
// `pendingNodeIds` into `forceReembedNodeIds`. Stamped with THIS run's
|
|
2572
|
+
// identity so a later model/provider change trips the resume mismatch
|
|
2573
|
+
// error rather than resuming under a foreign identity.
|
|
2574
|
+
if (embeddingResult.failedNodeIds.length > 0) {
|
|
2575
|
+
// `'partial'` and its attempt chain — see the `kind` doc in
|
|
2576
|
+
// repo-manager.ts and `nextAttemptCount` in embedding-checkpoint.ts.
|
|
2577
|
+
pendingEmbeddingCheckpoint = mintPartialCheckpoint(embeddingIdentity, embeddingResult, resumedEmbeddingCheckpoint);
|
|
2578
|
+
}
|
|
1386
2579
|
if (embeddingResult.semanticMode === 'exact-scan') {
|
|
1387
2580
|
semanticMode = 'exact-scan';
|
|
1388
2581
|
log('Semantic embeddings were generated without a VECTOR index; ' +
|
|
@@ -1394,20 +2587,101 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1394
2587
|
}
|
|
1395
2588
|
// ── Phase 5: Finalize (98–100%) ───────────────────────────────────
|
|
1396
2589
|
progress('done', 98, 'Saving metadata...');
|
|
1397
|
-
// Count embeddings in the index (cached + newly generated)
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
2590
|
+
// Count embeddings in the index (cached + newly generated). Tri-state, and
|
|
2591
|
+
// measured by the SHARED counter rather than a local copy — see
|
|
2592
|
+
// embedding-count.ts. What that buys HERE: the old silent `catch {}` left
|
|
2593
|
+
// "cannot ask" indistinguishable from "wrote nothing", so a diagnostic
|
|
2594
|
+
// failure crashed the run at the gate below with no clue why.
|
|
2595
|
+
const measuredEmbeddingCount = await measurePersistedEmbeddingCount(executeQuery);
|
|
2596
|
+
const embeddingCount = persistedEmbeddingCountOrUndefined(measuredEmbeddingCount);
|
|
2597
|
+
if (measuredEmbeddingCount.kind === 'unknown') {
|
|
2598
|
+
// Not silent any more: the operator gets the reason the count is unknown.
|
|
2599
|
+
log(`Warning: could not count persisted embeddings ` +
|
|
2600
|
+
`(${measuredEmbeddingCount.reason}); treating the embedding count as unknown.`);
|
|
1403
2601
|
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
2602
|
+
// ── Phase 5 embedding gate (#2790) ────────────────────────────────
|
|
2603
|
+
// Four genuinely different states used to collapse into
|
|
2604
|
+
// `embeddingCount === 0`, and the gate hard-crashed on three of them:
|
|
2605
|
+
// 1. the pipeline never ran (cap-skipped / not requested) —
|
|
2606
|
+
// `embeddingSkipped`, still short-circuited;
|
|
2607
|
+
// 2. the pipeline ran but had NOTHING to embed (totalNodes 0 after the
|
|
2608
|
+
// incremental filter — e.g. a resume whose pending sweep deleted the
|
|
2609
|
+
// last rows) over a legitimately empty table;
|
|
2610
|
+
// 3. the count query failed or answered non-numerically (above) — a
|
|
2611
|
+
// diagnostic failure, not an indexing failure;
|
|
2612
|
+
// 4. the pipeline embedded and NOTHING persisted — the real defect.
|
|
2613
|
+
// Only (4) throws. `attemptedEmbedding` is what separates it from (2):
|
|
2614
|
+
// `nodesProcessed` is now the REAL completed-node count and
|
|
2615
|
+
// `failedNodeIds` names the nodes whose rows were dropped, so
|
|
2616
|
+
// "attempted" ≡ at least one node was walked to a conclusion.
|
|
2617
|
+
const attemptedEmbedding = !embeddingSkipped &&
|
|
2618
|
+
embeddingResult !== undefined &&
|
|
2619
|
+
(embeddingResult.nodesProcessed > 0 || embeddingResult.failedNodeIds.length > 0);
|
|
2620
|
+
if (attemptedEmbedding && stats.nodes > 0 && embeddingCount === 0) {
|
|
1408
2621
|
throw new Error('Embedding generation completed without persisted embeddings. ' +
|
|
1409
|
-
'The index was not registered to avoid silently reporting embeddings: 0.'
|
|
2622
|
+
'The index was not registered to avoid silently reporting embeddings: 0. ' +
|
|
2623
|
+
'Check the embedding endpoint/model configuration (GITNEXUS_EMBEDDING_URL / ' +
|
|
2624
|
+
'GITNEXUS_EMBEDDING_MODEL) and re-run `gitnexus analyze --embeddings`; ' +
|
|
2625
|
+
'the graph itself is unaffected, so `--drop-embeddings` indexes without them.');
|
|
2626
|
+
}
|
|
2627
|
+
if (embeddingCount === undefined) {
|
|
2628
|
+
log('Warning: registering the index without a verified embedding count — the count query ' +
|
|
2629
|
+
'did not answer, so stats.embeddings falls back to the last known value. ' +
|
|
2630
|
+
'Re-run `gitnexus analyze --embeddings` if semantic search comes back empty.');
|
|
1410
2631
|
}
|
|
2632
|
+
// ── An unverifiable count must leave a way back (#2790) ───────────────
|
|
2633
|
+
// The carry-forward below is a GUESS, and the guess is load-bearing (see
|
|
2634
|
+
// embedding-count.ts). Clearing the checkpoint on top of it would report
|
|
2635
|
+
// unqualified success and erase the only record that this index was never
|
|
2636
|
+
// verified.
|
|
2637
|
+
//
|
|
2638
|
+
// Retain an identity-matching recovery marker instead — `'unverified-count'`,
|
|
2639
|
+
// whose whole job is to force the next run past the same-commit fast return
|
|
2640
|
+
// so the count can be re-derived (see the `kind` doc in repo-manager.ts).
|
|
2641
|
+
// Self-limiting: once the count answers, the marker is cleared, and the run
|
|
2642
|
+
// it forces embeds nothing, so `attemptedEmbedding` is false and nothing is
|
|
2643
|
+
// re-planted.
|
|
2644
|
+
if (attemptedEmbedding &&
|
|
2645
|
+
embeddingCount === undefined &&
|
|
2646
|
+
pendingEmbeddingCheckpoint === undefined &&
|
|
2647
|
+
embeddingIdentityForRun !== undefined) {
|
|
2648
|
+
log('Retaining an embedding checkpoint so the next `gitnexus analyze` re-derives the count ' +
|
|
2649
|
+
'instead of publishing an unverified one as final (#2790).');
|
|
2650
|
+
pendingEmbeddingCheckpoint = mintUnverifiedCountCheckpoint(embeddingIdentityForRun, {
|
|
2651
|
+
nodesProcessed: embeddingResult?.nodesProcessed ?? 0,
|
|
2652
|
+
totalNodes: embeddingResult?.nodesProcessed ?? 0,
|
|
2653
|
+
chunksProcessed: embeddingResult?.chunksProcessed ?? 0,
|
|
2654
|
+
});
|
|
2655
|
+
}
|
|
2656
|
+
// A partial index that is honest about itself beats no index — see the
|
|
2657
|
+
// `kind` doc in repo-manager.ts for why the dropped nodes are safe to ship.
|
|
2658
|
+
if (embeddingResult !== undefined && embeddingResult.failedNodeIds.length > 0) {
|
|
2659
|
+
log(`Warning: ${embeddingResult.failedNodeIds.length} node(s) lost their embeddings to ` +
|
|
2660
|
+
'embedding-endpoint failures and were dropped from this index (#2790). ' +
|
|
2661
|
+
'They are recorded as an embedding checkpoint, so the next `gitnexus analyze` run ' +
|
|
2662
|
+
'resumes from it and re-embeds exactly those nodes — `gitnexus status` reports the ' +
|
|
2663
|
+
`index as incomplete until it succeeds, and the retry gives up after ` +
|
|
2664
|
+
`${EMBEDDING_RESUME_MAX_ATTEMPTS} consecutive failures rather than staying incomplete ` +
|
|
2665
|
+
'forever. Pass --force or --drop-embeddings to abandon them instead.');
|
|
2666
|
+
}
|
|
2667
|
+
// What we can honestly persist as the embedding count: the measurement when
|
|
2668
|
+
// there is one, else the LAST KNOWN figure — never a fabricated 0 (see
|
|
2669
|
+
// embedding-count.ts). Folded by the shared `resolvePersistedEmbeddingCount`
|
|
2670
|
+
// so the CLI and the server cannot drift apart on the carry-forward the way
|
|
2671
|
+
// they already had on the measurement.
|
|
2672
|
+
//
|
|
2673
|
+
// "Last known" is the LATEST ON-DISK meta, re-read here (#2790). It used to
|
|
2674
|
+
// read `existingMeta`, which is assigned exactly once — before any
|
|
2675
|
+
// embedding work — so the fallback republished the pre-run figure and
|
|
2676
|
+
// OVERWROTE the fresher count this run's own terminal `onCheckpoint` had
|
|
2677
|
+
// already written to disk: prior meta says 0, a clean run inserts
|
|
2678
|
+
// embeddings and checkpoints the real count, the final probe is
|
|
2679
|
+
// unavailable, and finalization carries the stale 0 forward while reporting
|
|
2680
|
+
// success. `loadMeta` never throws (it returns null), and the checkpoint
|
|
2681
|
+
// writer already re-reads the same way, so this is the same freshness
|
|
2682
|
+
// discipline applied to the same field.
|
|
2683
|
+
const latestMetaForCount = embeddingCount === undefined ? ((await loadMeta(metaDir)) ?? existingMeta) : undefined;
|
|
2684
|
+
const persistedEmbeddingCount = resolvePersistedEmbeddingCount(measuredEmbeddingCount, latestMetaForCount?.stats?.embeddings);
|
|
1411
2685
|
const { getRuntimeCapabilities } = await import('./platform/capabilities.js');
|
|
1412
2686
|
const runtimeCapabilities = getRuntimeCapabilities();
|
|
1413
2687
|
// `semanticMode` is authoritative when set (Phase 4 reported what it
|
|
@@ -1433,6 +2707,8 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1433
2707
|
const newFileHashesRecord = {};
|
|
1434
2708
|
for (const [k, v] of newFileHashes)
|
|
1435
2709
|
newFileHashesRecord[k] = v;
|
|
2710
|
+
const resolutionOutcomes = pipelineResult.resolutionOutcomes ?? [];
|
|
2711
|
+
logUnresolvedReceiverFiles(resolutionOutcomes);
|
|
1436
2712
|
// Annotated so the capabilities stamp below is compile-checked against
|
|
1437
2713
|
// RepoMeta's status unions (tri-review 4669518496 P1/U3) — an unannotated
|
|
1438
2714
|
// literal widens the vectorSearch.status ternary to `string` and the
|
|
@@ -1441,6 +2717,7 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1441
2717
|
repoPath,
|
|
1442
2718
|
lastCommit: currentCommit,
|
|
1443
2719
|
indexedAt: new Date().toISOString(),
|
|
2720
|
+
runnerIdentity,
|
|
1444
2721
|
// Branch identity this index represents (#2106). Recorded for the flat
|
|
1445
2722
|
// slot too (so resolveBranchPlacement knows which branch owns it). When
|
|
1446
2723
|
// the label is null (detached HEAD / non-git re-analyze) we PRESERVE an
|
|
@@ -1456,13 +2733,26 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1456
2733
|
// origin remote, which is fine: paths-only repos behave as
|
|
1457
2734
|
// before.
|
|
1458
2735
|
remoteUrl: hasGitDir(repoPath) ? getRemoteUrl(repoPath) : undefined,
|
|
2736
|
+
// Absent on a healthy FULL run; present it and the index reports as
|
|
2737
|
+
// incomplete rather than fresh (`graph-write-collapsed`). Carried forward
|
|
2738
|
+
// when this run had no verdict — see `persistedCollapseStamp`.
|
|
2739
|
+
...(persistedCollapseStamp ? { graphWriteCollapsed: persistedCollapseStamp } : {}),
|
|
2740
|
+
// R3-1. Not a health signal — the index is complete and correct. This
|
|
2741
|
+
// records which fields the per-language inference declined to link so a
|
|
2742
|
+
// later query can say WHY it is returning nothing, instead of leaving an
|
|
2743
|
+
// empty result that reads as "unused".
|
|
2744
|
+
...(pipelineResult.propertyInference?.crossLanguageNames?.length
|
|
2745
|
+
? {
|
|
2746
|
+
crossLanguageProperties: pipelineResult.propertyInference.crossLanguageNames.map((e) => ({ name: e.name, languages: [...e.languages] })),
|
|
2747
|
+
}
|
|
2748
|
+
: {}),
|
|
1459
2749
|
stats: {
|
|
1460
2750
|
files: pipelineResult.totalFileCount,
|
|
1461
2751
|
nodes: stats.nodes,
|
|
1462
2752
|
edges: stats.edges,
|
|
1463
2753
|
communities: pipelineResult.communityResult?.stats.totalCommunities,
|
|
1464
2754
|
processes: pipelineResult.processResult?.stats.totalProcesses,
|
|
1465
|
-
embeddings:
|
|
2755
|
+
embeddings: persistedEmbeddingCount,
|
|
1466
2756
|
},
|
|
1467
2757
|
capabilities: {
|
|
1468
2758
|
graph: { provider: 'ladybugdb', status: runtimeCapabilities.graph },
|
|
@@ -1472,11 +2762,34 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1472
2762
|
// meta.json / `gitnexus doctor` honest about degraded search.
|
|
1473
2763
|
fts: {
|
|
1474
2764
|
provider: 'ladybugdb-fts',
|
|
1475
|
-
status:
|
|
2765
|
+
status: ftsReady ? runtimeCapabilities.fts : 'unavailable',
|
|
2766
|
+
// Persist WHICH cause degraded FTS, not merely THAT it degraded
|
|
2767
|
+
// (#2841 review H1). `status` alone collapses "the extension could
|
|
2768
|
+
// not load" and "the extension loaded but the build failed" into one
|
|
2769
|
+
// value, and §5.C's fast-path probe reads that value: with the cause
|
|
2770
|
+
// erased it must guess, guesses `extension-unavailable`, and a
|
|
2771
|
+
// `build-failed` run therefore re-analyzes the whole repo on every
|
|
2772
|
+
// subsequent no-op run — the build fails identically (an
|
|
2773
|
+
// un-tokenizable stored row, #2544/#2546, is deterministic), restamps
|
|
2774
|
+
// 'unavailable', and the next run does it again. Stamping the
|
|
2775
|
+
// discriminator the run already computed makes the read exact instead.
|
|
2776
|
+
skipReason: ftsReady ? undefined : ftsSkipReason,
|
|
1476
2777
|
},
|
|
1477
2778
|
vectorSearch: {
|
|
1478
2779
|
provider: effectiveSemanticMode === 'vector-index' ? 'ladybugdb-vector' : 'exact-scan',
|
|
1479
|
-
|
|
2780
|
+
// Reads the MEASURED count, not `persistedEmbeddingCount` (#2790).
|
|
2781
|
+
// The carry-forward exists so a later `--force` doesn't discard a
|
|
2782
|
+
// live cache — it is a guess, and a guess must never certify the
|
|
2783
|
+
// vector lane: `--drop-embeddings` + a failed count probe would
|
|
2784
|
+
// otherwise stamp 'vector-index' with 5000 embeddings over a table
|
|
2785
|
+
// holding zero. Unknown reads as 'unavailable' (the status union has
|
|
2786
|
+
// no unknown member, and adding one would touch every consumer);
|
|
2787
|
+
// the downgrade is recoverable — 'unavailable' is not carried
|
|
2788
|
+
// forward as `persistedSemanticMode`, so the next run that can
|
|
2789
|
+
// count restamps the real mode.
|
|
2790
|
+
status: embeddingCount !== undefined && embeddingCount > 0
|
|
2791
|
+
? effectiveSemanticMode
|
|
2792
|
+
: 'unavailable',
|
|
1480
2793
|
exactScanLimit: runtimeCapabilities.exactScanLimit,
|
|
1481
2794
|
reason: runtimeCapabilities.reason,
|
|
1482
2795
|
},
|
|
@@ -1485,11 +2798,29 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1485
2798
|
// analyze run can take the incremental DB-writeback path. Setting
|
|
1486
2799
|
// incrementalInProgress to undefined explicitly clears any prior
|
|
1487
2800
|
// dirty flag (full and incremental success paths converge here).
|
|
1488
|
-
|
|
2801
|
+
// Derived digest of the DDL this run created the tables from (#2798).
|
|
2802
|
+
// Git-only: non-git repos never take the incremental path.
|
|
2803
|
+
schemaFingerprint: hasGitDir(repoPath) ? SCHEMA_FINGERPRINT : undefined,
|
|
2804
|
+
unresolvedReceiverMembers: summarizeUnresolvedReceivers(resolutionOutcomes),
|
|
2805
|
+
// Carried forward ONLY when this run could not measure — `saveMeta` writes
|
|
2806
|
+
// a fresh object, so omitting the key deletes a prior record and turns a
|
|
2807
|
+
// hedged answer back into a confident one. A run that DID measure always
|
|
2808
|
+
// wins, including when it measured nothing: vendoring the missing
|
|
2809
|
+
// dependency and re-analyzing has to be able to clear the hedge, or the
|
|
2810
|
+
// field becomes permanent noise and readers learn to ignore it.
|
|
2811
|
+
undecidedInterfaceSatisfaction: pipelineResult.undecidedSatisfaction === undefined
|
|
2812
|
+
? existingMeta?.undecidedInterfaceSatisfaction
|
|
2813
|
+
: summarizeUndecidedSatisfaction(pipelineResult.undecidedSatisfaction),
|
|
2814
|
+
analysisFeatures: currentAnalysisFeatures,
|
|
1489
2815
|
// Always stamped with the live resolved mode (#2331/#2339) — unlike
|
|
1490
2816
|
// `pdg` below, 'none' is a meaningful value to compare, not an
|
|
1491
2817
|
// absence, so this is never conditionally omitted.
|
|
1492
2818
|
cjkSegmentation: getSearchFTSCjkSegmentation(),
|
|
2819
|
+
// The FLOAT[N] width this run created the vector column at (#2798).
|
|
2820
|
+
// Always stamped, like `cjkSegmentation` and unlike `schemaFingerprint`:
|
|
2821
|
+
// the CodeEmbedding table is created for every index, git or not, so
|
|
2822
|
+
// absence has exactly one meaning — an index older than the field.
|
|
2823
|
+
embeddingDims: EMBEDDING_DIMS,
|
|
1493
2824
|
fileHashes: hasGitDir(repoPath) ? newFileHashesRecord : undefined,
|
|
1494
2825
|
// This branch's full live chunk-key set (#2106 R6). `usedKeys` is every
|
|
1495
2826
|
// chunk hash touched in this scan — cache HITS included (see parse-impl
|
|
@@ -1497,6 +2828,9 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1497
2828
|
// so a sibling branch's prune can union it and not evict our shards.
|
|
1498
2829
|
cacheKeys: [...parseCache.usedKeys],
|
|
1499
2830
|
incrementalInProgress: undefined,
|
|
2831
|
+
// Cleared on a clean run; otherwise the marker Phase 4/5 minted above
|
|
2832
|
+
// (see the `kind` doc in repo-manager.ts).
|
|
2833
|
+
embeddingCheckpoint: pendingEmbeddingCheckpoint,
|
|
1500
2834
|
// The effective pdg config this run's DB rows were built under
|
|
1501
2835
|
// (#2099 F1). `undefined` on pdg-off runs — this meta is a fresh
|
|
1502
2836
|
// literal (no spread of existingMeta), so omission is what CLEARS the
|
|
@@ -1504,7 +2838,18 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1504
2838
|
// off==off and incremental eligibility is restored.
|
|
1505
2839
|
pdg: resolvePdgConfig(options),
|
|
1506
2840
|
};
|
|
1507
|
-
|
|
2841
|
+
// Re-resolve at the commit boundary. Long analyses can overlap an npm
|
|
2842
|
+
// upgrade, rebuilt dist tree, or native dependency replacement; stamping
|
|
2843
|
+
// the start-of-run receipt after such a mutation would falsely certify a
|
|
2844
|
+
// graph produced by two analyzer identities. Stable-read validation lives
|
|
2845
|
+
// inside the resolver, and a mismatch leaves the dirty flag intact so the
|
|
2846
|
+
// next run takes the established full-recovery path.
|
|
2847
|
+
meta.runnerIdentity = finalizeAnalyzerRunnerIdentity(import.meta.url, runnerIdentity);
|
|
2848
|
+
// #2614 F1: the freshness stamp (saveMeta) is written AFTER the atomic swap
|
|
2849
|
+
// below — never here — so a concurrent MCP reader can't observe
|
|
2850
|
+
// meta.indexedAt = T_new while lbugPath still resolves to the pre-swap
|
|
2851
|
+
// inode (which latched the reader on the stale index permanently). The meta
|
|
2852
|
+
// object is fully computed at this point; only its write is deferred.
|
|
1508
2853
|
// Persist the incremental parse cache for the next run. Wraps in
|
|
1509
2854
|
// try/catch so a cache-write failure never breaks an otherwise
|
|
1510
2855
|
// successful indexing run. Prune stale chunk-hash entries first so
|
|
@@ -1628,14 +2973,63 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1628
2973
|
// LadybugDB destructor double-free after --pdg writes — closeLbugBeforeExit
|
|
1629
2974
|
// CHECKPOINTs for durability then leaves the handles for process exit to
|
|
1630
2975
|
// reclaim (#2264). Long-lived callers close for real.
|
|
1631
|
-
|
|
2976
|
+
//
|
|
2977
|
+
// On Windows a swap must release the build handle before the rename (a
|
|
2978
|
+
// same-process open file can't be renamed), so it forces a real close —
|
|
2979
|
+
// safe because windowsSwapOk excludes --pdg (the #2264 case). POSIX renames
|
|
2980
|
+
// an open file, so it keeps the skip-native-close there.
|
|
2981
|
+
const forceRealCloseForSwap = useAtomicSwap && process.platform === 'win32';
|
|
2982
|
+
await (options.skipNativeCloseOnExit && !forceRealCloseForSwap
|
|
2983
|
+
? closeLbugBeforeExit()
|
|
2984
|
+
: closeLbug());
|
|
2985
|
+
// #2 atomic publish: the fresh index was built at buildPath (a full rebuild,
|
|
2986
|
+
// or an opt-in atomic incremental that copied the live index in first). Swap
|
|
2987
|
+
// it over the live lbugPath in one rename so an MCP reader that opened
|
|
2988
|
+
// mid-build only ever saw the previous complete index — never a wiped/
|
|
2989
|
+
// half-built file. The close above checkpoint-consolidated buildPath to a
|
|
2990
|
+
// single file (no .wal), so the rename publishes a complete index; a reader
|
|
2991
|
+
// holding the old inode keeps a consistent stale snapshot until the pool
|
|
2992
|
+
// re-opens onto the new one (the pool staleness invalidation). Runs only on
|
|
2993
|
+
// success — a thrown error skips this, leaving the live index intact and the
|
|
2994
|
+
// temp build to be cleared by the next run's wipe.
|
|
2995
|
+
// Only publish if the build actually produced a DB at buildPath. A
|
|
2996
|
+
// degenerate run (empty repo, or a mocked pipeline that never opened the
|
|
2997
|
+
// store) leaves nothing to swap — skip rather than throw ENOENT.
|
|
2998
|
+
const builtDbExists = useAtomicSwap
|
|
2999
|
+
? await fs.stat(buildPath).then(() => true, () => false)
|
|
3000
|
+
: false;
|
|
3001
|
+
if (useAtomicSwap && builtDbExists) {
|
|
3002
|
+
await retryRename(buildPath, lbugPath);
|
|
3003
|
+
// Clear any sidecars orphaned beside the replaced file. A cleanly-closed
|
|
3004
|
+
// prior index has none; a crashed one could, and it would be replay
|
|
3005
|
+
// poison next to the freshly published index. Best-effort.
|
|
3006
|
+
for (const suffix of ['.wal', '.shadow', '.wal.checkpoint']) {
|
|
3007
|
+
await fs.rm(`${lbugPath}${suffix}`, { force: true }).catch(() => { });
|
|
3008
|
+
}
|
|
3009
|
+
// #2614 F4: if the final checkpoint silently failed, the build may still
|
|
3010
|
+
// carry a residual .wal/.shadow under the temp name. MOVE it beside the
|
|
3011
|
+
// published index (not orphan/delete it) so the next open replays the
|
|
3012
|
+
// delta, rather than leaving it under a name LadybugDB never reconciles.
|
|
3013
|
+
for (const suffix of ['.wal', '.shadow']) {
|
|
3014
|
+
await fs.rename(`${buildPath}${suffix}`, `${lbugPath}${suffix}`).catch(() => { });
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
// #2614 F1: stamp the freshness metadata now that the index is published.
|
|
3018
|
+
// When meta.indexedAt becomes visible, lbugPath already resolves to the new
|
|
3019
|
+
// inode, so a reader reiniting on the stamp opens the fresh graph rather
|
|
3020
|
+
// than latching on the old one. Leaving the dirty flag set across the swap
|
|
3021
|
+
// is a crash-safety improvement: a failed swap leaves the previous index
|
|
3022
|
+
// live and the next run recovers via the full-rebuild path.
|
|
3023
|
+
await saveMeta(metaDir, meta);
|
|
1632
3024
|
progress('done', 100, 'Done');
|
|
1633
3025
|
return {
|
|
1634
3026
|
repoName: projectName,
|
|
1635
3027
|
repoPath,
|
|
1636
3028
|
stats: meta.stats,
|
|
1637
3029
|
pipelineResult,
|
|
1638
|
-
|
|
3030
|
+
...(graphWriteCollapsed ? { graphWriteCollapsed } : {}),
|
|
3031
|
+
ftsSkipped: !ftsReady,
|
|
3032
|
+
ftsSkipReason: ftsReady ? undefined : ftsSkipReason,
|
|
1639
3033
|
isPrimaryBranch: !placement.branch,
|
|
1640
3034
|
};
|
|
1641
3035
|
}
|
|
@@ -1662,6 +3056,23 @@ export async function runFullAnalysis(repoPath, options, callbacks) {
|
|
|
1662
3056
|
catch {
|
|
1663
3057
|
/* swallow */
|
|
1664
3058
|
}
|
|
3059
|
+
// Reclaim the staging index this run created (#2841 cleanup). Without this
|
|
3060
|
+
// a failed staged build orphans a FULL copy of the index — hundreds of MB on
|
|
3061
|
+
// a large repo — until the next `acquireIndexLock` sweeps `lbug.staging.`
|
|
3062
|
+
// artifacts, and the failure most likely to leave one (a machine whose
|
|
3063
|
+
// extension cannot load) is also the one least likely to be followed by
|
|
3064
|
+
// another analyze. Only ever removes a path this run minted: `buildPath`
|
|
3065
|
+
// differs from `lbugPath` exactly when the atomic-swap plan is in effect,
|
|
3066
|
+
// and the live index is never that path. Best-effort by construction — the
|
|
3067
|
+
// rethrow below is the surface, and the lock's sweep remains the backstop.
|
|
3068
|
+
if (useAtomicSwap && buildPath !== lbugPath) {
|
|
3069
|
+
try {
|
|
3070
|
+
await wipeLbugDbFiles(buildPath);
|
|
3071
|
+
}
|
|
3072
|
+
catch {
|
|
3073
|
+
/* swallow — orphan reclamation must never mask the real failure */
|
|
3074
|
+
}
|
|
3075
|
+
}
|
|
1665
3076
|
throw err;
|
|
1666
3077
|
}
|
|
1667
3078
|
}
|