coderadar-rs 0.6.6__tar.gz → 0.6.7__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (165) hide show
  1. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/Cargo.lock +1 -1
  2. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/Cargo.toml +1 -1
  3. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/PKG-INFO +1 -1
  4. coderadar_rs-0.6.7/core_indexer/src/graph/call_graph.rs +123 -0
  5. coderadar_rs-0.6.7/core_indexer/src/graph/config.rs +152 -0
  6. coderadar_rs-0.6.7/core_indexer/src/graph/embeddings.rs +95 -0
  7. coderadar_rs-0.6.7/core_indexer/src/graph/import_graph.rs +144 -0
  8. coderadar_rs-0.6.7/core_indexer/src/graph/indexing.rs +310 -0
  9. coderadar_rs-0.6.7/core_indexer/src/graph/inheritance.rs +223 -0
  10. coderadar_rs-0.6.7/core_indexer/src/graph/mod.rs +175 -0
  11. coderadar_rs-0.6.7/core_indexer/src/graph/module_resolution.rs +112 -0
  12. coderadar_rs-0.6.7/core_indexer/src/graph/mro.rs +211 -0
  13. coderadar_rs-0.6.7/core_indexer/src/graph/persistence.rs +157 -0
  14. coderadar_rs-0.6.7/core_indexer/src/graph/projection_ops.rs +699 -0
  15. coderadar_rs-0.6.7/core_indexer/src/graph/resolve_calls.rs +358 -0
  16. coderadar_rs-0.6.7/core_indexer/src/graph/tests/call_graph_tests.rs +44 -0
  17. coderadar_rs-0.6.7/core_indexer/src/graph/tests/embedding_tests.rs +101 -0
  18. coderadar_rs-0.6.7/core_indexer/src/graph/tests/import_graph_tests.rs +141 -0
  19. coderadar_rs-0.6.7/core_indexer/src/graph/tests/indexing_tests.rs +717 -0
  20. coderadar_rs-0.6.7/core_indexer/src/graph/tests/inheritance_tests.rs +217 -0
  21. coderadar_rs-0.6.7/core_indexer/src/graph/tests/mod.rs +84 -0
  22. coderadar_rs-0.6.7/core_indexer/src/graph/tests/mro_tests.rs +80 -0
  23. coderadar_rs-0.6.7/core_indexer/src/graph/tests/persistence_tests.rs +237 -0
  24. coderadar_rs-0.6.7/core_indexer/src/graph/tests/projection_tests.rs +56 -0
  25. coderadar_rs-0.6.7/core_indexer/src/graph/tests/query_compile_tests.rs +95 -0
  26. coderadar_rs-0.6.7/core_indexer/src/graph/tests/traversal_tests.rs +167 -0
  27. coderadar_rs-0.6.7/core_indexer/src/graph/traversal.rs +120 -0
  28. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/cli.py +1 -1
  29. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/server.py +1 -1
  30. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/pyproject.toml +1 -1
  31. coderadar_rs-0.6.6/core_indexer/src/graph.rs +0 -4770
  32. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/LICENSE +0 -0
  33. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/README.md +0 -0
  34. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/Cargo.toml +0 -0
  35. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/bash.scm +0 -0
  36. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/c.scm +0 -0
  37. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/clojure.scm +0 -0
  38. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/cmake.scm +0 -0
  39. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/cpp.scm +0 -0
  40. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/csharp.scm +0 -0
  41. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/dart.scm +0 -0
  42. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/dockerfile.scm +0 -0
  43. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/elisp.scm +0 -0
  44. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/elixir.scm +0 -0
  45. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/erlang.scm +0 -0
  46. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/fsharp.scm +0 -0
  47. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/go.scm +0 -0
  48. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/graphql.scm +0 -0
  49. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/groovy.scm +0 -0
  50. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/haskell.scm +0 -0
  51. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/hcl.scm +0 -0
  52. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/java.scm +0 -0
  53. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/javascript.scm +0 -0
  54. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/julia.scm +0 -0
  55. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/kotlin.scm +0 -0
  56. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/lua.scm +0 -0
  57. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/nix.scm +0 -0
  58. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/objc.scm +0 -0
  59. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/ocaml.scm +0 -0
  60. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/perl.scm +0 -0
  61. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/php.scm +0 -0
  62. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/powershell.scm +0 -0
  63. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/protobuf.scm +0 -0
  64. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/python.scm +0 -0
  65. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/r.scm +0 -0
  66. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/ruby.scm +0 -0
  67. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/rust.scm +0 -0
  68. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/scala.scm +0 -0
  69. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/shell.scm +0 -0
  70. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/sql.scm +0 -0
  71. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/swift.scm +0 -0
  72. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/systemverilog.scm +0 -0
  73. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/typescript.scm +0 -0
  74. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/verilog.scm +0 -0
  75. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/queries/zig.scm +0 -0
  76. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/buffers.rs +0 -0
  77. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/decorators.rs +0 -0
  78. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/docstring.rs +0 -0
  79. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/mod.rs +0 -0
  80. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/single_pass.rs +0 -0
  81. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/spans.rs +0 -0
  82. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/tagger.rs +0 -0
  83. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/extract/walker.rs +0 -0
  84. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/fs/git.rs +0 -0
  85. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/fs/mod.rs +0 -0
  86. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/fs/watcher.rs +0 -0
  87. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/lib.rs +0 -0
  88. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/mutation/edit.rs +0 -0
  89. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/mutation/indent.rs +0 -0
  90. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/mutation/mod.rs +0 -0
  91. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/mutation/write_guard.rs +0 -0
  92. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/query/exec.rs +0 -0
  93. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/query/grammar.pest +0 -0
  94. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/query/grammar.rs +0 -0
  95. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/query/mod.rs +0 -0
  96. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/cache.rs +0 -0
  97. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/import_graph.rs +0 -0
  98. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/mod.rs +0 -0
  99. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/orchestrator.rs +0 -0
  100. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/signature.rs +0 -0
  101. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/resolve/stack_graph.rs +0 -0
  102. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/engine.rs +0 -0
  103. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/metrics.rs +0 -0
  104. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/mod.rs +0 -0
  105. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rule.rs +0 -0
  106. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/brain_method.rs +0 -0
  107. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/data_class.rs +0 -0
  108. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/deep_nesting.rs +0 -0
  109. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/excessive_returns.rs +0 -0
  110. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/god_class.rs +0 -0
  111. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/high_cyclomatic_complexity.rs +0 -0
  112. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/long_method.rs +0 -0
  113. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/long_parameter_list.rs +0 -0
  114. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/mod.rs +0 -0
  115. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/rules/too_many_fields.rs +0 -0
  116. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/smells/types.rs +0 -0
  117. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/storage.rs +0 -0
  118. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/types.rs +0 -0
  119. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/update/diff.rs +0 -0
  120. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/update/mod.rs +0 -0
  121. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/update/patch.rs +0 -0
  122. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/core_indexer/src/update/wal.rs +0 -0
  123. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/__init__.py +0 -0
  124. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/agent/__init__.py +0 -0
  125. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/agent/graphrag.py +0 -0
  126. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/config.py +0 -0
  127. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/embedding/__init__.py +0 -0
  128. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/embedding/dedup.py +0 -0
  129. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/flatbuffer.py +0 -0
  130. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/lsp/__init__.py +0 -0
  131. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/lsp/pool.py +0 -0
  132. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/__init__.py +0 -0
  133. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/affected.py +0 -0
  134. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/budget.py +0 -0
  135. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/explore.py +0 -0
  136. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/node.py +0 -0
  137. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mcp/search.py +0 -0
  138. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mutation/__init__.py +0 -0
  139. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/mutation/tool_router.py +0 -0
  140. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/pipeline.py +0 -0
  141. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/query/__init__.py +0 -0
  142. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/query/cache.py +0 -0
  143. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/query/executor.py +0 -0
  144. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/query/planner.py +0 -0
  145. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/__init__.py +0 -0
  146. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/actix.py +0 -0
  147. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/aspnet.py +0 -0
  148. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/base.py +0 -0
  149. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/django.py +0 -0
  150. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/exports.py +0 -0
  151. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/express.py +0 -0
  152. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/fastapi.py +0 -0
  153. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/flask.py +0 -0
  154. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/go.py +0 -0
  155. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/laravel.py +0 -0
  156. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/nestjs.py +0 -0
  157. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/rails.py +0 -0
  158. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/reactrouter.py +0 -0
  159. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/resolution.py +0 -0
  160. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/springboot.py +0 -0
  161. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/resolvers/vuerouter.py +0 -0
  162. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/visualizers/__init__.py +0 -0
  163. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/visualizers/call_graph.py +0 -0
  164. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/visualizers/graphviz_viz.py +0 -0
  165. {coderadar_rs-0.6.6 → coderadar_rs-0.6.7}/py_agent/src/coderadar/visualizers/mermaid.py +0 -0
@@ -445,7 +445,7 @@ checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
445
445
 
446
446
  [[package]]
447
447
  name = "core_indexer"
448
- version = "0.6.6"
448
+ version = "0.6.7"
449
449
  dependencies = [
450
450
  "crossbeam-channel",
451
451
  "dashmap",
@@ -3,6 +3,6 @@ members = ["core_indexer"]
3
3
  resolver = "2"
4
4
 
5
5
  [workspace.package]
6
- version = "0.6.6"
6
+ version = "0.6.7"
7
7
  edition = "2021"
8
8
  license = "MIT"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: coderadar-rs
3
- Version: 0.6.6
3
+ Version: 0.6.7
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Intended Audience :: Developers
6
6
  Classifier: License :: OSI Approved :: MIT License
@@ -0,0 +1,123 @@
1
+ use std::collections::{BTreeSet, HashMap};
2
+
3
+ use dashmap::DashMap;
4
+ use petgraph::stable_graph::{NodeIndex, StableDiGraph};
5
+
6
+ use crate::types::*;
7
+
8
+ // ── Call Graph (§3.4a) — EntityId-based ─────────────────────────────────────
9
+
10
+ #[derive(Clone, Debug)]
11
+ pub struct CallNode {
12
+ pub entity_id: EntityId,
13
+ pub qualified_name: String,
14
+ }
15
+
16
+ #[derive(Clone, Debug)]
17
+ pub struct CallEdge {
18
+ pub confidence: f32,
19
+ pub resolution_method: ResolutionMethod,
20
+ pub call_site_span: ByteSpan,
21
+ pub args_span: Option<ByteSpan>,
22
+ }
23
+
24
+ pub struct CallGraph {
25
+ // pub(super): accessed by the shared test helpers in `tests/mod.rs`
26
+ // (make_call_node / make_call_edge), which live outside this module.
27
+ pub(super) graph: StableDiGraph<CallNode, CallEdge>,
28
+ pub(super) path_to_node: DashMap<String, NodeIndex>,
29
+ }
30
+
31
+ impl CallGraph {
32
+ pub fn new() -> Self {
33
+ Self {
34
+ graph: StableDiGraph::new(),
35
+ path_to_node: DashMap::new(),
36
+ }
37
+ }
38
+
39
+ pub fn find_callers(&self, target_id: &str, max_depth: usize) -> Vec<(CallNode, usize)> {
40
+ let target = match self.path_to_node.get(target_id) {
41
+ Some(n) => *n,
42
+ None => return vec![],
43
+ };
44
+
45
+ let mut visited = BTreeSet::new();
46
+ let mut queue = vec![(target, 0usize)];
47
+ let mut result = Vec::new();
48
+
49
+ while let Some((node, depth)) = queue.pop() {
50
+ if depth > max_depth || !visited.insert(node.index()) {
51
+ continue;
52
+ }
53
+ if depth > 0 {
54
+ if let Some(cn) = self.graph.node_weight(node) {
55
+ result.push((cn.clone(), depth));
56
+ }
57
+ }
58
+ for neighbor in self.graph.neighbors_directed(node, petgraph::Incoming) {
59
+ queue.push((neighbor, depth + 1));
60
+ }
61
+ }
62
+ result
63
+ }
64
+
65
+ pub fn find_call_chain(
66
+ &self,
67
+ source_id: &str,
68
+ target_id: &str,
69
+ max_depth: usize,
70
+ ) -> Option<Vec<CallNode>> {
71
+ let (start, end) = match (
72
+ self.path_to_node.get(source_id),
73
+ self.path_to_node.get(target_id),
74
+ ) {
75
+ (Some(s), Some(e)) => (*s, *e),
76
+ _ => return None,
77
+ };
78
+
79
+ let mut visited = BTreeSet::new();
80
+ let mut parent: HashMap<NodeIndex, Option<NodeIndex>> = HashMap::new();
81
+ let mut queue = vec![start];
82
+ visited.insert(start.index());
83
+ parent.insert(start, None);
84
+
85
+ while let Some(node) = queue.pop() {
86
+ if node == end {
87
+ let mut chain = Vec::new();
88
+ let mut current = Some(node);
89
+ while let Some(n) = current {
90
+ if let Some(cn) = self.graph.node_weight(n) {
91
+ chain.push(cn.clone());
92
+ }
93
+ current = parent[&n];
94
+ }
95
+ chain.reverse();
96
+ return Some(chain);
97
+ }
98
+
99
+ let current_depth = {
100
+ let mut d = 0;
101
+ let mut p = Some(node);
102
+ while let Some(n) = p {
103
+ p = parent.get(&n).copied().flatten();
104
+ d += 1;
105
+ }
106
+ d
107
+ };
108
+
109
+ if current_depth >= max_depth {
110
+ continue;
111
+ }
112
+
113
+ for neighbor in self.graph.neighbors_directed(node, petgraph::Outgoing) {
114
+ if !visited.insert(neighbor.index()) {
115
+ continue;
116
+ }
117
+ parent.insert(neighbor, Some(node));
118
+ queue.push(neighbor);
119
+ }
120
+ }
121
+ None
122
+ }
123
+ }
@@ -0,0 +1,152 @@
1
+
2
+ // ── Graph Config (§15) ──────────────────────────────────────────────────────
3
+
4
+ #[derive(Clone, Debug)]
5
+ pub struct GraphConfig {
6
+ pub resolution: ResolutionConfig,
7
+ pub stack_graph: StackGraphConfig,
8
+ pub import_graph: ImportGraphConfig,
9
+ pub signature: SignatureConfig,
10
+ pub memory: MemoryConfig,
11
+ pub mutation: MutationConfig,
12
+ pub query: QueryConfig,
13
+ pub git: GitConfig,
14
+ }
15
+
16
+ impl Default for GraphConfig {
17
+ fn default() -> Self {
18
+ Self {
19
+ resolution: ResolutionConfig::default(),
20
+ stack_graph: StackGraphConfig::default(),
21
+ import_graph: ImportGraphConfig::default(),
22
+ signature: SignatureConfig::default(),
23
+ memory: MemoryConfig::default(),
24
+ mutation: MutationConfig::default(),
25
+ query: QueryConfig::default(),
26
+ git: GitConfig::default(),
27
+ }
28
+ }
29
+ }
30
+
31
+ #[derive(Clone, Debug)]
32
+ pub struct ResolutionConfig {
33
+ pub min_confidence: f32,
34
+ }
35
+ impl Default for ResolutionConfig {
36
+ fn default() -> Self {
37
+ Self { min_confidence: 0.3 }
38
+ }
39
+ }
40
+
41
+ #[derive(Clone, Debug)]
42
+ pub struct StackGraphConfig {
43
+ pub rules_dir: String,
44
+ pub max_path_depth: usize,
45
+ pub incremental: bool,
46
+ }
47
+ impl Default for StackGraphConfig {
48
+ fn default() -> Self {
49
+ Self { rules_dir: String::new(), max_path_depth: 10, incremental: true }
50
+ }
51
+ }
52
+
53
+ #[derive(Clone, Debug)]
54
+ pub struct ImportGraphConfig {
55
+ pub max_import_depth: usize,
56
+ pub include_same_package: bool,
57
+ pub max_wildcard_hops: u8,
58
+ }
59
+ impl Default for ImportGraphConfig {
60
+ fn default() -> Self {
61
+ Self { max_import_depth: 3, include_same_package: true, max_wildcard_hops: 3 }
62
+ }
63
+ }
64
+
65
+ #[derive(Clone, Debug)]
66
+ pub struct SignatureConfig {
67
+ pub min_score: f32,
68
+ pub name_weight: f32,
69
+ pub arity_weight: f32,
70
+ pub proximity_weight: f32,
71
+ /// Pattern from CodeGraph's name-matcher.ts: when a name is defined more
72
+ /// than this many times, fuzzy resolution strategies decline to prevent
73
+ /// near-certain-wrong edges and O(K²) blowup (vendored themes, SDK copies).
74
+ /// Precise strategies (qualified-name, import-based) still run unaffected.
75
+ pub ambiguous_name_ceiling: usize,
76
+ }
77
+ impl Default for SignatureConfig {
78
+ fn default() -> Self {
79
+ Self { min_score: 0.5, name_weight: 0.4, arity_weight: 0.3, proximity_weight: 0.3, ambiguous_name_ceiling: 500 }
80
+ }
81
+ }
82
+
83
+ #[derive(Clone, Debug)]
84
+ pub struct MemoryConfig {
85
+ pub stack_graph_mb: usize,
86
+ pub call_graph_mb: usize,
87
+ pub resolution_cache_mb: usize,
88
+ pub projected_graph_mb: usize,
89
+ pub spill_compression: String,
90
+ }
91
+ impl Default for MemoryConfig {
92
+ fn default() -> Self {
93
+ Self {
94
+ stack_graph_mb: 60, call_graph_mb: 40, resolution_cache_mb: 20,
95
+ projected_graph_mb: 200, spill_compression: "zstd".to_string(),
96
+ }
97
+ }
98
+ }
99
+
100
+ #[derive(Clone, Debug)]
101
+ pub struct MutationConfig {
102
+ pub enabled: bool,
103
+ pub default_dry_run: bool,
104
+ pub max_files_per_plan: usize,
105
+ pub max_edits_per_plan: usize,
106
+ pub max_body_tokens: usize,
107
+ pub backup_retention_hours: u64,
108
+ pub post_verify: bool,
109
+ pub max_repair_attempts: u32,
110
+ pub require_clean_git: bool,
111
+ pub allow: Vec<String>,
112
+ pub deny: Vec<String>,
113
+ }
114
+ impl Default for MutationConfig {
115
+ fn default() -> Self {
116
+ Self {
117
+ enabled: true, default_dry_run: true, max_files_per_plan: 100,
118
+ max_edits_per_plan: 500, max_body_tokens: 4000,
119
+ backup_retention_hours: 24, post_verify: true, max_repair_attempts: 3,
120
+ require_clean_git: false,
121
+ allow: vec!["src/".into(), "lib/".into(), "tests/".into(), "scripts/".into()],
122
+ deny: vec![".git/".into(), ".harness/".into(), ".codegraph/".into(),
123
+ "/migrations/".into(), "/*.lock".into(), "/generated/".into()],
124
+ }
125
+ }
126
+ }
127
+
128
+ #[derive(Clone, Debug)]
129
+ pub struct QueryConfig {
130
+ pub max_depth: usize,
131
+ pub default_top_k: usize,
132
+ pub cache_ttl_seconds: u64,
133
+ pub cache_max_size: usize,
134
+ pub use_rust_graph_for_traversal: bool,
135
+ }
136
+ impl Default for QueryConfig {
137
+ fn default() -> Self {
138
+ Self { max_depth: 5, default_top_k: 10, cache_ttl_seconds: 300,
139
+ cache_max_size: 256, use_rust_graph_for_traversal: true }
140
+ }
141
+ }
142
+
143
+ #[derive(Clone, Debug)]
144
+ pub struct GitConfig {
145
+ pub enabled: bool,
146
+ pub reindex_on_branch_switch: bool,
147
+ }
148
+ impl Default for GitConfig {
149
+ fn default() -> Self {
150
+ Self { enabled: true, reindex_on_branch_switch: true }
151
+ }
152
+ }
@@ -0,0 +1,95 @@
1
+ use std::sync::Arc;
2
+
3
+ use super::CodeGraph;
4
+ use crate::types::*;
5
+
6
+ impl CodeGraph {
7
+ /// Store an embedding vector on any entity type.
8
+ /// Updates the in-memory embedding field and commits the projection.
9
+ pub fn set_embedding(
10
+ &self,
11
+ entity_id: &str,
12
+ embedding: &[f64],
13
+ content_hash: &str,
14
+ ) -> Result<(), String> {
15
+ let mut projection = (*self.snapshot()).clone();
16
+ let emb = EmbeddingVec { vec: embedding.to_vec(), hash: content_hash.to_string() };
17
+ if let Some(e) = projection.functions.get_mut(entity_id) {
18
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
19
+ } else if let Some(e) = projection.classes.get_mut(entity_id) {
20
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
21
+ } else if let Some(e) = projection.modules.get_mut(entity_id) {
22
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
23
+ } else if let Some(e) = projection.imports.get_mut(entity_id) {
24
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
25
+ } else if let Some(e) = projection.constants.get_mut(entity_id) {
26
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
27
+ } else if let Some(e) = projection.type_aliases.get_mut(entity_id) {
28
+ std::sync::Arc::make_mut(e).embedding = emb.clone();
29
+ } else {
30
+ return Err(format!("Entity not found: {}", entity_id));
31
+ }
32
+ self.commit_projection(projection);
33
+ Ok(())
34
+ }
35
+
36
+ /// Clear embedding vectors for all entities in a file.
37
+ /// Called after mutation to invalidate stale embeddings.
38
+ pub fn clear_embeddings_for_file(&self, file_path: &str) {
39
+ let normalized = file_path.replace('/', std::path::MAIN_SEPARATOR_STR)
40
+ .replace('\\', std::path::MAIN_SEPARATOR_STR);
41
+ // Try both with and without ./ prefix (cross-platform path variance)
42
+ let module_id_a = format!("{}::module", normalized);
43
+ let module_id_b = format!(".{}{}::module", std::path::MAIN_SEPARATOR_STR, normalized.trim_start_matches('.').trim_start_matches(std::path::MAIN_SEPARATOR));
44
+ let module_id_c = format!("./{}::module", normalized.replace("\\", "/"));
45
+ let candidates = [&module_id_a, &module_id_b, &module_id_c];
46
+ let mut projection = (*self.snapshot()).clone();
47
+ for candidate in &candidates {
48
+ if let Some(module) = projection.modules.get(*candidate) {
49
+ let ids: Vec<String> = module.functions.iter()
50
+ .chain(module.classes.iter())
51
+ .chain(module.imports.iter())
52
+ .chain(module.constants.iter())
53
+ .chain(module.type_aliases.iter())
54
+ .cloned()
55
+ .collect();
56
+ for id in &ids {
57
+ if let Some(f) = projection.functions.get_mut(id) {
58
+ std::sync::Arc::make_mut(f).embedding = EmbeddingVec::default();
59
+ }
60
+ if let Some(c) = projection.classes.get_mut(id) {
61
+ std::sync::Arc::make_mut(c).embedding = EmbeddingVec::default();
62
+ }
63
+ if let Some(i) = projection.imports.get_mut(id) {
64
+ std::sync::Arc::make_mut(i).embedding = EmbeddingVec::default();
65
+ }
66
+ if let Some(c) = projection.constants.get_mut(id) {
67
+ std::sync::Arc::make_mut(c).embedding = EmbeddingVec::default();
68
+ }
69
+ if let Some(ta) = projection.type_aliases.get_mut(id) {
70
+ std::sync::Arc::make_mut(ta).embedding = EmbeddingVec::default();
71
+ }
72
+ }
73
+ break;
74
+ }
75
+ }
76
+ self.commit_projection(projection);
77
+ }
78
+
79
+ /// v0.5: Set a module's `__all__` star-export names list.
80
+ /// Called from Python after static `__all__` analysis (exports.py).
81
+ /// Enables resolution of `from X import *` wildcard imports.
82
+ pub fn set_module_star_exports(
83
+ &self,
84
+ module_id: &str,
85
+ names: Vec<String>,
86
+ ) {
87
+ let mut projection = (*self.snapshot()).clone();
88
+ if let Some(module) = projection.modules.get(module_id) {
89
+ let mut m = (**module).clone();
90
+ m.star_exports = Some(names);
91
+ projection.modules.insert(module_id.to_string(), Arc::new(m));
92
+ }
93
+ self.commit_projection(projection);
94
+ }
95
+ }
@@ -0,0 +1,144 @@
1
+ use std::collections::BTreeSet;
2
+ use std::path::PathBuf;
3
+
4
+ use dashmap::DashMap;
5
+ use petgraph::stable_graph::{NodeIndex, StableDiGraph};
6
+
7
+ use crate::types::*;
8
+
9
+ // ── Import Graph (§3.4a) — EntityId-based ───────────────────────────────────
10
+
11
+ #[derive(Clone, Debug)]
12
+ pub struct ImportNode {
13
+ pub path: PathBuf,
14
+ pub module_id: Option<EntityId>,
15
+ pub language: Language,
16
+ }
17
+
18
+ pub struct ImportGraph {
19
+ graph: StableDiGraph<ImportNode, ()>,
20
+ path_to_node: DashMap<String, NodeIndex>,
21
+ node_to_path: DashMap<NodeIndex, String>,
22
+ exports: DashMap<String, Vec<Export>>,
23
+ }
24
+
25
+ impl ImportGraph {
26
+ pub fn new() -> Self {
27
+ Self {
28
+ graph: StableDiGraph::new(),
29
+ path_to_node: DashMap::new(),
30
+ node_to_path: DashMap::new(),
31
+ exports: DashMap::new(),
32
+ }
33
+ }
34
+
35
+ pub fn remove_file(&mut self, file_path: &str) {
36
+ if let Some(node) = self.path_to_node.remove(file_path) {
37
+ let (_, old) = node;
38
+ self.node_to_path.remove(&old);
39
+ self.graph.remove_node(old);
40
+ }
41
+ }
42
+
43
+ pub fn transitive_imports(&self, file_path: &str, max_depth: usize) -> Vec<ImportNode> {
44
+ let path_str = file_path.to_string();
45
+ let start = match self.path_to_node.get(&path_str) {
46
+ Some(n) => *n,
47
+ None => return vec![],
48
+ };
49
+
50
+ let mut visited = BTreeSet::new();
51
+ let mut queue = vec![(start, 0usize)];
52
+ let mut result = Vec::new();
53
+
54
+ while let Some((node, depth)) = queue.pop() {
55
+ if depth > max_depth || !visited.insert(node.index()) {
56
+ continue;
57
+ }
58
+ if let Some(import_node) = self.graph.node_weight(node) {
59
+ result.push(import_node.clone());
60
+ }
61
+ for neighbor in self.graph.neighbors_directed(node, petgraph::Outgoing) {
62
+ queue.push((neighbor, depth + 1));
63
+ }
64
+ }
65
+ result
66
+ }
67
+
68
+ pub fn add_file(
69
+ &mut self,
70
+ file_path: &str,
71
+ module_id: Option<EntityId>,
72
+ language: Language,
73
+ ) -> NodeIndex {
74
+ // v0.5: Return existing node if already registered (prevents
75
+ // duplicate nodes with missing outgoing edges in multi-hop chains).
76
+ if let Some(existing) = self.path_to_node.get(file_path) {
77
+ return *existing;
78
+ }
79
+ let node = ImportNode {
80
+ path: PathBuf::from(file_path),
81
+ module_id,
82
+ language,
83
+ };
84
+ let idx = self.graph.add_node(node);
85
+ self.path_to_node.insert(file_path.to_string(), idx);
86
+ self.node_to_path.insert(idx, file_path.to_string());
87
+ idx
88
+ }
89
+
90
+ /// Add all import edges for a file's extracted imports. Thread-safe:
91
+ /// takes the import_graph lock internally. Called from parallel workers.
92
+ pub fn build_import_edges(
93
+ import_graph: &parking_lot::RwLock<Self>,
94
+ units: &[ExtractedUnit],
95
+ file_path: &str,
96
+ language: Language,
97
+ module_id: &str,
98
+ ) {
99
+ use crate::types::ImportKind;
100
+
101
+ let mut ig = import_graph.write();
102
+ ig.add_file(file_path, Some(module_id.to_string()), language);
103
+
104
+ for unit in units {
105
+ if let ExtractedUnit::Import(i) = unit {
106
+ let src_mod: Option<String> = match &i.kind {
107
+ ImportKind::FromImport { module, .. }
108
+ | ImportKind::ModuleImport { module, .. }
109
+ | ImportKind::StarImport { module, .. } => Some(module.clone()),
110
+ ImportKind::RelativeImport { module, .. } => module.clone(),
111
+ _ => None,
112
+ };
113
+ if let Some(src_mod) = src_mod {
114
+ // Use a simplified path: assume same-directory modules.
115
+ // The full find_module_by_dotted_name requires the projection
116
+ // which isn't available in parallel. The import graph edges
117
+ // will be refined during the sequential insert phase.
118
+ let target_path = format!("{}/{}.py",
119
+ std::path::Path::new(file_path).parent()
120
+ .map(|p| p.to_string_lossy().to_string())
121
+ .unwrap_or_default(),
122
+ src_mod.replace('.', "/"));
123
+ ig.add_file(&target_path, None, language);
124
+ ig.add_import_edge(file_path, &target_path);
125
+ }
126
+ }
127
+ }
128
+ }
129
+
130
+ pub fn add_import_edge(&mut self, importer: &str, imported: &str) {
131
+ let from = self.path_to_node.get(importer);
132
+ let to = self.path_to_node.get(imported);
133
+ if let (Some(f), Some(t)) = (from, to) {
134
+ self.graph.add_edge(*f, *t, ());
135
+ }
136
+ }
137
+
138
+ pub fn get_exports(
139
+ &self,
140
+ path: &str,
141
+ ) -> Option<dashmap::mapref::one::Ref<'_, String, Vec<Export>>> {
142
+ self.exports.get(path)
143
+ }
144
+ }