Tearleads

pending_document_discoveries Client SQLite table

Untrusted listing candidates retained until signed placement can be checked.

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

Columns

  • container_idtext
    • not null

    Container the listing placed the document in: one row per container.

  • document_idtext
    • not null

    Id of the listed document.

  • access_epochinteger
    • not null

    Access epoch the listing claimed for the document, not yet verified.

  • generationinteger
    • not null

    Discovery request generation (document_discovery_sequence) that last staged the row. A listing from an older generation does not overwrite it.

  • input_jsontext
    • not null

    The listing candidate as JSON, narrowed to this container. Settling or deferring a candidate matches this text exactly, and a requiresCurrentHead flag in it forces a read of the current signed head instead of the cached one.

  • retry_atinteger
    • not null
    • default 0

    Epoch milliseconds before which the candidate is not checked again; 0 means due now. Reset to 0 when a listing changes the candidate.

  • attemptsinteger
    • not null
    • default 0

    Checks that found no usable signed head, capped at 8. The delay before retryAt starts at 15 minutes and doubles with each. Reset to 0 when a listing changes the candidate.

Keys and constraints

  • Primary key(container_id, document_id)

Indexes

  • pending_document_discoveries_document_idx(document_id, container_id)

    DDL

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

    CREATE TABLE IF NOT EXISTS "pending_document_discoveries" (
      "container_id" TEXT NOT NULL,
      "document_id" TEXT NOT NULL,
      "access_epoch" INTEGER NOT NULL,
      "generation" INTEGER NOT NULL,
      "input_json" TEXT NOT NULL,
      "retry_at" INTEGER NOT NULL DEFAULT 0,
      "attempts" INTEGER NOT NULL DEFAULT 0,
      PRIMARY KEY ("container_id", "document_id")
    );
    
    CREATE INDEX IF NOT EXISTS "pending_document_discoveries_document_idx" ON "pending_document_discoveries" ("document_id", "container_id");