pub struct CachedRegistryProvider { /* private fields */ }Expand description
The coherence contract as a type (ADR-019 §4, POC-R’s named deliverable; substrate.md §the coherence contract) — the cached read provider the advertisement path rides:
- Cached set: the whole record table as one immutable snapshot —
an
Arcmap swapped under a short lock. Whole-table is deliberate: record tables are small, whole snapshots make coalesced refreshes trivially correct (a refresh re-reads the table; there is no delta application to get wrong), and readers never block a writer. - Hot path: one lock read +
Arcclone + lookup. Zero I/O on the steady state — the provider holds no durable-side handle at all; it serves last-installed state and nothing else. - Invalidation triggers: (1) alkstore wakes (the post-commit
notify hint, or sqlite’s file-wide
data_versionbump from any writer — the delivery wiring is the reactor’s wake runner); (2) the provider’s own writes (write-through, viaCachedRegistryProvider::install_one/CachedRegistryProvider::install_removal— theRegistryBackendstore methods call these); (3) the reconcile tick (driven throughCachedRegistryProvider::refresh_from, the same body the wake handler runs). - Staleness bound: mutation visibility ≤ one wake delivery + one
refresh. One
refresh_fromafter a mutation is always enough to surface it — the snapshot is whole-table, so there is no partial state between installs. - Refresh coalescing: correct by the snapshot swap — a burst of mutations collapses into one refresh, and one refresh carries the whole burst.
- Failure posture: refresh failures leave the previous snapshot serving; the next wake, write, or tick retries.
Implementations§
Source§impl CachedRegistryProvider
impl CachedRegistryProvider
Sourcepub fn install(&self, rows: Vec<RegistryRow>)
pub fn install(&self, rows: Vec<RegistryRow>)
Install a whole-table snapshot (the wake handler’s and the reconcile tick’s body — a swap, not a delta).
Sourcepub fn install_one(&self, row: RegistryRow)
pub fn install_one(&self, row: RegistryRow)
Write-through install of one row — the store’s own write path (no table read involved).
Sourcepub fn install_removal(&self, repo_id: &str)
pub fn install_removal(&self, repo_id: &str)
Write-through removal — the store’s own removal path.
Sourcepub async fn refresh_from(
&self,
registry: &dyn RegistryWrite,
) -> Result<(), RegistryError>
pub async fn refresh_from( &self, registry: &dyn RegistryWrite, ) -> Result<(), RegistryError>
Pull-and-install from the durable side — the body the wake
handler and the reconcile tick both run. The whole table is
re-read (rows_since(0)) and swapped in; on failure nothing is
installed and the previous snapshot keeps serving.
Sourcepub fn snapshot(&self) -> Arc<HashMap<String, RepoRecord>> ⓘ
pub fn snapshot(&self) -> Arc<HashMap<String, RepoRecord>> ⓘ
The installed snapshot (observation without refresh — replication-style consumers and the tests’ coherence asserts).
Sourcepub fn refresh_count(&self) -> u64
pub fn refresh_count(&self) -> u64
How many installs have landed (test-observation for the refresh-count pins: idle-stability across idle windows, one refresh per coalesced burst).