fix(sys): exact Flatpak commit binding, non-destructive cleanup previews, reverse deps; record VM evidence
Some checks are pending
ci / test (push) Waiting to run
Some checks are pending
ci / test (push) Waiting to run
This commit is contained in:
parent
ec1f7c5b0b
commit
3bdeb08f76
9 changed files with 473 additions and 321 deletions
|
|
@ -3,6 +3,61 @@
|
|||
All notable changes are recorded here. The authoritative history is `git log`;
|
||||
this file is the curated, human-readable summary.
|
||||
|
||||
## 2026-09-25 — Second-round `sys` fixes: safe cleanup previews, exact update transactions, reverse dependencies
|
||||
|
||||
Follow-up review found three further confirmed defects; all three are fixed with
|
||||
regression tests, and the disposable-VM acceptance is extended. This entry
|
||||
supersedes any earlier claim that every review finding was already fixed.
|
||||
|
||||
- **Cache-cleanup preview no longer deletes (finding 1).** `eclean-dist`/
|
||||
`eclean-pkg` **delete by default**; only `--pretend` previews. The planner now
|
||||
runs `--pretend --deep` (the same selection policy as the destructive run) and
|
||||
combines stdout and stderr into a sorted, bound item set. The Nix preview uses
|
||||
the documented `nix-store --gc --print-dead` (a bare `--gc`, and the
|
||||
undocumented `--dry-run`, were unsafe assumptions). Tests prove reconciliation
|
||||
and cancelled approval run no destructive cleaner.
|
||||
- **Exact Flatpak/Snap update transactions (finding 2).** A reviewed update now
|
||||
carries a structured `UpdateTransaction`: the full Flatpak ref (from
|
||||
`remote-ls`) plus installed and remote **full commits** (from `flatpak info`,
|
||||
because Flatpak's `commit` column is abbreviated), or the snap name plus
|
||||
old/new revisions and tracking channel. Execution consumes the reviewed
|
||||
transaction, is pinned (`flatpak update --commit=<commit>`), and revalidates
|
||||
each source immediately before its mutation — including after an earlier
|
||||
source has run. A commit republished under an unchanged human version, a newly
|
||||
appearing update, or a non-exact transaction is refused; a source whose
|
||||
resolution failed is never re-discovered at execution.
|
||||
- **Reverse-dependency self-reference (finding 3).** The reverse branch compared
|
||||
the dependency target with the queried package and dropped exactly the valid
|
||||
matches. It now excludes only a genuine self-reference (the *dependent* is the
|
||||
queried package), so installed targets, full and bare names, and
|
||||
conditional/versioned dependencies are reported.
|
||||
- **Determinism and execution robustness.** `All selected packages:` removals
|
||||
are sorted so depclean previews are order-independent (previously a false
|
||||
"plan changed"); `emerge --depclean` runs with `--ask=n`; plan aggregation
|
||||
includes `updates`.
|
||||
- **Tests:** +22 (workspace `cargo test --workspace` green, 661 → 683). New
|
||||
regressions cover the non-destructive preview, drift/failed/cancelled
|
||||
cleanup, exact Flatpak identities/commits, Snap revisions, reverse
|
||||
dependencies, and Nix generation handling.
|
||||
- **VM-verified (disposable images):** real `eclean` preview/approve/cancel/
|
||||
drift/failed and `depclean` cancel/approve with history and preserved user
|
||||
data; real reverse dependencies (`sys-libs/glibc`, `sys-libs/zlib`); a real
|
||||
Flatpak reviewed update (Portage-installed Flatpak, flathub, downgraded commit,
|
||||
reviewed update to the reviewed full commit, verified); custom-ebuild
|
||||
stage/build/install/remove; managed AppImage acquire/list/launch/remove with a
|
||||
tampered-SHA refusal; a Nix-enabled install with a real `nodejs-slim` profile
|
||||
(inventory, filtering, generations); and the **non-root `pkexec sys --broker`
|
||||
path** (cancelled authentication, successful broker execution, replay
|
||||
rejection) after installing the shipped polkit action and the standard
|
||||
wheel-admin rule. The read-only acceptance matrix re-run on the final static
|
||||
`sys` (`dd61c610…`) reports `PASS=38 FAIL=0` (the matrix gained a reverse-
|
||||
dependency regression).
|
||||
- **Not completed (see `docs/HANDOFF.md`):** Snap install/refresh/remove (no
|
||||
snapd in the image; needs `app-containers/snapd`, AppArmor and network); live
|
||||
AI (a local model was served, but the sandboxed call exceeds the 120 s
|
||||
transport timeout on CPU); and the distinct recovery boot (the recovery BLS
|
||||
entry is present; selecting it interactively is not automated).
|
||||
|
||||
## 2026-09-25 — Fix the `sys` catalogue review findings (host/target, revalidation, update effects, Nix inventory, dependencies)
|
||||
|
||||
Follow-up to the package-management interface: seven review findings are fixed,
|
||||
|
|
|
|||
192
docs/HANDOFF.md
192
docs/HANDOFF.md
|
|
@ -3,126 +3,104 @@
|
|||
Rolling note between work sessions. **Update this file before you finish**, then
|
||||
commit it. It should be short and current; use `git log` for detail.
|
||||
|
||||
- **Last updated:** this session (2026-09-25). Follow-up to commit `05d7075`:
|
||||
the seven review findings on the `sys` package-management interface are fixed
|
||||
(host/target rooting, maintenance effect revalidation, exact Flatpak/Snap
|
||||
update effects, complete source constraints, truthful cache-cleanup outcomes,
|
||||
Nix active-profile inventory, VDB-based dependency inspection), with
|
||||
regression tests. The disposable-VM acceptance matrix is extended and the
|
||||
fresh-install / mutating / rollback journeys below were completed.
|
||||
- **Interface contract (unchanged):** every ordinary request uses the AI
|
||||
workflow; only an explicit `--legacy` selects deterministic handling; source
|
||||
flags constrain the AI and never bypass it; a missing model stops the workflow
|
||||
and offers the exact `--legacy` command without executing it; both modes share
|
||||
the same validated typed actions, approval controls and execution layer.
|
||||
- **Last updated:** this session (2026-09-25), second-round `sys` review fixes.
|
||||
Follow-up to `d3f676a`. Three further confirmed defects are fixed with
|
||||
regression tests: unsafe cleanup previews, non-exact Flatpak/Snap update
|
||||
execution, and reverse-dependency self-reference. `make test` is green
|
||||
(661 → 683 tests). This corrects the earlier blanket claim that every review
|
||||
finding was already fixed.
|
||||
- **Interface contract (unchanged):** ordinary requests use AI; only explicit
|
||||
`--legacy` selects deterministic handling; source flags constrain the AI and
|
||||
never bypass it; a missing model stops the workflow and offers the exact
|
||||
`--legacy` command without executing it.
|
||||
|
||||
## What this session changed (code)
|
||||
|
||||
1. **Host/target rooting (finding 1).** `Exec::tool_in_target` resolves tools
|
||||
from the target; `actions::target_spec` is shared by catalogue, chooser and
|
||||
update paths. Snap is host-only and is reported unavailable (and refused for
|
||||
mutation) for an alternate root. Recording-runner tests assert no host
|
||||
`flatpak`/`snap` process is invoked for an alternate root.
|
||||
2. **Maintenance revalidation (finding 2).** `resolves_effects` covers
|
||||
`Depclean`/`ApplyUpdates`/`CleanCache`; depclean removals are structured
|
||||
`PackageEffect`s parsed from `emerge --pretend --depclean`, so a changed
|
||||
removal set changes the digest and aborts at the execution boundary (and
|
||||
within multi-action plans). Plan aggregation now carries `cleanup` intents.
|
||||
3. **Exact update effects (finding 3).** `ApplyUpdates` resolves per-source
|
||||
effects (each Flatpak app by ref, each snap by name) bound to approval and
|
||||
revalidated; unrestricted update-all is gone. Lanes with no safe transaction
|
||||
are refused. Cache cleanup reviews each cleaner's dry run via
|
||||
`ResolvedPlan.cleanup`.
|
||||
4. **Source constraints (finding 4).** `backend()` classifies Portage-only
|
||||
actions; `constrain_action` rewrites `DiscoverCandidates`/`ChoosePackage` and
|
||||
refuses the cross-lane `InspectInstallation` before querying.
|
||||
5. **Cache-cleanup truthfulness (finding 5).** A cleaner that ran and failed
|
||||
fails the action (partial successes preserved); unavailable is distinct;
|
||||
the report reaches exit status, assistant response and transaction history.
|
||||
6. **Nix inventory (finding 6).** Active-profile `manifest.json` (v1/v2/v3)
|
||||
packages are enumerated with profile/user scope and identity; historical
|
||||
generations and realised store paths are separate; unsupported formats and
|
||||
base profiles are stated explicitly.
|
||||
7. **Dependencies (finding 7).** Forward/reverse dependencies use installed VDB
|
||||
`DEPEND`/`RDEPEND`/`BDEPEND` (`qdepends` tree fallback), include
|
||||
already-satisfied/conditional/versioned deps, never self, and distinguish a
|
||||
failed query from an empty set.
|
||||
1. **Cleanup previews are non-destructive (finding 1).** `eclean-dist`/
|
||||
`eclean-pkg` delete by default, so `portage_cleaners` now previews with
|
||||
`--pretend --deep` (same selection policy as execution) and executes with
|
||||
`--deep`; the Nix preview uses the documented `nix-store --gc --print-dead`.
|
||||
Items are read from stdout+stderr, sorted and bound. Tests prove a cleaner
|
||||
never runs destructively during planning, revalidation or cancelled approval.
|
||||
2. **Exact Flatpak/Snap update transactions (finding 2).**
|
||||
`ResolvedPlan.updates` carries `UpdateTransaction`s: full Flatpak ref + full
|
||||
installed/remote commits (via `flatpak info`, since the `commit` column is
|
||||
abbreviated), or snap name + old/new revisions + channel. Execution consumes
|
||||
the reviewed transaction (`add_executable`… `flatpak update --commit=<c>`),
|
||||
revalidates each source immediately before its mutation, verifies the
|
||||
resulting commit/revision, and refuses non-exact transactions. A source whose
|
||||
resolution failed is never re-discovered. `PlanStore` aggregation includes
|
||||
`updates`.
|
||||
3. **Reverse dependencies (finding 3).** The reverse branch no longer drops
|
||||
valid matches; it excludes only a genuine self-reference (the *dependent* is
|
||||
the queried package).
|
||||
4. **Determinism.** `All selected packages:` removals are sorted (depclean
|
||||
previews are now order-independent); `emerge --depclean --ask=n`.
|
||||
|
||||
Unit tests: `cargo test --workspace` (all green; see CHANGELOG). Build/static
|
||||
binaries: `make build` and `make static`; the static `sys` built from the final
|
||||
tree has SHA-256 `65307d85…` (see the VM log `TEST_SYS_SHA`).
|
||||
## Verified in disposable VMs
|
||||
|
||||
## Verified in disposable VMs (this session)
|
||||
- **Cache cleanup + depclean (real tools):** `eclean` upstream preview is
|
||||
non-destructive; `sys clean cache` preview/cancelled/approved/drift/failed all
|
||||
behave correctly; depclean cancel/approve with transaction history and
|
||||
preserved `/home`.
|
||||
- **Reverse dependencies:** `sys-libs/glibc` and `sys-libs/zlib` report real
|
||||
dependents (conditional/versioned included).
|
||||
- **Flatpak:** installed via Portage (`sys-apps/flatpak`, enabling
|
||||
`media-libs/freetype[harfbuzz]`), flathub added, an app installed and
|
||||
downgraded, then `sys apply updates --flatpak` resolved full ref+commits,
|
||||
deployed the pinned commit, and verified it.
|
||||
- **Custom ebuild:** stage → build/install (VDB entry + installed file) →
|
||||
remove.
|
||||
- **Managed AppImage:** acquire with pinned SHA-256, list, run the managed ELF,
|
||||
remove; a placeholder SHA is refused.
|
||||
- **Nix:** a `NIX_ENABLED=yes` install bootstraps Nix; `nix profile install
|
||||
nixpkgs#nodejs-slim` into `/nix/var/nix/profiles/profile` is enumerated by
|
||||
`sys list --nix` and found by `sys list nodejs --nix`, with store paths and
|
||||
generations reported separately.
|
||||
- **Non-root `pkexec sys --broker`:** with the shipped polkit action and the
|
||||
standard wheel-admin rule installed on the disposable image, a wheel user
|
||||
authenticated through a terminal agent; cancellations changed nothing, the
|
||||
approved removal returned the broker JSON outcome, and the replay was
|
||||
rejected. The shipped privilege policy is unchanged.
|
||||
- **Read-only acceptance:** `installer/tests/vm/sys-acceptance.sh` `PASS=38
|
||||
FAIL=0` re-run against the final static `sys` (`dd61c610…`), including the new
|
||||
`rdeps-legacy` reverse-dependency regression.
|
||||
|
||||
- **Fresh install** (`fresh-install-1.qcow2`, test.conf `DESKTOP_PROFILE=none`,
|
||||
`NIX_ENABLED=no`): `===INSTALL-RC=0===`, `NO_SECRET_LEAK`, then a detached
|
||||
boot: `boot-systemd-running` PASS.
|
||||
- **Out-of-box Portage permissions:** `/etc/portage` 755,
|
||||
`repos.conf` 755, `repos.conf/gentoo.conf` 644,
|
||||
`package.use/phoebus` 644 → non-root `sys search firefox --legacy` returns 3
|
||||
real results and `sys updates --legacy` reports 10 available. This is the
|
||||
fresh-install proof that `normalize_config_permissions` works without manual
|
||||
repair.
|
||||
- **Acceptance matrix:** `installer/tests/vm/sys-acceptance.sh` `SUMMARY PASS=37
|
||||
FAIL=0` on both an existing installed clone and the fresh install, including
|
||||
the new regressions `snap-alternate-root`, `list-nix-legacy`, `deps-legacy`.
|
||||
- **Privileged mutating journeys** on the fresh install (via root; see blocked
|
||||
note): install + VDB, remove, history, depclean, cache cleanup (honest
|
||||
nonzero failure with no cleaner), alternate-root Snap refusal, and a Portage
|
||||
`apply updates` journey — 7/7 PASS.
|
||||
- **Rollback acceptance** on a disposable clone: snapshot → controlled change
|
||||
(root marker + `app-misc/hello`) → `sys undo` → detached boot. The package
|
||||
database fingerprint returned to the pre-change value, the root marker is
|
||||
absent, the `/home` marker survives, and systemd is running.
|
||||
- **Revision:** the final static `sys` (`TEST_SYS_SHA:65307d85…`) was re-fetched
|
||||
into the fresh VM and the acceptance matrix re-run against it: `PASS=37
|
||||
FAIL=0`. The installed `/usr/local/bin/sys` from the install-time build was
|
||||
`SYS_SHA:22232a25…`; the only delta is the cleanup-intent plan-binding fix,
|
||||
which the read-only matrix does not exercise.
|
||||
## Not completed / blocked
|
||||
|
||||
## Blocked / not yet verified
|
||||
|
||||
- **pkexec/Polkit `sys --broker --execute-plan` path:** the serial console has no
|
||||
Polkit agent, so `pkexec` elevation cannot complete. Privileged execution was
|
||||
exercised by running the same reviewed plan as root (initiator uid 0); the
|
||||
ledger/replacement/replay logic remains unit-tested and was previously
|
||||
reviewed. To unblock: a seat-providing/graphical VM with a working Polkit
|
||||
agent, or a disposable test image with a passwordless-sudo polkit agent.
|
||||
- **Nix profile journey:** the disposable install sets `NIX_ENABLED=no`, so no
|
||||
Nix profile exists in the VM. The manifest parser (v1/v2/v3, unsupported
|
||||
formats, inactive elements, historical generations) is unit-tested with
|
||||
realistic fixtures. To unblock: install with Nix enabled and a known profile.
|
||||
- **Snap install/refresh/remove:** no snapd/AppArmor in the minimal image; the
|
||||
lane journey would need `app-containers/snapd`, AppArmor and network.
|
||||
- **Managed AppImage acquire/launch/remove** and **custom-ebuild
|
||||
stage/build/install/remove:** not run in the VM (no AppImage fixture/FUSE and
|
||||
no build budget); the code paths are unit-tested.
|
||||
- **Live AI:** no provider credential is present. `sys ask`/guided install and
|
||||
source-constrained live AI remain unverified; do not invent a credential.
|
||||
- **NVIDIA:** no GPU.
|
||||
- **Snap install/refresh/remove:** no snapd in the image. Prerequisite:
|
||||
`app-containers/snapd` + AppArmor + network, installed through the supported
|
||||
integration. The Snap transaction code is unit-tested only.
|
||||
- **Live AI:** a local OpenAI-compatible model (`llama-server` + a GGUF model)
|
||||
was served on the host; the AI workflow reached the model, but the sandboxed
|
||||
call exceeded the 120 s transport timeout on CPU (`curl` exit 28). Needs a
|
||||
faster model/GPU or a remote provider credential. Fixture-backed routing and
|
||||
failure tests pass (`ask-offline`, missing-model offer, source constraint).
|
||||
- **Recovery boot (distinct from rollback):** the recovery BLS entry is present
|
||||
and asserted in the rollback acceptance, but booting it interactively was not
|
||||
automated. Method: select "Phoebus Recovery (known-good snapshot)" in the
|
||||
systemd-boot menu with no network.
|
||||
- **Nix re-run flakiness:** a later `sys list --nix` re-run reported the profile
|
||||
link dangling (the profile store path was gone) and correctly listed no
|
||||
packages; the first run with a real profile is the positive evidence.
|
||||
|
||||
## Known blockers / risks
|
||||
|
||||
- A full VM install takes ~2 h; the fresh `fresh-install-1.qcow2` is now
|
||||
available for future work. `make doctor` reports low host disk space; delete
|
||||
build/VMs deliberately, never a physical disk.
|
||||
- The pre-existing `test-disk.qcow2` still cannot be unlocked (unknown
|
||||
passphrase); do not guess or brute-force.
|
||||
- OpenCode transport concatenates messages; multi-turn AI investigation is
|
||||
best-effort there.
|
||||
- VM serial login is occasionally flaky; retry the boot when `detached-boot-login`
|
||||
fails.
|
||||
- `make doctor` passes (KVM accessible via an ACL). Disk is shared by build and
|
||||
VM; watch free space.
|
||||
- The pre-existing `test-disk.qcow2` cannot be unlocked (unknown passphrase); do
|
||||
not guess or brute-force it.
|
||||
|
||||
## Next actions (in order)
|
||||
|
||||
1. **pkexec/Polkit broker acceptance** in a seat-providing or passwordless-agent
|
||||
disposable VM: successful approval, cancelled authentication, plan
|
||||
replacement during authentication, replay after deleting user-owned plan
|
||||
state, and real ownership of personal settings.
|
||||
2. **Nix profile journey** with `NIX_ENABLED=yes` and a profile containing a
|
||||
known package (`nodejs`), verifying inventory, filtering and generations.
|
||||
3. **Snap/AppImage/custom-ebuild lane journeys** with benign fixtures and
|
||||
recorded confinement limitations.
|
||||
4. **Live AI** (`sys ask`, source-constrained discovery, reviewed install,
|
||||
missing-model/provider-failure) once a credential or local model exists.
|
||||
1. **Snap lane acceptance** with `app-containers/snapd` (install/refresh/remove,
|
||||
confinement recorded).
|
||||
2. **Recovery boot** by selecting the recovery BLS entry with the network down.
|
||||
3. **Live AI** with a faster local model/GPU or an authorized provider
|
||||
credential (natural-language discovery, source constraints, reviewed install).
|
||||
4. **Nix profile GC stability** if the dangling re-run is reproducible.
|
||||
|
||||
## Definition of a good stopping point
|
||||
|
||||
|
|
|
|||
|
|
@ -93,17 +93,19 @@ still not VM-verified.
|
|||
| Personal preferences + alert state (user-owned, system-default precedence) | yes | yes (save/reload/isolation/precedence/failure) | yes (installed VM: saved to user config, exit 0) | no |
|
||||
| Personal write ownership (elevated chown, symlink refusal, cross-uid refusal) | yes | yes (ownership-fixer seam + CLI refusal) | no | no |
|
||||
| Personal preference does not need the root-owned system transaction log | yes | yes (CLI regression: read-only transaction dir) | yes (installed VM acceptance) | n/a |
|
||||
| Installed `sys` acceptance matrix (read-only/failure) | yes | yes | yes (installed VM: `PASS=37 FAIL=0`, catalogue + regression group) | no |
|
||||
| Installed `sys` acceptance matrix (read-only/failure) | yes | yes | yes (installed VM: `PASS=38 FAIL=0`, catalogue + regression group) | no |
|
||||
| Portage config readable for non-root queries (`normalize_config_permissions`) | yes | yes (modes + keyring exclusion) | yes (fresh VM install: 0755/0644 out of the box; non-root `search` returns 3 results, `updates` reports 10) | no |
|
||||
| Privileged catalogue mutations (install/remove/depclean/cache/apply updates, alternate-root) | yes | yes (unit) | yes (fresh installed VM via root: 7/7 PASS) | no |
|
||||
| Rollback acceptance (snapshot -> change -> `sys undo` -> detached verify) | yes | yes | yes (clone: package DB restored, root marker gone, `/home` survives, boot running) | no |
|
||||
| Privileged `--broker` plan execution + replay rejection in a VM (pkexec path) | yes | yes (privileged entry point) | no (serial console has no Polkit agent; direct privileged execution exercised via root) | n/a |
|
||||
| Privileged `--broker` plan execution + replay rejection in a VM (pkexec path) | yes | yes (privileged entry point) | yes (non-root `pkexec` with a terminal polkit agent: cancelled auth, broker JSON success, replay rejected; required the shipped policy + wheel-admin rule) | n/a |
|
||||
| Cache-cleanup preview is non-destructive (real `eclean`/`nix-store`) | yes | yes (preview uses `--pretend --deep` / `--print-dead`; sorted bound items) | yes (real `eclean`: upstream preview, cancelled approval, approved run, drift refusal, failed cleaner; user data preserved) | n/a |
|
||||
| Reverse-dependency inspection includes installed targets | yes | yes (self-reference compares the dependent, not the target) | yes (real `sys-libs/glibc`, `sys-libs/zlib` dependents) | n/a |
|
||||
| Transaction log (outcomes, protective snapshots) | yes | yes | read-only in installed VM; write path needs root | no |
|
||||
| Flatpak/Nix bounded typed actions | yes | yes | no | no |
|
||||
| Shared hardware-aware source selection (all lanes) | yes | yes | no | no |
|
||||
| Snap lane (detect/install/list/remove/refresh/connections) | yes | yes | no | no |
|
||||
| AppImage lane (import/acquire/integrity/desktop/remove) | yes | yes | no | no |
|
||||
| Custom ebuild overlay (stage/approve/build/remove) | yes | yes | no | no |
|
||||
| Snap lane (detect/install/list/remove/refresh/connections) | yes | yes (incl. exact revisions) | no (no snapd in the image; needs `app-containers/snapd`, AppArmor, network) | no |
|
||||
| AppImage lane (import/acquire/integrity/desktop/remove) | yes | yes | yes (VM: acquire with pinned SHA, list, launch fixture, remove; tampered SHA refused) | no |
|
||||
| Custom ebuild overlay (stage/approve/build/remove) | yes | yes | yes (VM: stage → build/install → VDB+file present → remove) | no |
|
||||
| `sys` installed into the target + verified in chroot | yes | yes (unit) | yes (detached boot verified) | no |
|
||||
| AI-first install workflow (`sys install`, `sys ask`) | yes | yes | explicit-backend journey; AI-selected not run | no |
|
||||
| Bounded AI investigation (typed read-only evidence) | yes | yes | read-only actions on a booted VM | no |
|
||||
|
|
@ -118,7 +120,8 @@ still not VM-verified.
|
|||
| Unified package search (`sys search`, all lanes, `--legacy`) | yes | yes (cross-lane; unavailable/failed/empty distinguished; source filter) | no | no |
|
||||
| Installed-package inventory (`sys list`, all lanes, `--legacy`) | yes | yes (VDB/Flatpak/Snap/AppImage; **Nix active-profile packages** vs generations/store; custom ebuild never double-counted) | yes (VM read-only group) | no |
|
||||
| Package information (`sys info`, `--legacy`) | yes | yes (installed/available, version/deps/size/provenance; ambiguity flagged) | yes (VM read-only group) | no |
|
||||
| Cross-source update check/apply (`sys updates`, `apply updates`) | yes | yes (exact per-source identities bound to approval + revalidated; manual/project-specific refused) | yes (VM: check read-only; Portage apply journey) | no |
|
||||
| Cross-source update check/apply (`sys updates`, `apply updates`) | yes | yes (exact per-source transactions with full Flatpak commits/snap revisions, pinned and revalidated; manual/project-specific refused) | Flatpak verified in VM (reviewed ref+commit, pinned update, verified); Snap unit-tested only; Portage verified | no |
|
||||
| Nix active-profile inventory (`sys list --nix`) | yes | yes (manifest v1/v2/v3; scope; generations vs store) | yes (NIX_ENABLED=yes install: real `nodejs-slim` profile listed and filtered; a re-run correctly reported a dangling profile) | no |
|
||||
| Catalogue maintenance (`depclean`, `clean cache`, `owners`, `deps`/`rdeps`) | yes | yes (structured depclean effects; cache-cleanup dry-run review + failure propagation; VDB dependency metadata) | yes (VM: depclean + cache-cleanup journeys; deps read-only) | no |
|
||||
| AI-default catalogue routing (source flags constrain, never bypass) | yes | yes (investigation loop, full backend classification + optional-backend rewrite, fallback offers exact `--legacy` command) | yes (read-only routing cases) | no |
|
||||
| Alternate-root catalogue/update/maintenance rooting | yes | yes (chroot for Portage/Flatpak/Nix; Snap refused; recording-runner no-host-command tests) | yes (VM: alternate-root Snap refused) | no |
|
||||
|
|
|
|||
41
docs/SYS.md
41
docs/SYS.md
|
|
@ -298,27 +298,40 @@ sys rdeps vim --legacy # reverse dependencies (equery)
|
|||
repository, `DEPEND`/`RDEPEND`/`BDEPEND`) with resolved candidates and policy
|
||||
metadata. When more than one real package matches, the report is marked
|
||||
**ambiguous** and lists every match instead of guessing.
|
||||
- **Updates** check every supported lane. Applying updates resolves the exact
|
||||
affected identities per source immediately before execution (each Flatpak app
|
||||
by ref, each snap by name) and re-checks the reviewed effect set at the
|
||||
execution boundary; a changed set aborts as a stale plan. AppImage (pinned
|
||||
URL+SHA) and Nix (project/declarative) are refused as a system-level
|
||||
transaction rather than reported as updated. A source that was attempted and
|
||||
failed fails the whole action while the report still shows the sources that
|
||||
succeeded. Background **preparation** (`prepare updates`, `what are you
|
||||
compiling`) remains distinct from **activation**.
|
||||
- **Updates** check every supported lane. Applying a Flatpak or Snap update
|
||||
**executes exactly the reviewed transaction**: the plan binds the full Flatpak
|
||||
ref (`app/…/arch/branch`, from `remote-ls`) plus the installed and remote
|
||||
**full commits** (from `flatpak info`, since Flatpak's `commit` column is
|
||||
abbreviated), or the snap name plus its old/new revisions and tracking
|
||||
channel. Execution is pinned (`flatpak update --commit=<commit>`) and the
|
||||
source is revalidated immediately before its mutation — including after an
|
||||
earlier source has run — so a commit republished under an unchanged human
|
||||
version, a newly appearing update, or a change in the active installation
|
||||
aborts as stale. A source whose resolution failed is never re-discovered and
|
||||
executed later. `flatpak` and `snap` both require backend prerequisites and
|
||||
are refused explicitly when they cannot run. AppImage (pinned URL+SHA) and Nix
|
||||
(project/declarative) are refused as a system-level transaction rather than
|
||||
reported as updated. A source that was attempted and failed fails the whole
|
||||
action while the report still shows the sources that succeeded. Background
|
||||
**preparation** (`prepare updates`, `what are you compiling`) remains distinct
|
||||
from **activation**.
|
||||
- **Maintenance**: `depclean` records its removal set as **structured package
|
||||
effects** (not only prose) from `emerge --pretend --depclean` at review time,
|
||||
so a changed removal set is caught before execution; it refuses when the
|
||||
selection cannot be established, and preserves config files and user data.
|
||||
`clean cache` reviews each cleaner's non-destructive dry run and binds it to
|
||||
approval; a cleaner that ran and failed propagates as a failed action while
|
||||
partial successes are preserved, and an unavailable cleaner is reported
|
||||
`clean cache` reviews each cleaner's real **non-destructive preview**
|
||||
(`eclean-dist`/`eclean-pkg` delete by default, so the preview passes
|
||||
`--pretend` with the same `--deep` selection as the destructive run;
|
||||
`nix-store --gc`'s documented preview is `--print-dead`) and binds the item
|
||||
set to approval; a cleaner that ran and failed propagates as a failed action
|
||||
while partial successes are preserved, and an unavailable cleaner is reported
|
||||
distinctly from one that found nothing. `package_owners` and
|
||||
`package_dependencies` use the installed VDB metadata (forward dependencies
|
||||
include already-satisfied and conditional/versioned dependencies, never the
|
||||
requested package itself) with `qdepends`/`equery` as the tree fallback, and
|
||||
report an explicit unsupported error when the tool is absent.
|
||||
requested package itself; reverse dependencies exclude only a genuine
|
||||
self-reference where the *dependent* is the queried package) with
|
||||
`qdepends`/`equery` as the tree fallback, and report an explicit unsupported
|
||||
error when the tool is absent.
|
||||
- **Rooting**: every catalogue, update-check and maintenance command is built
|
||||
for the *intended target* — directly for `/`, or inside the target chroot for
|
||||
an alternate root. Snap acts on the running daemon and is therefore reported
|
||||
|
|
|
|||
|
|
@ -436,12 +436,18 @@ pub fn parse_emerge_pretend(text: &str) -> ResolvedPlan {
|
|||
source,
|
||||
});
|
||||
}
|
||||
// `emerge --unmerge --pretend` does not use the `[ebuild ...]` form; it
|
||||
// lists the packages slated for removal. Parse them so a removal has a
|
||||
// concrete, reviewable plan instead of being refused as unestablished.
|
||||
// `emerge --unmerge --pretend`/`--depclean --pretend` do not use the
|
||||
// `[ebuild ...]` form; they list the packages slated for removal. Parse
|
||||
// them so a removal has a concrete, reviewable plan instead of being
|
||||
// refused as unestablished. Portage does not guarantee the order of this
|
||||
// list, so sort and dedupe it: otherwise two previews of the *same*
|
||||
// selection would produce different digests and falsely report drift.
|
||||
for line in text.lines() {
|
||||
if let Some(rest) = line.trim().strip_prefix("All selected packages:") {
|
||||
for atom in rest.split_whitespace() {
|
||||
let mut atoms: Vec<&str> = rest.split_whitespace().collect();
|
||||
atoms.sort_unstable();
|
||||
atoms.dedup();
|
||||
for atom in atoms {
|
||||
plan.effects.push(PackageEffect {
|
||||
target: atom.to_string(),
|
||||
previous: None,
|
||||
|
|
@ -618,6 +624,16 @@ Total: 5 packages (2 upgrades, 2 new, 1 uninstall), Size of downloads: 10,240 Ki
|
|||
assert_eq!(plan.digest.len(), 64);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn depclean_selection_parsing_is_order_independent() {
|
||||
// Portage does not guarantee the order of `All selected packages`.
|
||||
let a = parse_emerge_pretend("All selected packages: app-misc/one-1.0 app-misc/two-2.0\n");
|
||||
let b = parse_emerge_pretend("All selected packages: app-misc/two-2.0 app-misc/one-1.0\n");
|
||||
assert_eq!(a.effects.len(), 2);
|
||||
assert_eq!(a.digest, b.digest);
|
||||
assert!(!changed_materially(&a, &b));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_unmerge_pretend_output() {
|
||||
let text = "\n>>> These are the packages that would be unmerged:\n\n \
|
||||
|
|
|
|||
|
|
@ -310,61 +310,38 @@ fn flatpak_cols(line: &str) -> Vec<String> {
|
|||
}
|
||||
}
|
||||
|
||||
/// Parse `flatpak remote-ls --updates` and `flatpak list` output into exact,
|
||||
/// immutable-revision update transactions.
|
||||
///
|
||||
/// `updates` columns: `ref,application,version,branch,commit,origin,installation,type,arch`.
|
||||
/// `installed` columns: `ref,application,version,branch,commit,installation,type,arch`.
|
||||
/// A transaction is `exact` only when both the ref and the target commit are
|
||||
/// present; otherwise the source must be refused rather than approximated.
|
||||
pub(crate) fn parse_flatpak_transactions(updates: &str, installed: &str) -> Vec<UpdateTransaction> {
|
||||
use std::collections::BTreeMap;
|
||||
// ref -> (version, commit)
|
||||
let mut current: BTreeMap<String, (Option<String>, Option<String>)> = BTreeMap::new();
|
||||
for line in installed.lines() {
|
||||
if line.trim().is_empty() {
|
||||
continue;
|
||||
/// Parse `flatpak info --system <ref>`: the installed `Version`, the installed
|
||||
/// `Active commit` and the remote `Latest commit`. Flatpak's `--columns=commit`
|
||||
/// truncates to 12 characters, so `info` is used for full immutable commits.
|
||||
pub(crate) fn parse_flatpak_info(text: &str) -> (Option<String>, Option<String>, Option<String>) {
|
||||
fn nonempty(value: &str) -> Option<String> {
|
||||
let value = value.trim();
|
||||
if value.is_empty() {
|
||||
None
|
||||
} else {
|
||||
Some(value.to_string())
|
||||
}
|
||||
let cols = flatpak_cols(line);
|
||||
let (Some(r), version, commit) = (
|
||||
cols.first().filter(|s| !s.is_empty()).cloned(),
|
||||
cols.get(2).cloned(),
|
||||
cols.get(4).cloned(),
|
||||
) else {
|
||||
continue;
|
||||
};
|
||||
current.insert(r, (version, commit));
|
||||
}
|
||||
let mut txns = Vec::new();
|
||||
for line in updates.lines() {
|
||||
if line.trim().is_empty() {
|
||||
continue;
|
||||
let (mut version, mut active, mut latest) = (None, None, None);
|
||||
for line in text.lines() {
|
||||
let t = line.trim();
|
||||
if let Some(v) = t.strip_prefix("Version:") {
|
||||
version = nonempty(v);
|
||||
} else if let Some(v) = t.strip_prefix("Active commit:") {
|
||||
active = nonempty(v);
|
||||
} else if let Some(v) = t.strip_prefix("Latest commit:") {
|
||||
latest = nonempty(v);
|
||||
}
|
||||
let cols = flatpak_cols(line);
|
||||
let Some(identity) = cols.first().filter(|s| !s.is_empty()).cloned() else {
|
||||
continue;
|
||||
};
|
||||
let next_version = cols.get(2).cloned().unwrap_or_default();
|
||||
let next_revision = cols.get(4).filter(|s| !s.is_empty()).cloned();
|
||||
let scope = cols.get(6).filter(|s| !s.is_empty()).cloned();
|
||||
let previous = current.get(&identity);
|
||||
txns.push(UpdateTransaction {
|
||||
source: UpdateSource::Flatpak,
|
||||
identity,
|
||||
previous_version: previous.and_then(|(v, _)| v.clone()),
|
||||
next_version,
|
||||
previous_revision: previous.and_then(|(_, c)| c.clone()),
|
||||
next_revision: next_revision.clone(),
|
||||
scope,
|
||||
related: Vec::new(),
|
||||
exact: next_revision.is_some(),
|
||||
});
|
||||
}
|
||||
txns.sort_by(|a, b| a.identity.cmp(&b.identity));
|
||||
txns
|
||||
(version, active, latest)
|
||||
}
|
||||
|
||||
/// Resolve the exact Flatpak update transactions for the target.
|
||||
///
|
||||
/// `remote-ls` provides the remote refs with updates and their latest version;
|
||||
/// `flatpak info` supplies the installed and remote full commits. A transaction
|
||||
/// is `exact` only when both commits are known; otherwise the source is refused
|
||||
/// rather than approximated.
|
||||
pub(crate) fn flatpak_update_transactions(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
|
|
@ -385,9 +362,9 @@ pub(crate) fn flatpak_update_transactions(
|
|||
"flatpak",
|
||||
&[
|
||||
"remote-ls".into(),
|
||||
"--system".into(),
|
||||
"--updates".into(),
|
||||
"--columns=ref,application,version,branch,commit,origin,installation,type,arch"
|
||||
.into(),
|
||||
"--columns=ref,version".into(),
|
||||
],
|
||||
))
|
||||
.map_err(|e| {
|
||||
|
|
@ -407,36 +384,74 @@ pub(crate) fn flatpak_update_transactions(
|
|||
),
|
||||
));
|
||||
}
|
||||
let installed = exec
|
||||
let mut txns = Vec::new();
|
||||
for line in updates.stdout_lossy().lines() {
|
||||
if line.trim().is_empty() {
|
||||
continue;
|
||||
}
|
||||
let cols = flatpak_cols(line);
|
||||
let Some(identity) = cols.first().filter(|s| !s.is_empty()).cloned() else {
|
||||
continue;
|
||||
};
|
||||
// `remote-ls` reports refs with the `app/`/`runtime/` type prefix, which
|
||||
// is exactly what `flatpak info` and `flatpak update --commit` accept.
|
||||
let next_version = cols.get(1).cloned().unwrap_or_default();
|
||||
let info = exec
|
||||
.runner
|
||||
.execute(&target_spec(
|
||||
root,
|
||||
"sys",
|
||||
"resolve flatpak updates",
|
||||
"flatpak",
|
||||
&[
|
||||
"list".into(),
|
||||
"--columns=ref,application,version,branch,commit,installation,type,arch".into(),
|
||||
],
|
||||
&["info".into(), "--system".into(), identity.to_string()],
|
||||
))
|
||||
.map_err(|e| {
|
||||
ExecError::operation(
|
||||
"sys",
|
||||
"resolve flatpak updates",
|
||||
format!("flatpak list could not run: {e}"),
|
||||
format!("flatpak info {identity} could not run: {e}"),
|
||||
)
|
||||
})?;
|
||||
if !installed.success {
|
||||
if !info.success {
|
||||
return Err(ExecError::operation(
|
||||
"sys",
|
||||
"resolve flatpak updates",
|
||||
format!("flatpak list failed: {}", installed.stderr_lossy().trim()),
|
||||
format!(
|
||||
"flatpak info {identity} failed: {}",
|
||||
info.stderr_lossy().trim()
|
||||
),
|
||||
));
|
||||
}
|
||||
Ok(parse_flatpak_transactions(
|
||||
&updates.stdout_lossy(),
|
||||
&installed.stdout_lossy(),
|
||||
))
|
||||
let (installed_version, active, latest) = parse_flatpak_info(&info.stdout_lossy());
|
||||
txns.push(UpdateTransaction {
|
||||
source: UpdateSource::Flatpak,
|
||||
identity,
|
||||
previous_version: installed_version,
|
||||
next_version,
|
||||
previous_revision: active,
|
||||
next_revision: latest,
|
||||
scope: Some("system".to_string()),
|
||||
related: Vec::new(),
|
||||
exact: false,
|
||||
});
|
||||
}
|
||||
// `remote-ls --system` covers the system installation only. If the user
|
||||
// installation also has applications, we cannot bind their updates here,
|
||||
// so refuse the operation rather than approve an incomplete transaction.
|
||||
let user_apps = exec.runner.execute(&target_spec(
|
||||
root,
|
||||
"sys",
|
||||
"resolve flatpak updates",
|
||||
"flatpak",
|
||||
&["list".into(), "--user".into(), "--columns=ref".into()],
|
||||
));
|
||||
let user_present =
|
||||
matches!(&user_apps, Ok(o) if o.success && !o.stdout_lossy().trim().is_empty());
|
||||
for txn in &mut txns {
|
||||
txn.exact = txn.next_revision.is_some() && txn.previous_revision.is_some() && !user_present;
|
||||
}
|
||||
txns.sort_by(|a, b| a.identity.cmp(&b.identity));
|
||||
Ok(txns)
|
||||
}
|
||||
|
||||
/// Parse `snap refresh --list` and `snap list` output into exact update
|
||||
|
|
@ -687,11 +702,17 @@ fn cleanup_items(output: &CommandOutput) -> Vec<String> {
|
|||
}
|
||||
text.push_str(&output.stderr_lossy());
|
||||
}
|
||||
text.lines()
|
||||
let mut items: Vec<String> = text
|
||||
.lines()
|
||||
.map(str::trim)
|
||||
.filter(|l| !l.is_empty())
|
||||
.map(str::to_string)
|
||||
.collect()
|
||||
.collect();
|
||||
// The upstream cleaner does not guarantee output order; sort and dedupe so
|
||||
// two previews of the same selection bind to the same digest.
|
||||
items.sort();
|
||||
items.dedup();
|
||||
items
|
||||
}
|
||||
|
||||
/// Resolve a reviewable cache-cleanup plan from non-destructive dry runs. A
|
||||
|
|
@ -2151,6 +2172,21 @@ Total: 1 package (1 new), Size of downloads: 512 KiB
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn cleanup_items_are_order_independent() {
|
||||
let mk = |s: &str| CommandOutput {
|
||||
status: 0,
|
||||
success: true,
|
||||
stdout: s.as_bytes().to_vec(),
|
||||
stderr: Vec::new(),
|
||||
duration: std::time::Duration::from_millis(1),
|
||||
};
|
||||
let a = cleanup_items(&mk("b.tar.gz\na.tar.gz\n"));
|
||||
let b = cleanup_items(&mk("a.tar.gz\nb.tar.gz\n"));
|
||||
assert_eq!(a, b);
|
||||
assert_eq!(a, vec!["a.tar.gz", "b.tar.gz"]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resolve_cleanup_effects_never_runs_a_destructive_cleaner() {
|
||||
let runner = RecordingRunner::new();
|
||||
|
|
|
|||
|
|
@ -521,12 +521,20 @@ fn historical_generation_count(root: &Path) -> usize {
|
|||
let base = target_path(root, "nix/var/nix/profiles");
|
||||
let mut count = 0;
|
||||
let mut visit = |dir: &Path| {
|
||||
// The current generation is the one the active `profile` link points
|
||||
// at; only the other `profile-N-link` generations are historical.
|
||||
let active = std::fs::canonicalize(dir.join("profile")).ok();
|
||||
if let Ok(entries) = std::fs::read_dir(dir) {
|
||||
for entry in entries.flatten() {
|
||||
let name = entry.file_name().to_string_lossy().to_string();
|
||||
if name.starts_with("profile-") && name.ends_with("-link") {
|
||||
count += 1;
|
||||
if !(name.starts_with("profile-") && name.ends_with("-link")) {
|
||||
continue;
|
||||
}
|
||||
let target = std::fs::canonicalize(entry.path()).ok();
|
||||
if active.is_some() && target == active {
|
||||
continue;
|
||||
}
|
||||
count += 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
@ -749,6 +757,34 @@ mod tests {
|
|||
.any(|n| n.contains("historical profile generation")));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn current_generation_is_not_counted_as_historical() {
|
||||
let runner = RecordingRunner::new();
|
||||
let exec = make_exec(runner, false);
|
||||
let root = Path::new(&exec.root);
|
||||
let store = root.join("nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-nodejs-22.11.0");
|
||||
std::fs::create_dir_all(&store).unwrap();
|
||||
std::fs::write(store.join("manifest.json"), profile_manifest_v3()).unwrap();
|
||||
let profiles = root.join("nix/var/nix/profiles");
|
||||
std::fs::create_dir_all(&profiles).unwrap();
|
||||
// `profile` points at the current generation, which is a package
|
||||
// profile (it has a manifest), not a historical generation.
|
||||
std::os::unix::fs::symlink(&store, profiles.join("profile-1-link")).unwrap();
|
||||
std::os::unix::fs::symlink("profile-1-link", profiles.join("profile")).unwrap();
|
||||
|
||||
let inventory = installed_packages(root);
|
||||
assert_eq!(inventory.packages.len(), 1);
|
||||
assert_eq!(inventory.packages[0].profile, "profile");
|
||||
assert!(
|
||||
!inventory
|
||||
.notes
|
||||
.iter()
|
||||
.any(|n| n.contains("historical profile generation")),
|
||||
"{:?}",
|
||||
inventory.notes
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn installed_packages_reports_unsupported_manifest_formats_explicitly() {
|
||||
let runner = RecordingRunner::new();
|
||||
|
|
|
|||
|
|
@ -944,7 +944,15 @@ pub fn depclean(exec: &Exec, root: &Path) -> Result<String> {
|
|||
preview.trim()
|
||||
));
|
||||
}
|
||||
run_mut(exec, root, "emerge", &["--depclean", "--color=n"])?;
|
||||
// `--ask=n` keeps the destructive run non-interactive: the human
|
||||
// confirmation happened in the approval layer, and Portage must not try to
|
||||
// read a second answer from the (already consumed) stdin.
|
||||
run_mut(
|
||||
exec,
|
||||
root,
|
||||
"emerge",
|
||||
&["--depclean", "--ask=n", "--color=n"],
|
||||
)?;
|
||||
Ok(format!(
|
||||
"removed unused packages; configuration files and user data were preserved\n\
|
||||
reviewed selection (emerge --pretend --depclean):\n{}",
|
||||
|
|
@ -1141,11 +1149,19 @@ fn revalidate_snap(exec: &Exec, root: &Path, approved: &[UpdateTransaction]) ->
|
|||
}
|
||||
|
||||
/// Installed Flatpak commits keyed by ref.
|
||||
fn installed_flatpak_commits(
|
||||
/// The installed active commit for every ref, from
|
||||
/// `flatpak list --system --columns=ref,active`. `list` reports the bare ref
|
||||
/// (without the `app/`/`runtime/` type prefix) and an abbreviated commit.
|
||||
fn installed_flatpak_active(
|
||||
exec: &Exec,
|
||||
root: &Path,
|
||||
) -> Result<std::collections::BTreeMap<String, String>> {
|
||||
let out = capture(exec, root, "flatpak", &["list", "--columns=ref,commit"])?;
|
||||
let out = capture(
|
||||
exec,
|
||||
root,
|
||||
"flatpak",
|
||||
&["list", "--system", "--columns=ref,active"],
|
||||
)?;
|
||||
if !out.success {
|
||||
return Err(ExecError::operation(
|
||||
"sys",
|
||||
|
|
@ -1155,32 +1171,54 @@ fn installed_flatpak_commits(
|
|||
}
|
||||
let mut map = std::collections::BTreeMap::new();
|
||||
for line in out.stdout_lossy().lines() {
|
||||
if let Some((r, commit)) = line.split_once('\t').or_else(|| line.split_once(' ')) {
|
||||
if !r.trim().is_empty() && !commit.trim().is_empty() {
|
||||
map.insert(r.trim().to_string(), commit.trim().to_string());
|
||||
}
|
||||
let mut cols = line.splitn(2, '\t');
|
||||
let (Some(reference), Some(active)) = (cols.next(), cols.next()) else {
|
||||
continue;
|
||||
};
|
||||
if !reference.trim().is_empty() && !active.trim().is_empty() {
|
||||
map.insert(reference.trim().to_string(), active.trim().to_string());
|
||||
}
|
||||
}
|
||||
Ok(map)
|
||||
}
|
||||
|
||||
/// Strip the `app/`/`runtime/` type prefix so a remote ref can be matched
|
||||
/// against a `flatpak list` bare ref.
|
||||
fn strip_flatpak_type(reference: &str) -> &str {
|
||||
reference
|
||||
.strip_prefix("app/")
|
||||
.or_else(|| reference.strip_prefix("runtime/"))
|
||||
.unwrap_or(reference)
|
||||
}
|
||||
|
||||
fn execute_flatpak(exec: &Exec, root: &Path, txns: &[UpdateTransaction]) -> Result<String> {
|
||||
for txn in txns {
|
||||
let mut args = vec!["update".to_string(), "-y".to_string()];
|
||||
if let Some(scope) = &txn.scope {
|
||||
args.push(format!("--installation={scope}"));
|
||||
// Scope to the system installation and pin the exact reviewed commit so
|
||||
// a remote that republishes in the window cannot deploy unreviewed.
|
||||
let mut args = vec![
|
||||
"update".to_string(),
|
||||
"--system".to_string(),
|
||||
"--noninteractive".to_string(),
|
||||
"-y".to_string(),
|
||||
];
|
||||
if let Some(commit) = &txn.next_revision {
|
||||
args.push(format!("--commit={commit}"));
|
||||
}
|
||||
args.push("--".to_string());
|
||||
args.push(txn.identity.clone());
|
||||
let refs: Vec<&str> = args.iter().map(|s| s.as_str()).collect();
|
||||
run_mut(exec, root, "flatpak", &refs)?;
|
||||
}
|
||||
// Post-execution verification: every reviewed ref must now be at the
|
||||
// reviewed immutable commit.
|
||||
let commits = installed_flatpak_commits(exec, root)?;
|
||||
// reviewed commit (compared by prefix, since `flatpak list` abbreviates).
|
||||
let active = installed_flatpak_active(exec, root)?;
|
||||
for txn in txns {
|
||||
let actual = commits.get(&txn.identity);
|
||||
if txn.next_revision.is_some() && actual != txn.next_revision.as_ref() {
|
||||
let key = strip_flatpak_type(&txn.identity);
|
||||
let actual = active.get(key);
|
||||
let reached = match (txn.next_revision.as_deref(), actual) {
|
||||
(Some(next), Some(a)) => next.starts_with(a.as_str()),
|
||||
_ => false,
|
||||
};
|
||||
if !reached {
|
||||
return Err(ExecError::operation(
|
||||
"sys",
|
||||
"verify flatpak updates",
|
||||
|
|
@ -1770,15 +1808,12 @@ mod tests {
|
|||
}
|
||||
}
|
||||
|
||||
/// One fake Flatpak ref update (`ref,app,version,branch,commit,origin,installation,type,arch`).
|
||||
/// One fake Flatpak ref update (normalized ref, latest version, target commit).
|
||||
#[derive(Clone)]
|
||||
struct FpUpdate {
|
||||
reference: String,
|
||||
app: String,
|
||||
version: String,
|
||||
commit: String,
|
||||
installation: String,
|
||||
kind: String,
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
|
|
@ -1823,14 +1858,48 @@ mod tests {
|
|||
if spec.args.iter().any(|a| a == "remote-ls") {
|
||||
let state = self.state.lock().unwrap();
|
||||
let mut text = String::new();
|
||||
// remote-ls columns: ref, version (the remote ref form is
|
||||
// normalized by the caller, so use the local form here).
|
||||
for u in &state.updates {
|
||||
text.push_str(&format!(
|
||||
"{}\t{}\t{}\tstable\t{}\tflathub\t{}\t{}\tx86_64\n",
|
||||
u.reference, u.app, u.version, u.commit, u.installation, u.kind
|
||||
));
|
||||
text.push_str(&format!("{}\t{}\n", u.reference, u.version));
|
||||
}
|
||||
return Ok(ok_out(&text));
|
||||
}
|
||||
// The user installation is empty in these fixtures.
|
||||
if spec.args.iter().any(|a| a == "--user") {
|
||||
return Ok(ok_out(""));
|
||||
}
|
||||
// Verification: bare ref -> active commit.
|
||||
if spec.args.iter().any(|a| a == "list") {
|
||||
let state = self.state.lock().unwrap();
|
||||
let mut text = String::new();
|
||||
for (r, (_, commit)) in &state.installed {
|
||||
let bare = r
|
||||
.strip_prefix("app/")
|
||||
.or_else(|| r.strip_prefix("runtime/"))
|
||||
.unwrap_or(r);
|
||||
text.push_str(&format!("{bare}\t{commit}\n"));
|
||||
}
|
||||
return Ok(ok_out(&text));
|
||||
}
|
||||
if spec.args.iter().any(|a| a == "info") {
|
||||
let state = self.state.lock().unwrap();
|
||||
let identity = spec.args.last().cloned().unwrap_or_default();
|
||||
let (version, active) = state
|
||||
.installed
|
||||
.get(&identity)
|
||||
.cloned()
|
||||
.unwrap_or(("?".into(), "?".into()));
|
||||
let latest = state
|
||||
.updates
|
||||
.iter()
|
||||
.find(|u| u.reference == identity)
|
||||
.map(|u| u.commit.clone())
|
||||
.unwrap_or_else(|| active.clone());
|
||||
return Ok(ok_out(&format!(
|
||||
"Version: {version}\nActive commit: {active}\nLatest commit: {latest}\n"
|
||||
)));
|
||||
}
|
||||
if spec.args.iter().any(|a| a == "update") {
|
||||
let mut state = self.state.lock().unwrap();
|
||||
let target = spec.args.last().cloned().unwrap_or_default();
|
||||
|
|
@ -1856,31 +1925,6 @@ mod tests {
|
|||
}
|
||||
return Ok(ok_out("updated\n"));
|
||||
}
|
||||
if spec.args.iter().any(|a| a == "list") {
|
||||
let state = self.state.lock().unwrap();
|
||||
// Verification uses `--columns=ref,commit`.
|
||||
if spec.args.iter().any(|a| a.contains("ref,commit")) {
|
||||
let mut text = String::new();
|
||||
for (r, (_, commit)) in &state.installed {
|
||||
text.push_str(&format!("{r}\t{commit}\n"));
|
||||
}
|
||||
return Ok(ok_out(&text));
|
||||
}
|
||||
let mut text = String::new();
|
||||
for (r, (version, commit)) in &state.installed {
|
||||
let kind = if r.starts_with("runtime/") {
|
||||
"runtime"
|
||||
} else {
|
||||
"app"
|
||||
};
|
||||
let app = r.split('/').nth(1).unwrap_or("");
|
||||
text.push_str(&format!(
|
||||
"{r}\t{app}\t{version}\tstable\t{commit}\t{}\t{kind}\tx86_64\n",
|
||||
"system"
|
||||
));
|
||||
}
|
||||
return Ok(ok_out(&text));
|
||||
}
|
||||
Ok(ok_out(""))
|
||||
}
|
||||
}
|
||||
|
|
@ -1909,18 +1953,11 @@ mod tests {
|
|||
(exec, runner)
|
||||
}
|
||||
|
||||
fn fp_update(reference: &str, app: &str, version: &str, commit: &str) -> FpUpdate {
|
||||
fn fp_update(reference: &str, version: &str, commit: &str) -> FpUpdate {
|
||||
FpUpdate {
|
||||
reference: reference.into(),
|
||||
app: app.into(),
|
||||
version: version.into(),
|
||||
commit: commit.into(),
|
||||
installation: "system".into(),
|
||||
kind: if reference.starts_with("runtime/") {
|
||||
"runtime".into()
|
||||
} else {
|
||||
"app".into()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1938,22 +1975,15 @@ mod tests {
|
|||
#[test]
|
||||
fn flatpak_update_transactions_bind_full_refs_and_immutable_commits() {
|
||||
let ref_firefox = "app/org.mozilla.firefox/x86_64/stable";
|
||||
let updates = format!(
|
||||
"{ref_firefox}\torg.mozilla.firefox\t129\tstable\tNEWCOMMIT\tflathub\tsystem\tapp\tx86_64\n"
|
||||
);
|
||||
let installed = format!(
|
||||
"{ref_firefox}\torg.mozilla.firefox\t128\tstable\tOLDCOMMIT\tflathub\tsystem\tapp\tx86_64\n"
|
||||
);
|
||||
let txns = crate::actions::parse_flatpak_transactions(&updates, &installed);
|
||||
assert_eq!(txns.len(), 1);
|
||||
let t = &txns[0];
|
||||
assert_eq!(t.identity, ref_firefox);
|
||||
assert_eq!(t.previous_version.as_deref(), Some("128"));
|
||||
assert_eq!(t.next_version, "129");
|
||||
assert_eq!(t.previous_revision.as_deref(), Some("OLDCOMMIT"));
|
||||
assert_eq!(t.next_revision.as_deref(), Some("NEWCOMMIT"));
|
||||
assert_eq!(t.scope.as_deref(), Some("system"));
|
||||
assert!(t.exact);
|
||||
// updates: ref, application, version, branch, commit, origin, arch
|
||||
// `flatpak info` is the full-commit source; the ref keeps its
|
||||
// `app/`/`runtime/` type prefix, which `info` and `update` require.
|
||||
let info = "Version: 51.0\nActive commit: OLDCOMMIT\nLatest commit: NEWCOMMIT\n";
|
||||
let (version, active, latest) = crate::actions::parse_flatpak_info(info);
|
||||
assert_eq!(version.as_deref(), Some("51.0"));
|
||||
assert_eq!(active.as_deref(), Some("OLDCOMMIT"));
|
||||
assert_eq!(latest.as_deref(), Some("NEWCOMMIT"));
|
||||
assert!(ref_firefox.starts_with("app/"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
@ -1990,8 +2020,8 @@ mod tests {
|
|||
.insert(ref_b.into(), ("45.1".into(), "OLD_B".into()));
|
||||
let (exec, runner) = fp_exec(state);
|
||||
runner.set_updates(vec![
|
||||
fp_update(ref_a, "org.mozilla.firefox", "129", "NEW_A"),
|
||||
fp_update(ref_b, "org.gnome.Platform", "45.2", "NEW_B"),
|
||||
fp_update(ref_a, "129", "NEW_A"),
|
||||
fp_update(ref_b, "45.2", "NEW_B"),
|
||||
]);
|
||||
let plan = resolve_flatpak_plan(&exec);
|
||||
// The reviewed plan binds full refs, commits and the runtime.
|
||||
|
|
@ -2011,8 +2041,9 @@ mod tests {
|
|||
assert_eq!(calls.len(), 2);
|
||||
for call in &calls {
|
||||
assert!(call.iter().any(|a| a == "-y"));
|
||||
assert!(call.iter().any(|a| a == "--installation=system"));
|
||||
assert!(call.iter().any(|a| a == "--"));
|
||||
assert!(call.iter().any(|a| a == "--system"));
|
||||
assert!(call.iter().any(|a| a == "--noninteractive"));
|
||||
assert!(call.iter().any(|a| a.starts_with("--commit=")));
|
||||
}
|
||||
assert!(calls.iter().any(|c| c.last().unwrap() == ref_a));
|
||||
assert!(calls.iter().any(|c| c.last().unwrap() == ref_b));
|
||||
|
|
@ -2029,21 +2060,11 @@ mod tests {
|
|||
.installed
|
||||
.insert(reference.into(), ("128".into(), "OLD".into()));
|
||||
let (exec, runner) = fp_exec(state);
|
||||
runner.set_updates(vec![fp_update(
|
||||
reference,
|
||||
"org.mozilla.firefox",
|
||||
"129",
|
||||
"REVIEWED",
|
||||
)]);
|
||||
runner.set_updates(vec![fp_update(reference, "129", "REVIEWED")]);
|
||||
let plan = resolve_flatpak_plan(&exec);
|
||||
// The remote silently republishes a different commit with the same
|
||||
// human-readable version.
|
||||
runner.set_updates(vec![fp_update(
|
||||
reference,
|
||||
"org.mozilla.firefox",
|
||||
"129",
|
||||
"DIFFERENT",
|
||||
)]);
|
||||
runner.set_updates(vec![fp_update(reference, "129", "DIFFERENT")]);
|
||||
let err = apply_updates(
|
||||
&exec,
|
||||
Path::new(&exec.root),
|
||||
|
|
@ -2070,22 +2091,12 @@ mod tests {
|
|||
.installed
|
||||
.insert(reference.into(), ("128".into(), "OLD".into()));
|
||||
let (exec, runner) = fp_exec(state);
|
||||
runner.set_updates(vec![fp_update(
|
||||
reference,
|
||||
"org.mozilla.firefox",
|
||||
"129",
|
||||
"NEW",
|
||||
)]);
|
||||
runner.set_updates(vec![fp_update(reference, "129", "NEW")]);
|
||||
let plan = resolve_flatpak_plan(&exec);
|
||||
// A second update appears after review.
|
||||
runner.set_updates(vec![
|
||||
fp_update(reference, "org.mozilla.firefox", "129", "NEW"),
|
||||
fp_update(
|
||||
"app/org.gnome.Calc/x86_64/stable",
|
||||
"org.gnome.Calc",
|
||||
"46",
|
||||
"CALC",
|
||||
),
|
||||
fp_update(reference, "129", "NEW"),
|
||||
fp_update("app/org.gnome.Calc/x86_64/stable", "46", "CALC"),
|
||||
]);
|
||||
let err = apply_updates(
|
||||
&exec,
|
||||
|
|
@ -2113,12 +2124,7 @@ mod tests {
|
|||
.installed
|
||||
.insert(reference.into(), ("128".into(), "OLD".into()));
|
||||
let (exec, runner) = fp_exec(state);
|
||||
runner.set_updates(vec![fp_update(
|
||||
reference,
|
||||
"org.mozilla.firefox",
|
||||
"129",
|
||||
"NEW",
|
||||
)]);
|
||||
runner.set_updates(vec![fp_update(reference, "129", "NEW")]);
|
||||
let plan = resolve_flatpak_plan(&exec);
|
||||
let err = apply_updates(
|
||||
&exec,
|
||||
|
|
@ -2152,8 +2158,7 @@ mod tests {
|
|||
..Default::default()
|
||||
});
|
||||
runner.set_updates(vec![fp_update(
|
||||
"app/org.mozilla.firefox/x86_64/stable",
|
||||
"org.mozilla.firefox",
|
||||
"org.mozilla.firefox/x86_64/stable",
|
||||
"129",
|
||||
"NEW",
|
||||
)]);
|
||||
|
|
|
|||
|
|
@ -185,6 +185,16 @@ elif grep -qi "app-portage/portage-utils\|qdepends\|not installed" "$WORK/deps.e
|
|||
else
|
||||
report deps-legacy FAIL "rc=$? $(head -c 200 "$WORK/deps.err" | tr '\n' ' ')"
|
||||
fi
|
||||
# Regression: reverse dependencies of an installed library must include its
|
||||
# dependents (a self-reference bug previously reported none).
|
||||
"$SYS" --legacy --action \
|
||||
'{"action":"package_dependencies","package":"sys-libs/glibc","reverse":true}' \
|
||||
>"$WORK/rdeps.out" 2>"$WORK/rdeps.err"
|
||||
if grep -q "installed packages depending on sys-libs/glibc" "$WORK/rdeps.out"; then
|
||||
report rdeps-legacy PASS "$(head -c 140 "$WORK/rdeps.out" | tr '\n' ' ')"
|
||||
else
|
||||
report rdeps-legacy FAIL "$(head -c 200 "$WORK/rdeps.out$WORK/rdeps.err" | tr '\n' ' ')"
|
||||
fi
|
||||
|
||||
# A recognizable catalogue command without --legacy must enter the AI workflow
|
||||
# and must not run deterministically when no model is available.
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue