Client
oversqlite is the SQLite client SDK for the current bundle-based contract.
NewClient(...) installs the runtime and metadata tables, but it does not attach a user. The
startup flow is:
Open(ctx)Attach(ctx, userID)after sign-in- normal sync operations
oversqlite manages source identity internally. Host application code does not provide source ids
to Open(), does not rotate them manually, and does not provide replacement source ids to
Rebuild().
Authenticated sync requests still carry the runtime’s current source through
Oversync-Source-ID. Auth remains separately host-owned.
SQLite State
_sync_dirty_rows: one coalesced local dirty row per structured key_sync_snapshot_stage: rows staged during rebuild_sync_outbox_bundle: singleton frozen push snapshot state_sync_outbox_rows: rows belonging to that frozen snapshot_sync_push_stage: authoritative committed rows staged before final replay_sync_row_state: authoritative replicated row state for managed tables_sync_managed_tables: registry of managed tables whose triggers were installed byoversqlite_sync_source_state: per-source sequencing state and replacement lineage_sync_attachment_state: current source, binding state, bundle checkpoint, and rebuild gate_sync_operation_state: lifecycle and source-recovery state_sync_apply_state: trigger suppression state during authoritative local apply
Public Operations
Open(ctx) errorAttach(ctx, userID) (AttachResult, error)Detach(ctx) (DetachResult, error)PendingSyncStatus(ctx) (PendingSyncStatus, error)SyncStatus(ctx) (SyncStatus, error)SyncThenDetach(ctx) (SyncThenDetachResult, error)UninstallSync(ctx) errorPushPending(ctx) (PushReport, error)PullToStable(ctx) (RemoteSyncReport, error)Sync(ctx) (SyncReport, error)Rebuild(ctx) (RemoteSyncReport, error)LastBundleSeqSeen(ctx) (int64, error)SourceInfo(ctx) (SourceInfo, error)
Preconditions
Require no prior lifecycle step:
Open(ctx)
Require successful Open(ctx):
Attach(ctx, userID)PendingSyncStatus(ctx)SourceInfo(ctx)UninstallSync(ctx)
Require successful Open(ctx) plus durable attached local state:
Detach(ctx)
Require successful Open(ctx) plus successful Attach(ctx, userID):
PushPending(ctx)PullToStable(ctx)Sync(ctx)Rebuild(ctx)SyncStatus(ctx)LastBundleSeqSeen(ctx)SyncThenDetach(ctx)
Recovery
PullToStable()may rebuild from snapshots while keeping the current source- committed-remote replay pruned below the retained floor also uses keep-source rebuild behavior
- stale/out-of-order upload cases enter durable source-recovery-required mode
PushPending(),PullToStable(), andSync()fail closed while source recovery is activeRebuild(ctx)is the explicit recovery entry point- when source recovery is active,
Rebuild(ctx)internally chooses rebuild-plus-rotate and preserves frozen outbox intent across that recovery
Diagnostic Surface
SourceInfo(ctx) is debug-only. It exposes:
CurrentSourceIDRebuildRequiredSourceRecoveryRequiredSourceRecoveryReason
CurrentSourceID is opaque. Callers must not persist it externally or treat its format as part of
the host API contract.
Typed Preconditions And Results
OpenRequiredErrorAttachRequiredErrorDestructiveTransitionInProgressError
Normal lifecycle and sync branches such as retry-later attach, blocked detach, paused push/pull,
and already-at-target pull are reported as structured result values with error == nil.