Skip to content

ADR-0008 — Patch placement in upstream's blob table

  • Status: Accepted
  • Date: 2026-11-12
  • Supersedes: none
  • Authors: project maintainers

Context

A patch's bytes have to live somewhere, and where they live decides what upstream's saver does when it meets one. The compatibility promise requires that upstream fail loudly on a thread we wrote, never return partial state. Two shapes were compared in a spike (patch-placement.md):

Patch bytes in checkpoint_blobs under our own type tag, plus a side table for the base pointer Patch bytes in a table of our own
Upstream reading our thread Raises on the unknown type tag (measured by tests/integration/test_patch_placement.py) Sees a missing channel and returns partial state
Database refuses a patch without its base Foreign key from the side table to the base row Foreign key from the patch table to the base row
Read One table for bytes, one small join Join of two blob tables

Decision

We will store patches in upstream's checkpoint_blobs under the type tag opc:zstd-patch:<type> and saver-compressed full copies under opc:zstd:<type>, with a side table opc_blob_patch whose foreign key to the base row is DEFERRABLE INITIALLY DEFERRED.

Alternatives considered

  • Our own patch table — rejected: upstream sees a missing channel and returns partial state, and none of its ON DELETE choices gives both a working delete and a safe prune (measured in the spike).
  • An immediate foreign key — rejected: upstream's delete_thread then fails on every thread that holds a patch (measured in the spike).

Consequences

  • The loud failure comes from the storage shape, not from a check someone can forget.
  • The database refuses a patch whose base is gone, which closes write rule 4 in architecture.md §4.
  • The deferred key makes deletes heavier; its cost is not yet measured on a quiet host (architecture.md §10).

References