S048: test file, release notes, packaging fixes, progress

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
astar76 2026-11-26 17:36:34 -06:00
commit 4d95d6d98c
8 changed files with 61 additions and 10 deletions

View file

@ -19,12 +19,12 @@ All 206, same size, same type; nodes differ only in mtime (nginx ETag = `"<size
When a reply's validators differ from the known ones but the total size is equal: do not fail. Check bytes instead: compare a sample of bytes already on disk with the same range from this reply (the existing `same_bytes` path in fetch.rs ~205; make the sample big enough, e.g. 64 KiB or what is there) before writing. Bytes equal → mark the task's link as a *farm* (validators unreliable): from then on compare size + byte samples only, send no `If-Range` (a Last-Modified `If-Range` makes other nodes answer 200 full), keep the first validators for display. Bytes differ, or size differs → `Changed` as today. A 200 to a range on a farm is `RangeIgnored`, not `Changed`. Also nginx-style ETags that differ only after the size part count as "maybe the same file" (still checked by bytes).
## Steps
- [ ] testserver: a farm mode (several "nodes" with the same bytes but different Last-Modified/ETag picked per request, nginx-style weak ETags), and a liar mode (same size, different bytes) — docs in the lib.rs header
- [ ] Engine: the rule above, in probe, parts and resume; the farm flag stored with the task (store migration) so a restart keeps it; parts on a farm still run in parallel
- [ ] Tests: farm download with 4 parts completes with the right hash; pause/restart/resume on a farm; liar same-size-different-bytes still fails with Changed and keeps what is there; If-Range not sent on a farm; unit tests for the ETag comparison
- [ ] Full workspace suite once (absolute TMPDIR), release build, hidden smoke against testserver farm on a spare port (the user's Medlar 0.1.1 runs on 17616: never stop it)
- [ ] `tools/package.sh` (0.1.1, rebuilds dist/), copy the four files to `~/Projects/Medlar/dist/` as well; notes in docs/releases/0.1.1.md
- [ ] Test file with Results, PROGRESS, tick INDEX, commit `S048: …`, `git push origin HEAD`
- [x] testserver: a farm mode (several "nodes" with the same bytes but different Last-Modified/ETag picked per request, nginx-style weak ETags), and a liar mode (same size, different bytes) — docs in the lib.rs header
- [x] Engine: the rule above, in probe, parts and resume; the farm flag stored with the task (store migration) so a restart keeps it; parts on a farm still run in parallel
- [x] Tests: farm download with 4 parts completes with the right hash; pause/restart/resume on a farm; liar same-size-different-bytes still fails with Changed and keeps what is there; If-Range not sent on a farm; unit tests for the ETag comparison
- [x] Full workspace suite once (absolute TMPDIR), release build, hidden smoke against testserver farm on a spare port (the user's Medlar 0.1.1 runs on 17616: never stop it)
- [x] `tools/package.sh` (0.1.1, rebuilds dist/), copy the four files to `~/Projects/Medlar/dist/` as well; notes in docs/releases/0.1.1.md
- [x] Test file with Results, PROGRESS, tick INDEX, commit `S048: …`, `git push origin HEAD`
## Pitfalls
Never contact romsgames.net or any real site in tests; testserver only. Never weaken the "two files are never mixed" guarantee.

View file

@ -68,7 +68,7 @@ Tracker: https://claude.ai/artifact/XouimfVJS6FYVKskGJ8s7H
- [x] [S045](10%20Distribution/S045-installer-arch.md) installer.sh and Arch package
- [x] [S046](10%20Distribution/S046-fixes-0.1.1.md) 0.1.1: names from the server, raise on arrival, copy in fields
- [ ] [S047](10%20Distribution/S047-close-to-tray-wayland.md) Close to tray that works on Wayland
- [ ] [S048](10%20Distribution/S048-server-farms.md) Servers behind a load balancer with different validators
- [x] [S048](10%20Distribution/S048-server-farms.md) Servers behind a load balancer with different validators
## Later (after version 1; not run by /orchestrate)

View file

@ -61,3 +61,4 @@
- D-059 — 2026-11-25 — A pasted link is looked at 0.5 s after the last change, without being kept; links of a batch are not. A list makes 10,000 downloads at most, the rest is counted and said. Patterns count in what the user writes, never in what programs and files give. — One-time links, servers and the user's patience. — 03, 05
- D-061 — 2026-11-25 — A task's keyring items are named `task:…`, one per site and login of what was added together, and deleted by the manager with the last task that has them. Folders by type and the recent ones are in `view.json`. A start time is a `Waiting` task with `Hold::Until`. — No secrets stay behind; no new setting. — 03, 04, 05
- D-071 — 2026-11-25 — What the list knows comes first in the dialog: the same link or checksum offers Resume or Show, a likely match offers Continue; `Same` goes on at once, all other verdicts are shown before a second click, `Different` leaves only a new file. The same name alone changes nothing: the new file gets a number. — Nothing is lost or loaded twice by accident. — 03, 05
- D-072 — 2026-11-26 — Server farms: a same-size HTTP reply with other validators is used only after its bytes equal a known 64 KiB sample; proven versions are kept per link (a liar node stays untrusted), a farm gets no If-Range, the first validators stay for display, `tasks.farm` is stored. FTP/SFTP stay strict. — S048

View file

@ -275,3 +275,8 @@ Seen: boxes were ticked together after the tests, against rule 3.
- Server name beats placeholder (`output.bin`), window raised on arrival, Ctrl+C/A in fields, readable speed (2 s mean, 1 s hold), setting "One bar / One per part", snail cap 8 kB/s (migrated) and a snail button.
- Version 0.1.1; `dist/` has tar.gz, AppImage, Arch package, SHA256SUMS-0.1.1; notes in `docs/releases/0.1.1.md`. Nothing in releases/.
- Suite passed except one mirror timing flake under load. Not done: tray tooltip smoothing, live Wayland raise, snail covers pause icon at 480x360.
## S048 — Server farms
- Same-size replies with other dates/tags (nginx `W/"size-mtime"`) are checked by 64 KiB of bytes before writing; proven versions per link, no If-Range on a farm, `tasks.farm` stored (migration 007). HTTP only; FTP keeps mtime strict.
- testserver `farm=N`, `liar=1`; `crates/core/tests/farm.rs`. Hidden smoke on a farm passed; dist/ rebuilt (0.1.1), copied to `~/Projects/Medlar/dist/`.
- Not done: `connector_flood_15` fails (connector untouched), CPU right after done 160 %, packaged builds not launched, no real farm.

View file

@ -21,8 +21,15 @@ Fixes and small changes after 0.1.0. Linux x86_64, glibc 2.44 or newer.
- **Snail mode.** The cap is now 8 kB/s (was 32 kB/s). A saved 32 kB/s moves to 8 kB/s; a value you changed is kept.
A round snail button at the bottom right of the main window turns it on and off; its tooltip shows the shortcut.
- **Server farms.** Links served by several servers behind one address (for example romsgames.net), which answer with
the same file but their own dates and tags, no longer fail with "File changed on the server". When a reply has other
dates but the same size, Medlar compares 64 KiB of bytes it already has, or that a known server sent, before writing
anything. The same bytes: the download goes on in parts and remembers the farm across restarts. Other bytes or another
size: it still stops with "File changed", and what is already downloaded is kept. Two files are never mixed.
## Known gaps
- Needs glibc 2.44 or newer; not tested on other systems.
- The snail button can cover the right edge of the last row in a very small window (480x360).
- The snail crawl motion and the raise on a real Wayland desktop were not watched live.
- yt-dlp and ffmpeg are not bundled.
- The farm fix was tested against a local server that imitates one, not against a real farm.

View file

@ -0,0 +1,37 @@
# S048 — Servers behind a load balancer with different validators: test file
Written by the worker that built it, run in the same session (Phase: test). Results say what was seen.
## Built
- `crates/core/src/http/mod.rs` · `Validators::maybe_same`: equal known sizes, nginx tags `W/"<size hex>-<mtime hex>"` agree on the size part; `Source::web` (HTTP only).
- `crates/core/src/http/fetch.rs` · `Farm` per link: versions proven to have the same bytes, one known 64 KiB sample; `send_range` sends no If-Range on a farm, 200 on a farm is `RangeIgnored`; `sure_range` and `prove` compare bytes before anything of an unsure reply is written.
- `crates/core/src/http/download.rs` · probe and resume accept a same-size reply (HTTP only), seed the sample from disk, store `task.farm` once proven.
- `crates/core/src/store/007.sql` · `tasks.farm` column; `crates/core/src/model.rs` `Task::farm`.
- `crates/testserver` · `farm=N` (N nodes in turn, own Last-Modified and nginx ETag) and `liar=1` (odd nodes other bytes, same size).
- Tests: `crates/core/tests/farm.rs`, unit `farm_versions` in `http/mod.rs`.
## Checks
| # | Risk | Do this | Expect | How | Result |
|---|---|---|---|---|---|
| 1 | HIGH | Download 8 MB from `farm=3`, throttle 1 MB/s per connection | Right SHA-256, at least 3 parts at different starts, `task.farm` true | integration (`a_farm_downloads_in_parts`) | pass (3 starts seen in most runs, 4 in some) |
| 2 | HIGH | Stop a farm download when every part has bytes, resume with the farm flag stored | Right hash, first ETag/Last-Modified kept, no `If-Range` sent | integration (`a_farm_goes_on_after_a_stop`) | fixed (proof flake: `prove` now ends when another part proved the version), then 15/15 |
| 3 | HIGH | Same as 2 with the flag cleared before resuming | Right hash; farm found again by bytes or not needed | integration | fixed, then pass |
| 4 | HIGH | Fresh download from `farm=2&liar=1` | `Changed` with `task.farm` false, or a file wholly of one version; never mixed | integration (`a_liar_of_the_same_size_is_another_file`) | pass |
| 5 | HIGH | Half an honest farm download, then switch to liar mode and resume | `Changed`; finished bytes untouched and equal to the right content | integration (`a_liar_on_the_way_keeps_what_is_there`) | pass |
| 6 | HIGH | Tags differing after the size part; other size; other size in tag; opaque tags; unknown size | maybe same / no / no / maybe / no | unit (`farm_versions`) | pass |
| 7 | HIGH | FTP file with a new mtime, same size, resumed | Still `Changed` (farm rule is HTTP only) | integration (`ftp_resumes`) | fixed (rule had leaked to FTP) |
| 8 | HIGH | Old store opened | Migration 007 adds `farm` = 0 | integration (store tests in suite) | pass |
| 9 | MED | Full workspace suite, absolute TMPDIR | All green | `cargo test --no-fail-fast` | 35 targets ok; `relink` pause/resume race passed on rerun; `control::connector_flood_15` fails (40 ok, 0 busy): connector untouched by S048, KNOWN BUG, timing of the rate gate |
| 10 | MED | Release build, hidden run (spare port 17998, testserver 18431, throwaway home), POST a 64 MB `farm=3` link | Done, hash equal to the plain file, `tasks.farm` = 1 | by hand (`tools/hidden.sh`) | pass: hash 0095b3fa…, farm 1, list shows Done |
| 11 | LOW | Same hidden run: CPU 1 s after done | 0 % when idle | by hand | not run cleanly: 160 % measured 1 s after done (graph still moving or finishing); idle not measured later |
| 12 | MED | `tools/package.sh` 0.1.1 | AppImage, tar.gz, Arch package, SHA256SUMS; checksums verify | by hand | pass (PKGBUILD tar.gz hash updated); the packaged builds were not launched |
## Needs
`crates/testserver` on 127.0.0.1 only. Spare ports 17998/18431 and a throwaway home for hidden runs. Never romsgames.net or any real site; never the user's Medlar on 17616 or `~/.local/share/medlar`.
## Doubts
- A sticky load balancer that never again shows the probe's node at a fresh start: parts are accepted only for proven versions, which needs one sure reply to compare against; PROOF_TRIES (12) may be too few on a big farm.
- Proof compares 64 KiB at one place. A same-size different file that matches there would be taken as the same; the plan accepts this.
- Without the stored flag a resumed task may finish without re-proving the farm (the flag then stays false).
- `connector_flood_15` and the 160 % CPU right after done were not investigated (outside the plan).
- Never tried against a real farm.

View file

@ -15,7 +15,7 @@ conflicts=('medlar')
options=('!strip' '!debug')
# MEDLAR_TARBALL points at a local copy (offline build); default is the release download.
source=("Medlar-$pkgver-Linux-x86_64.tar.gz::${MEDLAR_TARBALL:-$url/releases/download/v$pkgver/Medlar-$pkgver-Linux-x86_64.tar.gz}")
sha256sums=('e89db7fc43b55ec4dc5c919914ffb95702176561eb83a4037ccab21499a2d484')
sha256sums=('62fd4b310834650fe11597d846db37d2109e5aaf8b11c6d690143127335f4327')
package() {
cd "$srcdir/medlar-$pkgver"

View file

@ -2,7 +2,7 @@
# Builds dist/Medlar-<version>-Linux-x86_64.tar.gz, dist/Medlar-<version>-x86_64.AppImage, the Arch package
# dist/Medlar-<version>-arch-x86_64.pkg.tar.zst (makepkg from that tar.gz, offline) and dist/SHA256SUMS-<version>.
# ARCH_ONLY=1 only adds the Arch package to an existing dist/ (the other files keep their bytes).
# Nothing is downloaded. appimagetool comes from ~/Projects/Mulberry/dist and runs extracted (no FUSE, no runtime fetch).
# Nothing is downloaded. appimagetool comes from $APPIMAGETOOL, ~/Projects/Mulberry/dist or ~/.local/opt/build-tools and runs extracted (no FUSE, no runtime fetch).
# Not bundled: system libraries (only libc, libm, libgcc_s are linked), yt-dlp, ffmpeg. Never writes to releases/.
set -euo pipefail
root=$(cd "$(dirname "$0")/.." && pwd)
@ -52,7 +52,8 @@ fi
exec "$here/usr/bin/medlar" "$@"
RUN
chmod +x "$a/AppRun"
cp ~/Projects/Mulberry/dist/appimagetool "$work/appimagetool"
tool=${APPIMAGETOOL:-$(ls ~/Projects/Mulberry/dist/appimagetool ~/.local/opt/build-tools/appimagetool 2>/dev/null | head -1 || true)}
cp "${tool:?appimagetool not found}" "$work/appimagetool"
(cd "$work" && ./appimagetool --appimage-extract >/dev/null)
ARCH=x86_64 "$work/squashfs-root/AppRun" --no-appstream "$a" "$out/Medlar-$ver-x86_64.AppImage" >"$work/ait.log" 2>&1 || { tail -20 "$work/ait.log"; exit 1; }
arch_pkg