# Decisions Fork-only. Append-only, newest first. Never edit or delete an entry - supersede it with a new one that links back. One entry per decision a future maintainer would otherwise have to reverse-engineer. No index: `grep -n '^## ' docs/DECISIONS.md` lists every entry. ## 2026-11-12 - Proton Drive's test server reports events as the real one does **Status:** accepted (supersedes ruling 8 of "Proton Drive follows volume events for change notification", below; plan 002 Task 6) **Context:** Ruling 8 described the fake server's events, to be checked live. The check (free account, `rclone test changenotify` at the 30 s floor, changes made with rclone and the official CLI 0.9.0) found: | Action | Events | |---|---| | upload (at commit), mkdir, server-side copy | Create (1); a copied folder: one per link | | new revision | Update (2) | | rename, move, trash (file or folder) | UpdateMetadata (3) | | permanent delete, empty trash | Delete (0), one per link removed | Link fields (`ParentLinkID`, `IsTrashed`) are the link's state when the events are read: a folder made and removed between polls comes back as a Create with `IsTrashed` set; a link deleted for good has no parent and isn't trashed. Pages hold 299 events; a 2783-event poll read 10 pages. **Decision:** The fake emits these types and reports Link fields at read time; events added with `InjectEvent` keep their own fields. The backend needed no change: only Delete is treated specially, so UpdateMetadata is handled like Update. `pollEvents` logs one DEBUG line per page (IDs and counts only). Live `FsChangeNotify` is ignored for `TestProtonDrive:`: fstests waits 27 s, below the 30 s floor. **Alternatives:** Keeping the fake's per-change snapshots (tests would pass on states the real server never reports). **Consequences:** A file trashed and emptied between polls is named at its cached path only; its Delete names no parent. ## 2026-11-12 - Proton Drive follows volume events for change notification **Status:** accepted (plan 002 rulings 1-9, as built in M5 Tasks 2-4; ruling 2 amended in the Task 4 review; ruling 9 and the idle cache added in Task 7) **Context:** The node cache never saw changes made by other clients, so a long `rclone mount` or `rclone serve` showed stale listings. Proton's volume events (`GET /drive/volumes/{volumeID}/events/latest` for the start cursor, `GET /drive/v2/volumes/{volumeID}/events/{eventID}` for pages) report changed nodes by ID only: no names, no paths, no client. **Decision:** 1. Own writes come back as events and are applied like any other (invalidate, re-fetch on next use); there is no attempt to recognise them. 2. `ChangeNotify` names a cached node at its old path (from the dircache), and at its new folder if it moved to a known one. A node that wasn't cached is reported at once as its parent folder, if that is in the dircache, else not at all, and at its old path if it is a folder the dircache holds. Its ID is then kept (at most 1000, oldest dropped) for the next two polls, which look it up in the node cache even when they bring no events; if it has been cached by then (an own upload or `Mkdir` caches its node a round trip after the server commits it, so its event can be applied first) it is reported at its exact path. No extra requests are made to name nodes; pending IDs are dropped on refresh, volume gone, `Shutdown` and when the last subscriber leaves. A folder renamed in place is reported as its old path plus its parent, since events carry no names. Nothing outside the `Fs` root is reported. 3. `Refresh` (cursor unknown or expired) clears the node cache, takes the returned `EventID` as the cursor and notifies `""` as a directory. The dircache is flushed but keeps the root folder's ID, not `ResetRoot`: after `ResetRoot` an `Fs` below the volume root would name later events relative to the volume root until something found its root again. `DirCacheFlush` keeps the root's ID for the same reason. 4. A Delete, or an Update that moves or trashes a folder, drops the node and everything cached below it (`invalidateTree`). Every applied batch flushes each changed folder's old path, and everything below it, from the dircache, with or without `ChangeNotify`. 5. Proton code 2501 on an events route (volume gone) stops polling for the life of the `Fs`, clears the cache, logs one ERROR and notifies subscribers as for a refresh. 6. The hidden option `events_min_interval` (default 30s) sets the floor; below 30s it is raised to 30s, with a NOTICE, when the endpoint host is `proton.me` or ends in `.proton.me` (trailing dot ignored) or can't be parsed. The interval rclone passes to `ChangeNotify` is used when longer. Each wait adds up to 1s of jitter; failures back off by Fibonacci multiples of the interval, capped at 10 minutes. 7. Each `Fs` polls on its own and keeps its own cache; the five cross-`Fs` cache tests stay ignored. 8. The fake server emits Create at upload commit, Update at a revision commit, rename, move and trash, Create on copy, and nothing for a draft's deletion; to be checked against the real server (plan 002 Task 6). 9. `Shutdown` stops the poller; using the `Fs` again restarts it from the cursor it had, an interval later, so a `Shutdown` and reuse never make two events requests within an interval. `Shutdown` returns once a poll in flight has ended (not its notifications), so nothing of it runs, or logs, afterwards. `Disconnect` stops it for good. 10. With nothing subscribed, a node cache unused (neither read nor filled; applying events doesn't count) for 10 minutes is cleared, which stops polling as an empty cache does; the next use refills it and polls from the kept cursor. The poller is a `time.AfterFunc` timer, polling only while the node cache holds anything or a `ChangeNotify` subscribes. Subscribers (and the dircache observer) are called only from the poller's goroutine, never from inside a user operation, which may hold dircache or VFS locks the subscriber takes. The first fill of an empty cache fetches the start cursor in the caller's path, so no change after the fill is missed; once that fetch has failed, later ones wait for the backoff instead. Events requests are paced but not retried by the pacer, so the poller's own backoff governs failures; a Retry-After isn't waited out in the request (nor given to the pacer, which would hold every call of the client) but delays the next poll. The data race fixed in `fstests` `FsChangeNotify` (commit `27e1a9c54`: its maps were written from the backend's goroutine and read from the test's without a lock) is a generic test fix, not Proton-specific. **Alternatives:** Recognising own writes (v2 events name no client); a fetch per unknown node to name it (extra requests per poll; under review); a cache shared across the `Fs` of one account (package state, which the spec rules out); `ResetRoot` on refresh (wrong paths below the volume root). **Consequences:** A mount sees other clients' changes within about one poll interval. A moved node is reported under its old name in its new folder, and an own upload's event applied before the node is cached is reported only as its folder. An `Fs` that is never shut down and holds anything in its cache polls until the cache has gone unused for 10 minutes. If the root folder is deleted and recreated by another client while the cursor is expired, the `Fs` keeps the old root ID. ## 2026-11-12 - Proton Drive maps only the app-version codes to "upgrade rclone" **Status:** accepted (handoff ruling 30). Supersedes spec 6.6's "2000/2028 ... to a fatal error telling the user to upgrade rclone". **Context:** 2000 is Proton's generic "requirements not met" code, which the server returns for a stale `OriginalHash` or `CurrentRevisionID`, as after a rename whose response was lost and which was resent. Mapping it to a fatal "upgrade rclone" error aborted whole runs over a rename that had succeeded. 2028 means a feature is disabled, rate-limited or blocked for abuse (`driveTypes.ts`). The code Proton returns for a rejected app version is 5003 ("You need to update this app", `coreTypes.ts`), and 5001 for a missing one (go-proton-api), neither of which was mapped. **Decision:** 5001 and 5003 are a fatal error telling the user to upgrade rclone. 2000 is a no-retry error keeping Proton's message. 2028 is retried through the pacer (honouring `Retry-After` when sent), then returned as it is. 2064 (malformed header) is left unmapped. **Alternatives:** Keeping the spec's mapping (false fatal errors); treating 2028 as a no-retry error (fails at once on rate limiting). **Consequences:** A feature Proton disables outright costs the low-level retries before its error is returned. ## 2026-11-12 - Proton Drive caps the Argon2 cost of node and share keys **Status:** accepted **Context:** go-crypto unlocks an Argon2-locked key with whatever parameters it carries, up to 2 TiB of memory and 255 passes, and runs the KDF before it can tell the passphrase is wrong. Node and share keys come from the server, or from other users' clients in shared folders, so one crafted key could crash every listing that includes it. **Decision:** Before unlocking a node or share key, every secret key packet's S2K is checked: Argon2 may use at most 4 passes, parallelism 8 and 2^17 KiB (128 MiB). gopenpgp and OpenPGP.js write 3, 4 and 64 MiB by default, and Proton's node keys use an iterated and salted S2K, whose one-byte count encoding already bounds it to 4 times the default. A key beyond the limits is an integrity error, making the node unreadable, and `ignore_signature_errors` doesn't change that. **Alternatives:** Refusing Argon2 on node keys outright (no genuine node key is known to use it, but a future client might); capping the iterated count below the encoding's maximum (could refuse genuine old keys for a bounded cost). **Consequences:** At most 128 MiB per unlock while a listing decrypts nodes. The account's own user keys aren't checked yet (`docs/TODO.md`). ## 2026-11-12 - Proton Drive refuses a file whose content key is unsigned **Status:** accepted (handoff ruling 29) **Context:** Anyone holding a file's public node key, which the server stores, can make a content key packet for it. Proton's SDK checks the content key packet's signature only when one is present. A server could then send its own content key without a signature: rclone would encrypt every update of the file with a key the server knows, and a ranged read (which can't check the manifest) would return whatever the server encrypted under it. **Decision:** A content key whose signature is missing or invalid makes the file unverified, as an unverified node key does (rulings 18 and 22): reads, full and ranged, and updates are refused unless `ignore_signature_errors` is set, when rclone logs an `ERROR` once per file and operation and goes ahead. The pre-2023 fallback to the account's other address keys still applies to a signature which is present but fails, as in the SDK. Integrity checks are never turned off. This is stricter than the SDK. **Alternatives:** Following the SDK (leaves the hole); a creation-date exemption for unsigned keys (the date is server-supplied, so it would exempt anything the server back-dates). **Consequences:** A genuine file whose content key was never signed, if any client ever wrote one, needs `ignore_signature_errors`. Every file in the golden fixtures, written by Proton's web app, CLI and the old library, has a signed content key. ## 2026-11-12 - Proton Drive deletes an upload's draft only on an explicit refusal **Status:** accepted. Supersedes the read-back half of handoff ruling 11 ("a draft is deleted only on positive proof it never committed", where a read showing the draft or the old revision counted as proof). **Context:** Proton's server can take a moment to show a commit (entry below). After a failed commit, one stale read showing the draft or the base revision made the client delete the draft, but the commit may have landed: `delete_multiple` against what is now an active file, or `DELETE .../revisions/{id}` against what is now the active revision. What the real server does with those is unconfirmed, so this could lose data. **Decision:** The draft is deleted only when the server explicitly refused the commit, meaning a 4xx `api.Error` (not 408) with a Proton code, on a single attempt that the pacer did not resend. A resend after 5xx/408/network/timeout makes the outcome unknown even if the final answer is a refusal, because an earlier attempt may have landed. No read-back decides deletion, and a refusal is not read back at all. Every other failure (5xx, network, timeout, cancelled ctx, resent attempts) returns `errUploadOutcomeUnknown` and deletes nothing. The read after such a failure can still turn it into a success when it shows the upload's revision. It retries through lag while the caller's ctx lives, and reads once, detached, if ctx is done. **Alternatives:** Requiring every read across the whole lag window to show the pre-commit state (a heuristic, as the lag length is unmeasured); the old single-read proof. **Consequences:** More drafts are left behind after ambiguous failures. The next upload of the name replaces them, otherwise they stay (see `docs/TODO.md`). A refused commit fails at once, with no reads. ## 2026-11-12 - Proton Drive uploads tolerate read-after-write lag, but never invent the result **Status:** accepted **Context:** Against the real service an upload whose commit succeeded failed because the node read back just after was missing or still a draft with an empty active revision (`errUploadSuperseded` with revision "", and "object not found"). The client read the node once and trusted it. **Decision:** After a commit the node is read again with backoff (100 ms doubling to 2 s, 8 reads, about 7 s) while it is missing, active with no revision, or - when the commit returned success - still as it was before the commit. `errUploadSuperseded` is kept for a non-empty revision which is neither ours nor the one we started from. If the lag outlasts the reads, the upload returns `errUploadUnconfirmed` (no low-level retry, as for `errUploadOutcomeUnknown`), deletes nothing, and a later sync pass finds the file. The same not-found retry covers a copy's read back and, with `enable_caching` off, a folder to write into (with it on, a folder the client made is cached, so a miss means it is gone). **Alternatives:** Returning success with a node built from what was committed (the caller then reads, moves or updates through it, and that needs the decrypted keys and server metadata the client would be inventing; a wrong node would be cached and acted on); retrying every read after any write (slows every genuine not-found). **Consequences:** With `enable_caching` off, a put into a folder deleted elsewhere takes about 7 s longer to fail. A lag longer than 7 s still fails the upload, now with an error saying it was committed. See `docs/TODO.md` for the read-after-write spots not yet tolerant. ## 2026-11-12 - Proton Drive golden captures fail closed **Status:** accepted; amends "Proton Drive golden fixtures are re-keyed captures" below **Context:** Review found the capture could copy account data into a fixture: an intended-recipient fingerprint of a key not being replaced (in the notes), and the user ID of a node key. It also reused `-remote`, so a mistyped `-run` would start the writing integration suite against the account. **Decision:** The capture names its folder with `-capture-remote` and refuses to run with `-remote` set. Every key written has the user ID `golden `; a node key whose user ID holds an email other than the account's or the generic ones Proton's clients use (`no-reply@proton.me`, `noreply@protonmail.com`) fails the capture. A signature by, or intended for, a key not being replaced fails the capture, and the error names no key. A salt notation is written only where the original had one (with a new salt). `TestGoldenFixtures` also walks every key, key packet and signature, inside encrypted messages too, and fails on any key ID, fingerprint or user ID not of the test keys. **Consequences:** What the committed fixtures expose, by design: with the test keys in `keys.json`, anyone can decrypt the captured names, extended attributes (as the client wrote them: check them for camera or location fields before committing), literal-packet file names and dates, folder hash keys (so whether a guessed name exists in those real folders can be tested) and file contents; and the address key's creation time is kept. Node passphrases and the account's keys are not exposed. ## 2026-11-12 - Proton Drive golden fixtures are re-keyed captures **Status:** accepted **Context:** Plan Task 21 asks for fixtures of nodes written by Proton's web app and official CLI. Captured as they are, they would carry the test account's keys, IDs and emails. The owner chose to re-encrypt them under keys made for the tests. **Decision:** `TestGoldenCapture` (`-capture DIR -capture-label NAME -remote NAME:PATH`) writes `backend/protondrive/testdata/golden/