Pre-existing rustfmt drift across the workspace was blocking CI's
`Rustfmt` check on PR #373 + PR #377. Running plain `cargo fmt`
reformats 427 files; no semantic changes, no logic changes, no
behavior changes — just what rustfmt already wanted.
None of the touched files are in ruvector-rabitq, ruvector-rulake,
or the new mirror-rulake workflow — those were already fmt-clean
per the per-crate checks on commits 5a4b0d782, 5f32fd450, f5003bc7b.
Drift is in cognitum-gate-kernel, mcp-brain, nervous-system,
prime-radiant, ruqu-core, ruvector-attention, ruvector-mincut,
ruvix/* and sub-crates, plus several examples.
Verified post-fmt:
cargo check -p ruvector-rabitq -p ruvector-rulake → clean
cargo clippy -p ... -p ... --all-targets -- -D warnings → clean
cargo test -p ... -p ... --release → 82/82 pass
Intentionally does NOT touch clippy drift — many more warnings
(missing docs, precision-loss casts, too-many-args, unsafe-safety-
docs) spread across unrelated crates, each category a cross-cutting
design decision that deserves its own review.
With this commit Rustfmt CI goes green on PR #373 and PR #377.
Clippy will still fail — that's honest pre-existing state for a
separate dedicated PR.
Co-Authored-By: claude-flow <ruv@ruv.net>
New cargo examples under crates/ruvector-kalshi/examples/:
- list_markets.rs
Authenticated GET /markets against the live API. Tested against
api.elections.kalshi.com — returned 100 real markets (sports parlays,
cross-category bundles), proving the REST + sig path end-to-end.
- stream_orderbook.rs
Live WebSocket consumer. Uses ws_client::reconnect_forever +
FeedDecoder and prints canonical MarketEvents. Configurable via
argv tickers, KALSHI_MAX_EVENTS (default 50), KALSHI_WS_URL.
- live_trade.rs
Full live execution runner: WS -> FeedDecoder -> Strategy ->
CoherenceChecker -> RiskGate -> RestClient::post_order. Triple-
gated — requires KALSHI_ENABLE_LIVE=1, KALSHI_CONFIRM_LIVE=yes, and
a non-zero KALSHI_MAX_ORDERS cap before any signed request is
emitted. Conservative defaults: 0.10 Kelly fraction, 10_000¢
bankroll, 5% position cap, 2% daily-loss kill, 500 bps min edge.
Verified to fail-closed without the env flag.
paper_trade.rs:
- Now async (#[tokio::main]) to enable brain I/O in the fill path.
- When BRAIN_ENABLE=1, loads BRAIN_API_KEY from env or gcloud secret
BRAIN_SYSTEM_KEY and calls BrainClient::share per approved order.
- Run output unchanged: 7 intents / 1 coherence block / 6 approvals /
6 receipts / 4 replay segments / 3 retrievable.
Co-Authored-By: claude-flow <ruv@ruv.net>
neural-trader-strategies:
- Depend on neural-trader-coherence.
- New coherence_bridge module: CoherenceChecker wraps a CoherenceGate
and returns CoherenceOutcome::{Pass, Block} around an Intent. On gate
error we fail closed (never authorize actuation). simple_context()
builds a plausible GateContext from a rolling price window.
- Re-export CoherenceDecision, CoherenceGate, GateConfig, GateContext,
RegimeLabel, ThresholdGate, CoherenceChecker, CoherenceOutcome.
- 3 new tests (24 total): healthy context passes, low mincut blocks,
simple_context correctly classifies volatile regime.
ruvector-kalshi:
- Depend on neural-trader-coherence and neural-trader-replay.
- examples/paper_trade.rs rewritten to include coherence pre-check and
replay storage:
FeedDecoder → MarketEvent
→ ExpectedValueKelly.on_event
→ CoherenceChecker.check (ThresholdGate tuned for Kalshi depth)
→ RiskGate.evaluate
→ intent_to_order → NewOrder
→ ReservoirStore.maybe_write(ReplaySegment)
→ InMemoryReceiptLog.append_receipt(WitnessReceipt)
Observed depth is carried across frames so ticker/trade events
inherit the mincut floor from the last snapshot. CUSUM uses only
trade/ticker mids, not per-level snapshot prices.
- Run result: 7 intents emitted, 1 coherence-blocked, 6 risk-approved,
6 witness receipts, 4 replay segments stored and retrievable.
Tests: 60 unit (36 + 24). Live /exchange/status smoke still green.
Co-Authored-By: claude-flow <ruv@ruv.net>
Signer:
- api_key now Arc<str>, signing_key now Arc<SigningKey<Sha256>>. Clone
is O(1) (atomic fetch_add) instead of a 2048-bit RSA deep-copy.
Measured at 75 ns/iter in release (1M iters) — previously bound by
RsaPrivateKey::clone which deep-copies BigUint fields.
RestClient:
- base_url + pre-computed base_path stored as Arc<str>; sig_path_for()
formats against the cached base_path instead of reqwest::Url::parse
on every request. Measured at 14 ns/iter — the old path was a full
URL parse + to_string per call.
- RestClient::clone is also O(1) as a consequence.
Benchmark example:
- examples/bench_signing.rs reports clone / sign / sig_path numbers.
Release numbers on the real Kalshi PEM:
signer.clone 75.5 ns
sign_with_ts 0.78 ms (1284 sig/s — RSA-PSS floor)
sig_path_for 13.9 ns
All 57 unit tests, paper_trade example, and live /exchange/status
smoke test pass on the optimized paths.
Co-Authored-By: claude-flow <ruv@ruv.net>
New crate ruvector-kalshi: RSA-PSS-SHA256 signer (PKCS#1/#8), GCS/local/env
secret loader with 5-min cache, typed REST + WS DTOs, Kalshi→MarketEvent
normalizer (reuses neural-trader-core), transport-free FeedDecoder,
reqwest-backed REST client with live-trade env gate, and an offline
sign+verify example that validates against the real PEM.
New crate neural-trader-strategies: venue-agnostic Strategy trait, Intent
type, RiskGate (position cap, daily-loss kill, concentration, min-edge,
live gate, cash check), and ExpectedValueKelly prior-driven strategy.
36 unit tests pass across both crates. End-to-end offline validation
confirmed against the real Kalshi PEM via both local and GCS sources.
Co-Authored-By: claude-flow <ruv@ruv.net>