08. End-to-End Flows
Sequence diagrams tracing data across crate boundaries. The working detection pipeline, the working backtest run, a mostly-roadmap live atomic trade, and how the control plane closes the loop.
This chapter traces the data across crate boundaries. Three flows: the detection pipeline (works today), the backtest run (works today), and a live atomic trade (mostly roadmap, shown to make the seams concrete).
Flow A: Detection over a stream ✅
What lorenz-stream::detect_stream does, snapshot by snapshot. This is the exact
analysis step the live engine runs; only the source changes.
Key point: the rates that build the graph are f64 at a single probe size, so the
Cycle is a candidate. Certifying profit requires the exact, integer,
size-aware re-pricing shown in Flow B.
Flow B: Backtest run ✅
lorenz-backtest::run_backtest reuses the same detection step, then adds exact
sizing and the cost model.
The same CostConfig type feeds both this and the (future) live engine, so the
simulation cannot be quietly rosier than production (O4).
Flow C: Live atomic trade (mostly 🔭 / 🟡)
The intended production path. Bold steps exist and are tested; the rest are seams or roadmap. Shown to make precise what is missing.
Where each gap lives
| Gap | Status | Where | Chapter |
|---|---|---|---|
| Geyser/Yellowstone transport | 🟡 | lorenz-stream::geyser (connect → NotImplemented) | 04 |
| Tx builder / submission (versioned tx, LUTs, Jito bundle) | 🔭 | not in code | 01 |
| Flash-loan borrow/repay CPI | 🟡 | programs/executor mod flash_loan | 06 |
| Multi-DEX swap route CPI | 🟡 | programs/executor mod route | 06 |
| CLMM/DLMM decoders + tick-crossing math | 🔭 | lorenz-dex::decoder roadmap decoders | 04 |
| Real LLM client | 🔭 | implement lorenz-agent::LlmClient | 05 |
How the control plane closes the loop
Independently of the hot path, on a slower cadence:
The down-channel is only ever tighter limits + bounded params; the up-channel
is TradeRecord/EngineStats. Neither plane can violate the other's guarantees:
the agent cannot widen a cap, and the chain still refuses any unprofitable settle.
Continue to 09. Safety & Invariants.
07. Backtester
lorenz-backtest, the deterministic replay harness. The JSON market data model, the shared cost model, the run loop with exact hop-by-hop sizing, the BacktestReport, and the reproducible runnable binary.
09. Safety & Invariants
The architectural companion to the canonical invariants: the two tiers (on-chain I1–I5, off-chain O1–O5), why each holds and where to verify it, the threat model, and the honest limits of what safety does not yet cover.