Batch A: version restore, replaced files keep history (fail closed), trash protection, OIDC confirm, WebDAV quota, change-feed epoch (v0.6.343) #910

Merged
Cordy merged 41 commits from batch-a into main 2026-10-15 16:08:08 +00:00
Owner

Closes #902, #906, #908, #907, #903. Covers the change-feed part of #904; the rest of #904 is batch B.

Spec: docs/superpowers/specs/2026-10-15-batch-a-design.md. Plan: docs/superpowers/plans/2026-10-15-batch-a.md. Every task went through TDD and a task review; the whole branch then had a final review and a docs accuracy review.

What changes

  • #902 version restore: works for every file you can edit (personal, space, renamed or aliased space, flat mode). It goes through the scoped store, so the hold, lock, quota, mint, audit, activity and journal all apply. The panel shows a specific message for each refusal.
  • #908:
    • Every overwrite now keeps the old content as a version, or is refused (version-not-saved: 503 + Retry-After: 30, or 507). This covers PUT, upload, public link, TUS, WOPI, MOVE, COPY, REST rename, restore and reports.
    • Autosaves: an autosave skips making a version only after an earlier autosave version by the same person inside the window. Empty files get no versions.
    • Mint path: versions are made by server-side copy, and S3 requests are retried.
    • TUS finalize: a refused finalize can be resumed and is never reported as complete.
    • Names: a name too long for its version key is refused up front.
    • Refused editor saves: Cairn writes a rescue copy and sends a bell item to the editor. Admins get a bell item and metrics.
    • MOVE/COPY onto a file keeps the replaced content, and the two version chains merge.
    • Deleted files restores to "{name} 2" when the name is taken.
    • Self-moves and moves or copies into the item's own subtree are refused. This also fixes a COPY that never finished on POSIX.
  • #906 trash: trash trees can only be changed through Deleted files (admins get 403 trash-managed). A person's own permanent delete respects legal holds. The restore target in the sidecar is validated (NFC-tolerant).
  • #907 OIDC: a sign-in whose auth_time is within 10 minutes counts as the confirmation. A silent SSO (acr "0") does not. New switch: auth.oidcAlwaysSignInAgain.
  • #903 WebDAV quota: figures are per bucket and only sent when the properties are named; nothing is sent when no limit is known. A quota refusal (507) carries the RFC 4331 body. The S3 "0 free" bug is fixed.
  • #904 change feed: cursors are hash-chained, so a cursor from before a restore from an older backup expires instead of skipping changes.

908-2: a version, not a trash entry

A file replaced by MOVE or COPY keeps its old content as a version, not as a trash entry:

  • It is what a PUT over the same file already does, so the rule reads "every overwrite mints", whatever the method.
  • The file still exists at its path, so its history belongs in Versions. A trash entry would say the file was deleted when it wasn't, and restoring it would conflict with the file now at that path.
  • Folders keep going to Deleted files under their own name.

Failing before the fix (908-1, branch before Task 3)

--- FAIL: TestOverwriteKeepsVersionEverySurface
    b.txt chain (newest first) = ["b0"], want the replaced content B first      (dav move, rest rename)
    b.txt chain (newest first) = ["a0"], want the replaced content B first      (dav move on posix replaced b's chain with a's)
--- FAIL: TestCopyOntoFileBringsNoHistory
    b.txt chain = ["b0"], want [B b0]
--- FAIL: TestReplacedCollectionInDeletedFiles   (POSIX: the replaced folder stayed hidden on disk, never in Deleted files)

Upgrade notes

See CHANGELOG v0.6.343:

  • Change-feed cursors expire once after the upgrade.
  • A backend ENOSPC now answers 507.
  • TUS refusals carry codes.
  • The first autosave after the upgrade makes one extra version.
  • A version restore is refused under a legal hold.
  • Keycloak caveats.

Live checks

Spec §9, on both dogfoods after the merge. Results will be posted on the issues.

Closes #902, #906, #908, #907, #903. Covers the change-feed part of #904; the rest of #904 is batch B. Spec: `docs/superpowers/specs/2026-10-15-batch-a-design.md`. Plan: `docs/superpowers/plans/2026-10-15-batch-a.md`. Every task went through TDD and a task review; the whole branch then had a final review and a docs accuracy review. ## What changes - **#902 version restore:** works for every file you can edit (personal, space, renamed or aliased space, flat mode). It goes through the scoped store, so the hold, lock, quota, mint, audit, activity and journal all apply. The panel shows a specific message for each refusal. - **#908:** - Every overwrite now keeps the old content as a version, or is refused (`version-not-saved`: 503 + `Retry-After: 30`, or 507). This covers PUT, upload, public link, TUS, WOPI, MOVE, COPY, REST rename, restore and reports. - **Autosaves:** an autosave skips making a version only after an earlier autosave version by the same person inside the window. Empty files get no versions. - **Mint path:** versions are made by server-side copy, and S3 requests are retried. - **TUS finalize:** a refused finalize can be resumed and is never reported as complete. - **Names:** a name too long for its version key is refused up front. - **Refused editor saves:** Cairn writes a rescue copy and sends a bell item to the editor. Admins get a bell item and metrics. - MOVE/COPY onto a file keeps the replaced content, and the two version chains merge. - Deleted files restores to "{name} 2" when the name is taken. - Self-moves and moves or copies into the item's own subtree are refused. This also fixes a COPY that never finished on POSIX. - **#906 trash:** trash trees can only be changed through Deleted files (admins get 403 `trash-managed`). A person's own permanent delete respects legal holds. The restore target in the sidecar is validated (NFC-tolerant). - **#907 OIDC:** a sign-in whose `auth_time` is within 10 minutes counts as the confirmation. A silent SSO (`acr` "0") does not. New switch: `auth.oidcAlwaysSignInAgain`. - **#903 WebDAV quota:** figures are per bucket and only sent when the properties are named; nothing is sent when no limit is known. A quota refusal (507) carries the RFC 4331 body. The S3 "0 free" bug is fixed. - **#904 change feed:** cursors are hash-chained, so a cursor from before a restore from an older backup expires instead of skipping changes. ## 908-2: a version, not a trash entry A file replaced by MOVE or COPY keeps its old content as a **version**, not as a trash entry: - It is what a PUT over the same file already does, so the rule reads "every overwrite mints", whatever the method. - The file still exists at its path, so its history belongs in Versions. A trash entry would say the file was deleted when it wasn't, and restoring it would conflict with the file now at that path. - Folders keep going to Deleted files under their own name. ## Failing before the fix (908-1, branch before Task 3) ``` --- FAIL: TestOverwriteKeepsVersionEverySurface b.txt chain (newest first) = ["b0"], want the replaced content B first (dav move, rest rename) b.txt chain (newest first) = ["a0"], want the replaced content B first (dav move on posix replaced b's chain with a's) --- FAIL: TestCopyOntoFileBringsNoHistory b.txt chain = ["b0"], want [B b0] --- FAIL: TestReplacedCollectionInDeletedFiles (POSIX: the replaced folder stayed hidden on disk, never in Deleted files) ``` ## Upgrade notes See CHANGELOG v0.6.343: - Change-feed cursors expire once after the upgrade. - A backend ENOSPC now answers 507. - TUS refusals carry codes. - The first autosave after the upgrade makes one extra version. - A version restore is refused under a legal hold. - Keycloak caveats. ## Live checks Spec §9, on both dogfoods after the merge. Results will be posted on the issues.
versions Rename/Copy return after a Stat when both paths clean to the
same path, and never merge a chain into itself; S3 Rename is a no-op when
source and destination resolve to the same key; WebDAV MOVE/COPY onto the
source answers 403 (RFC 4918 9.8.5, 9.9.4); REST rename onto itself is a
200 no-op that never reaches the store.
PUT, MOVE and COPY onto an existing file mint into the file's own chain
(the owner's, for a grant) through a write grant, a full and a
folder-limited device and with homes off; with version writes failing
they are refused 503 version-not-saved and nothing changes. No bug found.
WebDAV MOVE/COPY also compares the resolved backend paths, so a space's
old name or a case-different name for the same folder answers 403 instead
of staging the folder aside. A destination inside the source (virtual or
backend, on a / boundary) answers 403 on WebDAV and 400 on REST rename
and copy. posix and s3 Copy/Rename refuse it too (storage.ErrIntoItself,
an ErrInvalidPath): posix COPY used to recurse forever, s3 MOVE left the
folder inside itself. Adds a case-only rename regression test.
Cordy merged commit e03fb6cb6b into main 2026-10-15 16:08:08 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: Cordy/Cairn#910
No description provided.