ADR-0129 — What a workspace stores is derived from the rows that hold it
Status: Accepted · Date: 2026-08-30 · Track: 010 phase 04, first slice
Context
Five kinds of artifact are now hosted and nothing counts a byte of them. The plan quota registry has fourteen axes and every one of them is a count of things; no deployment can answer "what does this workspace hold", so no plan could bound it even if 011 had priced one. Phase 04's first line item — the per-file cap as configuration — landed early with phase 02 (ADR-0125), because the alternative was a declared key nothing read. What remains starts here: the number itself.
Decision
- A resource records what it holds. Migration
000042addslinks.stored_bytes, written by the paths that WRITE bytes and by nothing else — the shape 006's last-editor column has (000035). It is deliberately not a column onUpdate: that path reads a struct back and writes it whole, so a number riding along on the struct would be cleared by every edit that said nothing about it, which is #393's defect and ADR-0096's, twice learned by this same table. - The number comes from the backend that did the writing.
SaveFilenow reports the bytes it actually wrote, because the store is the only party that knows what landed — and it is the only number that also counts a bundle's expansion, which is on disk beside the archive and which no size handed to the upload describes. A bundle is measured as archive + expansion, so the figure matches what deleting the resource frees. - The workspace total is DERIVED, summed over the rows that carry the tenant, one query for a whole list — 006's activity-feed rule one subject over (ADR-0112). A second running total kept beside the rows is a number that can disagree with them, and the disagreement is invisible until somebody audits a disk.
- It is exposed on the owner's own read —
GET /api/v1/workspaces, the call the workspace surface already makes, drawn there as a StudioStat. A number nothing shows would be this phase's version of what the whole track exists to refuse. A sum that fails leaves the figures at zero and still answers the list: a member who cannot see their workspaces because a total timed out is the worse answer. - An edit that stores no bytes rewrites no number. The recorder is called only where a document actually arrived; a zero written by an unrelated edit would be a workspace reporting that its disk had emptied.
What this does not decide
- The ladder. No quota axis is added here and no number is seeded: what a plan may store is the charter's Blocker 2, an owner decision, and 011 owns the tiers. This slice makes the figure exist so that bounding it is possible; bounding it is the next one, and an unset quota unlimits (004's fail-open), which stays the opposite of a capability's default deny.
- Freeing on delete. A resource's bytes go with its row today; what a delete should do about the store is the phase's third line item.
Consequences
- Rows written before the column existed read 0 until something rewrites their bytes. Measuring is a forward fact: a migration cannot stat an S3 bucket to reconstruct one, and a figure invented in SQL would be worse than a figure that admits it starts today. A backfill is an open item, not a silent guess.
- Generic uploads (
/api/v1/uploads) have no resource row and are not counted yet; they are the other half of phase 05's/uploads/*question. FileStorage.SaveFilegained a return value, so a backend that does not report what it wrote does not compile — the same reason the workspace handler takes its storage reader as a constructor parameter rather than a setter.
Source: docs/decisions/0129-what-a-workspace-stores-is-derived-from-the-rows-that-hold-it.md