Commit Graph

32 Commits

Author SHA1 Message Date
jgrusewski
c112d34fec refactor: point fxt build.rs at proto/ root, delete fat-client protos
fxt now compiles from the same service protos as all backend services.
Deleted 8 fat-client protos (3,286 lines) from bin/fxt/proto/.
Updated include_proto! macros to use new package names (trading, ml,
config instead of foxhunt.tli, foxhunt.ml, foxhunt.config).
Added risk, data_acquisition, and config_service proto modules.
Fixed duplicate include_proto in agent.rs to use crate::proto.

Existing command implementations will be rewritten to use new proto
types in Task 6.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 20:54:04 +01:00
jgrusewski
9501d581ad feat(fxt): add epoch financial metrics to train monitor output
Add print_financial_metrics() to the monitor command, displaying
per-model Sharpe ratio (color-coded green/yellow/red), win rate,
max drawdown, profit factor, total return, trade count, and
action distribution (BUY/SELL/HOLD percentages). Only shown when
sessions report non-zero financial data.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:08:19 +01:00
jgrusewski
778adb7ce0 feat(fxt): render epoch financial metrics in watch TUI list + detail views
Add Sharpe/Win% columns to training list table, financial summary lines
(Sharpe, Sortino, Win Rate, Max DD, PF, Return, Avg, Trades) to the
detail overview, action distribution (BUY/SELL/HOLD %) to current metrics,
and four new sparklines (Sharpe, Win Rate, Max DD, Total Return) to the
Metrics sub-tab.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 16:06:00 +01:00
jgrusewski
a471c913d7 feat(proto): add epoch financial metrics + GetEpochHistory to monitoring.proto
Add 11 financial fields (sharpe, sortino, win_rate, max_drawdown,
profit_factor, total_return, avg_return, total_trades, action
distribution) to TrainingSession (fields 36-46), a new
GetEpochHistory RPC with request/response messages, and wire the
Prometheus metric mapping in the monitoring service with a
stub RPC handler for task 7.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 15:57:27 +01:00
jgrusewski
d04b6c7023 fix(fxt,services): remove mock fallbacks and add gRPC health checks
- trade_ml.rs: Replace 3 mock data fallbacks (submit, predictions,
  performance) with proper error propagation. Commands now fail
  honestly when the API Gateway is unreachable instead of silently
  returning fake data. Mark 3 integration tests as #[ignore].

- monitoring_service: Add tonic-health with set_serving for
  MonitoringServiceServer. Enables grpc_health_probe readiness checks.

- ml_training_service: Add tonic-health with set_serving for
  MlTrainingServiceServer. Wired into both TLS and non-TLS paths.

- data_acquisition_service: Add tonic-health with set_serving for
  DataAcquisitionServiceServer.

- ml/cuda_streams: Fix pre-existing unused variable clippy warning.

All 8 services now have standard gRPC health checking enabled.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 14:14:51 +01:00
jgrusewski
afbc668dcd feat(fxt): enhance watch TUI with full training metrics and gRPC helpers
- Add connect_channel/connect_channel_lazy with TLS auto-detection
- Expand TrainingSession to 35+ proto fields (RL diagnostics, hyperopt,
  eval metrics, health counters, checkpoints)
- Add RL-specific rendering (entropy, action diversity, Q-values, rewards)
- Add hyperopt progress panel (trial/best objective tracking)
- Refactor all commands to use shared connect_channel helper
- Default API gateway URL to https://api.fxhnt.ai

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 13:38:58 +01:00
jgrusewski
72f092e0e5 fix(fxt): read JWT secret from config.toml for gateway auth
The fxt client was using a hardcoded dev fallback secret for JWT signing,
causing InvalidSignature errors against the API gateway. Now reads
jwt_secret from ~/.foxhunt/config.toml with fallback chain:
env var > config file > dev secret.

Also updates default api_gateway_url to https://api.fxhnt.ai.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 10:31:04 +01:00
jgrusewski
a5ca926af6 feat(fxt): wire all stub commands to real gRPC backends
- model list: calls MLTrainingService::ListAvailableModels
- model approve: calls MLTrainingService::ApproveModel
- model reject: calls MLTrainingService::RejectModel
- agent allocate-portfolio: replaces mock assets with GetSelectedAssets RPC
- auth login (non-interactive): real gRPC via LoginClient::login_with_credentials
- tune --watch: uncommented tune_stream module, wired into tune command

177 tests pass, 0 clippy warnings.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:02:20 +01:00
jgrusewski
0a15058990 feat(fxt): implement fxt watch streaming dashboard
- streams.rs: gRPC stream manager with reconnect + exponential backoff
  (training metrics, order updates, risk alerts, system status)
- render.rs: ratatui renderer for 4 tabs (Training/Trading/Risk/System)
- event_loop.rs: tokio::select! loop over gRPC streams, crossterm keys, 200ms tick
- Wired Watch command into CLI (main.rs Commands enum + dispatch)
- 35 tests pass, 0 clippy warnings

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:02:20 +01:00
jgrusewski
d4d070b70b feat(fxt): add dashboard state types with 5 tests
DashboardState with 4 tab substates (Training/Trading/Risk/System),
ring buffers for loss history and fills, scroll support.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:02:20 +01:00
jgrusewski
e1bab1a587 feat(fxt): add ratatui/crossterm deps and ApproveModel/RejectModel proto RPCs
- ratatui 0.29, crossterm 0.28 (event-stream), tokio-stream to deps
- ApproveModel + RejectModel RPCs added to MLTrainingService
- 4 new proto messages for model promotion workflow

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 02:02:20 +01:00
jgrusewski
6c7a7275de feat(fxt): add grad norm, RL diagnostics, and hyperopt trial detail to monitor
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-03 00:09:56 +01:00
jgrusewski
6b67f6193a infra: expose monitoring service via monitor.fxhnt.ai Tailscale proxy
Add DNS record, nginx gRPC proxy block, network policy for Tailscale
ingress, and auto-detect fxhnt.ai in fxt monitor URL derivation.
Show GPU telemetry even when no training sessions are active.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 22:56:40 +01:00
jgrusewski
1a62060dab fix(clippy): resolve all workspace clippy warnings
Fix pre-existing and new clippy issues across 5 files:
- service_auth.rs: .to_string() → .to_owned() on &str, backtick doc items
- streams.rs: backtick doc items, allow cognitive_complexity on reconnect_loop
- main.rs: .to_owned(), allow infinite_loop, drop must_use, rename shadow
- start.rs: eliminate shadow_reuse on endpoint binding
- enhanced_ml.rs: remove unnecessary f64 cast

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 22:06:25 +01:00
jgrusewski
06cf6bf39e feat(fxt): add 'fxt train monitor' subcommand with live TUI
Adds a new CLI subcommand that connects to the monitoring service via
gRPC to display live training metrics. Supports single-snapshot mode
(--once), model filtering (--model), and configurable streaming
interval. Renders per-model epoch/loss table, GPU telemetry, hyperopt
progress, and health counters.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 21:41:54 +01:00
jgrusewski
36d291a8e0 fix(fxt): robust ibapi handshake retry and config test isolation
- ibapi handshake: retry once after 1s on first failure (IB Gateway
  needs time to release stale client_id slots after disconnection)
- test_load_nonexistent_config → test_load_config_succeeds: remove
  default-value assertions that fail when ~/.foxhunt/config.toml exists
  (defaults already tested by test_serde_defaults and test_default_config)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:52:48 +01:00
jgrusewski
032be46e90 fix(fxt): default broker gateway URL 50060 → 50056
Match the actual K8s broker-gateway service port discovered during
live validation of fxt broker check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:49:23 +01:00
jgrusewski
47cea06e86 fix(fxt): default broker check port 4002 → 4004 (socat)
The IB Gateway JVM uses non-blocking I/O on port 4002, which causes
EAGAIN errors with ibapi's blocking Client::connect(). The gnzsnz
image provides socat on port 4004 as a stable proxy that bridges
blocking clients to the non-blocking gateway socket.

Port 4004 is the correct client-facing port for paper mode (4003 for
live). The K8s readiness probe stays on 4002 since TCP probes work
fine with non-blocking sockets.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 14:43:32 +01:00
jgrusewski
ea130bdb52 chore(fxt): suppress unused_crate_dependencies for ibapi
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:53:02 +01:00
jgrusewski
7dbecf2b64 feat(fxt): wire broker check subcommand into CLI
Add Broker variant to Commands enum with BrokerArgs (flatten),
route to execute_broker_command in match block (no JWT required),
exit(1) on check failure. Clone config.api_gateway_url to avoid
partial move. Add two CLI parsing tests for broker check.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:49:43 +01:00
jgrusewski
33208c928c feat(fxt): add broker check command with config resolution and connectivity checks
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:44:20 +01:00
jgrusewski
9afd985a34 feat(fxt): compile broker_gateway.proto for gRPC client stubs
Copy broker_gateway.proto from broker_gateway_service into fxt/proto/
and wire it into build.rs compile_protos + lib.rs proto module so the
CLI can call BrokerGatewayService RPCs (health check, account state,
session status).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:37:49 +01:00
jgrusewski
ec23919c97 feat(fxt): add BrokerConfig section to TliConfig
Adds IbkrConfig (host/port/client_id with defaults for paper trading)
and BrokerConfig (gateway_url + ibkr nested) to the TLI config file.
Both structs derive serde defaults so existing config files remain
backward-compatible.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:36:35 +01:00
jgrusewski
9e42c9264a feat(fxt): add ibapi optional dep behind broker-check feature
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-02 13:33:43 +01:00
jgrusewski
e2a0576ef5 docs: create/update README.md for all services, CLI, and testing crates
Create 3 missing service READMEs (api_gateway, data_acquisition_service,
trading_agent_service). Create bin/fxt/README.md. Create
testing/service-integration/README.md. Update existing service and testing
READMEs to standard template. Delete 4 subdirectory READMEs from
testing/integration/ and testing/e2e/.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 22:50:38 +01:00
jgrusewski
4a1add5806 cleanup: delete 92 scattered .md files and .serena artifacts
Remove stale test reports, quick-start guides, benchmark analyses,
profiling reports, and tool artifacts from across the workspace.
Keeps only root README.md per crate/service.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-01 22:42:36 +01:00
jgrusewski
48316d6874 feat(infra): add api.fxhnt.ai DNS + gRPC reverse proxy for API Gateway
Add nginx server block for api.fxhnt.ai with grpc_pass to the
api-gateway ClusterIP service. Add Scaleway DNS A record via Terraform
module. Fix fxt gRPC client to enable TLS when connecting to https://
endpoints (tonic requires explicit ClientTlsConfig).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 22:41:55 +01:00
jgrusewski
46f84f6770 feat(hyperopt): wire hyperopt dispatch through fxt CLI and K8s dispatcher
Add --hyperopt, --trials, and --parallel flags to `fxt train start` so
users can dispatch PSO hyperparameter optimization jobs alongside
regular training. The mode=hyperopt tag propagates through the service
layer which selects the correct binary (hyperopt_baseline_rl for DQN/PPO,
hyperopt_baseline_supervised for all others) and builds hyperopt-specific
CLI arguments via a new extra_args field on TrainingJobParams.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-28 22:29:51 +01:00
jgrusewski
0f9d756caa feat: on-demand training dispatch via K8s Jobs with sidecar uploader
Extend ml_training_service to dispatch GPU training jobs as K8s batch/v1
Jobs, collect results via a Rust sidecar uploader, and support model
promotion with operator approval via fxt CLI.

- K8s dispatcher creates Jobs on gpu-training pool with native sidecar
- training_uploader crate: watches DONE/FAILED marker, uploads to S3,
  reports completion via ReportJobCompletion gRPC
- PromotionManager compares metrics, queues better models for approval
- 4 new proto RPCs: ReportJobCompletion, ListPendingPromotions,
  ApprovePromotion, RejectPromotion
- fxt commands: train start, model list/approve/reject
- Training binaries write DONE/FAILED markers + metrics.json
- Dockerfile, K8s job template, and CI pipeline updated
- StartTraining gracefully falls back to in-process when outside K8s
- 27 new tests (16 service + 11 promotion), 141 total service tests pass

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 12:43:17 +01:00
jgrusewski
e72e4db235 refactor: delete 22 dead examples, 4 CSVs, consolidate data to test_data/
- Delete 22 dead/placeholder/broken example files (-3,489 lines code)
- Delete 4 tracked CSV files (-1.1M lines, were accidentally committed)
- Move baseline training data default from data/cache/ to test_data/
- Update 5 unified binary defaults, gitignore, k8s upload comment, docs
- Consolidate all training data under test_data/futures-baseline/

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-26 01:24:02 +01:00
jgrusewski
b84e14e175 fix(fxt): mark machine_id test as #[ignore] for container CI
test_machine_id_derivation reads /etc/machine-id which doesn't exist
in container environments.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 14:35:56 +01:00
jgrusewski
9c3d741a08 refactor: restructure repo — crates/, bin/, testing/ layout
Move 17 library crates into crates/, CLI binary into bin/fxt,
consolidate 10 test crates into testing/, split config crate
from deployment config files.

Root directory reduced from 38+ to ~17 directories.
All Cargo.toml paths and build.rs proto refs updated.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-25 11:56:00 +01:00