Synthesized in: Durability, checkpoints & crash recovery. That page presents the Order-A write protocol, the committed watermark, the checkpoint fold, and recovery at the architecture level; this record is the mechanism detail for how that data-loss-critical control flow is shared once (Template-Method traits + per-variant seams) across the byte, char, and future variants.
Crate libdictenstein. Baseline HEAD 1f120e8 (char on LockFreeOverlay). Pattern-driven, DRY,
non-blocking, scalable. This is the architecture for sharing the WHOLE overlay subsystem — not just the
flip-layer (done) but the durable-write + checkpoint + watermark + recovery machinery — across the byte
and char variants (and future ones), so there is ONE copy of the data-loss-critical control flow.
Design owner: parent. Pattern grounding: pgmcp software-pattern catalog (recommend_design_patterns +
software_pattern_search, queried 2026-06-03). Code grounding: §0 facts below, all verified.
template_method, score 0.70) + Form Template Method (form_template_method,
0.65): the governing structure. Each durable operation is an INVARIANT skeleton (the Order-A control
flow: durability-gate → present-hoist → durable WAL append → publish via overlay CAS → mark committed)
expressed as a trait DEFAULT method; the per-variant steps are deferred to abstract SEAM hooks. The
char→shared extraction is exactly "Form Template Method": push the common skeleton up, defer the
differing steps.strategy, 0.64): the per-variant seam hooks are injected behavior (WAL-record builder,
serializer, value-domain bound) — interchangeable policy behind one interface.rcu, 0.63) + CAS Loop (cas_loop, 0.63) + Wait-Free/lock-free (wait_free): the
substrate the architecture MUST PRESERVE — readers lock-free over the arc-swap root, writers publish
immutable new versions via root CAS, EBR reclaims after a grace period. The shared traits take &self
on reads and the publish path; NO seam introduces a hot-path lock.parallel_change, 0.62): the migration — extract char onto
the traits as a BEHAVIOR-IDENTICAL refactor (char correspondence suite is the oracle), byte impls the
same traits, both coexist; expand → migrate → (eventually) contract.protected_variations_grasp) / Encapsulate What Varies
(encapsulate_what_varies) / Open–Closed (open_closed_principle) / DRY (dry): wrap the
predicted variation (key encoding, WAL record shape, on-disk format, value domain) behind the stable
trait; a NEW variant = a new impl (open for extension), the shared control flow is unedited (closed for
modification); each data-loss-critical rule has ONE representation.god_object, 0.61): do NOT pile read + write + checkpoint + recovery into one mega-
trait. SPLIT into cohesive traits (one responsibility each — below). LockFreeOverlay (read+flip) is
already its own; DurableOverlayWrite and OverlayCheckpoint are separate, composable traits.speculative_generality_ap, 0.58): the "remain sensible" limit. Design for
the TWO real variants (char/byte) + clean extensibility; do NOT add hooks for hypothetical variants that
may never exist. The vocab variant is DELIBERATELY excluded (its allocator-index overlay doesn't fit —
proven). Seams exist only where char and byte ACTUALLY diverge.lock_convoy 0.59 / priority_inversion 0.58): the non-blocking
mandate. No seam may take a mutex on the read or write hot path; the only synchronization is the
arc-swap root CAS + EBR + the existing per-WAL append lock (already there, off the read path).&[K::Unit] + the value,
not a bag of fields), Primitive Obsession (use RankRegime/Lsn/typed records, not bare ints),
Feature Envy (the owned-read seams live on the variant that owns self.root).ALREADY SHARED in persistent_artrie::core (byte just reuses — DRY already won here):
wal::header::RankRegime (Owned/Overlay) — the regime enum.wal::codec::WalRecord — the WAL record types (Insert/Increment/BatchIncrement/Checkpoint/…).recovery::{reconcile_lww, reconcile_lww_with_regime, rebuild_from_wal_segments_regime_aware} — the A2
regime-aware LWW recovery (char's hardest-won machinery, already generic).overlay::{OverlayNode<K,V>, AtomicNodePtr<K,V>} + overlay::flip::LockFreeOverlay<K,V,S> (read engine
committed_watermark::CommittedWatermark — was CHAR-LOCAL (persistent_artrie/char/committed_watermark.rs);
K-agnostic (a contiguous-prefix LSN tracker) $\Rightarrow$ MOVE to core (pure DRY win). [Since executed: the
canonical tracker now lives at persistent_artrie/core/committed_watermark.rs; the char path re-exports it.]CHAR-CONCRETE (the extraction targets — push the skeleton up, keep the seam):
insert_cas_durable/remove_cas_durable/try_increment_cas_durable/
insert_cas_with_value_durable/upsert_cas_durable (char/lockfree_cas.rs:370/556/1654/1747/1862).capture_snapshot_immutable + the retaining publisher (char/persist.rs:109/383).CheckpointSnapshot (char/persist.rs) + the on-disk serializer — GENUINELY per-variant (char arena
format vs byte arena format) $\Rightarrow$ stays a seam.BYTE GAPS (red-team aec7447): byte has NONE of the durable-write/checkpoint/watermark/regime machinery;
it has only Phase A/B (overlay node + enable_lockfree + NO-WAL CAS). So byte both REUSES the shared traits
AND must provide the per-variant seams (WAL builder, serializer, value bound) + consume the already-shared
A2 recovery.
LockFreeOverlay<K,V,S> (DONE, overlay/flip.rs): route predicate, the non-faulting RCU read
engine, flip/kill-switch, the reestablish folds. Read + flip responsibility.DurableOverlayWrite<K,V,S>: LockFreeOverlay<K,V,S> (NEW): the Order-A *_cas_durable skeletons as
Template-Method defaults. SEAM hooks (Strategy): durability_policy(), append_durable_wal(record) -> Lsn (constructs+appends the variant's WalRecord, durable), mark_committed(lsn), value_bound(v) -> Result<CounterValue> (the per-variant value-domain check — char u64 vs byte i64-non-negative, the C4
guard), plus the already-present overlay_publish_* from trait 1. The skeleton owns: the durability-
policy gate, the NON-FAULTING present-hoist (RCU read, never faulting — the 75-min-deadlock rule), the
append-then-publish ORDER (Order-A: durable before visible), mark_committed. ONE copy.OverlayCheckpoint<K,V,S>: LockFreeOverlay<K,V,S> (NEW): the checkpoint route-split skeleton —
if route_overlay() { capture_immutable + publish_retaining } else { assert!(!route_overlay()); owned }
— as a default. SEAM hooks: capture_overlay_snapshot() -> Snapshot (walk the overlay root → the
variant's CheckpointSnapshot), publish_retaining(snapshot, watermark) (serialize + WAL-retain via
the committed watermark), capture_owned_snapshot() (the owned arm). The watermark/retention LOGIC is
shared (via the moved-to-core CommittedWatermark); only the serialize is a seam.reconcile_lww_with_regime +
rebuild_from_wal_segments_regime_aware through its 3 replay sinks (read header.regime(), gate
reestablish on Overlay). Reuse, not re-abstract (avoid Speculative Generality).CommittedWatermark char→core (pure relocation; char re-exports; suite green).DurableOverlayWrite + OverlayCheckpoint in core; extract char's 5 durable writes +
checkpoint route-split into the trait defaults (Form Template Method, BYTE-IDENTICAL — char
correspondence suite + full suite the oracle); char seam impl supplies the hooks. Reversible.DurableOverlayWrite (CounterValue=i64, the i64 value-bound
OverlayCheckpoint (byte serializer seam = C2) + the watermark wiring (C3) +
thread A2 regime recovery through byte's 3 sinks (H3). Each its own gate + a byte durability-witness
test. Reversible (overlay stays opt-in; no create-flip yet).Full cargo nextest --features persistent-artrie green + the char/byte correspondence suites + the D1
owned-seam grep gate (applied per-variant) + verify-formal-correspondence.sh exit 0 + 0 new unsafe. The
reestablish Rocq spec OverlayReestablishSpec.v is variant-agnostic (covers both). The #41/A2 TLA/loom
models are shared. M2's byte durable writes get a durability-witness test (durable write survives
reopen-without-checkpoint = the #41-closed witness, byte twin).
\approx$ the irreducible ~30%.review_design_patterns, 2026-06-03 — the flagged review questions, answered)The catalog review (paradigms: concurrent/OO/parallel) returned NO blocker; it surfaced review questions, each already handled by the existing RCU/immutable-node substrate (confirm-in-code, not change):
AtomicNodePtr/EBR and inherit this; no new ABA surface.&mut self-gated. No seam shares
in-place-mutable state across threads.OverlayNode<K,V>/AtomicNodePtr<K,V> are auto-Send/Sync (after
the G4 unsafe removal); the traits add no raw pointers, so the bounds are preserved. The seam value-route
uses SAFE Any (no unsafe).Vecs via the owned_*
seams, THEN clear_owned() — no live iterator is held across the &mut clear (the clear-owned-LAST
ordering already enforces this; the Rocq spec proves it).TypeId/Any u64-vs-i64-vs-() dispatch is LOCALIZED
to the value-route + reestablish-dispatch seams (~2–10 LOC each), not scattered — the Rust-idiomatic
stand-in for the missing specialization, contained behind the seam (Encapsulate What Varies).Can you improve this documentation?Edit on GitHub
cljdoc builds & hosts documentation for Clojure/Script libraries
| Ctrl+k | Jump to recent docs |
| ← | Move to previous article |
| → | Move to next article |
| Ctrl+/ | Jump to the search field |