Tearleads

access_manifest_heads API Postgres table

Current access manifest pointer for each access-controlled object.

Declared in packages/api-shared/src/schema/accessManifests.ts

Description

accessManifests stores the full append-only history. This table stores the current head for each (objectKind, objectId) so callers can validate stale writes and resolve current access state without scanning history.

Head advancement is monotonic by epoch: storing a manifest with a higher epoch updates the head, replaying the same epoch/hash is idempotent, and a different manifest hash for the same epoch is treated as a conflict. Older epochs do not move the head backward.

Indexes:

  • (objectKind, objectId) is unique because each object has one current access head.
  • manifestHash supports reverse lookups from a manifest to the current-head rows that reference it.

Columns

  • iduuid
    • primary key
    • not null
    • default gen_random_uuid()

    Surrogate database primary key. Domain identity is (objectKind, objectId).

  • object_kindtext
    • not null

    Kind of object whose current access head this row tracks.

  • object_iduuid
    • not null

    Stable id of the object whose current access head this row tracks.

  • organization_iduuid
    • not null

    Organization boundary copied from the current manifest.

  • epochinteger
    • not null

    Epoch of the current access manifest.

  • manifest_hashtext
    • not null

    Current manifest hash for the object. Joins to accessManifests.manifestHash.

  • updated_attimestamp
    • not null
    • default now()

    Server-side timestamp for the latest head write.

Indexes

  • access_manifest_heads_object_idx(object_kind, object_id)
    • unique
  • access_manifest_heads_manifest_hash_idx(manifest_hash)