Tearleads

container_sync_watermarks Client SQLite table

Per-lane sync state for container data: the server cursor and the local freshness marker share one row per lane.

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

Description

Container sync is split into lanes, such as a parent-container child lane or a container-document membership lane. The cursor lets the next request resume without replaying the entire tree. The freshness marker records the last fully drained check independently of the cursor: empty server responses do not always carry a new watermark, but startup still needs to know that it recently checked the lane before polling again.

Indexes:

  • (laneKind, laneId) is the primary key and stores one row per lane.

Columns

  • lane_kindtext
    • not null

    Sync lane category, such as container_parent or container_documents. container_restoration stores the last reconciled access loss for a folder.

  • lane_idtext
    • not null

    Lane identity. Root parent sync uses root, child sync uses a parent-prefixed container id, and document lanes use the container id.

  • watermark_updated_attext
    • nullable

    Server updatedAt value for the stored watermark; null until a watermark is saved.

  • watermark_idtext
    • nullable

    Server id tie-breaker for the stored watermark; null exactly when watermarkUpdatedAt is.

  • cursor_formatinteger
    • not null
    • default 1

    SDK format that applied the saved watermark.

  • updated_attext
    • nullable

    Local timestamp for when the cursor was saved.

  • checked_attext
    • nullable

    Local timestamp for the most recent fully drained lane check; null until one completes. On a container_documents lane it marks the lane settled: an applied listing left no candidate pending. A lane without it still owes a listing, which the reconciler resumes at start (see documentLaneDiscovery.ts).

Keys and constraints

  • Primary key(lane_kind, lane_id)

DDL

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

CREATE TABLE IF NOT EXISTS "container_sync_watermarks" (
  "lane_kind" TEXT NOT NULL,
  "lane_id" TEXT NOT NULL,
  "watermark_updated_at" TEXT,
  "watermark_id" TEXT,
  "cursor_format" INTEGER NOT NULL DEFAULT 1,
  "updated_at" TEXT,
  "checked_at" TEXT,
  PRIMARY KEY ("lane_kind", "lane_id")
);