feat(pacman): Pacman trait + LivePacman + MockPacman + Repo enum + parsers#13
Merged
Conversation
Plan §6.6 — final M1 Week 2 adapter probe path. Inventory only at M1;
install / remove / sync_databases arrive in M2 per Plan §7.3.
Public surface:
- pub trait Pacman { fn inventory(&self) -> Result<PacmanInventory, PacmanError>; }
- pub struct LivePacman with new() / with_paths() / pacman_path().
Internally tracks paru_path for M2's install/remove wiring.
- pub struct MockPacman (test-mocks feature) with new() /
with_inventory().
- pub enum Repo — Core, Extra, Multilib, Cachyos, CachyosV3,
CachyosV4, Aur, Other(String). from_name() round-trips through
name(), preserving unknown repos via Other.
- pub fn parse_pacman_conf(&str) -> Vec<String>.
- pub fn detect_arch_level(&str) -> ArchLevel.
- pub fn parse_qe / parse_qm / parse_sl / compose_inventory.
- pub enum PacmanError — NotInPath { tool, hint }, Io, InvocationFailed,
NotUtf8 (every variant carries the tool name so error messages
attribute correctly).
Inventory composition:
- explicit = keys of -Qe parse.
- foreign = -Qm parse.
- repos[name] = "aur" if foreign, else -Sl entry, else omitted (the
diff engine treats absence as drift).
LivePacman invokes:
- pacman -Qe
- pacman -Qm
- pacman -Sl
arch_level detection:
- avx512f flag in /proc/cpuinfo → V4.
- otherwise → V3 (CachyOS minimum).
Tests (18 passing):
- repos: from_name round-trips known repos, preserves unknown via
Other; pacman.conf lists in declaration order, skips [options] and
comments; detect_arch_level v3/v4 paths.
- inventory: parse_qe known output, parse_qm distinguishes foreign,
parse_sl returns last-repo-wins per pacman resolution, compose
classifies and omits unknown-repo packages, empty inputs, truncated
lines defensive.
- live: pacman_not_in_path_error_class.
- mock: empty + with_inventory round-trip.
Verification:
- cargo test -p pearlite-pacman (18 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.6 — final M1 Week 2 adapter probe path. Inventory only at M1; install/remove/sync_databases arrive in M2.
Public surface
trait Pacman { fn inventory() -> Result<PacmanInventory, PacmanError>; }struct LivePacman— invokespacman -Qe,-Qm,-Sl. Tracksparu_pathfor M2.struct MockPacman— feature-gated, canned inventory.enum Repo—Core,Extra,Multilib,Cachyos,CachyosV3,CachyosV4,Aur,Other(String). Lossless round-trip viafrom_name/name.fn parse_pacman_conf/detect_arch_level/parse_qe/parse_qm/parse_sl/compose_inventory.enum PacmanError— every variant carries the tool name (pacmanorparu) so error attribution is unambiguous.Inventory semantics
explicit= keys of-Qeparse.foreign=-Qmparse.repos[name]="aur"if foreign, else last-Slentry (pacman resolution: cachyos-v4 wins over extra), else omitted (diff engine treats absence as drift).arch_level detection
/proc/cpuinfo→V4.V3(CachyOS minimum).Tests (18 passing)
Verification
cargo test -p pearlite-pacman— 18 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