BAZ.Palantir
BAZ.Palantir
The Rust orchestration server at the centre of the BAZ trading platform. It validates and stores glither.hft rules, manages BAZ.CX market-data subscriptions, enriches incoming ticks and candles with technical indicators, and streams processed events to BAZ.Luna over WebSocket.
BAZ.Palantir sits between exchange feeds and the trading frontend. BAZ.CX streams raw ticks and candles in; BAZ.Palantir validates strategy rules, computes indicators from bounded ring buffers, and streams enriched events out to BAZ.Luna — all behind a constant-time bearer token boundary.
Enriched event stream
The WebSocket endpoint /ws streams enriched candle, indicator, backlog, and
signal events to BAZ.Luna. The mock below represents the kind of processed data
the stream carries:
Architecture
BAZ.CX (:8000)
│ WebSocket: tick, candle, position
▼
BAZ.Palantir (:8080) Rust · Axum · SQLite
│
├── Rule lifecycle PUT /api/rules/{name}
│ baz-hft-roux validation in-process
│ SQLite transactional store
│
├── Subscription mgr POST /api/subscribe
│ desired-set registry outside socket sessions
│ exponential-backoff reconnect to BAZ.CX
│
├── Enricher bounded ring buffers
│ SMA · EMA · RSI · Bollinger · volume ratios
│ candle range · price-to-SMA · bid/ask spread
│
└── WS/REST/GraphQL /ws · /api/* · /graphql
bearer auth on all non-health endpoints
/api/health is the only public endpoint
│
▼
BAZ.Luna (:5173)
WebSocket: candle · indicator · backlog · signal
REST: rule CRUD · daemon control · candle snapshots
Palantir binds to 127.0.0.1:8080. Binding to 0.0.0.0 is appropriate only
behind an authenticating proxy or private network. CORS is not enabled
permissively.
Rule lifecycle
Rule lifecycle
1BAZ.Palantir is the authoritative store for compiled glither.hft strategy rules.
When BAZ.Luna POSTs a rule, Palantir runs the full compiler pipeline in-process
via the baz-hft-roux facade before committing anything to SQLite.
Author .glith source in BAZ.Luna CodeMirror editor
POST rule source to PUT /api/rules/{name} — Palantir runs baz-hft-roux parse + check
Compilation summary returned: symbols, windows, indicators derived from source
Rule stored transactionally in SQLite on success
POST /api/subscribe — Palantir derives required market-data symbols and registers them with BAZ.CX
BAZ.CX begins streaming ticks and candles for subscribed symbols
Enriched events flow over /ws to BAZ.Luna; backlog entries logged to SQLite
Rule names are bounded ASCII — path traversal is prevented at the store layer. The compilation summary is a structured value, not a shell invocation.
HTTP and WebSocket surfaces
API surfaces
2| GET /api/health | — (public) | Liveness check — the only unauthenticated endpoint |
| GET /api/rules | Bearer | List stored rule names |
| GET /api/rules/{name} | Bearer | Read rule source |
| PUT /api/rules/{name} | Bearer | Validate (baz-hft-roux) and store rule |
| DELETE /api/rules/{name} | Bearer | Remove rule and clear subscriptions |
| POST /api/rules/{name}/compile | Bearer | Parse, check, and return compilation summary |
| POST /api/subscribe | Bearer | Resolve validated source market-data requirements |
| GET /api/backlog | Bearer | Read SQLite backlog entries |
| GET /api/candles | Bearer | Read bounded candle history |
| GET /api/daemon/status | Bearer | Read daemon state |
| POST /api/daemon/{action} | Bearer | Start, stop, attach, or detach daemon |
| WS /ws | Bearer | Stream enriched events: candle, indicator, backlog, signal |
| GET,POST /graphql | Bearer | GraphQL query and mutation surface |
curl -H "Authorization: Bearer $PALANTIR_API_TOKEN" \
http://127.0.0.1:8080/api/rules
Enrichment
In-process enrichment
3The enricher computes technical indicators from bounded ring buffers populated with candle data. It only computes signals for subscribed symbols — no work is done for market data that no active rule references.
Storage
SQLite storage
4The SQLite backlog is a lossy diagnostic store — it is not the canonical monetary audit trail. Signed monetary receipts (Ed25519, content-addressed, append-only chain) live in the BAZ.HFT host crate and are not yet durably integrated into BAZ.Palantir. Order execution cannot be enabled until that integration is complete.
WIT signal types
BAZ.Palantir's WebSocket events use types derived from the glither.hft WIT world:
package glither:hft;
interface hft-types {
record tick {
price: float32,
volume: float32,
timestamp: uint64,
bid: float32,
ask: float32,
}
record position {
entry-price: float32,
current-price: float32,
quantity: float32,
unrealized-pnl: float32,
}
variant action {
market-buy(string),
market-sell(string),
limit-buy(string),
limit-sell(string),
market-close-all(string),
cancel(string),
modify-to-market,
noop,
}
record receipt {
action: action,
reason: string,
timestamp: uint64,
}
}
The BAZ.Palantir WebSocket stream adds enriched fields (indicator values, ring buffer snapshots, backlog entries) on top of the raw WIT types.
Run and verify
# Environment
cp .env.example .env
set -a; . ./.env; set +a
# Run
cargo run
# Verify
cargo fmt --all -- --check
cargo clippy --all-targets -- -D warnings
cargo test --all-targets
Palantir uses sibling path dependencies on ../baz.hft and ../glither. The
container build context is the parent experiments/ directory so the image can
include both sibling compiler crates.
Current limitations and next steps
See BAZ.HFT for dialect ownership and the signed receipt chain, and BAZ architecture for the full platform overview including BAZ.CX and BAZ.Luna.