code2graph-rs 0.0.0b15__tar.gz → 0.0.0b17__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 (132) hide show
  1. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/Cargo.lock +6 -6
  2. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/Cargo.toml +3 -3
  3. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/PKG-INFO +1 -1
  4. {code2graph_rs-0.0.0b15/query → code2graph_rs-0.0.0b17}/README.md +4 -0
  5. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/Cargo.toml +8 -1
  6. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/src/convert.rs +0 -15
  7. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/pyproject.toml +1 -1
  8. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/Cargo.toml +2 -2
  9. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17/query}/README.md +4 -0
  10. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/c.rs +1 -1
  11. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/cpp.rs +1 -1
  12. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/csharp.rs +1 -1
  13. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/dart.rs +58 -10
  14. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/dispatch.rs +179 -14
  15. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/go.rs +1 -1
  16. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/hcl.rs +1 -1
  17. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/java.rs +1 -1
  18. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/javascript.rs +2 -2
  19. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/kotlin.rs +1 -1
  20. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/lua.rs +1 -1
  21. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/luau.rs +1 -1
  22. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/pascal.rs +1 -1
  23. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/php.rs +1 -1
  24. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/python.rs +98 -4
  25. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/ruby.rs +1 -1
  26. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/rust.rs +2 -2
  27. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/scala.rs +1 -1
  28. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/shell.rs +1 -1
  29. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/solidity.rs +1 -1
  30. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/sql.rs +1 -1
  31. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/svelte.rs +1 -1
  32. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/swift.rs +1 -1
  33. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/typescript.rs +452 -3
  34. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/graph/types.rs +7 -5
  35. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/graph/validate.rs +10 -7
  36. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/CODE_OF_CONDUCT.md +0 -0
  37. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/CONTRIBUTING.md +0 -0
  38. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/LICENSE +0 -0
  39. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/assets/discord-cta.svg +0 -0
  40. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/benches/pipeline.rs +0 -0
  41. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/LICENSE +0 -0
  42. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/README.md +0 -0
  43. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/code2graph-node.ts +0 -0
  44. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/commands.ts +0 -0
  45. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/index.ts +0 -0
  46. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/relations.ts +0 -0
  47. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/scan-service.ts +0 -0
  48. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/scan-worker.mjs +0 -0
  49. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/scan.ts +0 -0
  50. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/schema.ts +0 -0
  51. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/tools.ts +0 -0
  52. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/extensions/code2graph/types.ts +0 -0
  53. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/media/code2graph-preview.webp +0 -0
  54. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/media/code2graph-preview.zen +0 -0
  55. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/package.json +0 -0
  56. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/scripts/stage-release.mjs +0 -0
  57. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/extension.test.ts +0 -0
  58. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/graph-index-parity.test.ts +0 -0
  59. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/identity.test.ts +0 -0
  60. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/native-adapter.test.ts +0 -0
  61. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/pack.test.mjs +0 -0
  62. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/pi-package-smoke.test.mjs +0 -0
  63. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/query-index-lifecycle.test.ts +0 -0
  64. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/relations.test.ts +0 -0
  65. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/scan-service.test.ts +0 -0
  66. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/scan-worker.test.ts +0 -0
  67. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/test/stage-release.test.mjs +0 -0
  68. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/pi/tsconfig.json +0 -0
  69. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/README.md +0 -0
  70. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/src/api.rs +0 -0
  71. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/src/lib.rs +0 -0
  72. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/src/query.rs +0 -0
  73. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/bindings/python/tests/test_query.py +0 -0
  74. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/docs/ffi-support-matrix.md +0 -0
  75. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/docs/supported-languages.md +0 -0
  76. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/flux.toml +0 -0
  77. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/error.rs +0 -0
  78. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/impact.rs +0 -0
  79. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/index/build.rs +0 -0
  80. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/index/lookup.rs +0 -0
  81. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/index/mod.rs +0 -0
  82. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/index/update.rs +0 -0
  83. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/lib.rs +0 -0
  84. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/order.rs +0 -0
  85. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/read.rs +0 -0
  86. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/query/src/relation.rs +0 -0
  87. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/scripts/release/artifact_manifest.py +0 -0
  88. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/scripts/release/tests/test_contracts.py +0 -0
  89. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/scripts/release/version_contract.py +0 -0
  90. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/error.rs +0 -0
  91. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/binding.rs +0 -0
  92. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/mod.rs +0 -0
  93. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/extract/support.rs +0 -0
  94. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/c.rs +0 -0
  95. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/jni.rs +0 -0
  96. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/mod.rs +0 -0
  97. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/node_api.rs +0 -0
  98. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/python.rs +0 -0
  99. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/spec.rs +0 -0
  100. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/sync_tests.rs +0 -0
  101. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/ffi/wasm.rs +0 -0
  102. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/grammar.rs +0 -0
  103. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/graph/mod.rs +0 -0
  104. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/lang.rs +0 -0
  105. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/lib.rs +0 -0
  106. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/package/enrich.rs +0 -0
  107. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/package/manifest.rs +0 -0
  108. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/package/mod.rs +0 -0
  109. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/conformance.rs +0 -0
  110. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/external.rs +0 -0
  111. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/ffi_bridge/mod.rs +0 -0
  112. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/ffi_bridge/resolver.rs +0 -0
  113. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/delta.rs +0 -0
  114. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/mod.rs +0 -0
  115. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/state.rs +0 -0
  116. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/stitch.rs +0 -0
  117. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/store.rs +0 -0
  118. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/subgraph.rs +0 -0
  119. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/incremental/tracked.rs +0 -0
  120. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/layered.rs +0 -0
  121. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/local_typed_call.rs +0 -0
  122. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/mod.rs +0 -0
  123. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/normalized_name.rs +0 -0
  124. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/resolver.rs +0 -0
  125. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/scope_graph.rs +0 -0
  126. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/support.rs +0 -0
  127. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/resolve/symbol_table.rs +0 -0
  128. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/symbol/descriptor.rs +0 -0
  129. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/symbol/id.rs +0 -0
  130. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/symbol/mod.rs +0 -0
  131. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/src/symbol/serde_impl.rs +0 -0
  132. {code2graph_rs-0.0.0b15 → code2graph_rs-0.0.0b17}/tests/resolver_input_contracts.rs +0 -0
@@ -249,7 +249,7 @@ checksum = "c8d4a3bb8b1e0c1050499d1815f5ab16d04f0959b233085fb31653fbfc9d98f9"
249
249
 
250
250
  [[package]]
251
251
  name = "code2graph"
252
- version = "0.0.0-beta.15"
252
+ version = "0.0.0-beta.17"
253
253
  dependencies = [
254
254
  "fluxbench",
255
255
  "serde",
@@ -283,7 +283,7 @@ dependencies = [
283
283
 
284
284
  [[package]]
285
285
  name = "code2graph-cli"
286
- version = "0.0.0-beta.15"
286
+ version = "0.0.0-beta.17"
287
287
  dependencies = [
288
288
  "blake3",
289
289
  "clap",
@@ -304,7 +304,7 @@ dependencies = [
304
304
 
305
305
  [[package]]
306
306
  name = "code2graph-eval"
307
- version = "0.0.0-beta.15"
307
+ version = "0.0.0-beta.17"
308
308
  dependencies = [
309
309
  "code2graph",
310
310
  "protobuf",
@@ -313,7 +313,7 @@ dependencies = [
313
313
 
314
314
  [[package]]
315
315
  name = "code2graph-node"
316
- version = "0.0.0-beta.15"
316
+ version = "0.0.0-beta.17"
317
317
  dependencies = [
318
318
  "code2graph",
319
319
  "code2graph-query",
@@ -325,7 +325,7 @@ dependencies = [
325
325
 
326
326
  [[package]]
327
327
  name = "code2graph-py"
328
- version = "0.0.0-beta.15"
328
+ version = "0.0.0-beta.17"
329
329
  dependencies = [
330
330
  "code2graph",
331
331
  "code2graph-query",
@@ -337,7 +337,7 @@ dependencies = [
337
337
 
338
338
  [[package]]
339
339
  name = "code2graph-query"
340
- version = "0.0.0-beta.15"
340
+ version = "0.0.0-beta.17"
341
341
  dependencies = [
342
342
  "code2graph",
343
343
  "thiserror 2.0.18",
@@ -5,7 +5,7 @@ members = ["bindings/python", "query"]
5
5
  # Release CI stamps this package version plus both internal workspace dependency
6
6
  # requirements from the git tag, then mirrors the binding version into pyproject.toml / package.json.
7
7
  [workspace.package]
8
- version = "0.0.0-beta.15"
8
+ version = "0.0.0-beta.17"
9
9
  edition = "2024"
10
10
  rust-version = "1.85"
11
11
  license = "Apache-2.0"
@@ -15,9 +15,9 @@ readme = "README.md"
15
15
  # Exact requirements prevent a prerelease (for example 0.0.0-beta.2) from
16
16
  # silently resolving a different prerelease or the eventual stable release.
17
17
  # scripts/release/version_contract.py replaces this development sentinel for tagged builds.
18
- code2graph = { path = ".", version = "=0.0.0-beta.15" }
18
+ code2graph = { path = ".", version = "=0.0.0-beta.17" }
19
19
  directories = "6"
20
- code2graph-query = { path = "query", version = "=0.0.0-beta.15" }
20
+ code2graph-query = { path = "query", version = "=0.0.0-beta.17" }
21
21
  clap = { version = "4", features = ["derive"] }
22
22
  serde = { version = "1", features = ["derive"] }
23
23
  serde_json = "1"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: code2graph-rs
3
- Version: 0.0.0b15
3
+ Version: 0.0.0b17
4
4
  Classifier: Programming Language :: Python :: 3
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Summary: Source code to structural graph facts — Python bindings
@@ -111,6 +111,10 @@ code2graph callers helper
111
111
  code2graph impact helper --depth 3
112
112
  ```
113
113
 
114
+ By default the CLI rejects an incomplete index. `--allow-partial` explicitly permits
115
+ publishing and querying a partial source set; inspect the reported omissions before
116
+ relying on its results.
117
+
114
118
  `cargo install code2graph-cli` builds the binary from source with Cargo. No prebuilt binary distribution is promised here.
115
119
 
116
120
  ### Managing the cache
@@ -7,12 +7,19 @@ license.workspace = true
7
7
  publish = false
8
8
  readme = "README.md"
9
9
 
10
+ # `pyo3/extension-module` deliberately leaves the CPython symbols undefined so
11
+ # the interpreter resolves them at import time. That is correct for the shipped
12
+ # cdylib but makes a cargo test harness — an ordinary executable — unlinkable,
13
+ # so this crate declares no Rust test targets. It is a thin FFI shim; its
14
+ # behaviour is verified through the real boundary by `tests/test_query.py`.
10
15
  [lib]
11
16
  name = "code2graph"
12
17
  crate-type = ["cdylib"]
18
+ test = false
19
+ doctest = false
13
20
 
14
21
  [dependencies]
15
- code2graph_core = { package = "code2graph", path = "../..", version = "=0.0.0-beta.15", default-features = false, features = ["serde", "rust", "python", "typescript", "go", "java", "c", "cpp", "ruby", "php", "shell", "swift", "kotlin", "solidity", "sql", "hcl", "csharp", "scala", "dart", "lua", "luau", "pascal", "svelte"] }
22
+ code2graph_core = { package = "code2graph", path = "../..", version = "=0.0.0-beta.17", default-features = false, features = ["serde", "rust", "python", "typescript", "go", "java", "c", "cpp", "ruby", "php", "shell", "swift", "kotlin", "solidity", "sql", "hcl", "csharp", "scala", "dart", "lua", "luau", "pascal", "svelte"] }
16
23
  code2graph-query.workspace = true
17
24
  pyo3 = { version = "0.29", features = ["extension-module", "abi3-py39"] }
18
25
  pythonize = "0.29"
@@ -100,18 +100,3 @@ pub(crate) fn positive_limit(limit: u32) -> PyResult<usize> {
100
100
  }
101
101
  Ok(limit as usize)
102
102
  }
103
-
104
- #[cfg(test)]
105
- mod tests {
106
- use super::{edge_filter, positive_limit};
107
-
108
- #[test]
109
- fn filters_are_canonical_and_limits_are_positive() {
110
- assert!(edge_filter(Some("call"), None, None).is_err());
111
- assert!(edge_filter(None, Some("exact"), None).is_err());
112
- assert!(edge_filter(None, None, Some("scope_graph")).is_err());
113
- assert!(edge_filter(Some("Call"), Some("Exact"), Some("ScopeGraph")).is_ok());
114
- assert!(positive_limit(0).is_err());
115
- assert_eq!(positive_limit(1).expect("positive"), 1);
116
- }
117
- }
@@ -4,7 +4,7 @@ build-backend = "maturin"
4
4
 
5
5
  [project]
6
6
  name = "code2graph-rs"
7
- version = "0.0.0b15"
7
+ version = "0.0.0b17"
8
8
  description = "Source code to structural graph facts — Python bindings"
9
9
  requires-python = ">=3.9"
10
10
  license = { text = "Apache-2.0" }
@@ -17,11 +17,11 @@ thiserror = "2"
17
17
 
18
18
  [dependencies.code2graph]
19
19
  path = ".."
20
- version = "=0.0.0-beta.15"
20
+ version = "=0.0.0-beta.17"
21
21
  default-features = false
22
22
 
23
23
  [dev-dependencies.code2graph]
24
24
  path = ".."
25
- version = "=0.0.0-beta.15"
25
+ version = "=0.0.0-beta.17"
26
26
  default-features = false
27
27
  features = ["rust"]
@@ -111,6 +111,10 @@ code2graph callers helper
111
111
  code2graph impact helper --depth 3
112
112
  ```
113
113
 
114
+ By default the CLI rejects an incomplete index. `--allow-partial` explicitly permits
115
+ publishing and querying a partial source set; inspect the reported omissions before
116
+ relying on its results.
117
+
114
118
  `cargo install code2graph-cli` builds the binary from source with Cargo. No prebuilt binary distribution is promised here.
115
119
 
116
120
  ### Managing the cache
@@ -50,7 +50,7 @@ impl Extractor for CExtractor {
50
50
  Language::C
51
51
  }
52
52
 
53
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
53
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
54
54
  let ts_language = crate::grammar::c();
55
55
  let mut parser = Parser::new();
56
56
  parser
@@ -91,7 +91,7 @@ impl Extractor for CppExtractor {
91
91
  Language::Cpp
92
92
  }
93
93
 
94
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
94
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
95
95
  let ts_language = crate::grammar::cpp();
96
96
  let mut parser = Parser::new();
97
97
  parser
@@ -86,7 +86,7 @@ impl Extractor for CSharpExtractor {
86
86
  Language::CSharp
87
87
  }
88
88
 
89
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
89
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
90
90
  let ts_language = crate::grammar::csharp();
91
91
  let mut parser = Parser::new();
92
92
  parser
@@ -69,7 +69,7 @@ impl Extractor for DartExtractor {
69
69
  Language::Dart
70
70
  }
71
71
 
72
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
72
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
73
73
  let ts_language = crate::grammar::dart();
74
74
  let mut parser = Parser::new();
75
75
  parser
@@ -199,6 +199,21 @@ fn collect_top_level(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out:
199
199
  }
200
200
  }
201
201
 
202
+ /// Map a Dart identifier to its [`Visibility`].
203
+ ///
204
+ /// Dart's leading underscore is compiler-enforced *library privacy* (a `_name`
205
+ /// is inaccessible outside its defining library), so it is real visibility, not
206
+ /// a lint convention. A single leading underscore -> `Internal` (library-scoped,
207
+ /// like Go's package privacy and Python's `_`); everything else -> `Public`.
208
+ /// Dart has no nested-privacy convention, so there is no `Private` case here.
209
+ fn dart_visibility(name: &str) -> Visibility {
210
+ if name.starts_with('_') {
211
+ Visibility::Internal
212
+ } else {
213
+ Visibility::Public
214
+ }
215
+ }
216
+
202
217
  /// Emit a class or extension symbol and recurse into its `class_body` for members.
203
218
  fn collect_class(
204
219
  node: &Node,
@@ -212,12 +227,13 @@ fn collect_class(
212
227
  };
213
228
  let mut descriptors = prefix.to_vec();
214
229
  descriptors.push(Descriptor::Type(name.clone()));
230
+ let visibility = dart_visibility(&name);
215
231
  out.push(make_symbol(
216
232
  ctx,
217
233
  node,
218
234
  name,
219
235
  kind,
220
- Visibility::Unknown,
236
+ visibility,
221
237
  descriptors.clone(),
222
238
  one_line_signature(node_text(node, ctx.bytes), &['{', ';']),
223
239
  ));
@@ -237,12 +253,13 @@ fn collect_mixin(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out: &mut
237
253
  };
238
254
  let mut descriptors = prefix.to_vec();
239
255
  descriptors.push(Descriptor::Type(name.clone()));
256
+ let visibility = dart_visibility(&name);
240
257
  out.push(make_symbol(
241
258
  ctx,
242
259
  node,
243
260
  name,
244
261
  SymbolKind::Trait,
245
- Visibility::Unknown,
262
+ visibility,
246
263
  descriptors.clone(),
247
264
  one_line_signature(node_text(node, ctx.bytes), &['{', ';']),
248
265
  ));
@@ -260,12 +277,13 @@ fn collect_enum(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out: &mut
260
277
  };
261
278
  let mut descriptors = prefix.to_vec();
262
279
  descriptors.push(Descriptor::Type(name.clone()));
280
+ let visibility = dart_visibility(&name);
263
281
  out.push(make_symbol(
264
282
  ctx,
265
283
  node,
266
284
  name,
267
285
  SymbolKind::Enum,
268
- Visibility::Unknown,
286
+ visibility,
269
287
  descriptors.clone(),
270
288
  one_line_signature(node_text(node, ctx.bytes), &['{', ';']),
271
289
  ));
@@ -277,12 +295,13 @@ fn collect_enum(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out: &mut
277
295
  if let Some(const_name) = field_text(&member, "name", ctx.bytes) {
278
296
  let mut const_desc = descriptors.clone();
279
297
  const_desc.push(Descriptor::Term(const_name.clone()));
298
+ let visibility = dart_visibility(&const_name);
280
299
  out.push(make_symbol(
281
300
  ctx,
282
301
  &member,
283
302
  const_name,
284
303
  SymbolKind::Const,
285
- Visibility::Unknown,
304
+ visibility,
286
305
  const_desc,
287
306
  one_line_signature(node_text(&member, ctx.bytes), &['{', ';', ',']),
288
307
  ));
@@ -301,12 +320,13 @@ fn collect_extension(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out:
301
320
  };
302
321
  let mut descriptors = prefix.to_vec();
303
322
  descriptors.push(Descriptor::Type(name.clone()));
323
+ let visibility = dart_visibility(&name);
304
324
  out.push(make_symbol(
305
325
  ctx,
306
326
  node,
307
327
  name,
308
328
  SymbolKind::Class,
309
- Visibility::Unknown,
329
+ visibility,
310
330
  descriptors.clone(),
311
331
  one_line_signature(node_text(node, ctx.bytes), &['{', ';']),
312
332
  ));
@@ -328,12 +348,13 @@ fn collect_type_alias(node: &Node, ctx: &ExtractCtx, prefix: &[Descriptor], out:
328
348
 
329
349
  let mut descriptors = prefix.to_vec();
330
350
  descriptors.push(Descriptor::Type(name.clone()));
351
+ let visibility = dart_visibility(&name);
331
352
  out.push(make_symbol(
332
353
  ctx,
333
354
  node,
334
355
  name,
335
356
  SymbolKind::TypeAlias,
336
- Visibility::Unknown,
357
+ visibility,
337
358
  descriptors,
338
359
  one_line_signature(node_text(node, ctx.bytes), &['{', ';']),
339
360
  ));
@@ -360,12 +381,13 @@ fn collect_top_function(
360
381
  name: name.clone(),
361
382
  disambiguator: crate::symbol::MethodDisambiguator::empty(),
362
383
  });
384
+ let visibility = dart_visibility(&name);
363
385
  out.push(make_symbol(
364
386
  ctx,
365
387
  node,
366
388
  name,
367
389
  SymbolKind::Function,
368
- Visibility::Unknown,
390
+ visibility,
369
391
  descriptors,
370
392
  one_line_signature(node_text(node, ctx.bytes), &['{', ';', '=']),
371
393
  ));
@@ -403,12 +425,13 @@ fn emit_initialized_identifiers(
403
425
  if let Some(name) = field_text(&item, "name", ctx.bytes) {
404
426
  let mut descriptors = prefix.to_vec();
405
427
  descriptors.push(Descriptor::Term(name.clone()));
428
+ let visibility = dart_visibility(&name);
406
429
  out.push(make_symbol(
407
430
  ctx,
408
431
  decl_node,
409
432
  name,
410
433
  SymbolKind::Static,
411
- Visibility::Unknown,
434
+ visibility,
412
435
  descriptors,
413
436
  one_line_signature(node_text(decl_node, ctx.bytes), &['{', ';']),
414
437
  ));
@@ -504,12 +527,13 @@ fn emit_method(
504
527
  name: name.clone(),
505
528
  disambiguator: crate::symbol::MethodDisambiguator::empty(),
506
529
  });
530
+ let visibility = dart_visibility(&name);
507
531
  out.push(make_symbol(
508
532
  ctx,
509
533
  node,
510
534
  name,
511
535
  SymbolKind::Method,
512
- Visibility::Unknown,
536
+ visibility,
513
537
  descriptors,
514
538
  one_line_signature(node_text(node, ctx.bytes), &['{', ';', '=']),
515
539
  ));
@@ -1237,6 +1261,30 @@ void greet(String name) {
1237
1261
  );
1238
1262
  }
1239
1263
 
1264
+ #[test]
1265
+ fn leading_underscore_maps_to_internal_visibility() {
1266
+ let src = r#"
1267
+ void _private() {}
1268
+ void publicFn() {}
1269
+
1270
+ class _Hidden {}
1271
+ class Shown {}
1272
+ "#;
1273
+ let facts = extract(src, "lib/models/visibility.dart");
1274
+
1275
+ let private_fn = by_name(&facts, "_private").unwrap();
1276
+ assert_eq!(private_fn.visibility, Visibility::Internal);
1277
+
1278
+ let public_fn = by_name(&facts, "publicFn").unwrap();
1279
+ assert_eq!(public_fn.visibility, Visibility::Public);
1280
+
1281
+ let hidden_class = by_name(&facts, "_Hidden").unwrap();
1282
+ assert_eq!(hidden_class.visibility, Visibility::Internal);
1283
+
1284
+ let shown_class = by_name(&facts, "Shown").unwrap();
1285
+ assert_eq!(shown_class.visibility, Visibility::Public);
1286
+ }
1287
+
1240
1288
  #[test]
1241
1289
  fn mixin_is_extracted_as_trait() {
1242
1290
  let src = r#"
@@ -4,7 +4,7 @@
4
4
  //! ([`extract_file`], [`extract_path`]).
5
5
 
6
6
  use crate::error::{CodegraphError, Result};
7
- use crate::graph::FileFacts;
7
+ use crate::graph::{FileFacts, FileFactsValidationContext, validate_file_facts_with_context};
8
8
  use crate::lang::Language;
9
9
 
10
10
  #[cfg(feature = "c")]
@@ -55,30 +55,80 @@ use super::SwiftExtractor;
55
55
  use super::TypeScriptExtractor;
56
56
 
57
57
  /// A per-language source-to-facts extractor.
58
+ ///
59
+ /// Implementors provide the raw tree-sitter pass ([`Extractor::extract_facts`]);
60
+ /// callers use [`Extractor::extract`], which normalizes that output and enforces
61
+ /// the [`FileFacts`] context contract on it. Keeping the contract at this seam —
62
+ /// rather than only at the public dispatch entry points — means a language pass
63
+ /// that emits facts a consumer's deserialization boundary would reject fails
64
+ /// here, in that extractor's own tests, instead of silently degrading into an
65
+ /// omitted file downstream.
58
66
  pub trait Extractor {
59
67
  /// The language this extractor handles.
60
68
  fn lang(&self) -> Language;
61
69
 
62
70
  /// Parse `source` (the contents of `file`, a project-relative path) and
63
71
  /// return its definitions and references.
64
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts>;
72
+ ///
73
+ /// This is the implementation hook. Call [`Extractor::extract`] instead: it
74
+ /// applies the normalization and validation every consumer relies on.
75
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts>;
65
76
 
66
- /// Like [`Extractor::extract`], but given a [`crate::extract::BindingRules`]
67
- /// registry describing which language constructs carry embedded secondary
68
- /// artifacts (e.g. SQL strings). Extractors that don't recognize any such
69
- /// construct can ignore `rules` and behave exactly like [`Extractor::extract`]
70
- /// — which is what the default implementation does.
71
- fn extract_with_bindings(
77
+ /// Like [`Extractor::extract_facts`], but given a
78
+ /// [`crate::extract::BindingRules`] registry describing which language
79
+ /// constructs carry embedded secondary artifacts (e.g. SQL strings).
80
+ /// Extractors that don't recognize any such construct can ignore `rules` and
81
+ /// behave exactly like [`Extractor::extract_facts`] — which is what the
82
+ /// default implementation does.
83
+ fn extract_facts_with_bindings(
72
84
  &self,
73
85
  source: &str,
74
86
  file: &str,
75
87
  rules: &crate::extract::BindingRules,
76
88
  ) -> Result<FileFacts> {
77
89
  let _ = rules;
78
- self.extract(source, file)
90
+ self.extract_facts(source, file)
91
+ }
92
+
93
+ /// Extract normalized, contract-checked facts for `file`.
94
+ fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
95
+ let facts = self.extract_facts(source, file)?;
96
+ normalize_and_validate(facts, self.lang(), source, file)
97
+ }
98
+
99
+ /// Extract normalized, contract-checked facts for `file`, applying `rules`.
100
+ fn extract_with_bindings(
101
+ &self,
102
+ source: &str,
103
+ file: &str,
104
+ rules: &crate::extract::BindingRules,
105
+ ) -> Result<FileFacts> {
106
+ let facts = self.extract_facts_with_bindings(source, file, rules)?;
107
+ normalize_and_validate(facts, self.lang(), source, file)
79
108
  }
80
109
  }
81
110
 
111
+ /// Normalize a raw language pass's output and hold it to its context contract.
112
+ ///
113
+ /// A free function rather than a trait method so no implementor can weaken it.
114
+ fn normalize_and_validate(
115
+ mut facts: FileFacts,
116
+ lang: Language,
117
+ source: &str,
118
+ file: &str,
119
+ ) -> Result<FileFacts> {
120
+ dedupe_symbol_identities(&mut facts);
121
+ validate_file_facts_with_context(
122
+ &facts,
123
+ FileFactsValidationContext {
124
+ expected_file: file,
125
+ expected_language: lang,
126
+ source_len: source.len(),
127
+ },
128
+ )?;
129
+ Ok(facts)
130
+ }
131
+
82
132
  /// Extract facts from a single file, dispatching on its language, with no
83
133
  /// query-binding rules applied (equivalent to
84
134
  /// `extract_file_with_bindings(lang, source, file, &BindingRules::empty())`).
@@ -105,8 +155,7 @@ pub fn extract_file_with_bindings(
105
155
  rules: &super::BindingRules,
106
156
  ) -> Result<FileFacts> {
107
157
  #[allow(unreachable_patterns)]
108
- #[cfg_attr(not(feature = "_extractors"), allow(unused_mut))]
109
- let mut facts = match lang {
158
+ let facts = match lang {
110
159
  #[cfg(feature = "c")]
111
160
  Language::C => CExtractor.extract_with_bindings(source, file, rules),
112
161
  #[cfg(feature = "csharp")]
@@ -158,8 +207,8 @@ pub fn extract_file_with_bindings(
158
207
  lang.as_str()
159
208
  ))),
160
209
  }?;
161
- #[cfg(feature = "_extractors")]
162
- dedupe_symbol_identities(&mut facts);
210
+ // Every arm above returns through `Extractor::extract_with_bindings`, which
211
+ // has already deduped and validated against this exact context.
163
212
  Ok(facts)
164
213
  }
165
214
 
@@ -169,7 +218,6 @@ pub fn extract_file_with_bindings(
169
218
  /// two occurrences are one logical symbol, so keep the first and drop the
170
219
  /// rest. Mirrors the first-seen-wins dedup the layered resolver applies when
171
220
  /// merging (see `resolve::layered`).
172
- #[cfg(feature = "_extractors")]
173
221
  fn dedupe_symbol_identities(facts: &mut FileFacts) {
174
222
  let mut seen = std::collections::HashSet::with_capacity(facts.symbols.len());
175
223
  facts
@@ -227,4 +275,121 @@ fn identity() -> u32 { 2 }
227
275
  "cfg-gated duplicate definitions must dedupe to a single symbol, got {matches:?}"
228
276
  );
229
277
  }
278
+
279
+ /// The gate that keeps issue-class "the library accepted it, the consumer
280
+ /// rejected it" bugs from shipping: a language pass whose raw output breaks
281
+ /// the context contract must fail at the extractor seam, where its own unit
282
+ /// tests will see it — not silently downstream at a deserialization boundary
283
+ /// that turns the whole file into an omission.
284
+ #[test]
285
+ fn a_contract_violating_pass_fails_at_the_extractor_seam() {
286
+ struct ViolatingExtractor;
287
+
288
+ impl Extractor for ViolatingExtractor {
289
+ fn lang(&self) -> Language {
290
+ Language::Rust
291
+ }
292
+
293
+ fn extract_facts(&self, _source: &str, file: &str) -> Result<FileFacts> {
294
+ Ok(FileFacts {
295
+ file: file.to_owned(),
296
+ lang: "rust".to_owned(),
297
+ symbols: Vec::new(),
298
+ // `source_module` is an import-only field. Carrying it on a
299
+ // call is exactly the shape of metadata drift that a new
300
+ // role-specific field introduces.
301
+ references: vec![crate::graph::Reference {
302
+ name: "helper".to_owned(),
303
+ occ: crate::graph::Occurrence {
304
+ file: file.to_owned(),
305
+ line: 1,
306
+ col: 1,
307
+ byte: 0,
308
+ },
309
+ role: crate::graph::RefRole::Call,
310
+ source_module: Some("module".to_owned()),
311
+ from_path: None,
312
+ imported_name: None,
313
+ is_reexport: false,
314
+ qualifier: None,
315
+ scope: None,
316
+ type_ref_ctx: None,
317
+ cross_artifact: false,
318
+ self_receiver: false,
319
+ }],
320
+ scopes: Vec::new(),
321
+ bindings: Vec::new(),
322
+ ffi_exports: Vec::new(),
323
+ })
324
+ }
325
+ }
326
+
327
+ let source = "fn caller() { helper() }\n";
328
+ assert!(
329
+ ViolatingExtractor
330
+ .extract_facts(source, "src/lib.rs")
331
+ .is_ok(),
332
+ "the raw pass itself is unguarded — the seam is what enforces the contract"
333
+ );
334
+ let error = ViolatingExtractor
335
+ .extract(source, "src/lib.rs")
336
+ .expect_err("a contract-violating pass must not escape its extractor");
337
+ assert!(
338
+ error.to_string().contains("source_module"),
339
+ "the failure must name the rule that fired, got {error}"
340
+ );
341
+ }
342
+
343
+ #[test]
344
+ fn dispatch_returns_context_valid_member_read_facts() {
345
+ let source = "struct Entry { extra: i64 }\nfn read(entry: &Entry) -> i64 { entry.extra }\n";
346
+ let facts = extract_path("src/entry.rs", source).expect("dispatch extraction");
347
+ assert!(facts.references.iter().any(|reference| {
348
+ reference.role == crate::graph::RefRole::Read
349
+ && reference.name == "extra"
350
+ && reference.qualifier.as_deref() == Some("entry")
351
+ }));
352
+ validate_file_facts_with_context(
353
+ &facts,
354
+ FileFactsValidationContext {
355
+ expected_file: "src/entry.rs",
356
+ expected_language: Language::Rust,
357
+ source_len: source.len(),
358
+ },
359
+ )
360
+ .expect("public dispatch output must satisfy its context contract");
361
+ }
362
+
363
+ #[cfg(feature = "typescript")]
364
+ #[test]
365
+ fn dispatch_returns_context_valid_typescript_and_javascript_property_reads() {
366
+ for (file, language, source) in [
367
+ (
368
+ "src/entry.ts",
369
+ Language::TypeScript,
370
+ "interface Entry { extra: number }\nfunction read(entry: Entry) { return entry.extra; }\n",
371
+ ),
372
+ (
373
+ "src/entry.js",
374
+ Language::JavaScript,
375
+ "function read(entry) { return entry.extra; }\n",
376
+ ),
377
+ ] {
378
+ let facts = extract_path(file, source).expect("dispatch extraction");
379
+ assert!(facts.references.iter().any(|reference| {
380
+ reference.role == crate::graph::RefRole::Read
381
+ && reference.name == "extra"
382
+ && reference.qualifier.as_deref() == Some("entry")
383
+ }));
384
+ validate_file_facts_with_context(
385
+ &facts,
386
+ FileFactsValidationContext {
387
+ expected_file: file,
388
+ expected_language: language,
389
+ source_len: source.len(),
390
+ },
391
+ )
392
+ .expect("public dispatch output must satisfy its context contract");
393
+ }
394
+ }
230
395
  }
@@ -56,7 +56,7 @@ impl Extractor for GoExtractor {
56
56
  Language::Go
57
57
  }
58
58
 
59
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
59
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
60
60
  let ts_language = crate::grammar::go();
61
61
  let mut parser = Parser::new();
62
62
  parser
@@ -42,7 +42,7 @@ impl Extractor for HclExtractor {
42
42
  Language::Hcl
43
43
  }
44
44
 
45
- fn extract(&self, source: &str, file: &str) -> Result<FileFacts> {
45
+ fn extract_facts(&self, source: &str, file: &str) -> Result<FileFacts> {
46
46
  let ts_language = crate::grammar::hcl();
47
47
  let mut parser = Parser::new();
48
48
  parser