Skip to content

feat(primitives): file stores #199

Closed

Description

@allisonmahmood

Part of #193. Implements spec §5 and the bytes routes of §11; decisions The tables surface (bounds), Publish for a patch repo § Stated and Tier 1 serving § Bytes.

What to build

  • In packages/api: the four files.* operation schemas; list answers { name, size, contentType, updatedAt } pages with a cursor.
  • Files in packages/primitives: a store is an inventory row (patchy.stores), provisioned by the same diff as tables (new store allowed, omission reported, nothing dropped). Bytes are immutable objects in the content store under files/<patchId>/<store>/<objectId>, keyed by patch and store, never by version; the index patchy.files (patch_id, store, name, object_id, size, content_type, sha256, updated_at) is the pointer. put writes a new object then upserts the row under per-name serialisation (a failed byte write leaves the previous row), get reads the row's object, list (prefix, keyset on name), delete removes the row, idempotent; objects no row names are swept by ticket 3's sweep. Names: /-separated segments, 1–512 bytes, no . or ..; per-file cap 20 MiB (too_large). Nothing under files/ is served at a URL; retrievals are no-store and authorised live.
  • The bytes routes from ticket 4 get their handlers with ticket 4's admission (PUT with exact Origin, GET with Sec-Fetch-Site: same-origin, both with the wire and principal headers). The ArrayBuffer transfer on the envelope is ticket 12's.
  • Rollback and version cleanup never touch stored files: a test.

Admitted at merge

Manifests with files.

Done when

  • A store provisions on publish; an omitted store is reported and its bytes stay; put then get round-trips 20 MiB and refuses one byte more; two concurrent puts of one name leave the row pointing at one object whose size and hash match it; a put racing a delete never leaves a dangling row; a name with .. is invalid_request; list pages by prefix; delete twice is fine.
  • Fetching with a session that cannot open the patch is refused; the response is no-store; mutations appear in the runtime log with store and name as the resource.

Surfaces

The wire, vocabulary (File store in Primitives), docs/product.md § Primitives (files).

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready-for-agent

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions