Text chat 72: fluxer-platform updater: feed client, resumable verified download, install targets and apply (#434) #467

Manually merged
charles merged 9 commits from textchat-72-platform-updater into textchat 2026-11-13 16:12:20 +00:00
Owner

Stacked on: origin/textchat-69-proto-update-manifest, origin/textchat-71-core-updater

What

fluxer-platform::update (update spec §5):

  • http: UpdateHttp::new(user_agent) (reqwest, 15 s connect / 60 s read, no cookies, no auth, redirects only to the first request's origin) and fetch_manifest(&feed_base, channel) (<base>/<channel>.json, 256 KiB cap, 404 = NotPublished, parsed with fluxer_proto::update::parse_manifest against the feed file URL); FEED_BASE.
  • download: Downloader::download(&asset, &dir, progress): .part + .part.meta (validator, asset hash/size), resume with Range + If-Range, 200/416 restart, never writes past the manifest size, SHA-256 after completion, fsync + rename + dir fsync, progress throttled to 10 Hz; DownloadError (no URL/path in any message), CancelToken, VerifyPolicy::Sha256Only.
  • target: InstallTarget, detect_install / detect_install_as(TargetOs, …) with injectable EnvSource and VelopackProbe, capability_for (kind/target matrix + minimum_version), staging_dir.
  • appimage::{apply, relaunch}, sweep::sweep_leftovers.
  • velopack: pure update_options, check_agrees, progress_to_bytes (tested on every OS); VelopackInstallProbe, startup_hook(); Windows-only VelopackUpdater::{open, download, pending, apply_on_exit}, PendingUpdate.
  • settings.rs: [update] channel / automatic (absent table = defaults, unknown channel = None with a warning, wrong type costs only that value).

Tests

FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci green locally (Linux). New: tests/update_feed.rs (7), tests/update_download.rs (11), tests/update_apply.rs (12), 3 settings tests, unit tests in update/velopack.rs and update/http.rs. All tests named in the plan are present. velopack_crate_version_matches_vpk_version runs on every OS (pure file reads), not only on Windows; not_installed_exe_probe_is_false is #[cfg(windows)].

Windows-only code: this PR adds code that compiles only on Windows (update/velopack.rs, mod imp). I could not build the real crate graph for Windows here (no MSVC headers for ring), so I checked velopack.rs with cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warnings -W clippy::pedantic in a scratch crate against velopack 1.2.161 (ureq TLS features off only for that check): clean. Please watch the Windows runner.

deny.toml changes

  • licence exception webpki-roots → CDLA-Permissive-2.0 (ureq via velopack)
  • advisory ignores: RUSTSEC-2024-0388 (derivative, unmaintained) and RUSTSEC-2026-0367, -0368, -0369, -0429 (zip 8.6.0 vulnerabilities in ZipArchive::extract/ZipStreamReader::extract; velopack 1.2.161 requires zip 8 and never calls those APIs, see src/bundle.rs). Not anticipated by the plan; follow-up #466 to bump vpk + crate together to a release on zip 9.

Deviations from the plan

  • FeedError::TooLarge added (oversize manifest); DownloadError::Cancelled added (cancel needs a variant).
  • StagedFile { path, size } instead of { path, version } (the asset carries no version; the caller knows it).
  • The cancel token is a Downloader field (downloader.cancel), keeping download's signature as specified.
  • detect_install_as(TargetOs, …) added so the Windows rules are tested on Linux; staging_dir_name, DownloadError::is_verification, ApplyError defined here.
  • startup_hook() and VelopackInstallProbe exist on every OS (no-op / false off Windows) so Text chat 74 needs no cfg.
  • HttpSource::new without options: velopack's HttpOptions only has a whole-request timeout, which would cut large downloads.
  • relaunch uses process_group(0) instead of setsid (no libc dependency) and strips APPIMAGE/APPDIR/ARGV0/OWD.
  • max_deltas = 10 (Velopack's default), so deltas work once the release job packs them.
  • Note for Text chat 74: velopack logs via the log crate including URLs with a query; keep target velopack at warn.

Closes #434

🤖 Generated with Claude Code

Stacked on: origin/textchat-69-proto-update-manifest, origin/textchat-71-core-updater ## What `fluxer-platform::update` (update spec §5): - `http`: `UpdateHttp::new(user_agent)` (reqwest, 15 s connect / 60 s read, no cookies, no auth, redirects only to the first request's origin) and `fetch_manifest(&feed_base, channel)` (`<base>/<channel>.json`, 256 KiB cap, 404 = `NotPublished`, parsed with `fluxer_proto::update::parse_manifest` against the feed file URL); `FEED_BASE`. - `download`: `Downloader::download(&asset, &dir, progress)`: `.part` + `.part.meta` (validator, asset hash/size), resume with `Range` + `If-Range`, 200/416 restart, never writes past the manifest size, SHA-256 after completion, fsync + rename + dir fsync, progress throttled to 10 Hz; `DownloadError` (no URL/path in any message), `CancelToken`, `VerifyPolicy::Sha256Only`. - `target`: `InstallTarget`, `detect_install` / `detect_install_as(TargetOs, …)` with injectable `EnvSource` and `VelopackProbe`, `capability_for` (kind/target matrix + `minimum_version`), `staging_dir`. - `appimage::{apply, relaunch}`, `sweep::sweep_leftovers`. - `velopack`: pure `update_options`, `check_agrees`, `progress_to_bytes` (tested on every OS); `VelopackInstallProbe`, `startup_hook()`; Windows-only `VelopackUpdater::{open, download, pending, apply_on_exit}`, `PendingUpdate`. - `settings.rs`: `[update] channel / automatic` (absent table = defaults, unknown channel = `None` with a warning, wrong type costs only that value). ## Tests `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` green locally (Linux). New: `tests/update_feed.rs` (7), `tests/update_download.rs` (11), `tests/update_apply.rs` (12), 3 settings tests, unit tests in `update/velopack.rs` and `update/http.rs`. All tests named in the plan are present. `velopack_crate_version_matches_vpk_version` runs on every OS (pure file reads), not only on Windows; `not_installed_exe_probe_is_false` is `#[cfg(windows)]`. **Windows-only code**: this PR adds code that compiles only on Windows (`update/velopack.rs`, `mod imp`). I could not build the real crate graph for Windows here (no MSVC headers for ring), so I checked `velopack.rs` with `cargo clippy --target x86_64-pc-windows-msvc --all-targets -- -D warnings -W clippy::pedantic` in a scratch crate against velopack 1.2.161 (ureq TLS features off only for that check): clean. Please watch the Windows runner. ## deny.toml changes - licence exception `webpki-roots` → `CDLA-Permissive-2.0` (ureq via velopack) - advisory ignores: `RUSTSEC-2024-0388` (derivative, unmaintained) and **`RUSTSEC-2026-0367`, `-0368`, `-0369`, `-0429`** (zip 8.6.0 vulnerabilities in `ZipArchive::extract`/`ZipStreamReader::extract`; velopack 1.2.161 requires zip 8 and never calls those APIs, see `src/bundle.rs`). Not anticipated by the plan; follow-up #466 to bump vpk + crate together to a release on zip 9. ## Deviations from the plan - `FeedError::TooLarge` added (oversize manifest); `DownloadError::Cancelled` added (cancel needs a variant). - `StagedFile { path, size }` instead of `{ path, version }` (the asset carries no version; the caller knows it). - The cancel token is a `Downloader` field (`downloader.cancel`), keeping `download`'s signature as specified. - `detect_install_as(TargetOs, …)` added so the Windows rules are tested on Linux; `staging_dir_name`, `DownloadError::is_verification`, `ApplyError` defined here. - `startup_hook()` and `VelopackInstallProbe` exist on every OS (no-op / false off Windows) so Text chat 74 needs no `cfg`. - `HttpSource::new` without options: velopack's `HttpOptions` only has a whole-request timeout, which would cut large downloads. - `relaunch` uses `process_group(0)` instead of `setsid` (no `libc` dependency) and strips `APPIMAGE/APPDIR/ARGV0/OWD`. - `max_deltas` = 10 (Velopack's default), so deltas work once the release job packs them. - Note for Text chat 74: velopack logs via the `log` crate including URLs with a query; keep target `velopack` at warn. Closes #434 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Refs #433

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
UpdateHttp (no auth, no cookies, same-origin redirects, 256 KiB manifest
cap) and Downloader (.part + .part.meta resume with Range/If-Range,
200-instead-of-206 restart, size cap, SHA-256 before rename, CancelToken).

Refs #434

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
detect_install / capability_for / staging_dir, the atomic AppImage swap
and relaunch, the staging sweep, and the [update] settings table.

Refs #434

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
velopack 1.2.161 (Windows only, pinned to VPK_VERSION, no default
features): options, version agreement and progress mapping on every OS;
VelopackUpdater (open, download, pending, apply_on_exit), the install
probe and the startup hook on Windows. deny.toml: webpki-roots licence
exception and the derivative/zip 8 advisory ignores (follow-up #466).

Refs #434

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Author
Owner

Independent review: Text chat 72 (platform updater)

Scope: git diff ba7a8ae..origin/textchat-72-platform-updater (3 commits, 970c27c).

Tests named by the plan: all 37 exist (feed 5, download 10, targets 9, apply 3, Velopack pure 3, Windows-only 2, settings 3), and they assert what the plan says: 2026.105.412 vs 2026.0105.412, 256 KiB cap, 404 → NotPublished, off-origin 302 refused / same-origin /attachments/… followed, no authorization/cookie, Range: bytes=<len>- + If-Range, size cap respected during the write, verification failures delete the file, cancel keeps .part, progress ≤ 10 Hz. velopack_crate_version_matches_vpk_version runs on every OS and passes (=1.2.161 = VPK_VERSION).

Interfaces: all present with the plan's signatures (UpdateHttp::new/fetch_manifest, FEED_BASE, Downloader::download, DownloadError (+Cancelled), CancelToken, VerifyPolicy field, InstallTarget, detect_install(&impl EnvSource, &Path, &dyn VelopackProbe), staging_dir, capability_for with the plan's kind/target matrix, appimage::{apply, relaunch}, sweep_leftovers, update_options/VelopackOptions, check_agrees, progress_to_bytes, VelopackUpdater::{open, download, pending, apply_on_exit}, startup_hook). Deviations (StagedFile { path, size }, cancel token as a Downloader field, FeedError::TooLarge, detect_install_as) don't break Task 74's listed consumption.
Velopack API checked against the 1.2.161 source: UpdateOptions fields, UpdateCheck variants, the exhaustive velopack::Error match (incl. the cfg(windows) Win32), UpdateManager: Clone, AsRef<VelopackAsset> and HttpSource::new all match. Velopack calls no zip extract() (only comments mention it), so the deny.toml claim holds.

Invariants: only fluxer-platform (plus workspace Cargo.toml, deny.toml, Cargo.lock) changed. No core/ui/emoji changes, no secrets, no URL/path in any error Display or log line of this crate. [update] round-trips, and a value of the wrong type costs only that value.

Findings

  1. minor: manual mode writes into the user's Downloads folder. download() deletes an existing <name> of the same size whose hash doesn't match, and the final rename overwrites any existing <name>. That only matters for a user file with exactly the asset's name, but a unique name (or skipping the delete outside the staging dir) would be safer.
  2. minor (test): changed_etag_restarts_from_zero checks only the final bytes. The body is the same on both sides, so it would also pass if the client wrongly resumed. Asserting that the last request got a 200 (or that the file was rewritten from offset 0) would make it bite.
  3. minor / Task 74: Velopack logs feed URLs with a localVersion/id/stagingId query through log at info. Task 74 must keep the velopack target at warn, as the README says, or the "no URL query in logs" rule breaks.
  4. note: velopack.rs's #[cfg(windows)] part was only cross-clippied by the implementer. The integrator must watch the Windows runner after merge.

Local gate: FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci in a fresh review worktree passed ("all steps passed"; fmt, clippy, deny with the new exceptions, tests).

Verdict: approve. No blocking findings.

## Independent review: Text chat 72 (platform updater) Scope: `git diff ba7a8ae..origin/textchat-72-platform-updater` (3 commits, 970c27c). **Tests named by the plan:** all 37 exist (feed 5, download 10, targets 9, apply 3, Velopack pure 3, Windows-only 2, settings 3), and they assert what the plan says: `2026.105.412` vs `2026.0105.412`, 256 KiB cap, 404 → `NotPublished`, off-origin 302 refused / same-origin `/attachments/…` followed, no `authorization`/`cookie`, `Range: bytes=<len>-` + `If-Range`, size cap respected during the write, verification failures delete the file, cancel keeps `.part`, progress ≤ 10 Hz. `velopack_crate_version_matches_vpk_version` runs on every OS and passes (`=1.2.161` = `VPK_VERSION`). **Interfaces:** all present with the plan's signatures (`UpdateHttp::new/fetch_manifest`, `FEED_BASE`, `Downloader::download`, `DownloadError` (+`Cancelled`), `CancelToken`, `VerifyPolicy` field, `InstallTarget`, `detect_install(&impl EnvSource, &Path, &dyn VelopackProbe)`, `staging_dir`, `capability_for` with the plan's kind/target matrix, `appimage::{apply, relaunch}`, `sweep_leftovers`, `update_options`/`VelopackOptions`, `check_agrees`, `progress_to_bytes`, `VelopackUpdater::{open, download, pending, apply_on_exit}`, `startup_hook`). Deviations (`StagedFile { path, size }`, cancel token as a `Downloader` field, `FeedError::TooLarge`, `detect_install_as`) don't break Task 74's listed consumption. Velopack API checked against the 1.2.161 source: `UpdateOptions` fields, `UpdateCheck` variants, the exhaustive `velopack::Error` match (incl. the cfg(windows) `Win32`), `UpdateManager: Clone`, `AsRef<VelopackAsset>` and `HttpSource::new` all match. Velopack calls no zip `extract()` (only comments mention it), so the deny.toml claim holds. **Invariants:** only `fluxer-platform` (plus workspace `Cargo.toml`, `deny.toml`, `Cargo.lock`) changed. No core/ui/emoji changes, no secrets, no URL/path in any error `Display` or log line of this crate. `[update]` round-trips, and a value of the wrong type costs only that value. **Findings** 1. *minor*: manual mode writes into the user's Downloads folder. `download()` deletes an existing `<name>` of the same size whose hash doesn't match, and the final rename overwrites any existing `<name>`. That only matters for a user file with exactly the asset's name, but a unique name (or skipping the delete outside the staging dir) would be safer. 2. *minor (test)*: `changed_etag_restarts_from_zero` checks only the final bytes. The body is the same on both sides, so it would also pass if the client wrongly resumed. Asserting that the last request got a 200 (or that the file was rewritten from offset 0) would make it bite. 3. *minor / Task 74*: Velopack logs feed URLs with a `localVersion`/`id`/`stagingId` query through `log` at info. Task 74 must keep the `velopack` target at warn, as the README says, or the "no URL query in logs" rule breaks. 4. *note*: `velopack.rs`'s `#[cfg(windows)]` part was only cross-clippied by the implementer. The integrator must watch the Windows runner after merge. **Local gate:** `FLUXER_SCREENSHOT_TESTS=1 cargo xtask ci` in a fresh review worktree passed ("all steps passed"; fmt, clippy, deny with the new exceptions, tests). **Verdict: approve.** No blocking findings.
charles manually merged commit 03ad7edbf4 into textchat 2026-11-13 16:12:20 +00:00
Sign in to join this conversation.
No description provided.