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
43pub mod backend;
44pub mod capture;
45pub mod entry;
46pub mod error;
47pub mod hash;
48pub mod headers;
49pub mod kernel;
50pub mod manifest;
51pub mod markers;
52pub mod reader;
53pub mod replay;
54pub mod retention;
55pub mod snapshot;
56pub mod verifier;
57pub mod writer;
58
59mod wire;
60
61pub use backend::{
62    AppendEntry, EventStore, IndexKey, IndexKind, MemoryBackend, RedbBackend, ScanDirection,
63};
64pub use capture::{
65    BusCaptureAdapter, CaptureError, Encode, EncodeError, EncodedPayload, EncoderRegistry,
66    PAYLOAD_TYPE_ACCOUNT_STATE, PAYLOAD_TYPE_FILL_REPORT, PAYLOAD_TYPE_ORDER_FILLED,
67    PAYLOAD_TYPE_ORDER_STATUS_REPORT, PAYLOAD_TYPE_POSITION_STATUS_REPORT,
68    PAYLOAD_TYPE_SUBMIT_ORDER, TypedEncoder, default_registry, encode_account_state,
69    encode_fill_report, encode_order_filled, encode_order_status_report,
70    encode_position_status_report, encode_submit_order, register_default,
71};
72pub use entry::{EventStoreEntry, PayloadType, Topic};
73pub use error::EventStoreError;
74pub use hash::{EntryHash, compute_entry_hash};
75pub use headers::Headers;
76pub use kernel::{
77    BootError, EventStoreLifecycle, EventStoreLifecycleOptions, EventStoreSession, HaltSignal,
78    KernelError, RecoveredRun, RecoveryOutcome, build_run_id, open_run, open_run_with_options,
79    recover_predecessors,
80};
81pub use manifest::{RunId, RunManifest, RunStatus};
82pub use markers::{
83    CursorState, DEFAULT_MARKER_CHANNEL_CAPACITY, DEFAULT_MARKER_MAX_BATCH,
84    DEFAULT_MARKER_MAX_LATENCY, DataClass, DataCursorSnapshot, DataMarkerCapture,
85    DataMarkerExtractor, DataMarkerExtractorRegistry, HiFiMarker, MarkerBackend, MarkerCountKind,
86    MarkerFinding, MarkerGap, MarkerGapReason, MarkerManifest, MarkerMsg, MarkerReader,
87    MarkerRecordKind, MarkerVerifier, MarkerVerifyReport, MarkerWriter, MarkerWriterConfig,
88    MemoryMarkerBackend, RedbMarkerBackend, StoredMarkerRecord, StreamCursor, StreamDictEntry,
89    StreamSlot, compute_dict_hash, compute_gap_hash, compute_hifi_hash, compute_marker_hash,
90};
91#[cfg(feature = "persistence")]
92pub use markers::{JoinedStream, join_at_entry};
93pub use nautilus_system::{
94    RegisteredComponents,
95    event_store::{
96        DEFAULT_DATA_MARKER_CHANNEL_CAPACITY, DEFAULT_DATA_MARKER_SAFETY_FLUSH_INTERVAL,
97        DataMarkerClass, DataMarkerConfig, EventStoreConfig, RetentionMode, RunIdentity,
98    },
99};
100pub use reader::{DEFAULT_SCAN_CHUNK_SIZE, EventStoreReader, RangeScan, SnapshotReplayPlan};
101#[cfg(feature = "persistence")]
102pub use replay::ParquetReplayCatalog;
103pub use replay::{
104    CacheReplayError, CacheReplayReport, CatalogReplayData, CatalogReplayRecord,
105    CatalogReplaySlice, CatalogSliceCoverage, CatalogSlicePlan, CatalogSliceQuery,
106    CatalogSliceSelector, EventStoreReplayReport, ReplayCatalog, ReplayInputError, ReplayInputPlan,
107    ReplayInputs, ReplaySeqRange, ReplayTimeRange, apply_cache_replay_entry,
108    load_catalog_replay_inputs, load_forensics_replay_inputs, open_event_store_replay_source,
109    plan_catalog_replay_inputs, plan_forensics_replay_inputs, replay_cache_snapshot_tail,
110    restore_cache_from_sealed_run, restore_cache_snapshot_and_replay_tail,
111    restore_cache_snapshot_blob, validate_event_store_replay_source,
112};
113pub use retention::{
114    RetentionPlan, RetentionRun, SnapshotAnchorStatus, list_redb_sealed_runs, plan_redb_retention,
115    plan_retention,
116};
117pub use snapshot::{SnapshotAnchor, compute_snapshot_content_hash};
118pub use verifier::{
119    GapRange, IndexDrift, ManifestField, Verifier, VerifyError, VerifyFinding, VerifyReport,
120};
121pub use writer::{
122    DEFAULT_CHANNEL_CAPACITY, DEFAULT_HALT_THRESHOLD, DEFAULT_MAX_BATCH_ENTRIES,
123    DEFAULT_MAX_BATCH_LATENCY, EntryDraft, EventStoreWriter, HaltCallback, HaltReason, SubmitError,
124    WriterConfig, noop_halt,
125};