Skip to main content

Module auto

Module auto 

Source
Expand description

Background vault sync (3.12.3): the daemon syncs every shared vault of this machine without a manual lean-ctx cloud sync.

One cloud-sync thread per machine, started beside the scheduler (super::super::scheduler::spawn). A vault syncs when

  • its local data changed (the project’s knowledge journal moved, or its replica was written: docs, task and knowledge events queued there), DEBOUNCE after the last change, at the latest MAX_HOLD after the first one of a stream of changes;
  • Cloud said its log or trust advanced (log.advanced, trust.advanced on the bus, nudge_place); a purge at once;
  • or [cloud] pull_interval_minutes passed since its last attempt (the fallback that works without any bus frame).

The process that wrote a fact pushes it itself within about a second (super::on_write); this thread is the fallback for writes of other processes and the receiving side of a bus hint.

Bounded: one sync at a time, at most MAX_PER_PASS vaults per pass, at most one attempt per MIN_SPACING and, after a burst of BURST_MAX, one per BURST_EVERY per vault (a purge excepted), and a failed vault backs off exponentially up to BACKOFF_MAX, or as long as Cloud’s Retry-After asks. The burst cap and the backoff are shared with every other process of the machine that syncs (super::budget). Offline only backs off: pending events stay in the replica and go out with the next sync that reaches Cloud.

Never unshared data: only vaults Cloud already resolved for this machine (projects.json) sync, only against a C0 2.x Cloud, and this thread never maps a new project (no resolve); capture keeps its gate and screening.

The thread writes <data>/cloud/sync/status.json (kind cloud.sync).

Structs§

SyncStatus
VaultLock
A held vault sync lock (or the status lock). Dropping it unlocks the file explicitly before closing it: closing alone does not release an flock while a child process forked meanwhile by another thread (a git spawn, say) still holds a copy of the descriptor, and the next sync of the vault would find it busy until that child execs or exits.
VaultSyncStatus

Enums§

Trigger
What started a sync.

Functions§

load_status
lock_vault
The advisory lock of one vault’s sync. wait: block until free (the CLI); otherwise Ok(None) when another sync holds it (the thread skips).
note_manual
Record a manual lean-ctx cloud sync of record in the status, so the app shows it like a background one. Called with the vault’s sync lock: a person’s sync is never held to the shared budget, but it counts as an attempt there (the burst cap of every other sync sees it), and its result sets (or clears) the backoff every other sync keeps.
nudge_place
Cloud announced a change of place (log.advanced, trust.advanced): sync that vault soon. A hint only: the sync verifies what it fetches.
root_of
The local checkout to sync record from: its first recorded root that still exists.
spawn
Start the thread once per process (the daemon). A second call while it runs does nothing.
stop
End the thread (the scheduler stopped: disconnected, revoked, lapsed).