Skip to main content

Host Store SPI

Since 0.9.5, a host can keep a realm’s durable state in its own database by implementing meerkat_core::host_store::HostStore. Core builds the realm’s stores over it and stays the realm’s only writer. This page is the contract for store implementers. What a realm on a host store does at run time, and what its users see, is in Durable Runs and Host Stores.

Model

The store holds scopes. Each scope has:
  • a kind (ScopeKind): Session, Identity, Mob or Record;
  • a name (ScopeName), unique among the scopes of its kind in the realm;
  • a versioned head of opaque bytes;
  • ordered rows of opaque bytes.
Core assigns every version and every commit id. It lists every head when it opens a realm, keeps the heads in memory, and reads a scope’s rows only when it opens that scope (see What Core Reads), never before a commit. The store never interprets a payload. Rows have stable indices. Appended rows take the next indices, truncate_after removes rows at the end, and drop_before removes rows at the start without renumbering the rest. Every committed batch moves each scope it touches from one version to the next, and one batch may write several scopes: rebinding an identity or spawning a member touches more than one.

Operations

VersionedHead::commit_id is the commit id of the batch that wrote the visible version. After an indeterminate commit, Core compares it with its batch’s commit id to tell whether the batch landed.

Batches

A CommitBatch carries a commit id, the fence token of its writer and one update per scope it writes. Core builds it with CommitBatch::try_new, which refuses a batch:
  • with no update, or with two updates of one scope;
  • with an update that is not well formed (below);
  • with more than 8 MiB of heads and rows in all.
Each ScopeUpdate says what the batch does to one scope: The parts of an update apply in this order: truncate_after, drop_before, append, head. A creating update removes no rows and cannot delete. Core never creates a deleted scope’s name again, and a store may refuse such a create as Invalid.

Limits

Core keeps every batch within these limits. It writes a large value first, as chunks in scopes of their own keyed by the value’s digest, in as many batches as the value needs; then one commit batch, which alone fits the limits, makes the change visible by referring to the chunks and drops the chunks it supersedes. Your store therefore sees chunk batches before the commit batch that uses them. A chunk that no committed head refers to, for example one left by a commit that failed, is garbage, not corruption; Core deletes such chunks when it opens the realm and in a background sweep. A change that cannot be written this way, or that your store refuses for size with Invalid, fails as a whole with a typed size error: Core never truncates a value and never commits part of a change.

Errors

Answer Unavailable only when nothing was applied. When you cannot tell whether a commit landed, answer Indeterminate: Core then settles it by retrying the same batch or by loading the head.

How Core Settles A Commit

After Indeterminate, Core first loads the head of the batch’s first scope: when the head names the batch’s commit id (for a deleting update, when the scope is gone), the batch landed. Otherwise, and after Unavailable, Core sends the same batch again, with the same commit id (obligation 3), after a pause that starts at 100 ms and doubles up to 3.2 s, until the batch lands or its retry budget runs out (SpiRealmConfig::commit_retry_budget, 30 s by default). Each pause below 3.2 s is lengthened by up to half, by an amount derived from the batch’s commit id and the attempt number, so batches that fail together do not retry together. No pause is shorter than the schedule’s, so this never adds an attempt: with every attempt failing at once, a batch makes at most 14 within the default budget, and about 1.6% of batches make 13. Any other error ends the commit at once. The chunk batches of a large value are settled the same way. Core sends a batch, the first time or again, only while the realm holds its fence and before the self-fence deadline of the fence token the batch carries: the start of the writer’s last successful acquire or renew plus the self-fence window (see Fence Leases). A renew of that token moves the deadline later; a failed renew does not move it. The store’s lease for the token can end soon after that deadline, and another writer may then acquire. A commit still unsettled at the deadline stops there: its outcome is unknown, and it is never taken as landed (a head that shows its commit id still settles it). It fails with the typed RuntimeStoreError::UnsettledAtFenceWindow (SpiError::UnsettledAtFenceWindow for a layer that commits through the realm directly), its scopes are poisoned like those of any batch whose outcome stays unknown, and the realm keeps its fence. While renews fail, the retry budget is therefore cut at the self-fence window (20 s at the default timing). A batch sent before the deadline can still reach your store’s commit point after the lease ended, since Core sets no deadline on a commit: refusing it there with FencedOut (obligation 5) is what keeps it out of the realm. No bound on the writer’s side closes that case, a stricter one included (stopping at the first failed renew): obligation 5 at commit does. A commit that does not settle within its budget, or ends in another error, fails the call that made it with a write error, and every scope the batch would have changed is poisoned; FencedOut poisons the whole realm. A poisoned scope refuses every later call on it, reads included, with a typed refusal (RuntimeStoreError::ScopeRefused, naming the scope and its cause; RealmRefused for a poisoned realm) that answers the same until the realm is opened again, so a caller never retries it as an outage. Calls on other scopes keep serving. Only opening the realm again lifts the poison: the next open loads what your store holds, so a batch that did land after all is part of the realm, and one that did not is not. A call that reads across scopes, such as a listing, depends only on the scope families it reads: a poisoned scope of another family (a mob’s event log, a Meta document) refuses none of them. Where a read enumerates the sessions’ runtimes, a poisoned runtime is answered fail closed and never left out: the recovery-work scan lists it as holding work, and the delivery authority listing per runtime (RuntimeStore::list_runtime_delivery_authorities_or_unavailable) names it unavailable, so a mob boot stays lazy for every other member and the delivery owner drains every other runtime. The reads that cannot answer for a poisoned runtime refuse typed while one exists: the session catalog listing (sessions/list), the controller custody of governed administration, and the delivery backlog total.

Obligations

These nine obligations, with the self-fence margin rule under Fence Leases, are the whole contract. Each lists the ways a store may meet it, including the ways of an append-only store, one without updates or transactions.
  1. All or nothing. A load shows a batch completely, in every scope it touches, or not at all. Valid ways:
    • a transaction;
    • rows tagged with the commit id plus a commit marker row, where loads ignore rows that have no marker;
    • a pending-stream batch commit.
  2. Durable once acknowledged. After commit answers Ok, the batch survives a writer crash, and every later load shows it, from this writer or any later one, unless obligation 5 hides it.
  3. Idempotent retry. A commit id sent twice acts once. A store may refuse the duplicate or collapse it at load; answering Ok to a retry of a batch that already landed is the usual way.
  4. One version chain per scope. Core never sends two batches for one version of a scope, so no atomic precheck is required. If two exist anyway (a fenced-out writer, a bug), every load must resolve them the same way. Valid ways:
    • refuse the second batch at commit with Conflict;
    • fail the load with a typed conflict;
    • pick one by a fixed rule, such as the lowest commit id, decided per batch, so that a batch that loses in one scope is invisible in all of them.
    Whatever the rule, a batch carrying a lower fence token never beats one carrying a higher token at the same version.
  5. Fencing. After a token is acquired, a batch carrying a lower token whose commit point comes later never becomes visible. Every batch whose commit point comes before the acquire stays visible, whether or not its writer saw the acknowledgement: a load after the acquire shows it. The store refuses such a batch at commit with FencedOut. The writer learns there that another process holds the realm: Core ends its runs, and tells the callers waiting on them that the store keeps their inputs for the new owner. A store that only hides such a batch at load (ignoring every batch whose token is below the highest token acquired before its commit point) keeps loads consistent, but answers the stale writer’s commit Ok, so that writer’s own answers can claim work the realm never shows. Such a store is outside this contract. The commit point is the store’s own server-assigned commit order (for example its marker’s commit time), never a writer’s clock. Commit points that tie are ordered by a fixed rule, such as the commit id.
  6. Logical removal. Truncate, drop and delete take effect for loads together with their batch. Physical cleanup may come later or never; tombstones are fine. An append-only store should still compact, or its loads grow with history (see Mapping Onto A Database).
  7. Order. Rows load in commit order.
  8. Independence. No realm-wide lock, pointer, sequence or transaction on the commit path, and scopes commit concurrently. The fence is acquired and renewed off the hot path; commits only carry the token.
  9. Listing. A scope is listed once its creating batch is visible, and not after its deletion.
A store meets obligation 4 either at commit, answering Conflict, or at load, by the fixed rules above, and Core treats both the same way: the conflicting batch is not part of the realm. It meets obligation 5 at commit, answering FencedOut.

Fence Leases

The store records a lease for the holder of the highest token. It lasts FenceTiming::lease from the holder’s last acquire or renew, as the store’s own clock saw it, and the holder counts as live while it lasts. The host sizes the timing for its backend with HostStore::fence_timing, built with FenceTiming::try_new(renew_interval, lease) or, to declare the self-fence margin, FenceTiming::try_with_margin(renew_interval, lease, self_fence_margin), and then, to declare the longest commit, .try_with_max_commit_latency(max_commit_latency): FenceTiming::self_fence_window is the lease minus the self-fence margin, and try_with_margin refuses a margin below one renew interval or a window below two renew intervals. The margin must be at least the renew interval plus twice your store’s visibility lag. A renew written just before a takeover can stay invisible to the new holder for up to that lag, and the holder renews only once per interval, so the new holder’s wait can end before the old holder’s real lease; the margin makes the old holder stop first. A store whose writes become visible after a few seconds declares a margin larger by twice that. A shorter lease shortens the wait for the next process after a holder died, and at a takeover. A longer renew interval renews less often. The longest commit is how long one commit can take on your backend, the retries your store makes inside the call included (FenceTiming::max_commit_latency). Core uses it for one kind of write: a write to a mob member’s session that Core fences with the mob’s identity authority, as its identity reconciler does. Such a write first checks that the mob’s identity scope has no commit in flight. While one is in flight, Core checks again, after pauses that start at 5 ms and double up to 50 ms, for up to the longest commit, and then reports the write as backed off (RuntimeStoreError::WriteFenceBackoff, or a FenceBackoff outcome): the write changed nothing, nothing is poisoned, and the reconciler tries it again later. A store whose commits are slower declares a longer bound so that those writes do not back off. The wait covers the whole commit of the call that holds the identity scope: the chunk batches of that call’s large values (see Limits), the batch that refers to them, and Core’s retries of an unknown or unavailable answer (How Core Settles A Commit). Size the bound for the chunk batches and the batch at their slowest; while your store is in trouble the retries outlast it, and those writes back off. A session document’s chunk batches are not part of the wait: they belong to the commit of the session write itself, which Core sends after the identity check has released the identity scope. When no value written with the identity scope is large enough to be chunked, the bound only has to cover one batch. Core sets no deadline on a commit call itself. A commit that runs longer than the longest commit is waited for: Core does not fail it, does not retry it, and poisons nothing. The call that made it waits for its answer, later calls on the scopes it holds wait for those scopes, and a run waits for its round commit, since the runtime store over a host store declares no commit outcome deadline (RuntimeStore::commit_outcome_deadline is None). Core also uses the longest commit to tell a slow commit: one that met an unknown or unavailable answer, or whose first call has run longer than the longest commit, until it settles. Any commit on the realm counts, including the mob store’s and those of other layers that share the realm. A read of the runtime store across sessions (a listing, the delivery total) waits until no commit it could see is in flight, so it never reads a batch that has not settled. While a commit settles slowly, such a read waits without holding back the other sessions’ calls: it takes the store at a moment when no call holds it. Under a sustained partial outage, with slow commits overlapping, that wait can last several retry budgets.

Core’s Timeouts And The Safety Condition

The host also passes SpiRealmConfig when it opens the realm (for a Meta gateway, HostStoreMetaStorageProvider::open): A renew that does not answer within the shorter of renew_timeout and the renew interval stops the writer: it acquires again by itself at the next renew interval, proves with a fresh listing that nobody else wrote, renews once and resumes. So the tolerance of a slow renew is that shorter time, 5 s at the defaults. The safety condition is the timing bounds Core enforces when the timing is built, plus one obligation of yours:
  • Core enforces: the renew interval I is at least 1 s; the lease L is at least 3 x I and at most 1 hour; the self-fence margin M is at least I and at most L - 2 x I; the longest commit is above zero and at most L.
  • Your obligation: M >= I + 2 x V, where V is your store’s visibility lag (the time from the start of a write until every acquire and renew sees it). Size V for your store under load.
Neither renew_timeout nor commit latency is a safety term. The window counts from the start of each acquire or renew, which your store records no earlier, so a slow answer only makes the writer stop earlier, and renews are held to the renew interval anyway: any renew_timeout up to the renew interval is safe. Commits are fenced by token at your store’s commit point (obligation 5), and Core sends no commit attempt past its token’s self-fence deadline. To tolerate a slower store:
  • set renew_timeout to the renew interval (10 s at the default timing): this doubles the tolerance of a slow renew with no other change, and gives the acquires of a re-acquire 10 s too;
  • beyond that, lengthen the timing consistently: a renew interval above the slowest renew you want to tolerate, renew_timeout equal to it, M >= I + 2 x V and L >= M + 2 x I. For example, with V = 5 s: I = 20 s, M = 30 s, L = 70 s, a 40 s window. The cost is the wait after a crash or a kill: the next process waits up to L for the old lease.
An acquire Core gave up on at its timeout should not take effect later: where your store can, give it a server-side deadline below Core’s timeout. Core copes with one that does (see Core’s Writer Rules), but only by waiting out its lease, and a late takeover stops the realm.

Core’s Writer Rules

The store relies on Core keeping these rules:
  • Exclusive acquire. Core acquires with AcquireMode::Exclusive, so two processes never fence each other back and forth. Apart from Core taking over its own recorded lease (below), only an explicit takeover uses AcquireMode::Takeover. Core takes over its own recorded lease when a stopped holder re-acquires and an exclusive acquire answers Held with its own token.
  • Acquires Core gave up on. Each acquire of a re-acquire runs under SpiRealmConfig::renew_timeout, and Core records no token for one that times out. If your store grants it anyway, its token holds the fence, and Core meets it as the holder at its next re-acquire. While an acquire of its own timed out since its last grant, Core cannot tell that token from another writer’s: it waits out the holder’s recorded lease (the remaining of Held), makes no acquire before it ends, and then acquires exclusively again and checks the listing as at any re-acquire. The realm stops until it is opened again only when the same holder still holds the fence after that lease ended (only a live writer renews it), or when the listing shows a batch this writer did not write. With no acquire of its own timed out, a holder Core does not know stops the realm at once. A takeover your store grants after Core’s next successful acquire supersedes Core’s live token; Core then meets FencedOut and the realm stops until it is opened again.
  • Renewing. The holder renews once per renew interval. After a failed renew, or once its self-fence window has closed, it stops every write and dispatch, and goes on only through a fresh acquire, with a new token, which it makes by itself before its next write; if another process took the fence or committed meanwhile, the realm stops until it is opened again. It never resumes on a later renew. The rule is Core’s: a store answers a renew of the current token even when the holder’s lease lapsed, and refuses only a token that was superseded or that it never issued. A stop is a pause, not a failure: a run that reaches a model call or a tool call while the holder is stopped waits for that fresh acquire, for at most one self-fence window plus the acquire’s own timeouts (its two acquires and its renew, 35 s at the default timing), trying again once per renew interval while it fails, and goes on once it resumed the holder. A round commit refused while the holder is stopped waits the same way and is written again, once, when the acquire succeeds. A commit whose batch was already sent and is still unsettled at its token’s self-fence deadline is not refused but stopped: its scopes are poisoned (see How Core Settles A Commit), so writing them again is refused until the realm is opened again. When no acquire succeeds in that time and no other process shows up (a fence gap), the runtime suspends the run with its inputs bound to it and resumes it once the fence is back; the gap may last as long as the store does not answer. Only another process ends the run and the session’s live state here: one an acquire finds, or one a renew or a commit answered FencedOut reveals, wherever Core meets it first.
  • Self-fencing. The holder fences itself on its own clock: it makes no model call, dispatches nothing and commits nothing unless its last successful acquire or renew started less than the self-fence window ago. It checks the clock before each commit, before each model call, and right before each tool call starts, after the round’s pre-tool hooks; a call refused there never starts, and the round commits none of its results. While the window is open, a check takes no store request; the per-round path sends no fence request to the store.
  • Takeover wait. After an acquire that supersedes a live holder, the new holder waits out FenceGrant::superseded_lease before it makes a model call or dispatches anything. By then the old holder has fenced itself: the store started that lease no earlier than the holder started the acquire or renew it came from, and the holder stops the self-fence margin before the lease ends.
  • Bulk load. Core loads the heads with list_heads after the acquire and before its first commit, so the load observes one cut.
  • Commit ids. Core never reuses a commit id for different content, and never commits a scope’s next version while an earlier commit touching that scope has an unknown outcome. It settles the unknown first, by retrying the same batch or by loading the head.

How Core Lays Out A Realm

This section is informative: the layout is Core’s own, and a store must not depend on it.
  • Each session’s runtime is one Session scope.
  • Each mob storage is a few scopes: one Mob scope (its event log and records), one Identity scope (its identity authority) and Record scopes for flow runs and identity statuses.
  • Realm-wide maps are Record scopes, one per entry, such as one runtime per continuation key.
  • Each scoped tool grant is a Record scope of the family tg: its head holds the grant’s stored row and the key of the subject it is filed under. Each subject’s grant audit log is a Record scope of the family tga, whose rows are the audit rows; it is read on its first use in a process, never at open. A grant’s lifecycle change and its audit row commit in one batch.
  • Chunks of large values are scopes of their own.
  • Durable decisions are not kept in the host store: a host that supplies its own stores keeps them in approval_decisions.sqlite3 under its store path, as it keeps approvals.json.
A realm therefore holds a few scopes per session and per mob, and listing and the bulk load at open read every head once. Each scope’s name starts with the tag of its family and a :. Core never uses a family tag that starts with x or mx. A layer above Core that keeps scopes of its own in the realm, through the same realm handle, names its families with those prefixes, so no family a later Core release adds can take one of its tags.

What Core Reads

This section is informative too. A store must answer every operation whenever Core calls it; these are the reads Core makes. None of them reads superseded history (see Retention): they follow how many scopes the realm holds (archived sessions are never deleted) and its live state. Some live state grows with use and is not removed today: a runtime’s delivery authority, kept in its head, grows with every delivery and, once over 32 KiB, is read as a chunk at every open, dormant runtimes included; a runtime’s boundary receipts and delivery records grow the rows a load of it reads; and a mob’s event log grows the mob’s own scope. At open. After it acquires the fence and before its first commit, Core reads:
  • Every head, once. list_heads for each of the four scope kinds, asking for 2048 heads per call (256 before 0.9.7) and at least one call per kind, archived sessions and chunk scopes included. A store may answer fewer heads per call with HeadPage::next set; Core reads on from there.
  • Head entries kept as chunks. A head entry over 32 KiB is kept in a chunk scope: one load_head and its rows for each such entry of every runtime, dormant or not, and of every realm record.
  • The rows of runtimes with recovery work. A runtime’s session scope is read only when the facts its head pins show work recovery must act on: unsettled or queued inputs, input rows without a lifecycle record, a background operation completion not yet delivered, a running detached job wait, pending terminal owners, an open run’s provisional tail, or a current run (a lifecycle record Core cannot decode counts as one). Core reads its visible rows from the first visible row, 16 rows per read_rows call, then the chunks its rows and live entries refer to. An archived runtime is never read at open: one whose session was archived, or whose runtime was retired or destroyed (a retired mob member’s, for example).
No other row is read at open. Core reads up to 16 runtimes at once: their head entries kept as chunks, and the rows of those with recovery work. One runtime’s reads run in order, its rows and then its chunks. An open of K runtimes with recovery work therefore waits about ceil(K / 16) times as long as the reads of one runtime, not K times. If any of those reads fails, the open fails and serves nothing. When a mob’s storage is opened (its resume after a restart), Core reads the mob’s own scopes whole: its event log, identity, flow runs and statuses. The lift of a mob stopped in the same process finds them in memory and reads none of them. When a mob starts (that resume, or the lift of a stopped mob), Core reads the sessions of the members the start wakes. A start wakes a member with recovery work, a pending delivery or an owed kickoff, a member on TCP or UDS member comms, one wired to a member placed in another process, an orchestrator the resume notifies, a member without a durable endpoint, and the members the host requires. Under the default restore policy (MemberRestorePolicy::OnDemand) every other member stays dormant: its session scope gets no load_head and no read_rows. MemberRestorePolicy::OnDemandVerified reads every dormant member’s session rows once at every start, and MemberRestorePolicy::Eager wakes every member. A start wakes its members at most the mob’s restore concurrency at a time (MobBuilder::with_resume_restore_concurrency, 16 by default), and its verified reads run at most that many at a time too. A member the lift of a stopped mob has not reached yet stays dormant until it does, or until a delivery wakes it first. Later, on first use. A dormant member’s session is read when its first delivery wakes it. Any session not read yet is read the first time a call needs it, for example a read of its history. Seating a member on an existing session (MobHandle::seat_dormant_members) reads that session once, to check that it can be resumed; seating a member whose session does not exist yet reads nothing. A session read once stays in memory until it is archived, so it is not read again. Rarely. A start whose recovery scan fails wakes every member, and says so (MobHandle::boot_set_basis). A start that finds a woken member’s session gone searches the realm’s other sessions for its successor, reading each candidate once. A writer that stopped (a failed renew, or its self-fence window closed) and acquires the fence again lists every head once more, as at open, to check that no other writer committed meanwhile. The first start after an upgrade to 0.9.7. A runtime head that an earlier release wrote cannot show that no background operation completion is owed, so the first 0.9.7 start treats each such runtime that is not archived as holding work: it wakes its mob member once and reads its session. The runtime’s next commit records its facts in full, and later starts read only what this section lists. Listing pages from 0.9.7. Core asks list_heads for 2048 heads per call, eight times as many as before, so one answer of typical runtime heads is several MiB. If your backend or transport caps an answer below that (a message or page size limit), answer the heads that fit with HeadPage::next set, and leave next empty only when no scope of the kind is left to list. A store that sets next only when it answered a full page of limit heads ends the listing early once its cap cuts a page short, and Core then opens without the scopes it was not given. For example, a realm of 5,000 sessions where only one holds work, whose pinned entries are all inline and whose other kinds hold at most 2048 scopes each, takes at open one acquire_fence, three list_heads calls for the sessions and one for each other kind, and the read_rows calls of that one session.

Retention

When Core changes a row entry, it appends the entry again, whole, in a new row: a runtime’s registry of background operations, for example, is rewritten each time an operation finishes. The rows holding superseded values stay visible until a re-base drops them. A scope is re-based on its first commit after the rows appended since its last re-base pass four times the bytes of its live entries or 256 KiB (4 MiB before 0.9.7), whichever is larger. The re-base is one batch: a reset row, every live entry, and drop_before at the first of those rows, so a crash leaves the old window or the new one. A scope’s visible rows therefore stay within that bound plus its last commit’s rows, and re-bases add at most about a third to the row bytes Core writes. Core re-bases only a scope it has opened. A dormant member’s scope keeps its rows until the member is woken and commits again; Core does not read them in the meantime.

Mapping Onto A Database

Any database that meets the obligations works. Two common shapes: A transactional database. Commit each batch in one transaction. In it, check each update’s previous against the stored version and the batch’s token against the highest acquired token, and refuse with Conflict or FencedOut. Record the commit id with the scope’s version, so that a retry of a landed batch answers Ok. Keep the fence token and its lease expiry, on the database’s clock, in a row of their own. An append-only store (no updates, no transactions):
  • Commit. Append the batch with one pending-stream batch commit, or append its rows tagged with the commit id and close them with a marker row. Before the commit (or the marker), read the fence rows and answer FencedOut when a token higher than the batch’s was acquired (obligation 5). A takeover that lands between that read and the commit is not seen there: the load below still drops the batch, and Core’s writer learns of the takeover at its next renew, within one renew interval, but answers it gave in between can claim that batch. That window does not meet obligation 5, which asks that the commit itself be refused: keep it short, or make the fence check and the commit one transaction (a write conditional on the fence row).
  • Retries. A streaming insert can fail in transport under a burst of commits. Retry it a bounded number of times with jittered backoff. Per-row insert ids, and a load that keeps one copy of a repeated commit id and of a row written twice under one commit id (rows have stable indices), make such a retry safe. In one store, about a third of the commits in a burst met a transport error until it retried each insert up to six times.
  • Request size. A batch of up to 8 MiB grows to about 11 MB as JSON. Split its rows into requests of at most 7 MiB each as sent, and write the commit marker last.
  • Load. Take the scope’s committed batches, drop fenced-out batches by their marker’s commit order, collapse duplicate commit ids, keep the lowest commit id per version, and return the highest version’s head and its rows minus the removed ranges.
  • Fence. Acquiring appends a fence row with the next token and waits until it is visible. Renewing checks that no higher token exists and appends a lease row.
  • Clock. Commit timestamps are the store’s own, and ties break by commit id.
  • Open from current heads. Keep each scope’s current head where list_heads pages it directly (a table or an index of the latest versions), and serve read_rows when it is called, for one scope at a time. Core reads rows only as What Core Reads lists, so a store never needs to load every row before it answers.
  • Compaction. Off the commit path, remove what no load can show anymore: heads older than each scope’s visible head, rows below each scope’s first visible row, deleted scopes (chunk scopes among them) and fenced-out batches. Keep each scope’s visible head with its version and commit id (Core settles an unknown commit outcome by reading it), its visible rows, and the fence’s highest token and lease. Without compaction the log grows with every commit, and so does any load that scans it, while the realm’s live state stays bounded (Retention).

Conformance

The meerkat-store-conformance crate checks a store through the six operations alone, in its host store chapter (chapters::host_store::host_store). Give it a HostStoreFactory over one realm, which starts empty:
  • every open stands for a new process: a new handle over the same realm that holds nothing of the handles before it (for a remote backend, a new client over the same dataset);
  • lapse_fence_leases lets every recorded lease run out, by advancing the store’s clock or by waiting.
The chapter kills a process by dropping its handle, with any commit it has in flight. Where an obligation can be met at commit or at load, it accepts both; for obligation 5, a store that fences only at load passes the chapter but is outside the contract. Its rows run in order: The crate’s long-run and durable-worker chapters run scripted runs over a store, kill them at chosen points of a round, and check that each restart continues from the last commit under the same run id, or, when nothing was committed yet, runs the input again as a new run.

See Also