Skip to main content

Module sync

Module sync 

Source
Expand description

Database merge engine for sync.

This is the shared core of every sync mode (directory, SSH, stdin/stdout): merge one pxh database file into the live connection with deduplication, optional secret filtering, an optional incremental watermark, and unsealed-row upgrades. Callers own transport and presentation; this module owns the merge semantics and reports what happened via MergeStats.

Structsยง

MergeStats
What a merge did, for callers to present or assert on.

Constantsยง

CHUNK_SIZE ๐Ÿ”’
WRITE_RETRY_BUDGET ๐Ÿ”’
Generous budget: sync is background work, so wait out long writers rather than failing the merge.

Functionsยง

merge_attached ๐Ÿ”’
Merge other.command_history (already ATTACHed) into main.
merge_database_from_file
Merge history from a database file into conn, with an optional secret filter (rows whose command matches are skipped and counted) and an optional incremental-sync watermark (skip rows in the source whose id <= watermark). The unsealed-row update always scans the whole source since seal info may sit at any id, watermark or not.
read_only_uri ๐Ÿ”’
file: URI that opens path read-only. Bytes outside the URI-safe set are percent-encoded so arbitrary (even non-UTF8) paths round-trip.
set_sync_watermark
Persist the watermark for a source machine. Call only after a fully successful merge: an interrupted merge must re-consider its rows.
source_columns ๐Ÿ”’
Column names of other.command_history; empty when the table is absent.
sync_watermark
Read the incremental-sync watermark recorded for a source machine, i.e. the highest source id a previous merge fully processed.
watermark_key ๐Ÿ”’