Ark Engine
Bitemporal Market Audit Ledger
Diagramas
Survival Architecture
Project Overview
Ark Engine is the persistence and audit layer of the Nexus Quant line. What is in production is the bitemporal ledger: each candle is written with two independent time dimensions — the valid time (the bar's own closing timestamp, when the fact occurred in the market) and the transaction time (when the system learned about it). That separation is what allows the system's state of knowledge at any past instant to be reconstructed exactly, eliminating point-in-time bias in backtests — the same defect that causes look-ahead bias when a dataset is queried only by its most recent state. The code is organised in a Polylith architecture, with the domain isolated from I/O: pure-logic components (risk-guard, strategy-engine, candle-aggregator) separated from infrastructure adapters (ingestor, temporal-db, connector). The domain is described by Malli contracts that act as a firewall against dirty data. The risk layer exists and is covered by generative tests, implementing Trading Policy Statement NQ-GOV-001; the live execution path is still under construction.
Architecture & Implementation
Bitemporal Ledger (the core)
- The XTDB node runs on RocksDB, with three separate stores (
index-store,document-store,tx-log). An equivalent in-memory topology exists, used only in tests. - Each candle is normalised into a write operation that pins Valid-Time to the bar's own timestamp — this is
bar->put-opin thetemporal-dbcomponent. - The document ID is deterministic (
candle/<symbol>/<timeframe>/<timestamp>). This makes ingestion idempotent by construction: re-inserting the same bar overwrites the same document instead of duplicating it.
Measured Write Cost
- The
tx-logstores roughly 1.5 KB per transaction, regardless of document size. One candle per transaction is expensive; ingestion therefore groups bars into batches within a single transaction (ingest-bars!), reducing the transaction count by two orders of magnitude for the same data volume. - The consequence of the batch being atomic is documented in the code itself: validate and coerce before the call, because a single invalid document takes down the entire batch.
Polylith: Domain Isolated from I/O
- The root
deps.ednhas:paths []— nothing lives at the root; every component is mounted via:local/root. - Pure logic:
risk-guard,strategy-engine,candle-aggregator,orchestrator. - Infrastructure:
ingestor(consumption and backpressure),temporal-db(writes to XTDB),connector(exchange connectivity). - Domain:
domain-model, with Malli contracts validating every piece of data at the boundary.
State of the Risk Layer
- The
risk-guardimplements the Trading Policy Statement NQ-GOV-001 limits and is covered by generative tests (test.check). - It is imported by the
orchestrator, but the:livebranch is still alog/warn "NOT IMPLEMENTED YET". In other words: the policy exists and is verified; no live order traverses it yet.
Live Demo
Access the online demo or project page.