Documentation
¶
Overview ¶
Package accountvalues defines the tech-space carrier for account-scoped values and the pure diff that mirrors carrier state into target-space records. See docs/scoped-properties-proposal.md § "Account transport".
Topology: the tech space hosts ONE derived carrier object per target space (bounded DAG, 1:1 lifecycle, one-tree GC on space leave). Its `account_values` dataset holds one record per (objectId, dataset, recordId) of the target space; record fields are the account-scoped paths VERBATIM (`{typeId}.{propId}` for the objects row), so the record's own `_ver` — tech-tree versionIds, including entries retained by $unset — is the version source the mirror replays.
Index ¶
Constants ¶
const Dataset = "account_values"
Dataset is the carrier dataset name on the per-space carrier object.
const DeriveSeedPrefix = "builtin:accountValues/"
DeriveSeedPrefix builds the deterministic derive seed for a target space's carrier object: every device of the account mints the same carrier object id for the same target space.
const HandlerVersion = "accountValuesHandler-v1"
HandlerVersion is the DataVersion stamped on carrier changes. The tech space is account-private (owner-only ACL) — the only writer is the SDK itself; bump if the record shape ever changes incompatibly.
Variables ¶
This section is empty.
Functions ¶
func DeriveSeed ¶
DeriveSeed returns the carrier object's derive seed for spaceId.
func Key ¶
Key builds a carrier record id for a target (objectId, dataset, recordId). Colon is not a valid character in any-sync's content-addressable ids, so the segments can't collide. The objects row is the degenerate case: Key(objId, "objects", objId).
func KeyPrefixForObject ¶
KeyPrefixForObject returns the id range prefix selecting every carrier record of one target object (any dataset/recordId). Used by the object-delete GC.
Types ¶
type Batch ¶
Batch is one injected apply: every op in it carries the same carrier-tree versionId. The mirror issues one InjectedSet per Batch so per-path gating replays the carrier's converged order EXACTLY — stamping a single max version over many paths would over-claim.
func Diff ¶
Diff computes the injected applies that bring the target record's account-scoped paths in line with the carrier record. Pure function — both mirror paths (live carrier events and the on-load state re-mirror) share it, and it's table-testable.
- carrier value present ⇒ $set at the path's carrier version;
- carrier value absent but the carrier `_ver` retains (or covers) a version for a path the TARGET still holds ⇒ $unset at that version — this is how unsets reach devices that were offline;
- unknown propId (resolver) ⇒ skip — Hole A, retried by the next re-mirror once the definition syncs;
- declared scope ≠ account ⇒ skip (defensive — a buggy or stale carrier entry must not touch synced/local paths);
- target version ≥ carrier version ⇒ no-op (already applied; the injected gate would drop it anyway, skipping avoids event noise).
Op payloads are deep-cloned onto arena so the result outlives the carrier record's buffer. Batches are ordered by ascending VersionId. Returns nil when the records are already in sync.
type ScopeResolver ¶
ScopeResolver reports the declared scope of a (typeId, propId) pair in the TARGET space. known=false means the definition hasn't synced to this device yet — the diff skips such paths (never drops them: the carrier retains the value and the next re-mirror retries once the schema arrives).