Repository navigation
Expand file tree
/
Copy pathCargo.toml
More file actions
365 lines (299 loc) · 11.4 KB
/
Copy pathCargo.toml
File metadata and controls
365 lines (299 loc) · 11.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
[package]
name = "libcpg"
version = "0.1.1"
edition = "2021"
autobenches = false
authors = ["Dylon Edwards <dylon@f1r3fly.io>"]
description = "Code Property Graph library for program analysis, pattern detection, and semantic code understanding"
license = "MIT OR Apache-2.0"
repository = "https://github.com/f1r3fly-io/libcpg"
keywords = ["code-analysis", "cpg", "ast", "cfg", "dfg", "pattern-detection", "gnn"]
categories = ["development-tools", "parsing", "algorithms"]
[features]
default = []
# Graph Neural Network support
gnn = ["ndarray", "rand"]
# GPU acceleration via wgpu
gpu = ["wgpu", "pollster"]
# Design pattern detection.
#
# DPML (`dpml.rs`) parses pattern templates from YAML via `serde_yaml::from_str`,
# which requires `DpmlTemplate: serde::Deserialize` and hence the `serde` crate
# in scope. We pull the crate in directly with `dep:serde` (rather than the
# whole `serde` *feature*) so DPML's own `#[derive(Serialize, Deserialize)]` —
# gated `any(feature = "serde", feature = "design-patterns")` in `dpml.rs` —
# compiles, WITHOUT flipping `cfg(feature = "serde")` crate-wide (which would
# also pull `petgraph/serde-1` and activate every graph-level serde round-trip
# path). `serde`'s `derive` feature is already enabled on the dependency below.
design-patterns = ["serde_yaml", "toml_edit", "dep:serde"]
# Algorithm detection and complexity analysis
algorithm-detection = []
# Exact arbitrary-precision convex-polyhedral abstract domain.
abstract-domains = ["dep:num-bigint", "dep:num-rational", "dep:num-traits"]
# Rholang / MeTTa CPG node-mappers (Mode B — no grammar vendoring).
#
# These are intentionally EMPTY feature lists: they are pure logical `cfg`
# toggles that gate ONLY the `map_rholang` / `map_metta` node-mapper arms (and
# their `map_kind` / `should_include` dispatch) in `src/builder/node_mapper.rs`.
# Those arms reference only `ts_kind` strings and `tree_sitter::Node`
# navigation — never a `tree_sitter_rholang` / `tree_sitter_metta` symbol — so
# there is nothing to pull in: the ρ-calculus / S-expression CPG is built from a
# caller-supplied, already-parsed tree via `TreeSitterCpgBuilder::build_from_tree`
# (e.g. pgmcp, which links these grammars itself). Adding grammar `dep:` entries
# here would duplicate the consumer's grammars and risk a duplicate
# `tree_sitter_<lang>` C-symbol at link time for zero benefit (ADR-041 §7). The
# grammars ARE linked, but only as TEST-ONLY path `[dev-dependencies]` (which
# Cargo never propagates downstream), to drive the Mode-B unit tests.
rholang = []
metta = ["dep:libdictenstein"]
# Serialization support
serde = [
"dep:serde",
"petgraph/serde-1",
"num-bigint?/serde",
"num-rational?/serde",
]
# ML-based pattern classification using linfa
ml-linfa = ["linfa", "linfa-trees"]
# Rule-based pattern classification (no ML dependencies)
ml-rules = []
# Language support features (tree-sitter grammars)
lang-rust = ["dep:tree-sitter-rust"]
lang-python = ["dep:tree-sitter-python"]
lang-javascript = ["dep:tree-sitter-javascript"]
lang-typescript = ["dep:tree-sitter-typescript"]
lang-go = ["dep:tree-sitter-go"]
lang-java = ["dep:tree-sitter-java"]
lang-c = ["dep:tree-sitter-c"]
lang-cpp = ["dep:tree-sitter-cpp"]
lang-json = ["dep:tree-sitter-json"]
lang-html = ["dep:tree-sitter-html"]
lang-css = ["dep:tree-sitter-css"]
lang-bash = ["dep:tree-sitter-bash"]
lang-toml = ["dep:tree-sitter-toml-ng"]
lang-yaml = ["dep:tree-sitter-yaml"]
lang-markdown = ["dep:tree-sitter-md"]
lang-ruby = ["dep:tree-sitter-ruby"]
# Language groups
lang-systems = ["lang-rust", "lang-c", "lang-cpp", "lang-go"]
lang-scripting = ["lang-python", "lang-javascript", "lang-typescript", "lang-ruby"]
lang-web = ["lang-html", "lang-css", "lang-javascript", "lang-typescript"]
lang-config = ["lang-json", "lang-yaml", "lang-toml"]
lang-all = ["lang-systems", "lang-scripting", "lang-web", "lang-config", "lang-bash", "lang-markdown", "lang-java"]
# Full feature set
full = [
"gnn",
"design-patterns",
"algorithm-detection",
"abstract-domains",
"serde",
"ml-rules",
"lang-all",
]
[dependencies]
# Core graph library
petgraph = "0.7"
# Parallel processing
rayon = "1.10"
# Efficient hash maps
rustc-hash = "2.0"
# Exact symbol discrimination for MeTTa rewrite rules. This is the canonical
# dictionary crate extracted from liblevenshtein; depending on it directly
# avoids liblevenshtein's deprecated compatibility re-exports and does not pull
# fuzzy transducers into non-MeTTa builds.
libdictenstein = { version = "=4.0.0-rc.1", default-features = false, optional = true }
# Arbitrary-precision rational arithmetic for optional exact polyhedra.
# num-rational 0.4 uses the compatible num-bigint 0.4 line.
num-bigint = { version = "0.4.8", optional = true }
num-rational = { version = "0.4.2", optional = true }
num-traits = { version = "0.2.19", optional = true }
# Small vector optimization
smallvec = { version = "1.13", features = ["serde"] }
# Source code positions
text-size = "1.1"
# Error handling
thiserror = "2.0"
# Regex for pattern matching
regex = "1.11"
# Tree-sitter core (always required)
tree-sitter = "0.26"
# Tree-sitter language grammars (optional, feature-gated)
# NOTE: all grammars below expose `pub const LANGUAGE: LanguageFn` from
# `tree-sitter-language` 0.1, which is the same ABI shim `tree-sitter` 0.26
# links, so `LANGUAGE.into()` yields a `tree_sitter::Language` regardless of the
# grammar crate's own (dev-only) `tree-sitter` pin. Versions are the latest on
# crates.io that build against tree-sitter 0.26.
#
# For grammars that pgmcp ALSO links, keep the major.minor aligned with pgmcp's
# pins so the shared `tree_sitter_<lang>` C symbol is not duplicated at link
# time (python/javascript -> 0.25, c -> 0.24). See pgmcp P7b design section 4.3.
tree-sitter-rust = { version = "0.24", optional = true }
tree-sitter-python = { version = "0.25", optional = true }
tree-sitter-javascript = { version = "0.25", optional = true }
tree-sitter-typescript = { version = "0.23", optional = true }
tree-sitter-go = { version = "0.25", optional = true }
tree-sitter-java = { version = "0.23", optional = true }
tree-sitter-c = { version = "0.24", optional = true }
tree-sitter-cpp = { version = "0.23", optional = true }
tree-sitter-json = { version = "0.24", optional = true }
tree-sitter-html = { version = "0.23", optional = true }
tree-sitter-css = { version = "0.25", optional = true }
tree-sitter-bash = { version = "0.25", optional = true }
tree-sitter-toml-ng = { version = "0.7", optional = true }
tree-sitter-yaml = { version = "0.7", optional = true }
tree-sitter-md = { version = "0.5", optional = true }
tree-sitter-ruby = { version = "0.23", optional = true }
# Optional: DPML parsing (YAML/TOML formats)
serde_yaml = { version = "0.9", optional = true }
toml_edit = { version = "0.22", optional = true }
# Optional: ML-based classification
linfa = { version = "0.7", optional = true }
linfa-trees = { version = "0.7", optional = true }
# Optional: Numerical arrays for embeddings
ndarray = { version = "0.16", optional = true, features = ["serde"] }
# Optional: Random number generation for GNN initialization
rand = { version = "0.8", optional = true }
# Optional: GPU compute
wgpu = { version = "23", optional = true }
pollster = { version = "0.4", optional = true }
# Optional: Serialization
serde = { version = "1.0", features = ["derive", "rc"], optional = true }
[dev-dependencies]
criterion = "0.5"
proptest = "1.5"
# JSON format for serde round-trip tests (the `serde` feature only supplies the
# derives; a format crate is needed to actually (de)serialize). `float_roundtrip`
# uses the precise (not fast-but-lossy) float parser so every finite f64 that
# libcpg forwards verbatim round-trips exactly.
serde_json = { version = "1.0", features = ["float_roundtrip"] }
# Rholang / MeTTa tree-sitter grammars — TEST-ONLY (path dev-dependencies).
#
# These are `[dev-dependencies]`, NOT regular deps, on purpose: they are used
# solely by the `#[cfg(feature = "rholang")]` / `#[cfg(feature = "metta")]`
# unit tests in `builder::node_mapper`, which parse a `.rho`/`.metta` snippet
# and drive the Mode-B `build_from_tree` path end-to-end. Because Cargo does
# NOT propagate dev-dependencies to downstream crates, a consumer that links
# libcpg (e.g. pgmcp, which links these same grammars itself) never pulls them
# in transitively — so the duplicate-`tree_sitter_<lang>` C-symbol link hazard
# (design ADR-041 §7.2 / D1) cannot arise. The runtime `rholang`/`metta`
# features stay pure logical cfg toggles (`= []`, no grammar symbol referenced
# in non-test code), preserving the "Mode B, no grammar vendoring" decision.
tree-sitter-rholang = { package = "rholang-tree-sitter", path = "/home/dylon/Workspace/f1r3fly.io/rholang-rs/rholang-tree-sitter" }
# CONDITIONAL PATCH (droppable): points at a local, version-agnostic shim rather
# than MeTTa-Compiler/tree-sitter-metta directly. The canonical crate pins
# `tree-sitter = "0.25"` as a *normal* dep and binds `tree_sitter_metta()` to
# `tree_sitter::Language`; because `tree-sitter` is a `links = "tree-sitter"`
# native crate, that 0.25 pin cannot coexist with libcpg's `tree-sitter = "0.26"`.
# Bumping it upstream would break MeTTaTron (which itself pins tree-sitter 0.25),
# so `vendor/tree-sitter-metta` recompiles the SAME canonical C sources but
# exposes them via `tree-sitter-language` (like `rholang-tree-sitter`), yielding
# `LANGUAGE: LanguageFn`. Repoint this back at MeTTa-Compiler and delete the
# shim once that crate adopts tree-sitter-language / tree-sitter 0.26.
tree-sitter-metta = { package = "tree-sitter-metta", path = "vendor/tree-sitter-metta" }
[[bench]]
name = "scc_analysis"
harness = false
[[bench]]
name = "cpg_construction"
harness = false
[[bench]]
name = "pattern_matching"
harness = false
[[bench]]
name = "dataflow_liveness"
harness = false
[[bench]]
name = "bitset_domain"
harness = false
[[bench]]
name = "induction_analysis"
harness = false
[[bench]]
name = "condensation"
harness = false
[[bench]]
name = "dsm"
harness = false
[[bench]]
name = "wl"
harness = false
[[bench]]
name = "centrality"
harness = false
[[bench]]
name = "community"
harness = false
[[bench]]
name = "cohesion"
harness = false
[[bench]]
name = "spectral"
harness = false
[[bench]]
name = "cycles"
harness = false
[[bench]]
name = "motifs"
harness = false
[[bench]]
name = "ged"
harness = false
[[bench]]
name = "clones"
harness = false
[[bench]]
name = "advisory_bugs"
harness = false
[[bench]]
name = "api_usage_mining"
harness = false
[[bench]]
name = "cwe_templates"
harness = false
[[bench]]
name = "program_merge"
harness = false
[[bench]]
name = "traversal_primitives"
harness = false
[[bench]]
name = "dfg_extraction"
harness = false
required-features = ["lang-rust"]
[[bench]]
name = "pdg_construction"
harness = false
required-features = ["lang-rust"]
[[bench]]
name = "dominator_analysis"
harness = false
[[bench]]
name = "pattern_vf2"
harness = false
[[bench]]
name = "parallel_analysis"
harness = false
[[bench]]
name = "similarity_wl"
harness = false
[[bench]]
name = "analyze_corpus"
harness = false
required-features = ["lang-rust", "lang-python", "lang-javascript", "lang-go", "lang-c"]
[[bench]]
name = "reanalyze"
harness = false
required-features = ["lang-rust"]
[[bench]]
name = "resolve_calls"
harness = false
[[example]]
name = "profile_workloads"
path = "benches/profile_workloads.rs"
required-features = ["lang-rust", "lang-python", "lang-javascript", "lang-go", "lang-c"]
[[bench]]
name = "ifds_summaries"
harness = false
[[bench]]
name = "ifds_taint"
harness = false