767c: per-space quota — early upload refusal, named error, handbook #804

Closed
opened 2026-09-28 03:58:30 +00:00 by Cordy · 2 comments
Owner

Slice 3 of #767, after #802/#803.

Instructions

  1. tus create pre-check: at POST (creation) the declared Upload-Length is known. Ask the storage stack for the room at the target (a new optional capability storage.Roomer{ Room(ctx, path) (int64, bool, error) }: scope resolves virtual → backend and forwards; quota answers from the same prefix logic). Refuse with 507 before any bytes are spooled.
  2. Named error:
    • 507 responses from the quota decorator carry a short machine-readable reason header, Cairn-Quota: space=<name>; limit=<bytes> or user; limit=….
    • The web upload surfaces " is full — limit" / "Your storage is full — limit" instead of "insufficient storage".
    • WebDAV keeps the plain 507 (clients show their own message).
  3. Handbook: docs/handbook/spaces-quota.md:
    • who sets caps (admins);
    • the 1 GiB default for new spaces (#800 to make it configurable);
    • which cap refuses first (instance → space or home; never both);
    • staleness (30 s cache, credited writes, overwrites netted);
    • the overshoot bound (one in-flight write);
    • copy/move behaviour.

Tests

  • Go: tus create 507 when Upload-Length > room; the Roomer through scope.
  • Node: the header-to-message mapping.
Slice 3 of #767, after #802/#803. ## Instructions 1. **tus create pre-check:** at `POST` (creation) the declared `Upload-Length` is known. Ask the storage stack for the room at the target (a new optional capability `storage.Roomer{ Room(ctx, path) (int64, bool, error) }`: scope resolves virtual → backend and forwards; quota answers from the same prefix logic). Refuse with **507** before any bytes are spooled. 2. **Named error:** - 507 responses from the quota decorator carry a short machine-readable reason header, `Cairn-Quota: space=<name>; limit=<bytes>` or `user; limit=…`. - The web upload surfaces "<Space> is full — <limit> limit" / "Your storage is full — <limit> limit" instead of "insufficient storage". - WebDAV keeps the plain 507 (clients show their own message). 3. **Handbook:** `docs/handbook/spaces-quota.md`: - who sets caps (admins); - the 1 GiB default for new spaces (#800 to make it configurable); - which cap refuses first (instance → space or home; never both); - staleness (30 s cache, credited writes, overwrites netted); - the overshoot bound (one in-flight write); - copy/move behaviour. ## Tests - Go: tus create 507 when Upload-Length > room; the Roomer through scope. - Node: the header-to-message mapping.
Cordy closed this issue 2026-09-28 16:20:16 +00:00
Author
Owner

Shipped in v0.6.304 (PR #812, CI green; go test ./... passes, web 296/296), live on both dogfoods with clean boots. Implements mockup rev2 as greenlit: all-or-nothing pre-check through GET /api/v1/quota/room, tus create refusal (507 before spooling), plain messages without dashes, a dismiss × on the error banner (7 s auto-hide kept), and the handbook page spaces-quota.md.

Deviation from the issue text: no Cairn-Quota response header. The web app asks the room endpoint on a refusal and builds the same message.

Live check pending (needs a sign-in after the redeploy).

Shipped in **v0.6.304** (PR #812, CI green; `go test ./...` passes, web 296/296), live on both dogfoods with clean boots. Implements mockup rev2 as greenlit: all-or-nothing pre-check through `GET /api/v1/quota/room`, tus create refusal (507 before spooling), plain messages without dashes, a dismiss × on the error banner (7 s auto-hide kept), and the handbook page `spaces-quota.md`. Deviation from the issue text: no `Cairn-Quota` response header. The web app asks the room endpoint on a refusal and builds the same message. Live check pending (needs a sign-in after the redeploy).
Author
Owner

Verified live on Bao (v0.6.304). Temporary 3.5 MiB limit on Fall 3 (≈3.3 MB used); no files were added or removed, and the limit was cleared afterwards.

  • GET /quota/room for Fall 3 → {scope: space, limit: 3670016, free: 204641}; for personal storage → uncapped.
  • uploadFiles with 2 × 150 KB (the real function): refused before sending with "The 2 selected files together are larger than the space left in Fall 3 (3.5 MB limit). Nothing was uploaded. Free up space or select fewer files to upload." The folder listing was unchanged.
  • Single 300 KB: "Fall 3 doesn't have enough space left for qa804-c.bin (3.5 MB limit). Free up space or ask an administrator for more." Nothing was uploaded.
  • Direct tus create with Upload-Length 20 MB → 507 (refused before spooling).
  • Banner: a real click on × hides it immediately and the status line keeps the text; left alone, it auto-hides after 7 s.
  • The 3 GiB limits on app-owned-space and test and the view prefs are unchanged.
**Verified live on Bao (v0.6.304).** Temporary 3.5 MiB limit on `Fall 3` (≈3.3 MB used); no files were added or removed, and the limit was cleared afterwards. - `GET /quota/room` for Fall 3 → `{scope: space, limit: 3670016, free: 204641}`; for personal storage → uncapped. - `uploadFiles` with **2 × 150 KB** (the real function): refused before sending with "The 2 selected files together are larger than the space left in Fall 3 (3.5 MB limit). Nothing was uploaded. Free up space or select fewer files to upload." The folder listing was unchanged. - **Single 300 KB:** "Fall 3 doesn't have enough space left for qa804-c.bin (3.5 MB limit). Free up space or ask an administrator for more." Nothing was uploaded. - **Direct tus create** with `Upload-Length` 20 MB → **507** (refused before spooling). - **Banner:** a real click on × hides it immediately and the status line keeps the text; left alone, it auto-hides after 7 s. - The 3 GiB limits on `app-owned-space` and `test` and the view prefs are unchanged.
Sign in to join this conversation.
No labels
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#804
No description provided.