Skip to main content

zeppelin_embed/
lib.rs

1//! Embedded hybrid-search engine primitives.
2//!
3//! # Durability
4//!
5//! [`lifecycle::durability::DurabilityMode`] defaults to `Derived`. The default
6//! issues no synchronization primitive at any commit tier; under it,
7//! [`lifecycle::durability::CommitTier`] is ignored entirely. An application
8//! crash or process kill does not lose acknowledged writes because the
9//! operating-system page cache retains them and writes them out afterward. A
10//! power cut or kernel panic can lose recently acknowledged writes. Recovery
11//! truncates the log at the first record whose checksum fails, leaving a
12//! structurally valid store with a missing recent tail rather than silently
13//! wrong data.
14//!
15//! `Derived` asserts that another store is authoritative and this store can be
16//! rebuilt from it. If this store is the only copy of the data, select
17//! [`lifecycle::durability::DurabilityMode::Durable`] explicitly.
18
19#![deny(
20    clippy::expect_used,
21    clippy::indexing_slicing,
22    clippy::panic,
23    clippy::todo,
24    clippy::unimplemented,
25    clippy::unwrap_used,
26    unsafe_op_in_unsafe_fn
27)]
28#![warn(missing_docs)]
29
30#[cfg(all(
31    feature = "graph-cypher",
32    not(any(
33        target_os = "macos",
34        all(target_os = "windows", target_arch = "x86_64")
35    ))
36))]
37compile_error!("graph-cypher supports macOS (arm64, x86_64) and Windows x64 only");
38
39#[cfg(feature = "allocation-audit")]
40mod allocation_audit;
41
42#[cfg(any(test, feature = "test-seams"))]
43#[doc(hidden)]
44pub mod adversarial_test_support;
45
46/// Fixed keyed fixture for integration tests of the Cypher writer seam.
47#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
48#[doc(hidden)]
49pub mod graph_structured_write_test_support {
50    use crate::lifecycle::{CancelToken, QueryControl, Store};
51    use crate::property_graph::staging::{StructuredOperation, StructuredWrite, WriteImage};
52    use crate::property_graph::{
53        ApplicationKey, CanonicalContents, EntityId, EntityKind, GraphGeneration, GraphName,
54        GraphProperty, GraphRevision, NodeId, PropertyData, PropertyValue,
55    };
56
57    /// Creates one application-keyed `:A {v: 1}` through the real writer.
58    pub fn create_keyed_node(store: &Store) -> Result<(NodeId, GraphGeneration), String> {
59        let mut labels = [GraphName::new("A").map_err(|e| format!("label: {e:?}"))?];
60        let mut properties = [GraphProperty::new(
61            GraphName::new("v").map_err(|e| format!("property name: {e:?}"))?,
62            PropertyValue::new(PropertyData::I64(1))
63                .map_err(|e| format!("property value: {e:?}"))?,
64        )];
65        let image = CanonicalContents::node(&mut labels, &mut properties, None, None)
66            .map_err(|e| format!("node image: {e:?}"))?;
67        let receipts = store
68            .apply_native_graph(
69                &[StructuredWrite {
70                    key: ApplicationKey::new(EntityKind::Node, "app", "ze214")
71                        .map_err(|e| format!("application key: {e:?}"))?,
72                    revision: GraphRevision::new(1).map_err(|e| format!("revision: {e:?}"))?,
73                    operation: StructuredOperation::Create,
74                    image: Some(WriteImage::Node(&image)),
75                }],
76                &QueryControl::Cancel(CancelToken::new()),
77            )
78            .map_err(|e| format!("structured create: {e:?}"))?;
79        if receipts.len() != 1 {
80            return Err("structured create did not return exactly one receipt".to_owned());
81        }
82        let receipt = receipts
83            .first()
84            .ok_or_else(|| "structured create returned no receipt".to_owned())?;
85        match receipt.entity {
86            EntityId::Node(node) => Ok((node, receipt.generation)),
87            EntityId::Relationship(_) => {
88                Err("structured create returned a relationship".to_owned())
89            }
90        }
91    }
92}
93
94#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
95#[doc(hidden)]
96pub mod graph_native_vector_index_test_support {
97    pub use crate::property_graph::storage::search::{
98        ActualProbeReport, CleanPreparationObservation, CloseFailureObservation,
99        ControlProbeReport, IdentityProbeReport, KernelProbeReport, LimitProbeReport,
100        NativeFailureObservation, OracleControlObservation, OracleProbeReport, PhysicalReadReceipt,
101        PhysicalReadReport, ReopenIndexObservation, ReopenProbeReport, SmallWriteSourceObservation,
102        SmallWritesProbeReport, TraceBatchObservation, TraceProbeReport, TraceSourceObservation,
103        run_actual_probe, run_identity_probe, run_kernel_probe, run_oracle_probe,
104        run_preparation_schedule_probe, run_reopen_probe, run_small_writes_probe, run_trace_probe,
105    };
106}
107
108#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
109#[doc(hidden)]
110pub mod graph_read_view_test_support {
111    /// One completed production boundary, emitted only after its exact direct
112    /// assertion and any paired clean control returned successfully.
113    #[derive(Clone, Debug, Eq, PartialEq)]
114    pub struct PathReceipt {
115        /// Registry key owned by the completed boundary.
116        pub key: &'static str,
117        /// Actual scheduled failures observed at that boundary.
118        pub fires: u64,
119        /// Same-seed clean executions observed after or beside the failure.
120        pub clean_controls: u64,
121    }
122
123    /// Primitive actual relationship observation for the independent ZE-129
124    /// oracle crate; this type contains no expected answer or comparator.
125    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
126    pub struct ObservedRelationship {
127        pub rel: u128,
128        pub source: u128,
129        pub target: u128,
130        pub relationship_type: u64,
131    }
132
133    /// Exact receipts and actual rows from one controlled probe execution.
134    #[derive(Clone, Debug, Eq, PartialEq)]
135    pub struct ActualProbeReport {
136        pub receipts: Vec<PathReceipt>,
137        pub relationships: Vec<ObservedRelationship>,
138    }
139    /// Confirms that the controlled fixture boundary is linked only into a
140    /// test-support build. Behavioral acceptance remains on the internal scoped
141    /// adapter so no installer or read capability becomes a shipping API.
142    pub fn controlled_boundary_is_available() -> bool {
143        std::mem::size_of::<crate::lifecycle::native_graph::NativeReadLease>() > 0
144            && std::mem::size_of::<crate::property_graph::storage::GraphReadView<'_, '_, '_, '_>>()
145                > 0
146    }
147
148    /// Runs the real controlled native adapter, fault, lifetime and release paths.
149    /// Panics are retained as test failures; the shipping graph feature has no
150    /// installer or fixture surface because this module requires test-support.
151    pub fn run_actual_probe(seed: u64) -> ActualProbeReport {
152        crate::lifecycle::native_graph::tests::run_adversarial_probe(seed)
153    }
154}
155
156#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
157#[doc(hidden)]
158pub mod graph_publication_test_support {
159    /// Runs only the directed production coordinator paths and returns observed receipts.
160    pub fn run_actual_probe(seed: u64) -> crate::graph_read_view_test_support::ActualProbeReport {
161        crate::lifecycle::native_graph::tests::publication::run_actual_probe(seed)
162    }
163}
164
165#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
166#[doc(hidden)]
167pub mod graph_identity_test_support {
168    use crate::graph_read_view_test_support::PathReceipt;
169
170    /// One observed adjacency row, bound to the node the question named.
171    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
172    pub struct ObservedAdjacency {
173        /// Node the expansion was bound to.
174        pub bound_node: u128,
175        /// Exact relationship type identity.
176        pub relationship_type: u64,
177        /// Exact relationship identity.
178        pub rel: u128,
179        /// Other endpoint of that row.
180        pub neighbor: u128,
181    }
182
183    /// Exact outcome of one keyed request. It holds no expected answer.
184    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
185    pub struct ObservedOutcome {
186        /// Key ordinal the request named.
187        pub key: u32,
188        /// Primitive rejection name, absent when the request was admitted.
189        pub rejection: Option<&'static str>,
190        /// Installed or replayed identity; zero on a rejection.
191        pub entity: u128,
192        /// Installed or replayed revision; zero on a rejection.
193        pub revision: u64,
194        /// Original generation for a replay, changed generation otherwise.
195        pub generation: u64,
196        /// Exact replay classification.
197        pub replayed: bool,
198    }
199
200    /// Complete visible rows of one watched expansion after one batch.
201    #[derive(Clone, Debug, Eq, PartialEq)]
202    pub struct ObservedWatch {
203        /// Batch index this answer follows.
204        pub batch: usize,
205        /// Published generation the reader observed.
206        pub generation: u64,
207        /// Key ordinal whose current incarnation was bound.
208        pub key: u32,
209        /// Whether the expansion was outgoing.
210        pub outgoing: bool,
211        /// Complete rows, in the order the engine returned them.
212        pub rows: Vec<ObservedAdjacency>,
213    }
214
215    /// Actual state observed from one real keyed identity script.
216    #[derive(Clone, Debug, Eq, PartialEq)]
217    pub struct IdentityState {
218        /// Ordered receipts and rejections of the script.
219        pub outcomes: Vec<ObservedOutcome>,
220        /// Watched expansions after every batch.
221        pub watched: Vec<ObservedWatch>,
222        /// Generation held by a reader admitted before the deletion.
223        pub retained_generation: u64,
224        /// Rows that retained reader still observes after the deletion,
225        /// the recreation and a real reclamation cycle.
226        pub retained_rows: Vec<ObservedAdjacency>,
227        /// Generation observed by a reader admitted after those changes.
228        pub fresh_generation: u64,
229        /// Rows that newly admitted reader observes.
230        pub fresh_rows: Vec<ObservedAdjacency>,
231    }
232
233    /// Receipts emitted only after each directed identity body completes.
234    #[derive(Clone, Debug, Eq, PartialEq)]
235    pub struct IdentityProbeReport {
236        /// Completed path receipts with actual fired and clean counts.
237        pub receipts: Vec<PathReceipt>,
238        /// Actual state observed from one real script.
239        pub state: IdentityState,
240    }
241
242    /// Runs the directed production identity paths used by ZE-36 acceptance.
243    pub fn run_actual_probe(seed: u64) -> IdentityProbeReport {
244        crate::lifecycle::native_graph::tests::run_identity_probe(seed)
245    }
246}
247
248#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
249#[doc(hidden)]
250pub mod graph_reclaim_test_support {
251    use crate::graph_read_view_test_support::{ObservedRelationship, PathReceipt};
252
253    /// Actual state observed after one real reclaim cycle and a reopen. It
254    /// holds no expected answer and no comparator.
255    #[derive(Clone, Debug, Eq, PartialEq)]
256    pub struct ReclaimState {
257        /// First created node identity.
258        pub first_node: u128,
259        /// Second created node identity.
260        pub second_node: u128,
261        /// OUT rows of the first node after the cycle and the reopen.
262        pub relationships: Vec<ObservedRelationship>,
263        /// Generation replayed for the original installing request.
264        pub replay_generation: u64,
265        /// Whether that request was classified as an exact replay.
266        pub replayed: bool,
267        /// Bytes physically unlinked by the cycle.
268        pub removed_bytes: u64,
269        /// Summed on-disk lengths of the files the cycle unlinked.
270        pub unlinked_file_bytes: u64,
271    }
272
273    /// Receipts emitted only after each directed reclamation body completes.
274    #[derive(Clone, Debug, Eq, PartialEq)]
275    pub struct ReclaimProbeReport {
276        /// Completed path receipts with actual fired and clean counts.
277        pub receipts: Vec<PathReceipt>,
278        /// Actual state after a real cycle.
279        pub state: ReclaimState,
280        /// Actual post-sweep key visibility and original install replay generation.
281        pub detach_sweep: (bool, u64),
282    }
283
284    /// Narrow measured reader-race observations and serialized controls.
285    #[derive(Clone, Debug, Eq, PartialEq)]
286    pub struct RaceProbeReport {
287        /// Old generation, canonical bytes, and root/WAL unlink results.
288        pub observation: (u64, Vec<u8>, bool, bool),
289        /// Identical seed with serialized scheduling.
290        pub control: (u64, Vec<u8>, bool, bool),
291    }
292
293    /// Runs only ZE-176's same-coordinator reader races.
294    pub fn run_ze176_race_probe(seed: u64) -> RaceProbeReport {
295        crate::lifecycle::native_graph::tests::run_ze176_race_probe(seed)
296    }
297
298    /// Runs the directed production consolidation and reclamation paths used
299    /// by ZE-46 acceptance.
300    pub fn run_actual_probe(seed: u64) -> ReclaimProbeReport {
301        crate::lifecycle::native_graph::tests::run_reclaim_probe(seed)
302    }
303}
304
305#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
306#[doc(hidden)]
307pub mod graph_storage_fault_test_support {
308    use crate::graph_read_view_test_support::{ObservedRelationship, PathReceipt};
309    use crate::lifecycle::{OpenOptions, Store};
310    use crate::vfs::Vfs;
311    use std::path::Path;
312    use std::sync::Arc;
313
314    /// One keyed node observed in actual directory order. It holds no expected
315    /// answer and no comparator.
316    #[derive(Clone, Debug, Eq, PartialEq)]
317    pub struct ObservedKeyedNode {
318        /// Application-key bytes exactly as the fixture supplied them.
319        pub key: Vec<u8>,
320        /// Node identity the store resolved for that key.
321        pub node: u128,
322        /// Installed revision of that node record.
323        pub revision: u64,
324    }
325
326    /// Seeded per-class fault selection. The adversarial family owns the
327    /// schedule; this crate only executes the schedule it is handed.
328    #[derive(Clone, Copy, Debug, Eq, PartialEq)]
329    pub struct StorageFaultSchedule {
330        /// Byte position, modulo the damaged region, of the class-1 bit flip.
331        pub artifact_ref_offset: u64,
332        /// Upper bound on the keyed nodes class 2 commits while it discovers
333        /// which chunk splits the node directory.
334        pub split_keys: u32,
335        /// Which pre-split key class 2 resolves first through the old root.
336        pub split_probe: u32,
337        /// How many class-2 artifact creates succeed before the fault fires.
338        pub split_skip: u32,
339        /// Which class-3 adjacency append fails after the OUT append succeeds.
340        pub out_in_append: u32,
341        /// Selects the class-4 root-replacement variant order.
342        pub root_variant: u8,
343        /// Seeded byte offsets and selection fixture order for classes 5-6.
344        pub qualification_seed: u64,
345    }
346
347    /// Measured reclamation or scoped-mapping fault cell and its clean control.
348    #[derive(Clone, Debug, Default, Eq, PartialEq)]
349    pub struct QualificationCell {
350        /// Fault boundary actually executed.
351        pub name: String,
352        /// Actual targeted injections and clean completions.
353        pub fires: u64,
354        pub controls: u64,
355        /// Explicit refused outcome, never a successful callback.
356        pub refusal: String,
357        /// Unauthorized deletes and changed protected files.
358        pub unauthorized_unlinks: u64,
359        pub changed_live_files: u64,
360        /// Pending authority survived, and all remaining targets resumed once.
361        pub intent_preserved: bool,
362        pub resumed: bool,
363        /// Reported bytes and independently summed physical unlink lengths.
364        pub removed_bytes: u64,
365        pub unlinked_bytes: u64,
366        /// Callback exposure on a refused mapping.
367        pub exposed_blocks: u64,
368        /// Slot fills at the scoped transition.
369        pub filled: usize,
370        /// Open attempts from the source and the independent VFS log.
371        pub opens: usize,
372        pub logged_opens: usize,
373        pub scoped_opens: usize,
374        /// Actual mark run/merge counts or folded manifest count.
375        pub runs: usize,
376        pub merges: usize,
377        pub folded: usize,
378        /// Successful publications making the count-only foreground leg due.
379        pub count_debt: u64,
380    }
381
382    /// Pack census measured before oldest-first selection, without random IDs.
383    #[derive(Clone, Debug, Eq, PartialEq)]
384    pub struct QualificationPack {
385        pub serial: u64,
386        pub bytes: u32,
387        pub live: u64,
388        pub pages: u32,
389        pub records: u32,
390        pub graph_live: bool,
391    }
392    /// Actual selection inputs and outputs, and same-seed clean identities.
393    #[derive(Clone, Debug, Default, Eq, PartialEq)]
394    pub struct QualificationSelection {
395        pub packs: Vec<QualificationPack>,
396        pub selected_serials: Vec<u64>,
397        pub clean_serials: Vec<u64>,
398        pub byte_limit: u64,
399        /// Direction and fixture group ordinal identify a range semantically.
400        pub ranges: Vec<(u8, usize, usize)>,
401        pub selected_ranges: Vec<(u8, usize)>,
402        pub clean_ranges: Vec<(u8, usize)>,
403        pub fixture_pending: Vec<usize>,
404    }
405
406    /// Per-commit source open counts compared with actual VFS open calls.
407    #[derive(Clone, Debug, Eq, PartialEq)]
408    pub struct QualificationCommit {
409        pub generation: u64,
410        pub opens: usize,
411        pub logged_opens: usize,
412        pub filled: usize,
413        pub scoped_opens: usize,
414    }
415
416    /// ZE-172 executions, separate from classes 1-4 for scoped binding runs.
417    #[derive(Clone, Debug, Default, Eq, PartialEq)]
418    pub struct QualificationReport {
419        pub cells: Vec<QualificationCell>,
420        pub selection: Option<QualificationSelection>,
421        pub commits: Vec<QualificationCommit>,
422    }
423
424    /// Execute real class-5 reclamation or class-6 scoped mapping cells.
425    pub fn run_qualification_probe(seed: u64, mapping: bool) -> QualificationReport {
426        crate::lifecycle::native_graph::tests::storage_faults::run_qualification_probe(
427            seed, mapping,
428        )
429    }
430
431    /// Actual state observed by one complete ZE-47 / ZE-172 execution.
432    #[derive(Clone, Debug, Eq, PartialEq)]
433    pub struct StorageFaultState {
434        /// Typed classification of every class-1 damaged-artifact refusal.
435        pub artifact_refusals: Vec<String>,
436        /// Nodes observed after each class-1 damage was reverted byte-exactly.
437        pub surviving_nodes: Vec<ObservedKeyedNode>,
438        /// Actual node-directory root level after the splitting commit
439        /// published, observed through a fresh lease.
440        pub split_level: u16,
441        /// Root level the retained pre-split lease still reports after that
442        /// same publication. A pre-split oracle must still read level zero.
443        pub retained_split_level: u16,
444        /// Keyed nodes committed before the splitting chunk, so the family
445        /// can model exactly the population both leases must answer.
446        pub pre_split_keys: u32,
447        /// Pre-split keys observed through a fresh post-split lease.
448        pub committed_keys: Vec<ObservedKeyedNode>,
449        /// The same keys resolved through the retained pre-split root.
450        pub old_root_keys: Vec<ObservedKeyedNode>,
451        /// Published generations observed before and after the class-2 faults
452        /// on the splitting commit, each through its own fresh lease.
453        pub split_generations: (u64, u64),
454        /// Xxh3-64 over the retained pre-split root page, before the faults
455        /// and after the splitting chunk published cleanly.
456        pub retained_root_digests: (u64, u64),
457        /// Generations before and after the WAL-envelope fault on the
458        /// splitting commit, the second one read through a reopen because
459        /// that refusal stops read admissions.
460        pub unsplit_generations: (u64, u64),
461        /// Node-directory root level that same reopen exposes. A split whose
462        /// WAL envelope never landed must not survive recovery.
463        pub unsplit_reopen_level: u16,
464        /// Typed classification of every class-2 refusal.
465        pub split_refusals: Vec<String>,
466        /// OUT rows of the class-3 relationship after a reopen.
467        pub out_rows: Vec<ObservedRelationship>,
468        /// IN rows of the same relationship after the same reopen.
469        pub in_rows: Vec<ObservedRelationship>,
470        /// Typed classification of every class-3 half-prepared refusal.
471        pub out_in_refusals: Vec<String>,
472        /// Typed classification of every class-4 root-replacement refusal.
473        pub root_refusals: Vec<String>,
474        /// Generation exposed by the class-4 reopen.
475        pub reopened_generation: u64,
476        /// Generation acknowledged before the class-4 fault.
477        pub previous_generation: u64,
478        /// Measured class-5/6 executions.
479        pub qualification: QualificationReport,
480    }
481
482    /// Receipts emitted only after each directed storage-fault body completes.
483    #[derive(Clone, Debug, Eq, PartialEq)]
484    pub struct StorageFaultProbeReport {
485        /// Completed path receipts with actual fired and clean counts.
486        pub receipts: Vec<PathReceipt>,
487        /// Actual state observed by the six fault classes.
488        pub state: StorageFaultState,
489    }
490
491    /// Runs the six directed ZE-47 / ZE-172 storage fault classes against a
492    /// real native store under a faulty VFS, following the supplied schedule.
493    pub fn run_actual_probe(seed: u64, schedule: StorageFaultSchedule) -> StorageFaultProbeReport {
494        crate::lifecycle::native_graph::tests::run_storage_fault_probe(seed, schedule)
495    }
496
497    /// Forwards the crate-private native-store constructor so an external
498    /// test crate can place its own [`Vfs`] under a real native store.
499    /// `lifecycle::native_graph` is `pub(crate)`, so `NativeGraphError` cannot
500    /// cross this seam; the refusal is rendered through its `Display`.
501    pub fn create_native_graph_with_infrastructure(
502        path: &Path,
503        options: OpenOptions,
504        vfs: Arc<dyn Vfs>,
505    ) -> Result<Store, String> {
506        Store::create_native_graph_with_infrastructure(
507            path,
508            options,
509            None,
510            vfs,
511            Arc::new(crate::lifecycle::SystemMonotonicClock),
512            &mut crate::property_graph::storage::allocation::OsEntropy,
513        )
514        .map_err(|error| error.to_string())
515    }
516
517    /// Forwards the crate-private native-store reopen constructor. See
518    /// [`create_native_graph_with_infrastructure`] for the error contract.
519    pub fn open_native_graph_with_infrastructure(
520        path: &Path,
521        options: OpenOptions,
522        vfs: Arc<dyn Vfs>,
523    ) -> Result<Store, String> {
524        Store::open_native_graph_with_infrastructure(
525            path,
526            options,
527            None,
528            vfs,
529            Arc::new(crate::lifecycle::SystemMonotonicClock),
530        )
531        .map_err(|error| error.to_string())
532    }
533}
534
535#[cfg(all(feature = "graph-cypher", feature = "test-seams"))]
536#[doc(hidden)]
537pub mod graph_recovery_test_support {
538    use crate::graph_read_view_test_support::{ObservedRelationship, PathReceipt};
539
540    /// Actual state observed after reopening one real mixed native commit.
541    #[derive(Clone, Debug, Eq, PartialEq)]
542    pub struct RecoveryState {
543        /// Actual persistent store identity.
544        pub store: u128,
545        /// Actual reopened graph generation.
546        pub generation: u64,
547        /// Actual reopened complete-envelope sequence.
548        pub sequence: u64,
549        /// First created node identity.
550        pub first_node: u128,
551        /// Second created node identity.
552        pub second_node: u128,
553        /// Actual relationship row observed in both directions.
554        pub relationship: ObservedRelationship,
555    }
556
557    /// Receipts emitted only after each directed recovery body completes.
558    #[derive(Clone, Debug, Eq, PartialEq)]
559    pub struct RecoveryProbeReport {
560        /// Completed path receipts with actual fired/clean counts.
561        pub receipts: Vec<PathReceipt>,
562        /// Actual reopened mixed state.
563        pub state: RecoveryState,
564    }
565
566    /// Runs the nine directed production recovery paths used by ZE-40 acceptance.
567    pub fn run_actual_probe(seed: u64) -> RecoveryProbeReport {
568        crate::lifecycle::native_graph::tests::run_recovery_probe(seed)
569    }
570}
571
572/// Nonshipping public-facade observations for seeded ZE-41 qualification.
573#[cfg(all(feature = "graph-cypher", any(test, feature = "test-seams")))]
574pub mod graph_commit_recovery_test_support {
575    pub use crate::property_graph::commit_recovery_test_support::*;
576}
577
578/// Query diagnostics and health reporting.
579pub mod diag;
580/// Epoch identity and migration.
581pub mod epoch;
582/// Persisted-format framing, versions, and golden-fixture support.
583pub mod format;
584/// Full-text indexing and retrieval.
585pub mod fts;
586/// Hybrid result fusion.
587pub mod fusion;
588/// Per-segment vector graphs.
589pub mod graph;
590/// Ingest and mutation coordination.
591pub mod ingest;
592/// Runtime-dispatched compute kernels.
593pub mod kernels;
594/// Store lifecycle and memory accounting.
595pub mod lifecycle;
596/// Persistent manifest coordination.
597pub mod manifest;
598/// Columnar metadata and filters.
599pub mod meta;
600/// Query planning and selectivity decisions.
601pub mod planner;
602/// Native property-graph identity and values, independent of vector indexes.
603#[cfg(feature = "graph-cypher")]
604pub mod property_graph;
605/// Training-free vector quantization.
606pub mod quant;
607/// Exact vector scanning.
608pub mod scan;
609/// Immutable segment representation.
610pub mod segment;
611/// Operating-system integration wrappers.
612pub mod sys;
613/// Adaptive storage tiers.
614pub mod tier;
615/// Read-only end-to-end store verification.
616pub mod verify;
617/// Virtual filesystem and platform I/O.
618pub mod vfs;
619/// Write-ahead logging and durability.
620pub mod wal;
621
622#[cfg(test)]
623mod test_support;
624
625/// The current crate version.
626pub const VERSION: &str = env!("CARGO_PKG_VERSION");
627
628#[cfg(test)]
629#[allow(
630    clippy::expect_used,
631    clippy::indexing_slicing,
632    clippy::panic,
633    clippy::unwrap_used
634)]
635mod tests {
636    use rand::RngCore;
637
638    #[test]
639    #[cfg_attr(miri, ignore = "environment-dependent RNG is outside the Miri subset")]
640    fn seeded_rng_is_deterministic_per_name_and_env() {
641        let mut first =
642            crate::test_support::seeded_rng("tests::seeded_rng_is_deterministic_per_name_and_env");
643        let mut second =
644            crate::test_support::seeded_rng("tests::seeded_rng_is_deterministic_per_name_and_env");
645        let mut other_name = crate::test_support::seeded_rng("tests::another_test");
646
647        let first_draw = first.next_u64();
648        let second_draw = second.next_u64();
649        let other_name_draw = other_name.next_u64();
650
651        let environment_seed = std::env::var("ZE_TEST_SEED").unwrap_or_else(|_| String::from("0"));
652        let other_environment_seed = format!("{environment_seed}-different");
653        let mut other_env = crate::test_support::seeded_rng_from(
654            "tests::seeded_rng_is_deterministic_per_name_and_env",
655            &other_environment_seed,
656        );
657        let other_env_draw = other_env.next_u64();
658
659        assert_eq!(first_draw, second_draw);
660        assert_ne!(first_draw, other_name_draw);
661        assert_ne!(first_draw, other_env_draw);
662    }
663
664    #[test]
665    fn version_constant_is_current() {
666        assert_eq!(crate::VERSION, "0.6.0");
667    }
668}