Software Architect & Builder Ingestion & Ledger in Production · Live Execution Under Construction

Ark Engine

Bitemporal Market Audit Ledger

ClojurePolylithXTDBRocksDBMallicore.async

Diagramas

Survival Architecture

SURVIVAL ARCHITECTURE — ARK ENGINE"Survival is the precursor to success." — NQ-GOV-001Marketcandle closereal marketStrategy Enginegenerates the intentfor an orderRISK GUARDthe Constitutiondrawdown · leveragecarry · stalenessverified by test.checkOrder approvedwithin the limitsor refusedExecutionexit routeof the systemno signal — human or algorithmic —overrides the limits of the ConstitutionPillar 1 — Risk as a capital firewallLimits that exist before the order, not afterTiered drawdown: 6% → PAUSE · 15% → HALTSovereign exception: :reduce-only? always approvesThe right to leave is never blocked by bureaucracyPillar 2 — Bitemporal ledger (XTDB)Valid Time = when the fact occurred in the marketTransaction Time = when the system learned itRebuilds the state of knowledge at tBacktest without look-ahead bias · forensic auditPolylith · domain isolated from I/O · Malli contracts at the boundary · XTDB over RocksDBingestion and ledger in operation · live execution route under construction

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-op in the temporal-db component.
  • 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-log stores 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.edn has :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-guard implements the Trading Policy Statement NQ-GOV-001 limits and is covered by generative tests (test.check).
  • It is imported by the orchestrator, but the :live branch is still a log/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.

Access Site / Demo