Medlar/docs/DECISIONS.md
astar76 03590175ff S016: Add dialog, batch and duplicates
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-25 14:03:30 -06:00

63 lines
20 KiB
Markdown

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# Decisions
`D-NNN — date — decision — why — plans affected`. Never rewrite an entry; supersede it with a new one.
- D-001 — 2026-11-24 — The app is called Medlar (binary `medlar`). — User's choice. — all
- D-002 — 2026-11-24 — Linux only: AppImage and tar.gz. — User's choice. — all
- D-003 — 2026-11-24 — Own browser extension and own protocol; no AB Download Manager protocol. Nacre's existing "custom manager" JSON is accepted as it is, so Nacre needs no change. — User chose "own extension only"; Nacre already posts this format (`~/Projects/Nacre/src/net/dlm.rs`, `custom_body`). — 05
- D-004 — 2026-11-24 — No user stops during the work. The user is asked only before a release, and for things only they can do. — User's choice. — all
- D-005 — 2026-11-24 — Rust, egui/eframe 0.37 (glow), tokio. Motion starts from Damson's `src/motion.rs`, colour from Damson's `src/theme.rs`, shapes and the wavy line from Mulberry's `src/ui/shape.rs` and `src/ui/widgets.rs` (the user's own MIT code). — Same stack as the user's other apps. — all
- D-006 — 2026-11-24 — Default port 17616, 127.0.0.1 only. ABDM keeps 15151 on this PC and is left alone. — Free on this PC; no clash. — 05
- D-007 — 2026-11-24 — Torrent engine is librqbit if it passes a spike (features in FEATURES 5, loopback swarm); otherwise libtorrent-rasterbar through a small C++ bridge. — Pure Rust is easier to bundle. — 06
- D-008 — 2026-11-24 — The `/improve-animations` audit runs after the interface exists (category 08). Its "ask which findings" step is answered in advance: plan every HIGH and MEDIUM finding. Its plans go to `animation-plans/`. `AUDIT.md`, `PLAN-TEMPLATE.md` and `review-animations` are not installed with that skill, so the audit uses the eight categories named in its SKILL.md plus the motion rules in app-taste. — D-004. — 08
- D-009 — 2026-11-24 — `yt-dlp` and `ffmpeg` ship with the app; nothing tells the user to install something. — User's standing preference. — 06, 09
- D-010 — 2026-11-24 — No BitTorrent and no browser extension. The browser hands links straight to the local port; continuing from links and error recovery are first-class. Supersedes D-003's extension and D-007. — User's choice. — 02, 05
- D-011 — 2026-11-24 — Nothing is downloaded except Rust crates. Tests and builds use the yt-dlp and ffmpeg in /usr/bin and the appimagetool already in `~/Projects/Mulberry/dist`. Bundling yt-dlp and ffmpeg waits for the user; until then a missing tool shows a designed state. Supersedes D-009. — User's choice. — 06, 09
- D-012 — 2026-11-24 — Colours: "Follow desktop" and "Own colour" are equal choices in settings and first run; desktop is preselected when a scheme is found, otherwise own colour. — User answered "both". — 03
- D-013 — 2026-11-24 — 40 plans, reviewed by the user as a 43-plan table, then cut: torrents and extension out, error recovery (S007) and continuing from new links (S008) added. — User's answers. — all
- D-014 — 2026-11-24 — Work happens on the branch `claude/caveman-orchestrate-run-41d3a3`; the orchestrator fast-forwards `main` (local and `origin`) after each validated category. Sessions push only the branch. — User said yes to merging after each category. — all
- D-015 — 2026-11-24 — SQLite and settings hold only keyring item names; the store refuses cookie/authorization headers and `user:password@` in links, mirrors and proxies. Callers split them off first. Tokens in a link's query stay in the link. — Secrets must not sit in plain files. — 02, 04, 05
- D-016 — 2026-11-24 — Up to three plans run at once when they do not depend on each other and their "files touched" do not overlap; waiting sessions may be prepared out of INDEX order for this. All share one target folder, so cargo queues builds by itself. Replaces the "at most two" limit in ORCHESTRATOR.md. — User asked for three at once. — all
- D-017 — 2026-11-24 — HTTP client is reqwest 0.13.5 (pinned exactly), rustls with ring and the system certificates, HTTP/1.1 only, `Accept-Encoding: identity`, no decompression, no Referer of its own, its retries off, ≤ 10 redirects, 20 s connect and 30 s idle timeout, no proxy from the environment. Segments go to the final link; cookies and logins are dropped when its origin differs. — Docs of 0.13.5 checked: `http1_only`, `redirect::Policy`, `connect_timeout`, `read_timeout` (per read), `retry::never`. — 02, 05, 06
- D-018 — 2026-11-24 — HTTP/1.1 everywhere; no HTTP/2 or HTTP/3 (1.14), so reqwest's `http2` feature stays off. — Measured over TLS with netem, mean MB/s of HTTP/1.1 ×1, ×4, ×8 and HTTP/2 ×1: loopback 437, 950, 899, 306; 20 ms 8.7, 8.5, 8.9, 8.6; 20 ms with 0.1 % loss (15 runs) 7.6, 6.0, 7.3, 6.6; 50 ms with 0.5 % loss 1.7, 1.8, 3.2, 0.7. HTTP/2 never won. HTTP/3 was not measured: reqwest's needs an unstable build flag and another TLS stack (quinn). — 02
- D-019 — 2026-11-24 — A stored part with `end: None` means the server had no ranges: it starts over on resume unless the server has ranges by then. A part with an end never starts over by itself (`Error::NoResume`, `Error::Changed` instead). The record of parts is written only after `fdatasync` of the data it names. — No state loses finished bytes. — 02
- D-020 — 2026-11-25 — Connections start at 2 (or what the host stood, kept 7 days) and double, then go up by one, while the new ones bring ≥ 30 % of a fair share and more than twice the noise; measured 3 s after 1 s of settling. A failed try holds 30 s, doubling to 4 min; counts that were not proven are tried lower. Never below 2 without a refusal or cap. — The user's line is slow: a connection has to prove itself. — 02
- D-021 — 2026-11-25 — A refusal (429, 503, any other 4xx, no connection, 200 for a range) while others deliver lowers the count for 10 min for all downloads of that host, and is remembered; alone, 4xx and 200 are final. New requests per host: 16 at once, then 4/s. Idle connections close after 0.5 s; a host that refused gets 0.3 s to notice a closed one. A part that waits after a failure keeps its place, so that failures cause no further cuts. — Must not look like abuse. — 02
- D-022 — 2026-11-25 — A failed part never ends the download while others deliver. It ends after 5 failures in a row without a byte (1 s, doubling, half of it chance, ≤ 60 s) with nothing else delivering, or when Retry-After is longer than 60 s. Changed, disk, store, encoding and contradicting replies end it at once. Longer waits and task retries are S007's. — FEATURES 1.6. — 02
- D-026 — 2026-11-25 — Amounts on screen count in thousands: B, kB, MB, GB, one decimal, and speeds as the same per second (`ui::odometer::{amount, rate}`). — It is what the units mean, and disks and lines are sold in them. No setting until someone asks. — 03, 04
- D-027 — 2026-11-25 — Wave height and travel follow the logarithm of the bytes per second, from 0 to 64 MiB/s, not a share of the limit or of the fastest so far. At 0 B/s, when paused, and with motion off or reduced the bar is flat and draws no frames. — The same speed always looks the same, and a slow line still moves visibly. — 03
- D-028 — 2026-11-25 — Progress widgets keep their springs per `Id` and start in place when they were not drawn in the frame before, so scrolling shows no motion and the tick plays only for someone who saw the download finish. A list row's id comes from the task's id, not its position. — 03
- D-023 — 2026-11-25 — Menus are Medlar's own (`ui::menu`), not egui's: one open at a time, own keyboard. Dialogs never close by a click on the scrim (the side sheet does); Enter does the main action unless a button has the focus; dangerous questions start on Cancel. Elevated buttons have no shadow. — egui's arrow keys leave its menus; typed links must not be lost. — 03 and later
- D-029 — 2026-11-25 — Running set: at most `max_active`, one place per connection a host gives. Rank: forced start (latest first), priority, running before waiting, queue position, position. A running download gives way to a higher priority, a forced start or an "only", never to a better position; one that can't resume never gives way. Stop = pause and go last. Remove can be undone for 60 s and until the program ends; at the next start it is final. Closing turns running into queued, so that they go on at the next start. — FEATURES 1.1, 2.3, 7.3. — 02, 04, 05
- D-030 — 2026-11-25 — A file name belongs to the unfinished task that has it recorded, even when its file is empty or missing. Looking for a free name and taking it happens under `disk::names()`. Tasks are changed through `Store::edit_task` (one transaction), never read, changed and saved. — The command fuzz mixed up the files of two tasks without this. — 02, 06
- D-031 — 2026-11-25 — Retries of a task: 10 failures in a row without a new byte (setting, per task, 0 is forever), waits by kind (docs/RECOVERY.md), Retry-After honoured up to 24 h. Three network, busy or server failures of a host in a row shut it for all for 30 s, doubling to 10 min; then one download tries. Start and Resume by the user go past it. 4xx are never repeated blindly. — FEATURES 1.6, 1.17. — 02, 04
- D-032 — 2026-11-25 — Offline is only believed after a failure: downloads are always tried first, so local servers work without a network. D-Bus is `Bus::Off` by default; the app turns it on. zbus without its tokio feature. Downloads that can't resume are not stopped for sleep or a network change. — Never touch the real system in tests; lose no bytes. — 02, 03, 05
- D-033 — 2026-11-25 — A started download whose file or folder is gone waits for it (`Error::Missing`) and is never started over, nor its folder made again, by itself. A changed file fails and asks; keeping both leaves the old task as it is and adds a new one. — A pulled-out drive looks like a missing folder. — 02, 04
- D-034 — 2026-11-25 — A new link is judged by size, versions and bytes: the last 4096 bytes of up to 32 finished ranges, the first ones and 8 places in between. Equal samples with a matching tag or date are "same", without are "probably same". Another tag or date counts against it only on the same server, and a differing tag with the same date decides nothing. — Two servers name the same file differently. — 02, 04, 05
- D-035 — 2026-11-25 — Without ranges a new task starts over and the old one keeps its file until the new one is whole (`tasks.replaces`), then goes to the bin. — Nothing is lost if the new link fails too. — 02, 04
- D-036 — 2026-11-25 — Other programs' unfinished files are copied, never moved or written. Zero-filled stretches count only where the server has zeros too. — The browser may still have the file open, and space is often taken before it is filled. — 02, 04, 05
- D-037 — 2026-11-25 — Secrets go to the Secret Service over zbus, with the unencrypted ("plain") session and no keyring crate. Without a keyring, or when it stays locked, they are kept in memory until Medlar closes, and that is said. — Whoever could read the user's bus may ask for the secrets anyway; no new dependency. — 02, 04, 05
- D-038 — 2026-11-25 — Redirects are followed by Medlar, ≤ 10, each with its own rules, proxy and cookies. To another site (scheme, host or port; http to https on the standard ports is the same) only User-Agent, Accept, Accept-Language and Referer go along. Logins are sent only when asked for, never from a link with TLS to one without; a site's login needs a pattern with one owner. — reqwest keeps unknown headers across hosts. — 02, 05, 06
- D-039 — 2026-11-25 — Site rules and the app's proxy are settings. Proxy: the download's, else the site's, else the bypass list, else the app's (`system` at first: environment, then the desktop's portal). A proxy that makes no sense or fails is never gone around; SOCKS5 always resolves names itself. A certificate exception is one SHA-256 for one exact host. — No leaks. Replaces "no proxy from the environment" of D-017 for the app; plain `http::client` still has none. — 02, 04
- D-040 — 2026-11-25 — Rows have fixed heights and places worked out at once; motion is an offset that springs back (FLIP, `list::flow`). Nothing moves for over 30 changes, for 0.5 s after the keyboard, or when the width changes. New numbers alone patch rows in place. — 10,000 rows, 1.1 and 9.8 at once. — 03, 04
- D-041 — 2026-11-25 — A row is dragged by its handle only, and only in queue order within its heading; a drag anywhere else is the lasso. Dropping gives it the neighbours' queue and a position between theirs. — Full-width rows leave no empty ground for a lasso. — 03, 04
- D-042 — 2026-11-25 — Removing never asks: Del keeps files, Shift+Del bins them, both undone from the toast. Status in the rail is one of six; queue, tag, type, host and day narrow it further and show as chips. — Undo is better than a question. — 03, 05
- D-043 — 2026-11-25 — Weights lowest to highest: 1, 2, 4, 8, 16. Under a limit, bytes go to the download furthest behind its weighted share; without one, only connections are shared by weight. A host's connections (and all together) go by weight among the downloads that can use them, each gets one before any gets two, and the newest ones over a share are ended. Never more downloads run than connections exist. — No starvation, nothing unused — 04
- D-044 — 2026-11-25 — Bytes are limited after the read: pieces of 20 ms (at least 1 KiB), one chunk read ahead, then the socket is left full. reqwest gives no way to a smaller socket buffer. Under 8 KiB/s per connection fewer are used; while a limit holds a download back, connection counts are not tried out or remembered, and slow ones not replaced. The idle timeout is Medlar's own and counts only while bytes are waited for. — reqwest's counts while a limit holds bytes, too — 02, 04
- D-045 — 2026-11-25 — "Only this one" is a priority: the rest go back in line and come back first when it ends or is changed, those stopped last before others (not across a restart). Snail is a fourth mode; `before_snail` is the one to go back to. — Nothing of the others is changed, so nothing has to be restored — 04, 07
- D-046 — 2026-11-25 — All settings are one table (`views/settings/rows.rs`), each row naming the `Settings` keys it changes. Undo puts a page's keys back to what they were when the settings were opened. Changes count in the same frame and are written 0.4 s after the last one, beside the window. Pages without rows are hidden. — Later plans only add rows; an empty page or a switch that does nothing helps nobody. — all
- D-047 — 2026-11-25 — Every action has one shortcut, with exactly its modifiers. Only those that differ from the usual ones are kept (`shortcuts`), empty for none. Two actions with the same keys are a conflict wherever they count. Arrows, Tab, Esc, paste, cut and undo can't be shortcuts; plain keys only in the list. — Anywhere and list are heard at once — 03, 05
- D-048 — 2026-11-25 — First run is while `desktop_colors` is None; finishing or skipping decides it (the desktop's when it has a scheme). The palette has no motion and offers settings and downloads only once something is typed. Backups are the settings file under a dated name in the data folder, without logins. — D-012; instant at 10,000 downloads — 03, 08
- D-049 — 2026-11-25 — FTP and SFTP answer like a HTTP server (`transport`): `Source` gives a made-up reply with 206, Content-Range and Last-Modified, so parts, resume, limits and relinking are the same. FTP is Medlar's own, not suppaftp: that one gives TLS errors as text, can't go through a proxy with TLS from the start and brings a date library. Passive and binary only; the address in a PASV answer is ignored. `ftps` is TLS from the start, `ftpes` AUTH TLS; no silent fall back to plain. A path counts from the login's folder, `%2F` in front from the root. A refused login that worked a moment ago means too many connections.
- D-050 — 2026-11-25 — One listing type for all (`listing::Entry`), with the link made of the raw bytes of the name; entries whose names could leave their folder are dropped. SFTP is russh with ring (no aws-lc-rs) and russh-sftp: a connection per part, 2 to 64 reads of 32 KiB under way, more only when they come too late.
- D-051 — 2026-11-25 — Keys of SSH servers are in Medlar's own file (`Paths::known_hosts`), never in `~/.ssh`. An unknown or changed key stops the download before any login is sent; a key of another kind than the known one counts as changed. Only `host_keys.accept` adds one, and it replaces the server's old ones. With a key file, the login's password is its passphrase and is not sent to the server if it unlocked the key.
- D-052 — 2026-11-25 — From here on the plans run on the branch `claude/orchestrate-0ad55c` (a new worktree); the rest of D-014 holds: sessions push only the branch, the orchestrator fast-forwards `main` after each validated category. — New orchestrator session. — all
- D-053 — 2026-11-25 — A mirror is used only after S008's comparison with what is here (verdict same or probably same, at least 16 KiB here) and, where no version proves it, after two more places that the base and the mirror must both have. Whoever is caught with other bytes is dropped and all it gave comes again; between the base and a mirror the mirror is the liar. If the first link fails, the next one that passes becomes the base. Each connection goes to the server that brings the most per connection, an untried one first; a connection four times slower than another server's moves there. — A wrong byte costs more than a slow start — 02, 06
- D-054 — 2026-11-25 — Files are compared under their unfinished name, before they get their own, in the state `checking` (no place in the queue); `Checking` may go back to `Running` (pieces) and, for a file that was done before, to `Done`, which is no new finish. `Task::verified` holds what the file matched, so a new checksum counts as open by itself. The whole file's hash counts more than its pieces'. — A bad file never appears finished — 03, 05
- D-055 — 2026-11-25 — Headers give mirrors only with a `Digest` or `Repr-Digest` (RFC 6249); they and a linked metalink fill only what the task doesn't have. Sidecars are looked for only when asked. Metalinks are read by quick-xml within limits; a document type or an unknown entity refuses the file. — No extra requests, nothing to expand — 02, 06
- D-056 — 2026-11-25 — Streams are kept as pieces in one unfinished file with a record before each (`stream::tape`), and joined by ffmpeg with `-c copy` from sockets of this user: mp4 (m4a for sound alone) or what the name asks for, mkv where that can't hold it. — One file moves and bins like any other; needs twice, not three times the space. — 02, 06
- D-057 — 2026-11-25 — ffmpeg never opens links of lists: Medlar fetches all of HLS and DASH itself (proxy, logins, limits), and ffmpeg may open only `unix` sockets and known formats. For RTSP and MMS it connects itself, never when a proxy is set; logins go through its standard input. — Lists come from strangers; arguments are seen by all. — 02, 06
- D-058 — 2026-11-25 — Any sign of protection refuses the whole stream (`ErrorKind::Drm`): `ContentProtection`, keys other than AES-128 with `identity`, protected boxes in the first piece. — CLAUDE.md 4. — 02, 06
- 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