go-oversync

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:

  1. Open(ctx)
  2. Attach(ctx, userID) after sign-in
  3. 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

Public Operations

Optional Watch Wakeups

Config.BundleChangeWatchMode defaults to BundleChangeWatchOff. Set it to BundleChangeWatchAuto to let Start(ctx) use GET /sync/watch only when the server advertises bundle_change_watch=true.

Watch mode is a latency optimization. Events never mutate SQLite directly; the client wakes its existing pull/sync behavior, so dirty-row checks, outbox replay, source recovery, snapshot recovery, and download pause rules still apply. WatchFallbackInterval controls low-frequency fallback polling while a watch stream is active; 0 means BackoffMax, or 60s when BackoffMax is unset.

Preconditions

Require no prior lifecycle step:

Require successful Open(ctx):

Require successful Open(ctx) plus durable attached local state:

Require successful Open(ctx) plus successful Attach(ctx, userID):

Recovery

Source recovery can be entered for:

Host code should treat SourceRecoveryRequiredError as a durable recovery gate: surface that sync requires rebuild, call Rebuild(ctx) while authenticated, and let oversqlite manage the replacement source identity internally.

Diagnostic Surface

SourceInfo(ctx) is debug-only. It exposes:

CurrentSourceID is opaque. Callers must not persist it externally or treat its format as part of the host API contract.

Typed Preconditions And Results

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.