Skip to content

Fix PR #66 review follow-ups: export --source, admin gates, upgrade selection, version compare - #67

Merged
Marc-André Moreau (mamoreau-devolutions) merged 1 commit into
masterfrom
claude/pr66-review-followups-b6dee2
Nov 6, 2026
Merged

Marc-André Moreau (mamoreau-devolutions) merged 1 commit into
masterfrom
claude/pr66-review-followups-b6dee2

Conversation

@mamoreau-devolutions

Copy link
Copy Markdown
Contributor

Summary

Follow-ups to #66 from an independent post-merge review. Each finding is fixed in both the Rust and C# implementations, with tests.

1. Rust export --source failed; export format incomplete (Rust + C#)

  • Problem: Rust do_export passed --source into ListQuery, and Repository::list rejects a source without a query, so pinget export -o f.json --source winget failed. Rust also wrote every package under one hard-coded winget source, so REST and msstore packages could not be re-imported.
  • Fix (Rust): port C# ExportPayloadBuilder.Build as build_export_payload: list with ListQuery::default(), skip rows without a source, filter --source case-insensitively, and group by source_name, taking the argument and type (Microsoft.Rest / Microsoft.PreIndexed.Package) from list_sources().
  • Fix (both): the export now carries $schema, CreationDate, WinGetVersion and SourceDetails.Identifier. C# PackagesExportPayload serialized the schema key as "Schema"; it is now [JsonPropertyName("$schema")], and CliExportPayloadTests assert the right key. Import still reads only SourceDetails.Name.
  • Tests: Rust tests for grouping, the source filter, and an export → import round trip. A C# test for the header fields and Identifier.

2. Admin-setting gates had holes (Rust + C#)

  • --manifest on uninstall: the LocalManifestFiles check now lives inside load_manifest_from_path_with_documents / LoadManifestFromPathWithDocuments. Every --manifest load goes through it: install, repair, download, and the uninstall paths (uninstall_request / DescribeUninstallTarget and resolve_uninstall_matches / ResolveUninstallMatches). No validate-style reader uses these loaders.
  • --ignore-security-hash checked too late: install_request / Install and repair / Repair now check InstallerHashOverride first, before the agreement prompt and dependency installs. The check also covers the already-installed no-op, --dependencies, and msstore paths. The fetch-time check stays, for download.
  • Tests (both): install with an msstore installer and an agreement, with and without dependencies-only, is refused and never prompts; repair by id and by manifest is refused; uninstall and repair with --manifest are refused without LocalManifestFiles.

3. Upgrade selection (Rust + C#)

  • C#: pinget upgrade <query> without --all upgraded every substring match. The new UpgradeTargetSelector ports Rust select_upgrade_targets: an exact match wins; otherwise the command fails with "Multiple installed packages found matching input criteria. Please refine the input." and lists the candidates.
  • Both: --id is compared only to the id, --name only to the name, and the query / --query to either. Before, upgrade --id Git picked Git.Git because its name is Git.
  • --moniker: now counts as a selector in do_install / doInstall, so upgrade --moniker X upgrades instead of only listing. ListMatch has no moniker, so a single row from the moniker-filtered list is upgraded, and several rows are an error.
  • Rust upgrade --version / -v: added. It goes on the install PackageQuery, not on ListQuery (which filters on the installed version).
  • Tests: in both implementations.

4. Version comparison drift (C#, small Rust hardening)

  • Problem: C# CompareVersionStrings split only on ./- and took a leading number from each part, so 1.0.0-rc2 vs 1.0.0-rc10 sorted differently from Rust.
  • Fix: C# now uses the same tokenizer as Rust tokenize_version: split on ., -, _ and +, and at digit/letter boundaries. It uses the same rules too: numbers compare numerically; a number or missing part (padded "0") ranks above text; text compares ASCII case-insensitively. The existing expectations still hold, including 1.0.0 > 1.0.0-rc1 and "< X".
  • Both: digit runs longer than u64 now compare by length instead of falling back to text in Rust or saturating in C#.
  • Tests: rc2 < rc10, preview2 < preview10, case, separators, leading zeros and long digit runs, in VersionCompareTests and the Rust compare_version test.

Validation

  • Rust format: cargo +nightly fmt --all is clean.
  • Rust lint: cargo clippy --workspace --tests -- -D warnings is clean.
  • Rust core tests: cargo test -p pinget-core --lib -- --test-threads=1 gives 264 passed.
  • Rust CLI tests: cargo test -p pinget-cli gives 33 + 2 passed.
  • C# format: dotnet format was run, and its unrelated Publisher rewrites were reverted.
  • C# build: dotnet build -c Release succeeds.
  • C# tests: Devolutions.Pinget.Core.Tests gives 361 passed and 1 skipped (a live network test).
  • Pester: 13/13 tests passed. The container is still reported as failed because its AfterAll cleanup hit Access is denied while deleting the temp test root, a local file lock that is unrelated to this change.

🤖 Generated with Claude Code

- export: Rust lists everything and groups by source (port of
  ExportPayloadBuilder), so `export --source` works and REST/msstore
  packages re-import. Both emit $schema, CreationDate, WinGetVersion and
  SourceDetails.Identifier; C# no longer writes "Schema".
- admin gates: LocalManifestFiles is enforced in the local-manifest
  loader, covering uninstall/repair --manifest. InstallerHashOverride is
  checked at the start of install and repair, before agreement prompts and
  dependency installs, and on no-op/msstore/dependencies-only paths.
- upgrade: C# ports select_upgrade_targets (exact match wins, otherwise
  an ambiguity error). --id/--name match only their own field; --moniker
  triggers an install; Rust gains upgrade --version/-v for the install.
- versions: C# CompareVersionStrings uses Rust's tokenizer and rules
  (rc2 < rc10); both compare long digit runs without overflow.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mamoreau-devolutions
Marc-André Moreau (mamoreau-devolutions) merged commit f987f79 into master Nov 6, 2026
14 checks passed
@mamoreau-devolutions
Marc-André Moreau (mamoreau-devolutions) deleted the claude/pr66-review-followups-b6dee2 branch November 6, 2026 17:11
Marc-André Moreau (mamoreau-devolutions) added a commit that referenced this pull request Nov 8, 2026
## Summary

This PR fixes 120 defects in 12 waves of 10, in both the Rust (`rust/`)
and C# (`dotnet/`) implementations, so they stay aligned. It follows
#66 and #67.

- **How the defects were found:** two rounds of read-only audits, six
areas per round. WinGet behaviour was checked against the upstream
`winget-cli` sources.
- **Where only one side was wrong:** it was changed to match the other,
and a test was added on both sides to pin the shared behaviour.
- **Findings dropped after checking WinGet,** because WinGet does the
same thing: strict `--architecture`, RequireExplicitUpgrade still
skipped with `--include-pinned`, and the portable-upgrade removal order.
- **Tests** live in new per-wave files: `wave{N}_tests.rs`,
`wave{N}_cli_tests.rs`, `wave{N}_com_tests.rs` and
`Wave{N}DefectTests.cs`. Each wave is self-contained to review.

| Wave | Area | Highlights |
|---|---|---|
| 1 | Installer execution |
`InstallerSuccessCodes`/`ExpectedReturnCodes` and 3010 (reboot-required)
handled<br>Uninstall opens the exact ARP hive and view<br>Download file
names taken from the URL are sanitized<br>A missing `InstallerSha256`
needs `--ignore-security-hash`<br>NSIS `/D=` is passed last and
unquoted<br>`--uninstall-previous` removes the installed match |
| 2 | Package sources | REST single-package search moves Id/Name/Moniker
into `Inclusions` (servers AND the `Filters` list)<br>`sources.json`
keys now match between Rust and C#<br>LIKE wildcards in user input are
escaped<br>`source update` continues past failures and saves the
successes |
| 3 | Pins, correlation, settings | Pinning pins block `upgrade
--all`<br>`pin add --version` creates a Gating pin, compared part by
part<br>Settings JSON may contain comments, trailing commas or a
BOM<br>MSIX family names drop the resource id |
| 4 | Manifests and selection | `--manifest <dir>` loads every file of a
multi-file manifest<br>The installer is selected before dependencies are
installed<br>Dependency cycles stop<br>`MinimumOSVersion` pads missing
parts with zeros<br>A leading `v` in a version is ignored |
| 5 | CLI | The `error` command uses WinGet's HRESULT table (from
`AppInstallerErrors.h`)<br>C# YAML output quotes values like `1.10` /
`true`<br>Error paths exit non-zero<br>`hash` streams the file and
prints lowercase<br>`--count` must be 1–1000 |
| 6 | Publisher | Correlation values in the index are lowercased<br>C#
canonical JSON is byte-identical to serde_json<br>BOMs are stripped
before parsing<br>WinGet's PackageIdentifier rule<br>Windows-unsafe
names (trailing dot or space, device names) are rejected |
| 7 | Portable installs and archives | Uninstall removes only tracked
files unless `--purge`<br>Upgrade keeps user files<br>Nested zip
installers actually run<br>System tools are launched from their absolute
System32 path<br>MSI repair uses `msiexec /f` |
| 8 | Manifest model | `download` checks agreements and
`DownloadCommandProhibited`<br>`Markets`, `UnsupportedOSArchitectures`
and `UpgradeBehavior` are applied<br>Dependency `MinimumVersion` and the
`Upgrade` switch are honoured<br>The downloaded manifest keeps every
installer field |
| 9 | Sources and HTTP | **Security:** paths from a source's index can
no longer escape the cache folder<br>**Security:** `source add` requires
`https://`<br>REST 204 and 404 responses are handled<br>Packaged-layout
tombstones and YAML round-trip |
| 10 | Installed packages, round 2 | `pinning.db` uses WinGet's
schema<br>Blocking and Gating pins still apply with
`--include-pinned`<br>ARP version fallbacks<br>ARM architecture
stripping in name normalization<br>Pin source filters are
case-insensitive |
| 11 | CLI, PowerShell, COM | WinGet's common flags are
accepted<br>`-Scope System` works<br>`RebootRequired` is
reported<br>`validate` checks content on both
sides<br>`Update-PingetPackage` continues after a failure |
| 12 | Publisher, round 2 | An expired or rotated signing certificate no
longer blocks publishing<br>An interrupted publish can be recovered
(`pendingCommit` marker)<br>ARP ranges and correlation use effective
installers<br>Overlapping ARP ranges fail the build |

The commit message has one line per fix for each wave.

## Behaviour changes for reviewers

- **Installer hashes:** a non-msstore manifest without `InstallerSha256`
now fails unless `--ignore-security-hash` is given, as in WinGet.
- **`source add`:**
  - `http://`, `ftp://` and local paths are refused.
- With no `--type`, it creates a `Microsoft.PreIndexed.Package` source
(WinGet's default) instead of REST.
- **Pins:**
- A plain pin now hides the package from `upgrade` and `upgrade --all`.
  - `pin add` records the installed version.
- **Exit codes:**
  - A named `upgrade` with no target exits 1.
- Several C# error paths and `source update` with partial failures exit
non-zero.
- **Portable packages:**
- A plain uninstall leaves untracked files in place and warns; `--purge`
removes everything.
- Machine-scope x86 portables use `Program Files (x86)` and WOW6432Node.
- **Installer switches:**
  - Generic `exe` installers no longer get a guessed `/S` or `/SILENT`.
  - 1641 is still a failure, as in WinGet.
- **Rust `sources.json`:** now written in camelCase. It still reads the
old snake_case keys, but older Rust builds cannot read the new files.
- **Publisher:**
  - Builds whose ARP ranges overlap across versions fail.
- A PackageIdentifier casing change is refused for an existing
destination.
  - The ownership marker can carry `pendingCommit`.
  - `contract.md` is updated.
- **Output:** C# `hash` prints lowercase. Tables are no longer truncated
when stdout is piped.

## Validation

- `cargo +nightly fmt --check` and `cargo clippy --workspace --tests -D
warnings`: clean.
- `cargo test --workspace`: all pass.
  - pinget-core 387
  - pinget-cli 63 + 2
  - pinget-publisher 51 + 26 conformance
  - pinget-com 2
- `dotnet build` (Release): succeeds.
- `dotnet test` Core.Tests: 650 passed, 1 skipped (live-network test).
- `dotnet test` Publisher.Tests: 158 passed.
- `RunTests.ps1`: 13 passed, 0 failed, but the run is reported as failed
because its AfterAll cleanup throws "Access is denied" (a module DLL is
still loaded). I did not check whether this also happens on master.
- `dotnet format --verify-no-changes`: reports only IDE0060
unused-parameter warnings, mostly on signatures unchanged from master.
- **Known flaky tests:**
- C# `InstallerCompletion_DoesNotWaitForDetachedChildProcess` failed
once under heavy load and passes when run alone.
- Some Rust tests that use a local HTTP stub hung once while several
builds ran in parallel, and passed on every rerun.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant