@optave/codegraph 3.12.0 → 3.15.0
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 +83 -46
- package/dist/ast-analysis/engine.d.ts.map +1 -1
- package/dist/ast-analysis/engine.js +38 -40
- package/dist/ast-analysis/engine.js.map +1 -1
- package/dist/ast-analysis/rules/b2.d.ts +7 -0
- package/dist/ast-analysis/rules/b2.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b2.js +240 -0
- package/dist/ast-analysis/rules/b2.js.map +1 -0
- package/dist/ast-analysis/rules/b3.d.ts +6 -0
- package/dist/ast-analysis/rules/b3.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b3.js +105 -0
- package/dist/ast-analysis/rules/b3.js.map +1 -0
- package/dist/ast-analysis/rules/b4.d.ts +9 -0
- package/dist/ast-analysis/rules/b4.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b4.js +361 -0
- package/dist/ast-analysis/rules/b4.js.map +1 -0
- package/dist/ast-analysis/rules/b5.d.ts +4 -0
- package/dist/ast-analysis/rules/b5.d.ts.map +1 -0
- package/dist/ast-analysis/rules/b5.js +52 -0
- package/dist/ast-analysis/rules/b5.js.map +1 -0
- package/dist/ast-analysis/rules/c.d.ts +4 -0
- package/dist/ast-analysis/rules/c.d.ts.map +1 -0
- package/dist/ast-analysis/rules/c.js +143 -0
- package/dist/ast-analysis/rules/c.js.map +1 -0
- package/dist/ast-analysis/rules/index.d.ts.map +1 -1
- package/dist/ast-analysis/rules/index.js +34 -0
- package/dist/ast-analysis/rules/index.js.map +1 -1
- package/dist/ast-analysis/rules/javascript.d.ts.map +1 -1
- package/dist/ast-analysis/rules/javascript.js +3 -0
- package/dist/ast-analysis/rules/javascript.js.map +1 -1
- package/dist/ast-analysis/shared.d.ts.map +1 -1
- package/dist/ast-analysis/shared.js +2 -0
- package/dist/ast-analysis/shared.js.map +1 -1
- package/dist/ast-analysis/visitor-utils.d.ts +1 -0
- package/dist/ast-analysis/visitor-utils.d.ts.map +1 -1
- package/dist/ast-analysis/visitor-utils.js +5 -0
- package/dist/ast-analysis/visitor-utils.js.map +1 -1
- package/dist/ast-analysis/visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitor.js +60 -47
- package/dist/ast-analysis/visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/cfg-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/cfg-visitor.js +126 -76
- package/dist/ast-analysis/visitors/cfg-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/complexity-visitor.js +27 -15
- package/dist/ast-analysis/visitors/complexity-visitor.js.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.d.ts.map +1 -1
- package/dist/ast-analysis/visitors/dataflow-visitor.js +54 -21
- package/dist/ast-analysis/visitors/dataflow-visitor.js.map +1 -1
- package/dist/cli/commands/audit.d.ts.map +1 -1
- package/dist/cli/commands/audit.js +2 -1
- package/dist/cli/commands/audit.js.map +1 -1
- package/dist/cli/commands/batch.d.ts.map +1 -1
- package/dist/cli/commands/batch.js +1 -0
- package/dist/cli/commands/batch.js.map +1 -1
- package/dist/cli/commands/build.d.ts.map +1 -1
- package/dist/cli/commands/build.js +6 -1
- package/dist/cli/commands/build.js.map +1 -1
- package/dist/cli/commands/config.d.ts +3 -0
- package/dist/cli/commands/config.d.ts.map +1 -0
- package/dist/cli/commands/config.js +275 -0
- package/dist/cli/commands/config.js.map +1 -0
- package/dist/cli/commands/roles.d.ts.map +1 -1
- package/dist/cli/commands/roles.js +6 -1
- package/dist/cli/commands/roles.js.map +1 -1
- package/dist/cli/commands/triage.js +1 -1
- package/dist/cli/commands/triage.js.map +1 -1
- package/dist/cli/index.d.ts.map +1 -1
- package/dist/cli/index.js +10 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/shared/options.d.ts +2 -1
- package/dist/cli/shared/options.d.ts.map +1 -1
- package/dist/cli/shared/options.js +11 -1
- package/dist/cli/shared/options.js.map +1 -1
- package/dist/cli/types.d.ts +2 -0
- package/dist/cli/types.d.ts.map +1 -1
- package/dist/db/better-sqlite3.d.ts +2 -1
- package/dist/db/better-sqlite3.d.ts.map +1 -1
- package/dist/db/better-sqlite3.js.map +1 -1
- package/dist/db/connection.d.ts +7 -1
- package/dist/db/connection.d.ts.map +1 -1
- package/dist/db/connection.js +20 -5
- package/dist/db/connection.js.map +1 -1
- package/dist/db/index.d.ts +1 -1
- package/dist/db/index.d.ts.map +1 -1
- package/dist/db/index.js +1 -1
- package/dist/db/index.js.map +1 -1
- package/dist/db/migrations.d.ts.map +1 -1
- package/dist/db/migrations.js +69 -1
- package/dist/db/migrations.js.map +1 -1
- package/dist/db/repository/build-stmts.d.ts.map +1 -1
- package/dist/db/repository/build-stmts.js +18 -0
- package/dist/db/repository/build-stmts.js.map +1 -1
- package/dist/db/repository/dataflow.d.ts +5 -0
- package/dist/db/repository/dataflow.d.ts.map +1 -1
- package/dist/db/repository/dataflow.js +14 -0
- package/dist/db/repository/dataflow.js.map +1 -1
- package/dist/db/repository/index.d.ts +1 -1
- package/dist/db/repository/index.d.ts.map +1 -1
- package/dist/db/repository/index.js +1 -1
- package/dist/db/repository/index.js.map +1 -1
- package/dist/db/repository/native-repository.d.ts.map +1 -1
- package/dist/db/repository/native-repository.js +47 -34
- package/dist/db/repository/native-repository.js.map +1 -1
- package/dist/domain/analysis/context.d.ts +2 -2
- package/dist/domain/analysis/dependencies.d.ts +2 -2
- package/dist/domain/analysis/diff-impact.d.ts +2 -2
- package/dist/domain/analysis/fn-impact.d.ts +3 -1
- package/dist/domain/analysis/fn-impact.d.ts.map +1 -1
- package/dist/domain/analysis/fn-impact.js +4 -0
- package/dist/domain/analysis/fn-impact.js.map +1 -1
- package/dist/domain/analysis/implementations.d.ts +2 -2
- package/dist/domain/analysis/module-map.d.ts.map +1 -1
- package/dist/domain/analysis/module-map.js +32 -5
- package/dist/domain/analysis/module-map.js.map +1 -1
- package/dist/domain/analysis/roles.d.ts +7 -1
- package/dist/domain/analysis/roles.d.ts.map +1 -1
- package/dist/domain/analysis/roles.js +16 -0
- package/dist/domain/analysis/roles.js.map +1 -1
- package/dist/domain/analysis/symbol-lookup.d.ts +4 -4
- package/dist/domain/graph/builder/call-resolver.d.ts +29 -13
- package/dist/domain/graph/builder/call-resolver.d.ts.map +1 -1
- package/dist/domain/graph/builder/call-resolver.js +125 -205
- package/dist/domain/graph/builder/call-resolver.js.map +1 -1
- package/dist/domain/graph/builder/cha.d.ts +9 -1
- package/dist/domain/graph/builder/cha.d.ts.map +1 -1
- package/dist/domain/graph/builder/cha.js +17 -2
- package/dist/domain/graph/builder/cha.js.map +1 -1
- package/dist/domain/graph/builder/context.d.ts +1 -0
- package/dist/domain/graph/builder/context.d.ts.map +1 -1
- package/dist/domain/graph/builder/context.js.map +1 -1
- package/dist/domain/graph/builder/helpers.d.ts +24 -1
- package/dist/domain/graph/builder/helpers.d.ts.map +1 -1
- package/dist/domain/graph/builder/helpers.js +174 -65
- package/dist/domain/graph/builder/helpers.js.map +1 -1
- package/dist/domain/graph/builder/incremental.d.ts.map +1 -1
- package/dist/domain/graph/builder/incremental.js +166 -97
- package/dist/domain/graph/builder/incremental.js.map +1 -1
- package/dist/domain/graph/builder/pipeline.d.ts.map +1 -1
- package/dist/domain/graph/builder/pipeline.js +46 -5
- package/dist/domain/graph/builder/pipeline.js.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.d.ts +0 -2
- package/dist/domain/graph/builder/stages/build-edges.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/build-edges.js +554 -538
- package/dist/domain/graph/builder/stages/build-edges.js.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/collect-files.js +10 -7
- package/dist/domain/graph/builder/stages/collect-files.js.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/detect-changes.js +3 -2
- package/dist/domain/graph/builder/stages/detect-changes.js.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/finalize.js +4 -0
- package/dist/domain/graph/builder/stages/finalize.js.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.d.ts.map +1 -1
- package/dist/domain/graph/builder/stages/native-orchestrator.js +952 -343
- package/dist/domain/graph/builder/stages/native-orchestrator.js.map +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js +1 -1
- package/dist/domain/graph/builder/stages/resolve-imports.js.map +1 -1
- package/dist/domain/graph/resolver/points-to.d.ts.map +1 -1
- package/dist/domain/graph/resolver/points-to.js +105 -57
- package/dist/domain/graph/resolver/points-to.js.map +1 -1
- package/dist/domain/graph/resolver/strategy.d.ts +61 -0
- package/dist/domain/graph/resolver/strategy.d.ts.map +1 -0
- package/dist/domain/graph/resolver/strategy.js +222 -0
- package/dist/domain/graph/resolver/strategy.js.map +1 -0
- package/dist/domain/graph/watcher.d.ts.map +1 -1
- package/dist/domain/graph/watcher.js +16 -9
- package/dist/domain/graph/watcher.js.map +1 -1
- package/dist/domain/parser.d.ts +16 -5
- package/dist/domain/parser.d.ts.map +1 -1
- package/dist/domain/parser.js +58 -17
- package/dist/domain/parser.js.map +1 -1
- package/dist/domain/queries.d.ts +1 -1
- package/dist/domain/queries.d.ts.map +1 -1
- package/dist/domain/queries.js +1 -1
- package/dist/domain/queries.js.map +1 -1
- package/dist/domain/wasm-worker-entry.js +13 -2
- package/dist/domain/wasm-worker-entry.js.map +1 -1
- package/dist/domain/wasm-worker-pool.d.ts.map +1 -1
- package/dist/domain/wasm-worker-pool.js +26 -5
- package/dist/domain/wasm-worker-pool.js.map +1 -1
- package/dist/domain/wasm-worker-protocol.d.ts +8 -0
- package/dist/domain/wasm-worker-protocol.d.ts.map +1 -1
- package/dist/extractors/cpp.d.ts.map +1 -1
- package/dist/extractors/cpp.js +42 -1
- package/dist/extractors/cpp.js.map +1 -1
- package/dist/extractors/cuda.d.ts.map +1 -1
- package/dist/extractors/cuda.js +42 -1
- package/dist/extractors/cuda.js.map +1 -1
- package/dist/extractors/dart.js +48 -3
- package/dist/extractors/dart.js.map +1 -1
- package/dist/extractors/groovy.js +62 -3
- package/dist/extractors/groovy.js.map +1 -1
- package/dist/extractors/helpers.d.ts +15 -2
- package/dist/extractors/helpers.d.ts.map +1 -1
- package/dist/extractors/helpers.js +45 -1
- package/dist/extractors/helpers.js.map +1 -1
- package/dist/extractors/java.d.ts.map +1 -1
- package/dist/extractors/java.js +85 -8
- package/dist/extractors/java.js.map +1 -1
- package/dist/extractors/javascript.d.ts.map +1 -1
- package/dist/extractors/javascript.js +686 -169
- package/dist/extractors/javascript.js.map +1 -1
- package/dist/extractors/kotlin.js +58 -3
- package/dist/extractors/kotlin.js.map +1 -1
- package/dist/extractors/objc.js +25 -2
- package/dist/extractors/objc.js.map +1 -1
- package/dist/extractors/scala.js +62 -2
- package/dist/extractors/scala.js.map +1 -1
- package/dist/extractors/swift.js +52 -3
- package/dist/extractors/swift.js.map +1 -1
- package/dist/features/audit.js +26 -23
- package/dist/features/audit.js.map +1 -1
- package/dist/features/boundaries.d.ts.map +1 -1
- package/dist/features/boundaries.js +12 -9
- package/dist/features/boundaries.js.map +1 -1
- package/dist/features/cfg.d.ts.map +1 -1
- package/dist/features/cfg.js +25 -18
- package/dist/features/cfg.js.map +1 -1
- package/dist/features/check.d.ts.map +1 -1
- package/dist/features/check.js +18 -5
- package/dist/features/check.js.map +1 -1
- package/dist/features/communities.d.ts +4 -2
- package/dist/features/communities.d.ts.map +1 -1
- package/dist/features/communities.js +6 -4
- package/dist/features/communities.js.map +1 -1
- package/dist/features/dataflow.d.ts +60 -0
- package/dist/features/dataflow.d.ts.map +1 -1
- package/dist/features/dataflow.js +530 -6
- package/dist/features/dataflow.js.map +1 -1
- package/dist/features/manifesto.d.ts.map +1 -1
- package/dist/features/manifesto.js +59 -72
- package/dist/features/manifesto.js.map +1 -1
- package/dist/features/sequence.d.ts.map +1 -1
- package/dist/features/sequence.js +27 -22
- package/dist/features/sequence.js.map +1 -1
- package/dist/features/snapshot.d.ts.map +1 -1
- package/dist/features/snapshot.js +36 -28
- package/dist/features/snapshot.js.map +1 -1
- package/dist/features/structure-query.d.ts +1 -1
- package/dist/features/structure-query.d.ts.map +1 -1
- package/dist/features/structure-query.js +6 -6
- package/dist/features/structure-query.js.map +1 -1
- package/dist/features/structure.d.ts.map +1 -1
- package/dist/features/structure.js +150 -62
- package/dist/features/structure.js.map +1 -1
- package/dist/features/triage.d.ts.map +1 -1
- package/dist/features/triage.js +18 -11
- package/dist/features/triage.js.map +1 -1
- package/dist/graph/algorithms/bfs.d.ts +1 -1
- package/dist/graph/algorithms/bfs.d.ts.map +1 -1
- package/dist/graph/algorithms/bfs.js +14 -13
- package/dist/graph/algorithms/bfs.js.map +1 -1
- package/dist/graph/algorithms/tarjan.d.ts.map +1 -1
- package/dist/graph/algorithms/tarjan.js +5 -0
- package/dist/graph/algorithms/tarjan.js.map +1 -1
- package/dist/graph/builders/dependency.js +28 -22
- package/dist/graph/builders/dependency.js.map +1 -1
- package/dist/graph/classifiers/roles.d.ts +10 -1
- package/dist/graph/classifiers/roles.d.ts.map +1 -1
- package/dist/graph/classifiers/roles.js +60 -6
- package/dist/graph/classifiers/roles.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/config.d.ts +87 -4
- package/dist/infrastructure/config.d.ts.map +1 -1
- package/dist/infrastructure/config.js +424 -22
- package/dist/infrastructure/config.js.map +1 -1
- package/dist/infrastructure/registry.d.ts +27 -7
- package/dist/infrastructure/registry.d.ts.map +1 -1
- package/dist/infrastructure/registry.js +79 -5
- package/dist/infrastructure/registry.js.map +1 -1
- package/dist/infrastructure/update-check.d.ts.map +1 -1
- package/dist/infrastructure/update-check.js +49 -31
- package/dist/infrastructure/update-check.js.map +1 -1
- package/dist/mcp/server.d.ts +2 -10
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools/ast-query.d.ts +1 -1
- package/dist/mcp/tools/ast-query.d.ts.map +1 -1
- package/dist/mcp/tools/audit.d.ts +1 -1
- package/dist/mcp/tools/audit.d.ts.map +1 -1
- package/dist/mcp/tools/batch-query.d.ts +1 -1
- package/dist/mcp/tools/batch-query.d.ts.map +1 -1
- package/dist/mcp/tools/branch-compare.d.ts +1 -1
- package/dist/mcp/tools/branch-compare.d.ts.map +1 -1
- package/dist/mcp/tools/brief.d.ts +1 -1
- package/dist/mcp/tools/brief.d.ts.map +1 -1
- package/dist/mcp/tools/cfg.d.ts +1 -1
- package/dist/mcp/tools/cfg.d.ts.map +1 -1
- package/dist/mcp/tools/check.d.ts +1 -1
- package/dist/mcp/tools/check.d.ts.map +1 -1
- package/dist/mcp/tools/co-changes.d.ts +1 -1
- package/dist/mcp/tools/co-changes.d.ts.map +1 -1
- package/dist/mcp/tools/code-owners.d.ts +1 -1
- package/dist/mcp/tools/code-owners.d.ts.map +1 -1
- package/dist/mcp/tools/communities.d.ts +1 -1
- package/dist/mcp/tools/communities.d.ts.map +1 -1
- package/dist/mcp/tools/complexity.d.ts +1 -1
- package/dist/mcp/tools/complexity.d.ts.map +1 -1
- package/dist/mcp/tools/context.d.ts +1 -1
- package/dist/mcp/tools/context.d.ts.map +1 -1
- package/dist/mcp/tools/dataflow.d.ts +1 -1
- package/dist/mcp/tools/dataflow.d.ts.map +1 -1
- package/dist/mcp/tools/diff-impact.d.ts +1 -1
- package/dist/mcp/tools/diff-impact.d.ts.map +1 -1
- package/dist/mcp/tools/execution-flow.d.ts +1 -1
- package/dist/mcp/tools/execution-flow.d.ts.map +1 -1
- package/dist/mcp/tools/export-graph.d.ts +1 -1
- package/dist/mcp/tools/export-graph.d.ts.map +1 -1
- package/dist/mcp/tools/file-deps.d.ts +1 -1
- package/dist/mcp/tools/file-deps.d.ts.map +1 -1
- package/dist/mcp/tools/file-exports.d.ts +1 -1
- package/dist/mcp/tools/file-exports.d.ts.map +1 -1
- package/dist/mcp/tools/find-cycles.d.ts +1 -1
- package/dist/mcp/tools/find-cycles.d.ts.map +1 -1
- package/dist/mcp/tools/fn-impact.d.ts +1 -1
- package/dist/mcp/tools/fn-impact.d.ts.map +1 -1
- package/dist/mcp/tools/impact-analysis.d.ts +1 -1
- package/dist/mcp/tools/impact-analysis.d.ts.map +1 -1
- package/dist/mcp/tools/implementations.d.ts +1 -1
- package/dist/mcp/tools/implementations.d.ts.map +1 -1
- package/dist/mcp/tools/index.d.ts +2 -5
- package/dist/mcp/tools/index.d.ts.map +1 -1
- package/dist/mcp/tools/index.js.map +1 -1
- package/dist/mcp/tools/interfaces.d.ts +1 -1
- package/dist/mcp/tools/interfaces.d.ts.map +1 -1
- package/dist/mcp/tools/list-functions.d.ts +1 -1
- package/dist/mcp/tools/list-functions.d.ts.map +1 -1
- package/dist/mcp/tools/list-repos.d.ts +1 -1
- package/dist/mcp/tools/list-repos.d.ts.map +1 -1
- package/dist/mcp/tools/module-map.d.ts +1 -1
- package/dist/mcp/tools/module-map.d.ts.map +1 -1
- package/dist/mcp/tools/node-roles.d.ts +1 -1
- package/dist/mcp/tools/node-roles.d.ts.map +1 -1
- package/dist/mcp/tools/path.d.ts +1 -1
- package/dist/mcp/tools/path.d.ts.map +1 -1
- package/dist/mcp/tools/query.d.ts +1 -1
- package/dist/mcp/tools/query.d.ts.map +1 -1
- package/dist/mcp/tools/semantic-search.d.ts +1 -1
- package/dist/mcp/tools/semantic-search.d.ts.map +1 -1
- package/dist/mcp/tools/sequence.d.ts +1 -1
- package/dist/mcp/tools/sequence.d.ts.map +1 -1
- package/dist/mcp/tools/structure.d.ts +1 -1
- package/dist/mcp/tools/structure.d.ts.map +1 -1
- package/dist/mcp/tools/symbol-children.d.ts +1 -1
- package/dist/mcp/tools/symbol-children.d.ts.map +1 -1
- package/dist/mcp/tools/triage.d.ts +1 -1
- package/dist/mcp/tools/triage.d.ts.map +1 -1
- package/dist/mcp/tools/where.d.ts +1 -1
- package/dist/mcp/tools/where.d.ts.map +1 -1
- package/dist/mcp/types.d.ts +19 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +6 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/presentation/queries-cli/index.d.ts +1 -1
- package/dist/presentation/queries-cli/index.d.ts.map +1 -1
- package/dist/presentation/queries-cli/index.js +1 -1
- package/dist/presentation/queries-cli/index.js.map +1 -1
- package/dist/presentation/queries-cli/overview.d.ts +1 -0
- package/dist/presentation/queries-cli/overview.d.ts.map +1 -1
- package/dist/presentation/queries-cli/overview.js +20 -1
- package/dist/presentation/queries-cli/overview.js.map +1 -1
- package/dist/presentation/queries-cli.d.ts +1 -1
- package/dist/presentation/queries-cli.d.ts.map +1 -1
- package/dist/presentation/queries-cli.js +1 -1
- package/dist/presentation/queries-cli.js.map +1 -1
- package/dist/presentation/structure.d.ts +1 -1
- package/dist/presentation/structure.d.ts.map +1 -1
- package/dist/presentation/structure.js +2 -2
- package/dist/presentation/structure.js.map +1 -1
- package/dist/presentation/viewer.d.ts.map +1 -1
- package/dist/presentation/viewer.js +45 -32
- package/dist/presentation/viewer.js.map +1 -1
- package/dist/shared/constants.d.ts +21 -0
- package/dist/shared/constants.d.ts.map +1 -1
- package/dist/shared/constants.js +25 -0
- package/dist/shared/constants.js.map +1 -1
- package/dist/shared/normalize.d.ts.map +1 -1
- package/dist/shared/normalize.js +12 -22
- package/dist/shared/normalize.js.map +1 -1
- package/dist/shared/paginate.d.ts +4 -17
- package/dist/shared/paginate.d.ts.map +1 -1
- package/dist/shared/paginate.js.map +1 -1
- package/dist/types.d.ts +113 -1
- package/dist/types.d.ts.map +1 -1
- package/grammars/tree-sitter-erlang.wasm +0 -0
- package/grammars/tree-sitter-gleam.wasm +0 -0
- package/package.json +7 -8
- package/src/ast-analysis/engine.ts +43 -63
- package/src/ast-analysis/rules/b2.ts +263 -0
- package/src/ast-analysis/rules/b3.ts +127 -0
- package/src/ast-analysis/rules/b4.ts +378 -0
- package/src/ast-analysis/rules/b5.ts +65 -0
- package/src/ast-analysis/rules/c.ts +157 -0
- package/src/ast-analysis/rules/index.ts +34 -0
- package/src/ast-analysis/rules/javascript.ts +3 -0
- package/src/ast-analysis/shared.ts +2 -0
- package/src/ast-analysis/visitor-utils.ts +5 -0
- package/src/ast-analysis/visitor.ts +82 -52
- package/src/ast-analysis/visitors/cfg-visitor.ts +198 -84
- package/src/ast-analysis/visitors/complexity-visitor.ts +44 -16
- package/src/ast-analysis/visitors/dataflow-visitor.ts +68 -29
- package/src/cli/commands/audit.ts +2 -1
- package/src/cli/commands/batch.ts +1 -0
- package/src/cli/commands/build.ts +6 -1
- package/src/cli/commands/config.ts +353 -0
- package/src/cli/commands/roles.ts +6 -1
- package/src/cli/commands/triage.ts +1 -1
- package/src/cli/index.ts +10 -0
- package/src/cli/shared/options.ts +11 -1
- package/src/cli/types.ts +2 -0
- package/src/db/better-sqlite3.ts +5 -4
- package/src/db/connection.ts +23 -5
- package/src/db/index.ts +1 -0
- package/src/db/migrations.ts +69 -1
- package/src/db/repository/build-stmts.ts +30 -0
- package/src/db/repository/dataflow.ts +16 -0
- package/src/db/repository/index.ts +1 -1
- package/src/db/repository/native-repository.ts +56 -40
- package/src/domain/analysis/fn-impact.ts +4 -0
- package/src/domain/analysis/module-map.ts +38 -6
- package/src/domain/analysis/roles.ts +23 -0
- package/src/domain/graph/builder/call-resolver.ts +156 -218
- package/src/domain/graph/builder/cha.ts +18 -1
- package/src/domain/graph/builder/context.ts +1 -0
- package/src/domain/graph/builder/helpers.ts +205 -67
- package/src/domain/graph/builder/incremental.ts +249 -119
- package/src/domain/graph/builder/pipeline.ts +59 -6
- package/src/domain/graph/builder/stages/build-edges.ts +783 -652
- package/src/domain/graph/builder/stages/collect-files.ts +12 -6
- package/src/domain/graph/builder/stages/detect-changes.ts +4 -2
- package/src/domain/graph/builder/stages/finalize.ts +4 -0
- package/src/domain/graph/builder/stages/native-orchestrator.ts +1214 -398
- package/src/domain/graph/builder/stages/resolve-imports.ts +1 -1
- package/src/domain/graph/resolver/points-to.ts +182 -59
- package/src/domain/graph/resolver/strategy.ts +265 -0
- package/src/domain/graph/watcher.ts +19 -9
- package/src/domain/parser.ts +57 -16
- package/src/domain/queries.ts +1 -1
- package/src/domain/wasm-worker-entry.ts +13 -2
- package/src/domain/wasm-worker-pool.ts +29 -4
- package/src/domain/wasm-worker-protocol.ts +5 -0
- package/src/extractors/cpp.ts +44 -1
- package/src/extractors/cuda.ts +44 -1
- package/src/extractors/dart.ts +48 -3
- package/src/extractors/groovy.ts +62 -2
- package/src/extractors/helpers.ts +48 -2
- package/src/extractors/java.ts +88 -8
- package/src/extractors/javascript.ts +693 -167
- package/src/extractors/kotlin.ts +57 -3
- package/src/extractors/objc.ts +25 -1
- package/src/extractors/scala.ts +63 -1
- package/src/extractors/swift.ts +46 -3
- package/src/features/audit.ts +43 -34
- package/src/features/boundaries.ts +17 -9
- package/src/features/cfg.ts +31 -22
- package/src/features/check.ts +21 -5
- package/src/features/communities.ts +28 -19
- package/src/features/dataflow.ts +755 -6
- package/src/features/manifesto.ts +76 -75
- package/src/features/sequence.ts +29 -23
- package/src/features/snapshot.ts +36 -25
- package/src/features/structure-query.ts +7 -7
- package/src/features/structure.ts +185 -55
- package/src/features/triage.ts +28 -15
- package/src/graph/algorithms/bfs.ts +13 -12
- package/src/graph/algorithms/tarjan.ts +5 -0
- package/src/graph/builders/dependency.ts +35 -23
- package/src/graph/classifiers/roles.ts +74 -7
- package/src/index.ts +5 -1
- package/src/infrastructure/config.ts +511 -23
- package/src/infrastructure/registry.ts +117 -12
- package/src/infrastructure/update-check.ts +55 -33
- package/src/mcp/server.ts +2 -8
- package/src/mcp/tools/ast-query.ts +1 -1
- package/src/mcp/tools/audit.ts +1 -1
- package/src/mcp/tools/batch-query.ts +1 -1
- package/src/mcp/tools/branch-compare.ts +1 -1
- package/src/mcp/tools/brief.ts +1 -1
- package/src/mcp/tools/cfg.ts +1 -1
- package/src/mcp/tools/check.ts +1 -1
- package/src/mcp/tools/co-changes.ts +1 -1
- package/src/mcp/tools/code-owners.ts +1 -1
- package/src/mcp/tools/communities.ts +1 -1
- package/src/mcp/tools/complexity.ts +1 -1
- package/src/mcp/tools/context.ts +1 -1
- package/src/mcp/tools/dataflow.ts +1 -1
- package/src/mcp/tools/diff-impact.ts +1 -1
- package/src/mcp/tools/execution-flow.ts +1 -1
- package/src/mcp/tools/export-graph.ts +1 -1
- package/src/mcp/tools/file-deps.ts +1 -1
- package/src/mcp/tools/file-exports.ts +1 -1
- package/src/mcp/tools/find-cycles.ts +1 -1
- package/src/mcp/tools/fn-impact.ts +1 -1
- package/src/mcp/tools/impact-analysis.ts +1 -1
- package/src/mcp/tools/implementations.ts +1 -1
- package/src/mcp/tools/index.ts +2 -5
- package/src/mcp/tools/interfaces.ts +1 -1
- package/src/mcp/tools/list-functions.ts +1 -1
- package/src/mcp/tools/list-repos.ts +1 -1
- package/src/mcp/tools/module-map.ts +1 -1
- package/src/mcp/tools/node-roles.ts +1 -1
- package/src/mcp/tools/path.ts +1 -1
- package/src/mcp/tools/query.ts +1 -1
- package/src/mcp/tools/semantic-search.ts +1 -1
- package/src/mcp/tools/sequence.ts +1 -1
- package/src/mcp/tools/structure.ts +1 -1
- package/src/mcp/tools/symbol-children.ts +1 -1
- package/src/mcp/tools/triage.ts +1 -1
- package/src/mcp/tools/where.ts +1 -1
- package/src/mcp/types.ts +21 -0
- package/src/presentation/queries-cli/index.ts +1 -1
- package/src/presentation/queries-cli/overview.ts +35 -1
- package/src/presentation/queries-cli.ts +1 -0
- package/src/presentation/structure.ts +3 -3
- package/src/presentation/viewer.ts +98 -87
- package/src/shared/constants.ts +26 -0
- package/src/shared/normalize.ts +13 -22
- package/src/shared/paginate.ts +4 -18
- package/src/types.ts +127 -1
|
@@ -8,8 +8,8 @@ import fs from 'node:fs';
|
|
|
8
8
|
import path from 'node:path';
|
|
9
9
|
import { purgeFilesData } from '../../../db/index.js';
|
|
10
10
|
import { debug, warn } from '../../../infrastructure/logger.js';
|
|
11
|
-
import {
|
|
12
|
-
import { compileGlobs, matchesAny } from '../../../shared/globs.js';
|
|
11
|
+
import { buildIgnoreSet, EXTENSIONS, normalizePath } from '../../../shared/constants.js';
|
|
12
|
+
import { compileGlobs, globToRegex, matchesAny } from '../../../shared/globs.js';
|
|
13
13
|
import type {
|
|
14
14
|
BetterSqlite3Database,
|
|
15
15
|
CodegraphConfig,
|
|
@@ -48,14 +48,20 @@ export const BUILTIN_RECEIVERS: Set<string> = new Set([
|
|
|
48
48
|
'require',
|
|
49
49
|
]);
|
|
50
50
|
|
|
51
|
+
/** Phase 8.6: confidence penalty applied to CHA-dispatch edges. */
|
|
52
|
+
export const CHA_DISPATCH_PENALTY = 0.1;
|
|
53
|
+
/** Phase 8.6: fixed confidence for typed-receiver (interface/CHA) dispatch edges.
|
|
54
|
+
* File proximity is not meaningful for virtual dispatch — all three engine paths
|
|
55
|
+
* (WASM inline, WASM post-pass, native post-pass) must agree on this value. */
|
|
56
|
+
export const CHA_TYPED_DISPATCH_CONFIDENCE = 0.8;
|
|
57
|
+
|
|
51
58
|
/** Check if a directory entry should be skipped (ignored dirs, dotfiles). */
|
|
52
|
-
function shouldSkipEntry(entry: fs.Dirent,
|
|
59
|
+
function shouldSkipEntry(entry: fs.Dirent, ignoreSet: ReadonlySet<string>): boolean {
|
|
53
60
|
if (entry.name.startsWith('.') && entry.name !== '.') {
|
|
54
|
-
if (
|
|
61
|
+
if (ignoreSet.has(entry.name)) return true;
|
|
55
62
|
if (entry.isDirectory()) return true;
|
|
56
63
|
}
|
|
57
|
-
if (
|
|
58
|
-
if (extraIgnore?.has(entry.name)) return true;
|
|
64
|
+
if (ignoreSet.has(entry.name)) return true;
|
|
59
65
|
return false;
|
|
60
66
|
}
|
|
61
67
|
|
|
@@ -76,13 +82,65 @@ export function passesIncludeExclude(
|
|
|
76
82
|
return true;
|
|
77
83
|
}
|
|
78
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Parse the `.gitignore` file at the project root and return compiled regexes
|
|
87
|
+
* for each non-negated, non-comment pattern.
|
|
88
|
+
*
|
|
89
|
+
* Only the root-level `.gitignore` is read — nested `.gitignore` files and
|
|
90
|
+
* global gitignore are not consulted. This gives the WASM file-collection
|
|
91
|
+
* walker the same coarse gitignore respect that the Rust engine gets from the
|
|
92
|
+
* `ignore` crate's `git_ignore(true)` option, without requiring an additional
|
|
93
|
+
* npm dependency.
|
|
94
|
+
*
|
|
95
|
+
* Negation patterns (`!pattern`) are intentionally skipped — honoring them
|
|
96
|
+
* correctly requires ordered evaluation which is outside scope here. The Rust
|
|
97
|
+
* engine's `ignore` crate handles negation natively.
|
|
98
|
+
*/
|
|
99
|
+
export function readGitignorePatterns(rootDir: string): readonly RegExp[] {
|
|
100
|
+
const gitignorePath = path.join(rootDir, '.gitignore');
|
|
101
|
+
let contents: string;
|
|
102
|
+
try {
|
|
103
|
+
contents = fs.readFileSync(gitignorePath, 'utf-8');
|
|
104
|
+
} catch {
|
|
105
|
+
return [];
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const regexes: RegExp[] = [];
|
|
109
|
+
for (const rawLine of contents.split(/\r?\n/)) {
|
|
110
|
+
const line = rawLine.trim();
|
|
111
|
+
// Skip empty lines, comments, and negation patterns
|
|
112
|
+
if (!line || line.startsWith('#') || line.startsWith('!')) continue;
|
|
113
|
+
// Strip trailing slash (directory indicator) — we match files by path regardless
|
|
114
|
+
const pattern = line.endsWith('/') ? line.slice(0, -1) : line;
|
|
115
|
+
try {
|
|
116
|
+
// If pattern contains no '/', it should match at any depth — prefix with `**/`.
|
|
117
|
+
// If pattern starts with '/', it is anchored to root — strip the leading slash.
|
|
118
|
+
// Otherwise use as-is (e.g. `crates/codegraph-core/index.js`).
|
|
119
|
+
let normalized: string;
|
|
120
|
+
if (pattern.startsWith('/')) {
|
|
121
|
+
normalized = pattern.slice(1);
|
|
122
|
+
} else if (!pattern.includes('/')) {
|
|
123
|
+
normalized = `**/${pattern}`;
|
|
124
|
+
} else {
|
|
125
|
+
normalized = pattern;
|
|
126
|
+
}
|
|
127
|
+
regexes.push(globToRegex(normalized));
|
|
128
|
+
} catch {
|
|
129
|
+
// Ignore patterns that don't compile (e.g. those with unsupported syntax)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return Object.freeze(regexes);
|
|
133
|
+
}
|
|
134
|
+
|
|
79
135
|
/** Per-walk state computed once at the top-level invocation. */
|
|
80
136
|
interface CollectContext {
|
|
81
137
|
readonly rootDir: string;
|
|
82
138
|
readonly includeRegexes: readonly RegExp[];
|
|
83
139
|
readonly excludeRegexes: readonly RegExp[];
|
|
140
|
+
readonly gitignoreRegexes: readonly RegExp[];
|
|
84
141
|
readonly hasGlobFilters: boolean;
|
|
85
|
-
|
|
142
|
+
/** Merged set of IGNORE_DIRS + config.ignoreDirs + config.ignoreAdditionalDirs. */
|
|
143
|
+
readonly ignoreSet: ReadonlySet<string>;
|
|
86
144
|
readonly visited: Set<string>;
|
|
87
145
|
}
|
|
88
146
|
|
|
@@ -115,8 +173,10 @@ function readDirSafe(dir: string): fs.Dirent[] | null {
|
|
|
115
173
|
/** True if `entry` is a source file we should collect under `ctx`. */
|
|
116
174
|
function isCollectableSourceFile(full: string, entry: fs.Dirent, ctx: CollectContext): boolean {
|
|
117
175
|
if (!EXTENSIONS.has(path.extname(entry.name))) return false;
|
|
118
|
-
if (!ctx.hasGlobFilters) return true;
|
|
119
176
|
const rel = normalizePath(path.relative(ctx.rootDir, full));
|
|
177
|
+
// Respect .gitignore patterns before applying include/exclude globs
|
|
178
|
+
if (ctx.gitignoreRegexes.length > 0 && matchesAny(ctx.gitignoreRegexes, rel)) return false;
|
|
179
|
+
if (!ctx.hasGlobFilters) return true;
|
|
120
180
|
return passesIncludeExclude(rel, ctx.includeRegexes, ctx.excludeRegexes);
|
|
121
181
|
}
|
|
122
182
|
|
|
@@ -133,7 +193,7 @@ function walkCollect(
|
|
|
133
193
|
|
|
134
194
|
let hasFiles = false;
|
|
135
195
|
for (const entry of entries) {
|
|
136
|
-
if (shouldSkipEntry(entry, ctx.
|
|
196
|
+
if (shouldSkipEntry(entry, ctx.ignoreSet)) continue;
|
|
137
197
|
|
|
138
198
|
const full = path.join(dir, entry.name);
|
|
139
199
|
if (entry.isDirectory()) {
|
|
@@ -176,12 +236,19 @@ export function collectFiles(
|
|
|
176
236
|
const trackDirs = directories instanceof Set;
|
|
177
237
|
const includeRegexes = compileGlobs(config.include);
|
|
178
238
|
const excludeRegexes = compileGlobs(config.exclude);
|
|
239
|
+
const gitignoreRegexes = readGitignorePatterns(dir);
|
|
240
|
+
// Build the merged ignore set:
|
|
241
|
+
// - config.ignoreDirs are appended to IGNORE_DIRS (existing behaviour: per-repo overrides)
|
|
242
|
+
// - config.ignoreAdditionalDirs are also merged in on top of IGNORE_DIRS (new feature)
|
|
243
|
+
const extraDirs = [...(config.ignoreDirs ?? []), ...(config.ignoreAdditionalDirs ?? [])];
|
|
244
|
+
const ignoreSet = buildIgnoreSet(extraDirs.length ? extraDirs : undefined);
|
|
179
245
|
const ctx: CollectContext = {
|
|
180
246
|
rootDir: dir,
|
|
181
247
|
includeRegexes,
|
|
182
248
|
excludeRegexes,
|
|
249
|
+
gitignoreRegexes,
|
|
183
250
|
hasGlobFilters: includeRegexes.length > 0 || excludeRegexes.length > 0,
|
|
184
|
-
|
|
251
|
+
ignoreSet,
|
|
185
252
|
visited: new Set(),
|
|
186
253
|
};
|
|
187
254
|
|
|
@@ -313,9 +380,9 @@ function getEdgeStmt(db: BetterSqlite3Database, chunkSize: number): SqliteStatem
|
|
|
313
380
|
}
|
|
314
381
|
let stmt = cache.get(chunkSize);
|
|
315
382
|
if (!stmt) {
|
|
316
|
-
const ph = '(
|
|
383
|
+
const ph = '(?,?,?,?,?,?,?)';
|
|
317
384
|
stmt = db.prepare(
|
|
318
|
-
'INSERT INTO edges (source_id,target_id,kind,confidence,dynamic,technique) VALUES ' +
|
|
385
|
+
'INSERT INTO edges (source_id,target_id,kind,confidence,dynamic,technique,dynamic_kind) VALUES ' +
|
|
319
386
|
Array.from({ length: chunkSize }, () => ph).join(','),
|
|
320
387
|
);
|
|
321
388
|
cache.set(chunkSize, stmt);
|
|
@@ -344,7 +411,7 @@ export function batchInsertNodes(db: BetterSqlite3Database, rows: unknown[][]):
|
|
|
344
411
|
|
|
345
412
|
/**
|
|
346
413
|
* Batch-insert edge rows via multi-value INSERT statements.
|
|
347
|
-
* Each row: [source_id, target_id, kind, confidence, dynamic, technique]
|
|
414
|
+
* Each row: [source_id, target_id, kind, confidence, dynamic, technique, dynamic_kind]
|
|
348
415
|
*/
|
|
349
416
|
export function batchInsertEdges(db: BetterSqlite3Database, rows: unknown[][]): void {
|
|
350
417
|
if (!rows.length) return;
|
|
@@ -355,32 +422,26 @@ export function batchInsertEdges(db: BetterSqlite3Database, rows: unknown[][]):
|
|
|
355
422
|
const vals: unknown[] = [];
|
|
356
423
|
for (let j = i; j < end; j++) {
|
|
357
424
|
const r = rows[j] as unknown[];
|
|
358
|
-
vals.push(r[0], r[1], r[2], r[3], r[4], r[5] ?? null);
|
|
425
|
+
vals.push(r[0], r[1], r[2], r[3], r[4], r[5] ?? null, r[6] ?? null);
|
|
359
426
|
}
|
|
360
427
|
stmt.run(...vals);
|
|
361
428
|
}
|
|
362
429
|
}
|
|
363
430
|
|
|
431
|
+
/** Confidence assigned to CHA-expanded interface/abstract dispatch edges. */
|
|
432
|
+
export const CHA_DISPATCH_CONFIDENCE = 0.8;
|
|
433
|
+
|
|
364
434
|
/**
|
|
365
|
-
*
|
|
366
|
-
*
|
|
367
|
-
* Expands virtual-dispatch call edges for class hierarchies and interface
|
|
368
|
-
* implementations already present in the DB:
|
|
369
|
-
*
|
|
370
|
-
* 1. Build implementors map: parent/interface → [child/implementing class] from
|
|
371
|
-
* `extends` and `implements` edges.
|
|
372
|
-
* 2. Collect RTA evidence: class nodes that appear as `calls` targets (new X()).
|
|
373
|
-
* 3. Find all `calls` edges to qualified method nodes (name contains '.').
|
|
374
|
-
* 4. For each such call, expand to concrete overrides via the implementors map,
|
|
375
|
-
* filtered by RTA when evidence exists.
|
|
376
|
-
*
|
|
377
|
-
* Used by both the native orchestrator post-pass and the WASM build-edges pass.
|
|
435
|
+
* Build the parent→children implementor map from `extends`/`implements` edges.
|
|
436
|
+
* Returns null if no hierarchy edges exist.
|
|
378
437
|
*/
|
|
379
|
-
|
|
438
|
+
function buildImplementorMap(
|
|
439
|
+
db: BetterSqlite3Database,
|
|
440
|
+
): { implementors: Map<string, string[]>; implementorSets: Map<string, Set<string>> } | null {
|
|
380
441
|
const hasHierarchy = db
|
|
381
442
|
.prepare(`SELECT 1 FROM edges WHERE kind IN ('extends', 'implements') LIMIT 1`)
|
|
382
443
|
.get();
|
|
383
|
-
if (!hasHierarchy) return
|
|
444
|
+
if (!hasHierarchy) return null;
|
|
384
445
|
|
|
385
446
|
const hierarchyRows = db
|
|
386
447
|
.prepare(
|
|
@@ -401,11 +462,22 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
401
462
|
}
|
|
402
463
|
set.add(row.child_name);
|
|
403
464
|
}
|
|
404
|
-
if (implementorSets.size === 0) return
|
|
405
|
-
|
|
465
|
+
if (implementorSets.size === 0) return null;
|
|
466
|
+
|
|
467
|
+
// Convert to arrays for iteration compatibility
|
|
406
468
|
const implementors = new Map([...implementorSets.entries()].map(([k, v]) => [k, [...v]]));
|
|
469
|
+
return { implementors, implementorSets };
|
|
470
|
+
}
|
|
407
471
|
|
|
408
|
-
|
|
472
|
+
/**
|
|
473
|
+
* Collect RTA (Rapid Type Analysis) evidence: class names instantiated via
|
|
474
|
+
* constructor calls (`new X()`). Falls back to constructor/function-kind nodes
|
|
475
|
+
* for languages that record constructor calls differently (e.g. TS via WASM).
|
|
476
|
+
*/
|
|
477
|
+
function collectRtaInstantiated(
|
|
478
|
+
db: BetterSqlite3Database,
|
|
479
|
+
implementorSets: Map<string, Set<string>>,
|
|
480
|
+
): Set<string> {
|
|
409
481
|
let rtaRows = db
|
|
410
482
|
.prepare(
|
|
411
483
|
`SELECT DISTINCT tgt.name
|
|
@@ -414,6 +486,7 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
414
486
|
WHERE e.kind = 'calls' AND tgt.kind = 'class'`,
|
|
415
487
|
)
|
|
416
488
|
.all() as Array<{ name: string }>;
|
|
489
|
+
|
|
417
490
|
if (rtaRows.length === 0) {
|
|
418
491
|
// Fallback: some languages (e.g. TypeScript via WASM) record constructor calls as
|
|
419
492
|
// 'function' or 'constructor' kind rather than 'class'. Restrict to names that are
|
|
@@ -446,7 +519,89 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
446
519
|
}
|
|
447
520
|
}
|
|
448
521
|
}
|
|
449
|
-
|
|
522
|
+
|
|
523
|
+
return new Set(rtaRows.map((r) => r.name));
|
|
524
|
+
}
|
|
525
|
+
|
|
526
|
+
/**
|
|
527
|
+
* BFS-expand a single call-to-qualified-method into CHA dispatch edges.
|
|
528
|
+
*
|
|
529
|
+
* For `source_id` calling `typeName.methodSuffix`, walks the implementors
|
|
530
|
+
* map (BFS) and emits an edge for each concrete override that passes the
|
|
531
|
+
* RTA filter. New edges are appended to `newEdges`; `seen` is updated in
|
|
532
|
+
* place to prevent duplicate insertions within the same pass.
|
|
533
|
+
*/
|
|
534
|
+
function expandChaCall(
|
|
535
|
+
sourceId: number,
|
|
536
|
+
typeName: string,
|
|
537
|
+
methodSuffix: string,
|
|
538
|
+
implementors: Map<string, string[]>,
|
|
539
|
+
instantiated: Set<string>,
|
|
540
|
+
noRtaEvidence: boolean,
|
|
541
|
+
findMethodStmt: { all(name: string): unknown[] },
|
|
542
|
+
seen: Set<string>,
|
|
543
|
+
newEdges: Array<[number, number, string, number, number, string]>,
|
|
544
|
+
): void {
|
|
545
|
+
// BFS over the implementors map — handles multi-level hierarchies where
|
|
546
|
+
// abstract/non-instantiated classes sit between the call-site type and
|
|
547
|
+
// the concrete leaf implementations (matches runPostNativeCha, issue #1311).
|
|
548
|
+
const bfsQueue: string[] = [typeName];
|
|
549
|
+
const bfsVisited = new Set<string>([typeName]);
|
|
550
|
+
while (bfsQueue.length > 0) {
|
|
551
|
+
const current = bfsQueue.shift()!;
|
|
552
|
+
const children = implementors.get(current);
|
|
553
|
+
if (!children?.length) continue;
|
|
554
|
+
|
|
555
|
+
for (const cls of children) {
|
|
556
|
+
if (bfsVisited.has(cls)) continue;
|
|
557
|
+
bfsVisited.add(cls);
|
|
558
|
+
|
|
559
|
+
if (noRtaEvidence || instantiated.has(cls)) {
|
|
560
|
+
const qualifiedName = `${cls}.${methodSuffix}`;
|
|
561
|
+
const methodNodes = findMethodStmt.all(qualifiedName) as Array<{ id: number }>;
|
|
562
|
+
for (const methodNode of methodNodes) {
|
|
563
|
+
if (methodNode.id === sourceId) continue; // skip self-loops
|
|
564
|
+
const key = `${sourceId}|${methodNode.id}`;
|
|
565
|
+
if (seen.has(key)) continue;
|
|
566
|
+
seen.add(key);
|
|
567
|
+
newEdges.push([
|
|
568
|
+
sourceId,
|
|
569
|
+
methodNode.id,
|
|
570
|
+
'calls',
|
|
571
|
+
CHA_TYPED_DISPATCH_CONFIDENCE,
|
|
572
|
+
0,
|
|
573
|
+
'cha-expanded',
|
|
574
|
+
]);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
|
|
578
|
+
// Always traverse children — non-instantiated classes may have instantiated subclasses.
|
|
579
|
+
bfsQueue.push(cls);
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
/**
|
|
585
|
+
* CHA (Class Hierarchy Analysis) post-pass.
|
|
586
|
+
*
|
|
587
|
+
* Expands virtual-dispatch call edges for class hierarchies and interface
|
|
588
|
+
* implementations already present in the DB:
|
|
589
|
+
*
|
|
590
|
+
* 1. Build implementors map: parent/interface → [child/implementing class] from
|
|
591
|
+
* `extends` and `implements` edges.
|
|
592
|
+
* 2. Collect RTA evidence: class nodes that appear as `calls` targets (new X()).
|
|
593
|
+
* 3. Find all `calls` edges to qualified method nodes (name contains '.').
|
|
594
|
+
* 4. For each such call, expand to concrete overrides via the implementors map,
|
|
595
|
+
* filtered by RTA when evidence exists.
|
|
596
|
+
*
|
|
597
|
+
* Used by both the native orchestrator post-pass and the WASM build-edges pass.
|
|
598
|
+
*/
|
|
599
|
+
export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
600
|
+
const hierarchy = buildImplementorMap(db);
|
|
601
|
+
if (!hierarchy) return 0;
|
|
602
|
+
const { implementors, implementorSets } = hierarchy;
|
|
603
|
+
|
|
604
|
+
const instantiated = collectRtaInstantiated(db, implementorSets);
|
|
450
605
|
const noRtaEvidence = instantiated.size === 0;
|
|
451
606
|
if (noRtaEvidence) {
|
|
452
607
|
debug('runChaPostPass: no constructor-call evidence — proceeding without RTA filter');
|
|
@@ -454,19 +609,21 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
454
609
|
|
|
455
610
|
const callToMethods = db
|
|
456
611
|
.prepare(
|
|
457
|
-
`SELECT e.source_id, tgt.name AS method_name
|
|
612
|
+
`SELECT e.source_id, src.name AS caller_name, tgt.name AS method_name
|
|
458
613
|
FROM edges e
|
|
459
614
|
JOIN nodes tgt ON e.target_id = tgt.id
|
|
615
|
+
JOIN nodes src ON e.source_id = src.id
|
|
460
616
|
WHERE e.kind = 'calls' AND tgt.kind = 'method'
|
|
461
|
-
AND INSTR(tgt.name, '.') > 0
|
|
617
|
+
AND INSTR(tgt.name, '.') > 0
|
|
618
|
+
AND (e.technique IS NULL OR e.technique != 'cha-expanded')`,
|
|
462
619
|
)
|
|
463
|
-
.all() as Array<{ source_id: number; method_name: string }>;
|
|
620
|
+
.all() as Array<{ source_id: number; caller_name: string; method_name: string }>;
|
|
464
621
|
|
|
465
|
-
const seen = new Set<string>();
|
|
466
622
|
// Scope deduplication to only the source_ids we are about to expand, avoiding
|
|
467
623
|
// a full-table scan. CHA only inserts edges FROM callers that already call a
|
|
468
624
|
// qualified method (the source_ids in callToMethods), so we only need to
|
|
469
625
|
// check existing edges for those specific callers.
|
|
626
|
+
const seen = new Set<string>();
|
|
470
627
|
const callerIds = [...new Set(callToMethods.map((r) => r.source_id))];
|
|
471
628
|
if (callerIds.length > 0) {
|
|
472
629
|
// Chunk to stay within SQLite SQLITE_MAX_VARIABLE_NUMBER (999 in many builds).
|
|
@@ -492,36 +649,17 @@ export function runChaPostPass(db: BetterSqlite3Database): number {
|
|
|
492
649
|
if (dotIdx === -1) continue;
|
|
493
650
|
const typeName = method_name.slice(0, dotIdx);
|
|
494
651
|
const methodSuffix = method_name.slice(dotIdx + 1);
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
for (const cls of children) {
|
|
507
|
-
if (bfsVisited.has(cls)) continue;
|
|
508
|
-
bfsVisited.add(cls);
|
|
509
|
-
|
|
510
|
-
if (noRtaEvidence || instantiated.has(cls)) {
|
|
511
|
-
const qualifiedName = `${cls}.${methodSuffix}`;
|
|
512
|
-
const methodNodes = findMethodStmt.all(qualifiedName) as Array<{ id: number }>;
|
|
513
|
-
for (const methodNode of methodNodes) {
|
|
514
|
-
const key = `${source_id}|${methodNode.id}`;
|
|
515
|
-
if (seen.has(key)) continue;
|
|
516
|
-
seen.add(key);
|
|
517
|
-
newEdges.push([source_id, methodNode.id, 'calls', 0.8, 0, 'cha']);
|
|
518
|
-
}
|
|
519
|
-
}
|
|
520
|
-
|
|
521
|
-
// Always traverse children — non-instantiated classes may have instantiated subclasses.
|
|
522
|
-
bfsQueue.push(cls);
|
|
523
|
-
}
|
|
524
|
-
}
|
|
652
|
+
expandChaCall(
|
|
653
|
+
source_id,
|
|
654
|
+
typeName,
|
|
655
|
+
methodSuffix,
|
|
656
|
+
implementors,
|
|
657
|
+
instantiated,
|
|
658
|
+
noRtaEvidence,
|
|
659
|
+
findMethodStmt,
|
|
660
|
+
seen,
|
|
661
|
+
newEdges,
|
|
662
|
+
);
|
|
525
663
|
}
|
|
526
664
|
|
|
527
665
|
if (newEdges.length > 0) {
|