1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
//! Shared lock-free overlay node (G4 unification).
//!
//! The byte (`u8`) and char (`u32`) lock-free overlays used to carry
//! token-for-token-identical node implementations (`persistent_node.rs` /
//! `atomic_ptr.rs`) that differed only in the key-unit type, `MAX_PREFIX_LEN`
//! (12 vs 6), the inline zero filler (`0u8` vs `0u32`), and prose. G4 collapses
//! both into a single generic
//! [`OverlayNode<K, V>`](crate::persistent_artrie::core::overlay::OverlayNode) /
//! [`AtomicNodePtr<K, V>`](crate::persistent_artrie::core::overlay::AtomicNodePtr)
//! parameterized over `K: KeyEncoding` (its `Unit` is the key-unit width) and
//! the value `V`. The variants alias it:
//!
//! ```text
//! // byte: pub type PersistentNode<V = ()> = OverlayNode<ByteKey, V>;
//! // pub type AtomicNodePtr<V = ()> = overlay::AtomicNodePtr<ByteKey, V>;
//! // char: pub type PersistentCharNode<V = ()> = OverlayNode<CharKey, V>;
//! // pub type AtomicNodePtr<V = ()> = overlay::AtomicNodePtr<CharKey, V>;
//! // vocab: consumes the char alias at <u64> (unchanged).
//! ```
//!
//! Lives in `persistent_artrie::core` so the layering invariant holds: `SwizzledPtr`
//! is canonically `persistent_artrie::core::swizzled_ptr`, so this module imports it
//! with **zero** upward reference. Zero `unsafe` — `Send`/`Sync` auto-derive.
// G5.1 — the shared, key-encoding-generic overlay-backed `DictionaryNode` handle
// (`OverlayDictionaryNode<K, V>`), aliased by both variants as `PersistentARTrieNode`
// (byte) / `PersistentARTrieCharNode` (char). Auto-derives Send/Sync (no `unsafe`).
// The SAFE object-safe fault-in capability for the overlay-backed `DictionaryNode`
// (resolves `Child::OnDisk` overlay children during a graph walk without naming `S`
// and without `unsafe`). See `faulter.rs`.
// The shared lock-free-overlay flip (route + read-engine + flip/kill-switch +
// reestablish), generic over `K: KeyEncoding` (overlay-flip genericization §2).
pub
// The shared Order-A durable-write skeleton (Template Method): the durability
// gate + the append→publish→mark ordering + the commit-rank/watermark tail +
// the full increment template, as default methods over per-variant seams
// (overlay-durable-architecture.md, trait 2).
pub
// The shared checkpoint route-split skeleton (Template Method): the "capture the
// LIVE representation (overlay vs owned)" decision + the RES-4 total-loss guard,
// as a default method over per-variant capture/publish seams (trait 3).
pub
// The shared overlay-eviction + read-fault primitives (the 1c overwrite-race-safe
// single-node evict + the read-path single-level fault-in walk), lifted K-generic
// over `OverlayNode<K, V>` from char's proven impl via the `OverlayEvictable`
// subtrait of `OverlayFaulter` (overlay-eviction-v4 design §4). The per-attempt
// primitives are default methods over three variant-specific accessors; the
// loaders + registry plumbing + batch driver stay variant-specific.
pub
// F5 (Slice 3): the generic, compression-aware dense→overlay builder
// (`build_overlay_root_from_terms`) used by the F5 dense-image reopen loaders
// (`load_overlay_root_compressed` / `load_overlay_char_root_compressed`).
pub
// CX (task #43): the path-compressing overlay↔dense codec's shared, K-generic, PURE
// no-truncation core (`chain_chunks`). DORMANT until L2/L3 wire the codec.
pub
// CX-universal: the ONE generic path-compressed overlay serializer (`OverlayCompressedSerialize<K,V>`
// default-method loop + `peel_chain_generic`); per-variant seams cover the format-specific leaves.
pub
// G5.3' — the shared lock-free CAS-walk SKELETON (free generic-over-`<K,V>` COMMON
// descent helpers + the `OverlayCasWalk<K,V,S>` trait with per-variant
// specialization hooks + DEFAULT skeleton methods). The COMMON descent
// (find/spine/resolve_or_fault) is shared; the result/error enums + the
// `try_set_final` two-phase publish stay per-variant. See
// `docs/design/slice3-g5-overlay-genericization-2026-06-09.md` §G5.3'.
pub
pub use AtomicNodePtr;
pub use OverlayDictionaryNode;
pub use OverlayFaulter;
pub use ;
// F7 — the crash-injection fail points for the Owned→Overlay conversion crash-safety
// proptest (`tests/persistent_owned_to_overlay_conversion_crash.rs`). Re-exported `pub`
// from the `pub(crate)` `flip` module so the integration test can arm/disarm them;
// DISARMED by default (a single `Relaxed`/`SeqCst` atomic load on the cold reopen-convert
// path = zero production effect).
pub use f7_failpoint;
use Arc;
use crateKeyEncoding;
/// A root-to-node path recorded during a CAS walk, innermost last.
///
/// Each element pairs a node with the key unit that leads to the *next* node, so a
/// copy-on-write republish can rebuild the path from the leaf back to the root. Used
/// by the CAS walk and by both eviction paths.
pub type OverlaySpine<K, V> = ;
/// Child slots keyed by their incoming key unit, in insertion order.
///
/// The inverse pairing of [`OverlaySpine`]: here the unit *precedes* the node it
/// reaches. Used when staging children before a node is published.
pub type OverlayChildren<K, V> = ;
/// A single `(key unit, child)` slot, as produced by a completed subtree build.
pub type OverlayChildSlot<K, V> = ;
/// Outcome of a compare-and-swap publish attempt.
///
/// `Ok` carries the node that is now installed; `Err` carries the node found
/// instead, so the caller can retry against the observed state rather than
/// re-reading it.
pub type OverlayCasResult<K, V> = ;
/// A `(published root, published node)` pair returned by a copy-on-write republish.
pub type OverlayRootAndNode<K, V> = ;
use crateTrieRoot;
/// G4 Phase 6 (DRY bonus): the single `TrieRoot` impl for the unified overlay
/// node, replacing the two near-identical per-variant impls (byte
/// `persistent_artrie::mvcc` and char `persistent_artrie::char::mvcc`).
///
/// `Key = K::Unit` (`u8` for byte, `u32` for char — both satisfy `Key: Copy`);
/// `Value = V`. For `OverlayNode<ByteKey, i64>` this yields `Key=u8, Value=i64`
/// (identical to the old hand-written byte impl) and for `OverlayNode<CharKey, V>`
/// it yields `Key=u32, Value=V` (identical to the old char impl) — so the blanket
/// subsumes both exactly. Coherence holds: both `TrieRoot` and `OverlayNode` live
/// in `persistent_artrie::core`, so the blanket is canonical here (no orphan-rule
/// issue, single crate).