Skip to content

feat(pacman): Pacman trait + LivePacman + MockPacman + Repo enum + parsers#13

Merged
UnbreakableMJ merged 1 commit into
mainfrom
feat/pacman-adapter
Apr 27, 2026
Merged

feat(pacman): Pacman trait + LivePacman + MockPacman + Repo enum + parsers#13
UnbreakableMJ merged 1 commit into
mainfrom
feat/pacman-adapter

Conversation

@UnbreakableMJ

Copy link
Copy Markdown
Contributor

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 — invokes pacman -Qe, -Qm, -Sl. Tracks paru_path for M2.
  • struct MockPacman — feature-gated, canned inventory.
  • enum RepoCore, Extra, Multilib, Cachyos, CachyosV3, CachyosV4, Aur, Other(String). Lossless round-trip via from_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 (pacman or paru) so error attribution is unambiguous.

Inventory semantics

  • explicit = keys of -Qe parse.
  • foreign = -Qm parse.
  • repos[name] = "aur" if foreign, else last -Sl entry (pacman resolution: cachyos-v4 wins over extra), else omitted (diff engine treats absence as drift).

arch_level detection

  • avx512f flag in /proc/cpuinfoV4.
  • otherwise → V3 (CachyOS minimum).

Tests (18 passing)

  • repos: from_name round-trips, preserves unknown via Other; pacman.conf parser; arch-level detection.
  • inventory: -Qe / -Qm / -Sl parsers; compose_inventory classification; defensive on truncated lines; pacman last-repo-wins resolution.
  • 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
  • cargo fmt --all --check
  • scripts/ci/check-spdx.sh
  • pearlite-audit check . — 1 check, 0 violations

🤖 Generated with Claude Code

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>
@UnbreakableMJ
UnbreakableMJ merged commit d44fe7d into main Apr 27, 2026
3 checks passed
@UnbreakableMJ
UnbreakableMJ deleted the feat/pacman-adapter branch April 27, 2026 17:16
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.

1 participant