Add specs for dyalpm package query and batch explicit marking

This commit is contained in:
AI Bot
2026-04-13 22:34:51 +02:00
committed by Riyyi
parent 521b862919
commit 3b26ff9fc1
6 changed files with 196 additions and 0 deletions
@@ -0,0 +1,16 @@
## ADDED Requirements
### Requirement: MarkExplicit accepts multiple packages
The MarkExplicit method SHALL accept a slice of package names and mark all of them as explicitly installed using a single pacman -D call.
#### Scenario: Single package marked explicit
- **WHEN** MarkExplicit is called with one package name
- **THEN** pacman -D --explicit is called once with that package
#### Scenario: Multiple packages marked explicit
- **WHEN** MarkExplicit is called with multiple package names (e.g., ["pkg1", "pkg2"])
- **THEN** pacman -D --explicit is called once with all packages as arguments
#### Scenario: Empty package slice
- **WHEN** MarkExplicit is called with an empty slice
- **THEN** no pacman call is made, method returns nil immediately
@@ -0,0 +1,47 @@
## ADDED Requirements
### Requirement: ValidatePackages uses dyalpm library with batch AUR fallback
The ValidatePackages method SHALL accept a slice of package names, query them in batch using dyalpm, then batch query AUR for any not found in pacman databases.
#### Scenario: All packages found in local database
- **WHEN** ValidatePackages is called with packages that all exist in local pacman database
- **THEN** returns a slice of PackageInfo with Exists=true, InAUR=false for each
#### Scenario: Some packages found in sync database
- **WHEN** ValidatePackages is called with packages where some are only in sync databases
- **THEN** returns PackageInfo with Exists=true, InAUR=false for found packages
#### Scenario: Some packages found in AUR
- **WHEN** ValidatePackages is called and some packages are not in pacman databases
- **THEN** those packages are batched to single AUR HTTP request, returns PackageInfo with InAUR=true
#### Scenario: Packages not found anywhere
- **WHEN** ValidatePackages is called and some packages not found in pacman or AUR
- **THEN** returns PackageInfo with Exists=false, InAUR=false for those packages
### Requirement: Unified package cache
The Pac struct SHALL maintain a single cache map that stores all package query results (both pacman and AUR), replacing the separate aurCache.
#### Scenario: Package already cached
- **WHEN** ValidatePackages is called for a package already queried in current job
- **THEN** cached result returned without any dyalpm or AUR calls
#### Scenario: New Pac instance
- **WHEN** New() creates a new Pac instance
- **THEN** cache is empty (fresh job)
### Requirement: Single batch AUR call
The AUR HTTP API SHALL be called once with all package names not found in pacman databases.
#### Scenario: Multiple packages not in pacman
- **WHEN** 3 packages not found in local or sync databases
- **THEN** single AUR HTTP request with all 3 in arg[] params
- **AND** results cached for all 3
### Requirement: Fallback to process spawn if dyalpm unavailable
If dyalpm library is not available at runtime, ValidatePackages SHALL fall back to spawning pacman -Qip/-Sip processes in batch.
#### Scenario: dyalpm unavailable
- **WHEN** dyalpm initialization fails
- **THEN** uses pacman -Qip for local, -Sip for sync, AUR HTTP batch as fallback
- **AND** behavior is identical to using dyalpm