Tearleads

access_events API Postgres table

Signed access events that drive access manifest history.

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

Description

An access event is the signed action record for a container/document access mutation: create, grant/share, revoke, rekey, move, document link, document unlink, and related access changes. The event header is signed by a user key, the event body is stored alongside it, and bodyHash binds that body to the signed header. Verified events are content-addressed by eventHash; access manifests reference that hash in their own signed state.

This table is append-only in practice. Inserts are idempotent by eventHash: replaying the same verified event is accepted, while conflicting data for an existing hash is rejected by the store.

Indexes:

  • eventId is unique to reject accidental reuse of a client event id.
  • eventHash is unique because it is the content address for verified events.
  • (objectKind, objectId) supports object-history and projection queries.
  • organizationId supports deleting an organization's events when it is purged.

Columns

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

    Surrogate database primary key. Domain identity is eventHash; eventId is also unique as a client-generated event identifier.

  • versioninteger
    • not null

    Access event wire format version.

  • event_idtext
    • not null

    Client-generated stable event id. It prevents reusing one logical event id for different content.

  • event_typetext
    • not null

    Kind of access mutation represented by the event.

  • object_kindtext
    • not null

    Kind of object the event mutates, for example container or document.

  • object_iduuid
    • not null

    Stable id of the object being mutated.

  • organization_iduuid
    • not null

    Organization boundary for the mutated object.

  • previous_manifest_hashtext
    • nullable

    Previous access manifest hash for successor events, or null for initial/create events.

  • dependency_manifest_hashesjsonb
    • not null

    Signed manifest dependencies needed to verify the event in context, such as parent/container path manifests or other authorization dependencies, in signed order. Readers load the array with its event; nothing looks events up by dependency.

  • body_hashtext
    • not null

    Hash of body; included in the signed event header.

  • bodyjsonb
    • not null

    Canonical JSON event body. The server stores it so it can return complete event/manifest bundles and regenerate projections.

  • event_hashtext
    • not null

    Hash of the normalized signed event header. This is the stable content address referenced by accessManifests.eventHash.

  • signer_user_iduuid
    • not null

    User id that signed the event.

  • signer_device_idtext
    • not null

    Client/device id included in the signed event header.

  • signer_key_fingerprinttext
    • not null

    User signing key fingerprint used to verify signature.

  • signaturetext
    • not null

    Signature over the normalized unsigned event header.

  • signed_attimestamp
    • not null

    Client-supplied timestamp included in the signed event header.

  • created_attimestamp
    • not null
    • default now()

    Server-side insertion timestamp. It is not part of the signed event or eventHash.

Indexes

  • access_events_event_id_idx(event_id)
    • unique
  • access_events_event_hash_idx(event_hash)
    • unique
  • access_events_object_idx(object_kind, object_id)
    • access_events_organization_idx(organization_id)