fix(ingest): recognize Cargo.toml as a package manifest (#2434) - #2494
fix(ingest): recognize Cargo.toml as a package manifest (#2434)#2494ousamabenyounes wants to merge 1 commit into
Conversation
…s#2434) Cargo.toml was absent from PACKAGE_MANIFEST_NAMES, so a Rust crate got no canonical package node while pyproject.toml / go.mod / pom.xml all did. Add a 'cargo' ecosystem entry plus a deterministic _parse_cargo that reads name and version from [package] and dependency edges from [dependencies] and every [target.<cfg>.dependencies] table, mirroring _parse_pyproject's runtime-only scope. Virtual-workspace roots (no [package]) and workspace-inherited versions emit no fabricated node and do not crash.
There was a problem hiding this comment.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify reviewed this change.
Looks safe to merge — no coupling regressions and no blocking issues, checked against the code graph (not a self-assessment).
Graphify review — findings
This PR adds Cargo.toml to the set of package manifests that graphify parses deterministically (alongside apm.yml, pyproject.toml, go.mod, and pom.xml). It introduces a _parse_cargo function that extracts the package name/version from [package] and dependencies from [dependencies] and [target.<cfg>.dependencies] tables, registers it in the manifest name map and parser dispatch, and routes Cargo.toml to the CODE classification path. It also updates the changelog and doc comments, and adds tests covering classification, dep parsing, virtual workspaces, target-conditional deps, and workspace-inherited versions.
No blocking issues surfaced. 1 lower-confidence candidate did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 1337 functions depend on the 310 functions this change touches.
Health — this change adds coupling hotspots:
- worse:
classify_file()— 43 callers, 3 callees
Verification — 1337 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 978 function(s) in the blast radius were not formally verified this run
· 1 grounded finding(s) anchored inline below.
| @@ -488,7 +488,7 @@ def _shebang_file_type(path: Path) -> FileType | None: | |||
|
|
|||
|
|
|||
| def classify_file(path: Path) -> FileType | None: | |||
There was a problem hiding this comment.
classify_file()
43 callers depend on it (afferent coupling).
Grounded coupling-delta finding (deterministic), not an LLM guess.
What
Recognize Rust's
Cargo.tomlas a package manifest, alongside thepyproject.toml/go.mod/pom.xmlthatmanifest_ingestalready handles.Fix #2434 (scoped to the issue's Request 1 — "Add
Cargo.tomltoPACKAGE_MANIFEST_NAMES", which the issue calls out as "a one-line fixindependent of the rest of this issue"). Requests 2 and 3 (routing
.toml/.ini/.cfgintoDOC_EXTENSIONS, and a generic structural TOMLextractor) are deliberately left out — they are broader, separate concerns.
Why
PACKAGE_MANIFEST_NAMESmaps Python's, Go's, Maven's and apm's manifests to adeterministic parser that emits one canonical
packagenode per package (plusdepends_onedges). Rust'sCargo.tomlwas missing, so a Rust repo got nopackage node where an otherwise-identical Python repo did — the gap the issue
documents.
How
"cargo.toml": "cargo"toPACKAGE_MANIFEST_NAMESand a matching_parse_cargoin_PARSERS(both must move together — a name without aparser would route the file to a
KeyErrorpath)._parse_cargomirrors_parse_pyproject: name/version from[package],runtime deps from
[dependencies]and every[target.<cfg>.dependencies]table (platform-conditional deps are common in real crates). It reuses the
shared
_coerce_deps/_pkg_idhelpers, so an inline-table dep(
tokio = { version = "1", features = [...] }) keys by the dependency name.[package]) emits nothing rather than a fabricated node, and aworkspace-inherited version (
version.workspace = true, which parses to atable) is dropped instead of crashing.
dev-dependencies/build-dependenciesare intentionally excluded to match_parse_pyproject's runtime-only scope.classify_filecomment, andadded a
CHANGELOG.mdentry under0.9.34 (unreleased).Test verification (RED → GREEN)
Five new tests in
tests/test_manifest_ingest.py.RED — new tests against unmodified
v8(before the fix), production code stashed:GREEN — with the fix:
Full local CI (mirrors
.github/workflows/ci.yml)Baseline on
v8before the change was4044 passed, 3 skipped; the delta isexactly the 5 new tests, no regressions. New production lines are fully covered
by the new tests.