# Canonical execution and retained compatibility The earlier EventBus, mode-engine and strategy-framework migration described here was abandoned. Its uncompiled alternative modules and unused placeholder adapters have been removed. Do not use that design as an implementation guide. Current research and paper execution share the authoritative Rust core in [src/financial](src/financial/mod.rs): replay → matching → risk → ledger. TypeScript owns strategy decisions, worker supervision and durable SQL custody. [api/replay.rs](src/api/replay.rs) exposes `FinancialReplaySession`; [api/paper.rs](src/api/paper.rs) exposes `stageFinancialTransaction`. Start with the [code-reading guide](../../../docs/guide/code-reading.md) to trace a complete decision. ## Supported boundaries | Purpose | Code | Guidance | | --- | --- | --- | | Current financial execution | `src/financial/`, `src/api/replay.rs`, `src/api/paper.rs` | Use for canonical research and paper execution. Preserve deterministic ordering, financial invariants and recovery contracts. | | Indicators and analytical calculations | `src/indicators/`, `src/analytics/`, native risk/orderbook analytics, `libs/calculations/` | Retained capabilities. Reuse reviewed implementations and their fixtures. | | Legacy native execution and accounting | `TradingEngine`, native `BacktestEngine`, `src/core/`, `src/backtest/`, `src/positions/`, `src/risk/`, `src/strategies/` | Retained for compatibility, regression tests and existing algorithm examples. They are not an alternative execution path for current admitted research jobs. | The compiled `src/backtest/simple_results.rs`, `src/strategies/mean_reversion_fixed.rs`, public native constructors, and historical regression fixtures are unchanged by this cleanup. No saved dataset, strategy package, result or checkpoint is migrated or removed. ## CL15 removal and preservation inventory Evidence baseline: `700ee09c`. Cargo's library target is `src/lib.rs`; its module declarations, `src/backtest/mod.rs` and `src/strategies/mod.rs` define the compiled graph. Repository searches found no consumers of the removed adapters outside their own implementation and this former migration guide. | Previous path under `src/` | Disposition and reason | | --- | --- | | `adapters/{mod,events,strategy}.rs` | Removed unused compiled migration scaffold. The execution adapter fabricated price-100 fills without invoking the wrapped handler; status queries fabricated `Filled`. Event and strategy adapters targeted placeholder interfaces. None were NAPI exports or used by repository tests/applications. | | `lib_new.rs`, `lib_simplified.rs`, `test_lib.rs` | Removed undeclared alternative crate roots. Cargo has no target or source inclusion for them. | | `api_new/{mod,backtest,market_data,orders,positions,strategies,system}.rs` | Removed undeclared API skeleton targeting the abandoned root/domain/mode design; many operations were `todo!`. Current `src/api/` is retained. | | `domain.bak/{mod,market,orders,positions,events}.rs` | Removed undeclared duplicate domain types and elementary position helpers. Compiled legacy types/accounting remain in `src/lib.rs` and `src/positions/`; canonical equivalents remain in `src/financial/`. | | `events.bak/mod.rs` | Removed undeclared event-bus scaffold. No current event or recovery journal uses it. | | `modes.bak/{mod,backtest,paper,live}.rs` | Removed undeclared alternate runtime, mock broker and simplistic fill/accounting implementations. These depended on the abandoned event/domain design, not the canonical matcher or any supported broker. | | `strategies/framework/mod.rs` | Removed undeclared generic strategy trait/context and no-op base strategy. It contained no concrete signal algorithm; all compiled strategies remain. | | `backtest/metrics_calculator.rs`, `backtest/results.rs` | Removed uncompiled reporting prototypes; canonical metric calculations live in `@stock-bot/calculations`. | The archived calculator includes return, drawdown, streak and symbol-analysis logic alongside placeholder fields and incomplete methods. Moving it does not make those formulas reviewed or compilable. New calculations should enter the reviewed calculation library with explicit semantics and tests, not reactivate the abandoned financial simulator. ## Verification Run the Rust library tests and rebuild the addon from the same checkout before native binding, market-data and terminal-equity integration tests. Existing architecture checks must continue to prevent production TypeScript entrypoints from reaching prototype financial execution. This cleanup changes the source/module surface, not economic policies, native wire contracts or existing saved artifacts.