NautilusKernel and System Orchestration
Relevant Rust source files
crates/system/src/kernel.rscrates/system/src/config.rscrates/system/src/clock_factory.rscrates/system/src/trader.rscrates/common/src/msgbus/mod.rscrates/common/src/cache/database.rscrates/live/src/node/builder.rscrates/backtest/src/engine.rs
NautilusKernel is the Rust composition root shared by higher-level execution contexts. It owns the infrastructure and engine graph that must agree on identity, time, messaging, cache state, and lifecycle. It is not a process manager and it is not a global service locator for arbitrary application dependencies.
Construction paths
The public constructors make increasing levels of dependency ownership explicit:
NautilusKernel::newbuilds from a name and aNautilusKernelConfig.new_with_cache_databaseadds a concreteCacheDatabaseAdapter.new_withaccepts cache and event-store factories.new_with_dependenciesaccepts a completeNautilusKernelDependenciesvalue.
NautilusKernelDependencies is the seam for a ClockFactory, cache database factory, event-store factory, message-bus backing factory, and other owned infrastructure. This is the correct replacement point for storage or transport; domain and engine types remain unchanged.
Owned component graph
The kernel installs the in-process message bus, constructs the cache, wires the portfolio and engines, and exposes the trader used to register actors, strategies, and execution algorithms. LiveNodeBuilder adds provider-specific clients around this graph. BacktestEngine composes the same foundations with deterministic time and simulated exchanges.
Lifecycle
start activates the kernel-owned components in dependency order. start_trader starts the registered user components after infrastructure and engines are ready. stop_trader and stop_trader_after_start_failure provide distinct normal and rollback paths; callers should not collapse failed startup into ordinary shutdown because partially started components need bounded cleanup.
The kernel records whether it is running and coordinates trader state, but node and runner types own the outer process loop. A live runner handles signals and asynchronous client tasks. A backtest engine advances simulated time and dispatches data in timestamp order.
Time and determinism
The injected ClockFactory selects the temporal implementation. Backtests use a TestClock; live systems use LiveClock. Engines consume the clock contract rather than inspecting the execution environment. That makes timestamp ordering, timers, and lifecycle callbacks testable without changing component code.
Persistence boundaries
The cache is the current in-memory operating state. CacheDatabaseAdapter is the durability port for cache state. EventStoreFactory creates the append/replay facility used by the kernel when event sourcing is configured. A message-bus backing is a transport/egress concern and must not be mistaken for authoritative cache or event-store durability.
Failures to create a configured dependency are construction errors. Do not silently substitute an in-memory adapter in live operation: doing so changes recovery behavior. Likewise, component registration and client factory failures should stop node construction before external connectivity begins.
Integration rule
Applications should configure the kernel through typed config and narrow factories, then let BacktestNode or LiveNode own lifecycle. Rebuilding the kernel graph manually duplicates ordering and recovery invariants already encoded by Nautilus. Replace only a documented factory or adapter boundary when the required storage or provider is not supplied upstream.