Commit Graph

18 Commits

Author SHA1 Message Date
jgrusewski
3d3a84e0b0 feat(web-gateway,web-dashboard): WS ping/pong keepalive, vite build config
- Respond to WebSocket Ping frames with Pong for keepalive detection
- Refactor WS handler to share sender between broadcast and recv tasks
  via Arc<Mutex> (required for pong responses from recv task)
- Add vite production build config: source maps, manual chunk splitting
  for vendor/charts/query bundles

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:37:29 +01:00
jgrusewski
544315e351 safety(web-gateway,web-dashboard): harden for production deployment
Backend:
- Fail fast on empty JWT_SECRET at startup
- Restrict CORS to explicit methods (GET/POST/PUT/DELETE/OPTIONS) and
  headers (Authorization, Content-Type) instead of Any
- Add 1MB request body size limit (DefaultBodyLimit)
- Add gRPC status mappings: DeadlineExceeded->408, Cancelled->499,
  AlreadyExists->409, ResourceExhausted->429, Unavailable->503

Frontend:
- Guard ErrorBoundary console.error behind import.meta.env.DEV
- Read VITE_API_URL and VITE_WS_URL from env vars with fallbacks
- Add max reconnect attempts (50) to WebSocket manager
- Tune React Query: staleTime 10s, refetchInterval 15s,
  disable refetchOnWindowFocus to prevent thundering herd

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:34:37 +01:00
jgrusewski
bd3f558e5a fix(web-gateway): use :id path param syntax for Axum 0.7, add route handler tests
Axum 0.7 uses :id path param syntax, not {id} (which is 0.8+).
The {id} routes silently returned 404 at runtime with no compile error.
Also adds comprehensive handler tests across all 6 remaining route
modules (ml, training, backtesting, performance, config, tune) covering
auth gating, no-service errors, and body validation — 37 new tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:29:39 +01:00
jgrusewski
f4586f8982 test(web-gateway): add trading and risk route handler tests, env example
Trading tests (7): auth gating, no-service 500, order body validation, cancel/account paths
Risk tests (5): auth gating, no-service 500, emergency stop body validation

Total: 61 tests (up from 49)

Also adds web-dashboard/.env.example for production deployment configuration.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:09:25 +01:00
jgrusewski
f2340c2ecf test(web-gateway): add state, health endpoint, and router integration tests
Adds 10 new tests:
- state.rs: AppState creation, empty URL channel handling, broadcast, config wrapping, Clone trait
- routes/mod.rs: health check, readiness with/without services, auth gating, public routes

Total: 49 tests (up from 39)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:04:30 +01:00
jgrusewski
c688d7281f safety(web-gateway): replace silent unwrap_or_default with error-logged fallbacks in gRPC stream bridges
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:57:15 +01:00
jgrusewski
65ca5372f2 safety(web-gateway): use configured CORS origins, add health/readiness probes
- Replace CorsLayer::allow_origin(Any) with configured cors_origins whitelist
- Add GET /health liveness probe (returns {"status":"ok"})
- Add GET /ready readiness probe (reports gRPC channel availability)
- Fix unused import warning in auth middleware tests

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:53:02 +01:00
jgrusewski
356bd39810 feat(web-gateway): add public /api/auth/login route for JWT token issuance
- POST /api/auth/login accepts username/password, returns JWT token
- Route is public (no auth middleware) to allow initial authentication
- Validates non-empty credentials and configured JWT secret
- 3 tests: successful login, empty username, missing JWT secret

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:48:56 +01:00
jgrusewski
af2a17a827 test(web-gateway): add auth middleware and WebSocket token validation tests
- 6 auth middleware tests: missing header, malformed Bearer, invalid JWT,
  wrong secret, expired token, valid token passthrough
- 4 WebSocket token validation tests: valid token, invalid token,
  wrong secret, expired token
- Web-gateway now has 36 tests (up from 26)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:32:37 +01:00
jgrusewski
29aca309aa fix: resolve clippy warnings in common and web-gateway
- Replace redundant closures with function references in correlation.rs
- Use unwrap_or_default() instead of unwrap_or_else(T::new)
- Allow clippy::infinite_loop on intentional reconnect/heartbeat loops
- Allow clippy::empty_structs_with_brackets in generated proto code

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 06:40:06 +01:00
jgrusewski
254ffa5736 feat(web-gateway): wire gRPC stream bridges to real streaming RPCs
Replace placeholder futures with actual gRPC streaming client calls for
market data, order updates, risk alerts, and metrics. Each bridge
reconnects with exponential backoff on disconnection.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 06:36:08 +01:00
jgrusewski
28774d9c34 feat(web-gateway): wire training + tune routes to real MLTrainingService gRPC
Replace 6 stub handlers returning fake JSON with real gRPC proxies:
- training.rs: list_jobs→ListTrainingJobs, start_job→StartTraining, cancel_job→StopTraining
- tune.rs: start_tune→StartTuningJob, get_status/get_best→GetTuningJobStatus, stop_tune→StopTuningJob
Add ml_training proto module and MlTrainingServiceClient factory.
All 24/24 web-gateway REST endpoints now proxy to real gRPC services.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 05:20:35 +01:00
jgrusewski
f3d45cfca5 lint(web-gateway): add deny(unwrap_used, expect_used, panic, indexing_slicing)
All production code already uses safe patterns. This enforces the same
safety standard as ml, risk, common, data, and all service crates.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 04:58:03 +01:00
jgrusewski
6a8cafc091 lint: fix all 27 workspace warnings (0 remaining)
- trading_engine: replace 20 drop(Copy) with let _ = (drop on Copy is no-op)
- data: remove 4 unnecessary crate::error:: qualifications
- ml: remove stale #[allow] attribute on inference.rs
- web-gateway: allow dead_code on stub route body fields

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 02:49:11 +01:00
jgrusewski
a132bb6ead test(web-gateway): add 26 unit tests for error, config, auth, websocket
- error.rs: 10 tests for HTTP status code mapping (AppError → StatusCode)
- config.rs: 7 tests for defaults and from_env() fallback behavior
- claims.rs: 3 tests for JWT Claims serde round-trip
- messages.rs: 6 tests for WebSocket message serialization and topic()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 01:32:40 +01:00
jgrusewski
b3361f09bb lint(web-gateway): fix all clippy deny violations (49 errors → 0)
- Replace impl Trait params with concrete types or named generics
- Rename shadowed variables (tx/ch/inner → unique names per scope)
- Add -> ! return type on infinite reconnect/heartbeat loops
- Replace wildcard enum match with explicit tonic::Code variants
- Use drop() on #[must_use] broadcast send results

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 01:27:00 +01:00
jgrusewski
a1affb0767 feat(web-gateway): WebSocket infrastructure with topic-based subscriptions
Add WebSocket support:
- ws/messages.rs: ClientMessage (subscribe/unsubscribe) and ServerMessage
  (market_data, order_update, risk_alert, position_update, ml_prediction,
  training_progress, metrics, config_update)
- ws/handler.rs: WebSocket upgrade with JWT validation from query param,
  per-client topic filtering via HashSet, dual-task architecture
  (send from broadcast, receive client commands)
- grpc/streams.rs: Background bridge tasks connecting gRPC streaming RPCs
  to broadcast channel with exponential backoff reconnection.
  Includes 30s heartbeat for connectivity verification.

WebSocket endpoint at GET /api/ws?token=<jwt>

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 00:18:43 +01:00
jgrusewski
77ad1530cd feat(web-gateway): scaffold Axum REST gateway with all route modules
New web-gateway crate with:
- JWT auth middleware with claims extraction
- REST routes proxying to gRPC: trading, risk, ML, training, backtesting,
  performance, config, and hyperparameter tuning
- Proto compilation from shared tli/proto definitions
- AppState with lazy gRPC channels and WebSocket broadcast
- Axum server with CORS, tracing, and graceful shutdown

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