Skip to content

gordon-domain

Purpose

Shared domain crate for the Gordon platform. Holds every business type that crosses a service boundary — market primitives, order lifecycle types, intents, trades, events, deploy and reconcile records, strategy state, overlay decisions — plus the ExecutionModel trait implemented by both gordon-strategy's backtest engine and gordon-executor's live submission path. Carved out of gordon-contracts at the 7.0 split (2026-05-15). Isolating domain from the bus wire crate (gordon-protocol) and the infra kernel (gordon-kernel) is what keeps the latter two stable while domain churns with business changes.

Version + status

1.1.0 — active churn. Drift ceiling: 2 minors max. Churns weekly with business changes. Lean type roster after Wave 2.5 cleanup.

Public surface

types/

Cross-service domain types, exported as gordon_domain::types::<Name>:

  • marketSymbol, Timeframe, Side, PositionSide, OrderType, Kline, Pair, Candle
  • intentsOrderIntent, IntentType, EntryType, Network
  • ordersOrder, OrderRole, OrderState, OrderStatus, BinanceOrderType
  • tradesTrade, TradeSide
  • eventsBotEvent, BotCommand, DataEvent, SourceCommand, FlattenScope, FlattenStrategy, BreakGlassOutcome
  • botBotConfig, BotConfigHistoryRecord, DesiredState, StrategyParamsError
  • deployBotDeploy, DeployState, AbortReason
  • reconcileReconcileRun, ReconcileOutcome
  • strategy_stateBotStrategyState
  • overlay_decisionsOverlayDecision, OverlayDecisionPayload
  • error_responseErrorResponse HTTP body
  • EventEnvelope<T> — generic cross-service event wrapper (v, ts, trace_id, payload)

execution/

The ExecutionModel trait surface plus supporting types:

  • ExecutionModelasync_trait with submit_order, close_position, modify_stop_price, flatten_all. Implemented by gordon-strategy::BacktestExecution (backtest) and gordon-executor's live path (live). Same trait, two impls — structural backtest = live.
  • ExchangeOrderAck, FillEvent, FillKind, Position, ExecutionError, AckState — lifecycle types the trait surface uses.

Bus mirror discipline

OrderIntent lives here; OrderIntentEvent (the bus-wire mirror) lives in gordon-protocol. They are deliberately separate types: the wire type evolves additive-only with schema_version: u16; the in-process type is free to gain non-serialisable fields. Same pattern for FillEvent — the executor's lifecycle FillEvent lives in execution/, while the bus delivery payload lives in gordon-protocol::bus::trading.

Dependencies of note

  • gordon-kernel (^2) — GordonError / ErrorKind for Result<_, GordonError> returns and ExecutionModel error surfaces.
  • sqlxFromRow derives on Order, Trade, BotConfig, BotStrategyState so service consumers reuse the canonical struct.
  • utoipaToSchema derives on every public wire type so OpenAPI bodies are generated without redefining shapes.
  • rust_decimal — quantity / fee precision.

Invariants

  • Cross-service vocabulary only. Types internal to one service stay in that service.
  • No I/O. No DB, no HTTP, no async beyond the async_trait veneer on ExecutionModel.
  • Zero #[allow(...)].
  • When adding a type that rides a NATS subject, mirror it additive-only into gordon-protocol — do not share the in-process type with the wire.

Where it lives

  • Repo: gordon-domain/
  • kellnr: https://kellnr.lepaux.com/crates/gordon-domain (LAN-only)

Gordon — keep compounding without blowing up