Tearleads

principal_history_prefixes Client SQLite table

A completed, locally authenticated prefix; never an application trust pin.

Declared in packages/client-sdk/src/data/sqlite/schema/principalHistoryEvidenceSchema.ts

Columns

  • scope_idtext
    • primary key
    • not null

    Evidence scope: hex SHA-256 of the organization, the principal's type and id, and the history context. One prefix per scope.

  • organization_idtext
    • not null

    Organization the principal history belongs to.

  • versioninteger
    • not null

    Policy version of the verified head the prefix reaches.

  • identity_bundle_formatinteger
    • not null
    • default 1

    Format of the principal identity data in this row. Always 1; restoring a backup row with any other value is refused.

  • head_jsontext
    • not null

    Canonical JSON of the verified head: principalType, principalId, version, keyEpoch, stateHash, and keyFingerprint.

  • current_jsontext
    • not null

    JSON of the head's current artifacts: currentState, currentPayload, currentProjection, currentGrants, and currentMemberEnvelopes. A public history, which carries no private artifacts, stores the canonical JSON of the newest cited authority group head, or null.

  • progresstext
    • not null

    Sealed verifier progress, v3.<iv>.<ciphertext> with base64 parts: AES-GCM under a key derived from the local key, bound to the row's scope, organization, version, headJson, and currentJson. Writers compare it to detect a concurrent replacement.

  • root_hashtext
    • nullable

    Hex root hash of the history index the prefix proves; the prefix keeps that principal_history_nodes row live. A disposable liveness hint; null holds no reference.

Indexes

  • principal_history_prefixes_key_fingerprint_idx(json_extract(CASE WHEN json_valid("current_json") THEN "current_json" END, '$.currentState.keyFingerprint'), "version" desc)
    • principal_history_prefixes_organization_idx(organization_id)

      DDL

      The statements the client runs to create this table and its indexes.

      CREATE TABLE IF NOT EXISTS "principal_history_prefixes" (
        "scope_id" TEXT NOT NULL PRIMARY KEY,
        "organization_id" TEXT NOT NULL,
        "version" INTEGER NOT NULL,
        "identity_bundle_format" INTEGER NOT NULL DEFAULT 1,
        "head_json" TEXT NOT NULL,
        "current_json" TEXT NOT NULL,
        "progress" TEXT NOT NULL,
        "root_hash" TEXT
      );
      
      CREATE INDEX IF NOT EXISTS "principal_history_prefixes_key_fingerprint_idx" ON "principal_history_prefixes" (json_extract(CASE WHEN json_valid("current_json") THEN "current_json" END, '$.currentState.keyFingerprint'), "version" desc);
      
      CREATE INDEX IF NOT EXISTS "principal_history_prefixes_organization_idx" ON "principal_history_prefixes" ("organization_id");