feat(cargo): Cargo trait + LiveCargo + MockCargo + install-list parser#11
Merged
Conversation
Plan §6.7 — second M1 Week 2 adapter probe path. Inventory only at M1;
install/uninstall arrive in M2 with the rest of the apply-engine
adapters per Plan §7.3.
Public surface:
- pub trait Cargo { fn inventory(&self) -> Result<CargoInventory, CargoError>; }
- pub struct LiveCargo with new() / with_binary() / binary().
- pub struct MockCargo (test-mocks feature) with new() / with_inventory().
- pub fn parse_install_list(&str) -> CargoInventory — exposed because
parsing is purely textual and useful from tests / probes.
- pub enum CargoError — NotInPath (hint: paru -S rustup), Io,
InvocationFailed { code, stderr }, NotUtf8.
Parser handles:
- standard `crate-name vX.Y.Z:` header
- registry source spec `(registry+...)` after the version
- git source spec `(https://...#sha)` after the version
- version without `v` prefix (defensive against future cargo releases)
- indented binary listings (skipped — Pearlite tracks crates, not bins)
Tests (10 passing):
- inventory: parse_known_output, empty_output_yields_empty_inventory,
parses_registry_source_spec, parses_git_source_spec, ignores_binary_lines,
version_without_v_prefix_still_parses.
- live: cargo_not_in_path_error_class,
live_cargo_inventory_succeeds_in_a_rust_environment.
- mock: empty_mock_yields_empty_inventory, with_inventory_round_trips.
Cargo dep on pearlite-schema pinned to "0.1" per the cargo-deny
wildcard rule.
Verification:
- cargo test -p pearlite-cargo (10 passed; 0 failed)
- cargo clippy --workspace --all-targets -- -D warnings (zero warnings)
- cargo fmt --all --check
- scripts/ci/check-spdx.sh
- pearlite-audit check . (1 check, 0 violations)
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Plan §6.7 — second M1 Week 2 adapter probe path. Inventory only at M1; install/uninstall arrive in M2 with the apply-engine adapters per Plan §7.3.
Public surface
trait Cargo { fn inventory(&self) -> Result<CargoInventory, CargoError>; }struct LiveCargo— production, defaultcargofromPATH,with_binary()for test injection.struct MockCargo— feature-gated behindtest-mocks, in-memory canned inventory.fn parse_install_list(&str) -> CargoInventory— exposed pub for probe code that already has captured stdout.enum CargoError—NotInPath(hint:paru -S rustup),Io,InvocationFailed { code, stderr },NotUtf8.Parser coverage
crate-name vX.Y.Z:header(registry+...)source spec after the version(https://...#sha)git source specvprefix (defensive)Tests (10 passing)
Verification
cargo test -p pearlite-cargo— 10 passed; 0 failedcargo clippy --workspace --all-targets -- -D warningscargo fmt --all --checkscripts/ci/check-spdx.shpearlite-audit check .— 1 check, 0 violations🤖 Generated with Claude Code