feat(extract): Cargo manifest extractor — workspace crate→crate dependency edges
Add an opt-in --cargo extractor that emits crate→crate dependency edges from Cargo.toml.
Mirrors the existing --postgres path. Zero change for current users.
Problem
graphify's Rust graph is AST-only. Edges come from source-level relations (imports_from,
calls), each tagged with a syntactic context (call, generic_arg, return_type,
parameter_type, field). The extractor never opens Cargo.toml.
Consequence: the graph cannot express crate→crate dependencies or a dependency-layer view of a
workspace. On a Rust workspace, graphify can't adjudicate the top-value architectural claims —
a crate dependency-layers table, for one — even though every fact sits in
Cargo.toml [dependencies].
Precedent
graphify already merges non-AST extractors. pg_introspect.py::introspect_postgres(dsn) returns
a {nodes, edges} fragment that __main__.py folds into the result when --postgres DSN is
passed (__main__.py:4314-4331). A Cargo extractor mirrors this exactly.
Proposal
Add cargo_introspect.py exposing introspect_cargo(root), wired to an opt-in --cargo flag:
- Walk
Cargo.tomlmanifests under the scan root (workspace root + members). - Emit one node per crate, plus directed crate→crate edges.
- Name the relation
crate_depends_on, notdepends_on—depends_onis already used by the Terraform extractor (extract.py:11046). - Default to workspace-internal crates only (both ends are members). Gate external deps (serde, tokio, …) behind a sub-flag — they add hundreds of leaf nodes and bloat the graph.
- Opt-in flag ⇒ zero behavior change for existing users.
Direction (out of scope)
Crate→crate edges are inherently directed (A depends on B). The built graph is undirected by
default (build.py:107, directed: bool = False), so direction round-trips in
links[].source/target but flattens in traversal — same as today's AST edges. Making the graph
directed is a separate change.
I'll give this a try.