Skip to content

fix: harden dependency manifest parsers (Cargo, Poetry, pip, go.mod, npm)#70

Merged
Arthur742Ramos merged 1 commit into
mainfrom
arthur742ramos/fix-deps-parsers
Jun 15, 2026
Merged

fix: harden dependency manifest parsers (Cargo, Poetry, pip, go.mod, npm)#70
Arthur742Ramos merged 1 commit into
mainfrom
arthur742ramos/fix-deps-parsers

Conversation

@Arthur742Ramos

Copy link
Copy Markdown
Owner

Summary

A multi-agent correctness audit of the deterministic deps.ts engine (behind bootcamp deps and DEPENDENCIES.md) found that several real-world manifest forms were mis-parsed. This fixes all of them. Each was confirmed by two independent adversarial verifiers with a code-traced repro.

Manifest Bug Fix
Cargo currentSection never reset → keys under [features]/[profile.*]/[[bin]] after a deps section counted as dependencies Line-oriented walk; any non-deps header clears state
Cargo inline table dep = { version = "1.0", … } recorded version as "{" Parse the inner version field
Cargo [dependencies.<crate>] detailed tables invented a version dep and dropped the crate Record the crate from the header, fill version from its version = line
Poetry section capture stopped at the first [ in a value (extras = ["d"]), dropping later deps Terminate at the next table header
pip option/include lines (-r, -e, -c, --hash, --index-url) recorded as packages Skip --prefixed lines; strip extras/markers
go.mod only the first require ( … ) block read, dropping the // indirect block Iterate every block; dedupe
npm optionalDependencies ignored Included (tagged optional)
npm/Cargo console.debug on the "not this manifest" path wrote to stdout, corrupting deps --json on non-npm repos Silent on that path

Testing

  • New test/deps-parsers.test.ts: fixture-based tests for each manifest (Cargo section-reset + inline/detailed tables, Poetry section terminator, pip option-line skipping, go.mod multi-block, npm optional).
  • New e2e guard: a Cargo repo's bootcamp deps --json is clean, parseable JSON.
  • Full suite green: typecheck, lint, build, 1183 unit tests.

🤖 Generated with Claude Code

…npm)

An audit of the deterministic `deps.ts` engine (behind `bootcamp deps` and
DEPENDENCIES.md) found systematic mis-parsing of real-world manifests:

- Cargo: never reset section state, so keys under `[features]`,
  `[profile.*]`, `[[bin]]` etc. that follow a deps section were counted as
  dependencies. Inline tables (`dep = { version = "1.0", ... }`) recorded
  the version as `"{"`, and `[dependencies.<crate>]` detailed tables
  invented a `version` dep while dropping the real crate. Rewritten as a
  line-oriented walk that resets on every header, parses inline-table and
  detailed-table versions, and dedupes.
- Poetry: section capture terminated at the first `[` in a value (e.g.
  `extras = ["d"]`), dropping every dependency after such a line. Now
  terminates at the next table header and parses inline-table versions.
- requirements.txt: pip option/include lines (`-r`, `-e`, `-c`, `--hash`,
  `--index-url`) were recorded as bogus packages. Now skipped; extras and
  environment markers are stripped.
- go.mod: only the first `require ( … )` block was read, dropping the
  entire `// indirect` block that gofmt emits. Now reads every block and
  dedupes.
- npm: `optionalDependencies` were ignored entirely. Now included.
- npm/Cargo extractors no longer write a `console.debug` line to stdout on
  the "not this manifest" path, so `bootcamp deps --json` output on non-npm
  repos is no longer corrupted.

Covered by new fixture-based parser tests plus an e2e guard that a Cargo
repo's `--json` output is clean and parseable.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@Arthur742Ramos Arthur742Ramos merged commit d0178e2 into main Jun 15, 2026
13 checks passed
@Arthur742Ramos Arthur742Ramos deleted the arthur742ramos/fix-deps-parsers branch June 15, 2026 21:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants