Skip to main content

nautilus_event_store/
lib.rs

1// -------------------------------------------------------------------------------------------------
2//  Copyright (C) 2015-2026 Nautech Systems Pty Ltd. All rights reserved.
3//  https://nautechsystems.io
4//
5//  Licensed under the GNU Lesser General Public License Version 3.0 (the "License");
6//  You may not use this file except in compliance with the License.
7//  You may obtain a copy of the License at https://www.gnu.org/licenses/lgpl-3.0.en.html
8//
9//  Unless required by applicable law or agreed to in writing, software
10//  distributed under the License is distributed on an "AS IS" BASIS,
11//  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12//  See the License for the specific language governing permissions and
13//  limitations under the License.
14// -------------------------------------------------------------------------------------------------
15
16//! Event store and authoritative log of state-affecting messages for [NautilusTrader](https://nautilustrader.io).
17//!
18//! The `nautilus-event-store` crate provides an embedded, append-only event store that captures
19//! commands, events, venue reports, and correlations flowing across the message bus. Combined with
20//! cache snapshots, it provides stable restarts via tail-replay, deterministic incident replay,
21//! end-to-end audit of agent decisions, and counterfactual research.
22//!
23//! See `README.md` for the high-level specification.
24//!
25//! # NautilusTrader
26//!
27//! [NautilusTrader](https://nautilustrader.io) is an open-source, production-grade, Rust-native
28//! engine for multi-asset, multi-venue trading systems.
29//!
30//! The system spans research, deterministic simulation, and live execution within a single
31//! event-driven architecture, providing research-to-live semantic parity.
32
33#![warn(rustc::all)]
34#![warn(clippy::pedantic)]
35#![deny(unsafe_code)]
36#![deny(unsafe_op_in_unsafe_fn)]
37#![deny(nonstandard_style)]
38#![deny(missing_debug_implementations)]
39#![deny(clippy::missing_errors_doc)]
40#![deny(clippy::missing_panics_doc)]
41#![deny(rustdoc::broken_intra_doc_links)]
42#![allow(
43    clippy::assert_is_empty,
44    reason = "`assert!(x.is_empty())` is clearer than comparing against an empty value"
45)]
46
47pub mod backend;
48pub mod capture;
49pub mod codec;
50pub mod entry;
51pub mod error;
52pub mod hash;
53pub mod headers;
54pub mod kernel;
55pub mod manifest;
56pub mod markers;
57pub mod reader;
58pub mod replay;
59pub mod retention;
60pub mod snapshot;
61pub mod verifier;
62pub mod writer;
63
64mod format;
65mod wire;
66
67pub use backend::{
68    AppendEntry, EventStore, IndexKey, IndexKind, MemoryBackend, RedbBackend, ScanDirection,
69};
70pub use capture::{
71    BusCaptureAdapter, CaptureError, Encode, EncodeError, EncodedPayload, EncoderRegistry,
72    PAYLOAD_TYPE_ACCOUNT_STATE, PAYLOAD_TYPE_FILL_REPORT, PAYLOAD_TYPE_ORDER_FILLED,
73    PAYLOAD_TYPE_ORDER_STATUS_REPORT, PAYLOAD_TYPE_POSITION_STATUS_REPORT,
74    PAYLOAD_TYPE_SUBMIT_ORDER, TypedEncoder, default_registry, encode_account_state,
75    encode_fill_report, encode_order_filled, encode_order_status_report,
76    encode_position_status_report, encode_submit_order, register_default,
77};
78pub use entry::{EventStoreEntry, PayloadType, Topic};
79pub use error::EventStoreError;
80pub use hash::{EntryHash, compute_entry_hash};
81pub use headers::Headers;
82pub use kernel::{
83    BootError, EventStoreLifecycle, EventStoreLifecycleOptions, EventStoreSession, HaltSignal,
84    KernelError, RecoveredRun, RecoveryOutcome, build_run_id, open_run, open_run_with_options,
85    recover_predecessors,
86};
87pub use manifest::{RunId, RunManifest, RunStatus};
88pub use markers::{
89    CursorState, DEFAULT_MARKER_CHANNEL_CAPACITY, DEFAULT_MARKER_MAX_BATCH,
90    DEFAULT_MARKER_MAX_LATENCY, DataClass, DataCursorSnapshot, DataMarkerCapture,
91    DataMarkerExtractor, DataMarkerExtractorRegistry, HiFiMarker, MarkerBackend, MarkerCountKind,
92    MarkerFinding, MarkerGap, MarkerGapReason, MarkerManifest, MarkerMsg, MarkerReader,
93    MarkerRecordKind, MarkerVerifier, MarkerVerifyReport, MarkerWriter, MarkerWriterConfig,
94    MemoryMarkerBackend, RedbMarkerBackend, StoredMarkerRecord, StreamCursor, StreamDictEntry,
95    StreamSlot, compute_dict_hash, compute_gap_hash, compute_hifi_hash, compute_marker_hash,
96};
97#[cfg(feature = "persistence")]
98pub use markers::{JoinedStream, join_at_entry};
99pub use nautilus_system::{
100    RegisteredComponents,
101    event_store::{
102        DEFAULT_DATA_MARKER_CHANNEL_CAPACITY, DEFAULT_DATA_MARKER_SAFETY_FLUSH_INTERVAL,
103        DataMarkerClass, DataMarkerConfig, EventStoreConfig, RetentionMode, RunIdentity,
104    },
105};
106pub use reader::{DEFAULT_SCAN_CHUNK_SIZE, EventStoreReader, RangeScan, SnapshotReplayPlan};
107#[cfg(feature = "persistence")]
108pub use replay::ParquetReplayCatalog;
109pub use replay::{
110    CacheReplayError, CacheReplayReport, CatalogReplayData, CatalogReplayRecord,
111    CatalogReplaySlice, CatalogSliceCoverage, CatalogSlicePlan, CatalogSliceQuery,
112    CatalogSliceSelector, EventStoreReplayReport, ReplayCatalog, ReplayInputError, ReplayInputPlan,
113    ReplayInputs, ReplaySeqRange, ReplayTimeRange, apply_cache_replay_entry,
114    load_catalog_replay_inputs, load_forensics_replay_inputs, open_event_store_replay_source,
115    plan_catalog_replay_inputs, plan_forensics_replay_inputs, replay_cache_snapshot_tail,
116    restore_cache_from_sealed_run, restore_cache_snapshot_and_replay_tail,
117    restore_cache_snapshot_blob, validate_event_store_replay_source,
118};
119pub use retention::{
120    RetentionPlan, RetentionRun, SnapshotAnchorStatus, list_redb_sealed_runs, plan_redb_retention,
121    plan_retention,
122};
123pub use snapshot::{SnapshotAnchor, compute_snapshot_content_hash};
124pub use verifier::{
125    GapRange, IndexDrift, ManifestField, Verifier, VerifyError, VerifyFinding, VerifyReport,
126};
127pub use writer::{
128    DEFAULT_CHANNEL_CAPACITY, DEFAULT_HALT_THRESHOLD, DEFAULT_MAX_BATCH_ENTRIES,
129    DEFAULT_MAX_BATCH_LATENCY, EntryDraft, EventStoreWriter, HaltCallback, HaltReason, SubmitError,
130    WriterConfig, noop_halt,
131};