Commit Graph

26 Commits

Author SHA1 Message Date
jgrusewski
aff2b3445d fix(dashboard): remove direct trading OrderForm from trading page
Direct trading from the dashboard is not an option in our system.
Trading page is now read-only monitoring (positions, orders, order book).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 16:04:53 +01:00
jgrusewski
e5bf30c494 fix(web-dashboard): switch protobuf codegen to js+dts for TS 5.9 compat
TypeScript 5.9 erasableSyntaxOnly rejects enum declarations in .ts
files (they emit runtime code). Switch protoc-gen-es from target=ts
to target=js+dts which generates .js runtime + .d.ts type declarations.

Also fix type mismatches in useApi.ts (OrderSide/OrderType enum types,
StartBacktestRequest field mapping) and MLDashboard signal defaulting.
Add web-dashboard network policy for MinIO egress + proxy ingress.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 14:32:41 +01:00
jgrusewski
84877e5146 feat: add auth gRPC service + migrate dashboard from REST/WS to grpc-web
Backend (Rust):
- Create proto/auth.proto with Login and RefreshToken RPCs
- Implement AuthGrpcService in services/api with JWT issuance
- Register as unauthenticated service in main.rs (pre-auth)
- Update JWT issuer from foxhunt-api-gateway to foxhunt-api

Dashboard (TypeScript):
- Install @connectrpc/connect-web + @bufbuild/protobuf
- Generate TypeScript proto clients via buf (src/gen/)
- Create grpc.ts transport with JWT interceptor
- Rewrite all useApi hooks to typed gRPC calls
- Replace WebSocket with useGrpcStream server-streaming hooks
- Migrate all 6 pages + 6 components to grpc-web
- Delete api.ts, websocket.ts, useWebSocket.ts

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-05 00:05:18 +01:00
jgrusewski
5fb84a02f0 feat: training pipeline for all 10 ML ensemble models
- Add standalone training binaries: TGGN, KAN, xLSTM, Diffusion (DBN data)
- Update Dockerfile.training: 6 → 16 binaries (all 10 models + hyperopt + baseline)
- Expand train.sh: 4 → 10 models, fix registry URL and GPU pool nodeSelector
- Add GPU overlay manifests for trading-service and ml-training-service
- Create training data PVC and upload pod manifests
- Expand web-gateway model validation: 4 → 10 types (training + tune routes)
- Extend dashboard: 10 model cards grouped by category (RL/Temporal/Graph/Generative)
- Add training image build job to Gitea CI workflow
- Update GPU taint controller to exclude inference pool from tainting
- Fix job-template nodeSelector: gpu → gpu-training

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-24 20:47:50 +01:00
jgrusewski
8b81138262 docs: rewrite outdated READMEs and add web-gateway docs
Rewrite 7 crate READMEs to reflect current architecture: correct
model types (DQN/PPO/TFT/Mamba2), AtomicKillSwitch, real
EnsembleConfig source from ml, actual data crate purpose,
web-dashboard project details, ml_training_service ports.

Fix 5 api_gateway/TLI docs: strip swarm agent framing, update
service endpoints to api_gateway:50050, remove deleted dashboard
references and hardcoded paths.

Add missing web-gateway/README.md documenting 24 REST endpoints,
WebSocket support, JWT auth, and 3-tier rate limiting.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 18:39:12 +01:00
jgrusewski
2e43600bda safety(web-dashboard): add error boundaries to MLDashboard and ConfigDashboard
- Wrap Model Cards, Ensemble Panel, Training Progress in ComponentErrorBoundary
- Wrap Configuration Form in ComponentErrorBoundary
- Prevents full-page crash if individual sections throw render errors

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:47:28 +01:00
jgrusewski
576ad25d25 safety(web-gateway,web-dashboard): WS topic validation, audit logging, API timeouts
- Add VALID_TOPICS whitelist to WS handler, reject unknown topic subscriptions
- Add per-connection rate limit (50 topic changes/min) and max 20 subscriptions
- Remove wildcard "*" subscription (security risk)
- Add tracing::info! audit logging to all 8 mutation handlers
- Add 30s AbortController timeout to frontend API calls
- Fix clippy: rename _claims → claims in handlers that now use it

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:45:01 +01:00
jgrusewski
d966f30c7f safety(web-gateway,web-dashboard): validate tune/risk mutation endpoints, config a11y
- Add model_type + num_trials validation to tune.rs start_tune (3 tests)
- Add emergency_stop validation: require confirm, valid stop_type, non-empty reason, symbol format (4 tests)
- Add a11y to ConfigDashboard: role=tablist/tab, aria-selected, htmlFor/id on config inputs, role=alert on error

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:37:04 +01:00
jgrusewski
d42a0da105 safety(web-gateway,web-dashboard): server-side validation for backtesting and training routes
- Add validate_backtest(): strategy_name, symbols format, date range,
  initial_capital checks with 6 unit tests
- Add model_type validation against known types (dqn, ppo, tft, mamba2)
  with 1 integration test
- Add error banner to ConfigDashboard for failed config fetch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:30:13 +01:00
jgrusewski
71d988e5f1 safety(web-gateway,web-dashboard): security headers, server-side validation, prod build hardening
- Add HTTP security headers to all responses: X-Frame-Options: DENY,
  X-Content-Type-Options: nosniff, X-XSS-Protection: 0,
  Referrer-Policy: strict-origin-when-cross-origin,
  Strict-Transport-Security: max-age=31536000
- Add server-side input validation to submit_order: symbol format,
  side/order_type enum range, quantity range, price positivity,
  limit orders require price — 12 new tests
- Disable sourcemaps in production builds (vite.config.ts)
- Add global unhandled promise rejection handler (main.tsx)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:27:29 +01:00
jgrusewski
cab4fcda4c safety(web-dashboard): theme-consistent chart colors, a11y attributes, WS reconnect, loading skeletons
- Replace all hardcoded hex colors in chart components with CSS custom
  properties (getCssVar helper), making charts respect theme changes
- Add scope="col" to all table headers (PositionsTable, OrdersTable,
  BacktestingDashboard trade list)
- Connect form labels to inputs via htmlFor/id pairs (OrderForm,
  BacktestingDashboard)
- Add role="alert" to validation error messages
- Add aria-label to cancel button, progressbar role to backtest progress
- Add WsManager.reconnect() method with backoff reset
- Add Reconnect button to StatusBar when WS disconnected
- Add shimmer skeleton loading states to CandlestickChart and PnLChart

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:22:34 +01:00
jgrusewski
c7d336ec59 safety(web-dashboard): token expiry detection, session-expired banner, mutation error feedback
- Add isTokenExpired() / getTokenExpiry() JWT helpers to auth.ts
- Pre-flight token expiry check in apiFetch (60s margin)
- Graceful 401 handling: set session_expired flag before redirect
- LoginPage shows "session expired" banner when flag is set
- OrdersTable cancel button: add pending state + inline error display

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:16:31 +01:00
jgrusewski
35b7f6e27b feat(web-gateway,web-dashboard): request-id middleware, lazy routes, form validation
- Add X-Request-Id middleware with UUID v4 generation and header propagation
- Convert 6 dashboard routes to React.lazy() with Suspense for code splitting
- Add inline validation errors to OrderForm (symbol, quantity, price)
- Add date range + symbol validation to BacktestingDashboard form
- Fix !Send future issue: use .instrument(span) instead of span.entered()

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 09:09:44 +01:00
jgrusewski
3c3bf30062 safety(web-gateway,web-dashboard): clippy clean, gRPC timeouts, health probes, responsive grids, error boundaries
- Fix all 98 clippy warnings (0 remaining with -D warnings)
- Add 30s default gRPC timeout on all channels via Endpoint::timeout()
- Replace readiness probe is_some() with actual gRPC health check (returns 503 when degraded)
- Add responsive Tailwind breakpoints to all 5 dashboard pages
- Add ComponentErrorBoundary for crash-prone chart components
- Log JWT validation errors at debug level instead of silently discarding

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:59:20 +01:00
jgrusewski
bee0591ea1 safety: enforce JWT secret min length, validate order symbol input
- Require JWT_SECRET >= 32 characters at startup (prevents weak secrets)
- Add SECURITY comment documenting auth.rs login as dev-only stub
- Add symbol input validation in OrderForm: uppercase, alphanumeric
  with dots/hyphens/underscores, max 20 chars, visual error state

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:40:50 +01:00
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
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
f930b4f1b7 a11y(web-dashboard): add aria labels, roles, and live regions to interactive components
- EmergencyControls: aria-label on all buttons and confirmation input
- OrderForm: aria-label and aria-pressed on buy/sell toggle buttons
- DashboardLayout: aria-label on navigation
- StatusBar: aria-live on connection status, aria-hidden on decorative indicator dot

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:06:46 +01:00
jgrusewski
5b96d64432 fix(web-dashboard): add 401 auto-logout, error states, WS backoff fix, regime data wiring
- api.ts: intercept 401 responses, clear tokens, redirect to /login
- websocket.ts: fix backoff ordering (increase before scheduling retry)
- All dashboards: add error banners with retry buttons when API queries fail
- MLDashboard: replace hardcoded regime data with WebSocket metrics stream

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 08:04:54 +01:00
jgrusewski
08c487bb17 feat(web-dashboard): show username in StatusBar, add Sign Out button
- Display logged-in username (from JWT sub claim) in status bar
- Add Sign Out button that clears tokens and disconnects WebSocket
- Fix useWebSocket hook with stable empty topics reference

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:53:23 +01:00
jgrusewski
4ae5fc7b0e feat(web-dashboard): add login page, route guards, and error boundary
- ErrorBoundary: catches unhandled render errors, shows recovery UI
- ProtectedRoute: redirects to /login when not authenticated
- LoginPage: username/password form that calls /api/auth/login
- All dashboard routes now require authentication
- Login page redirects to /trading on success

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:47:21 +01:00
jgrusewski
066d85d766 fix(web-dashboard): wire P&L chart data from API in PerformanceDashboard
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:33:45 +01:00
jgrusewski
9630d915b4 fix(web-dashboard): wire API data into dashboard pages, fix stub panels
- ConfigDashboard: merge fetched API config over defaults instead of ignoring it
- TradingDashboard: wire OrderBook with market_data WebSocket topic
- BacktestingDashboard: wire active backtest status polling and trade results
- PerformanceDashboard: wire sortino_ratio from API, add to PerformanceMetrics type
- Remove unused Vite scaffold react.svg asset
- Set page title to "Foxhunt Trading System"

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 07:32:13 +01:00
jgrusewski
6c118d1f53 feat(web-dashboard): trading, risk, ML, performance, backtesting, config dashboards
Phase 5: Trading dashboard with candlestick chart (TradingView lightweight-charts v5),
order book, positions table, order form, and orders table with cancel support.

Phase 6: Risk dashboard with radial gauges (VaR, position utilization, drawdown),
drawdown chart, WebSocket-fed alerts panel, and emergency stop controls.

Phase 7: ML dashboard with model cards (DQN/PPO/TFT/Mamba2), ensemble voting
panel, regime state indicator, and training job progress tracking.

Phase 8: Performance dashboard with metric cards and P&L charts, backtesting
dashboard with strategy form and trade list, config dashboard with tabbed
category editor and audit log.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-22 00:18:43 +01:00
jgrusewski
4f184bf9a5 feat(web-dashboard): React + TypeScript frontend scaffold with routing
Vite + React 18 + TypeScript project with:
- Tailwind CSS for styling (dark theme, trading-focused color palette)
- React Router with 6 dashboard routes (Trading, Risk, ML, Performance,
  Backtest, Config) and keyboard shortcuts (T/R/M/P/B/C)
- TanStack Query for data fetching with auto-refetch
- Shared lib layer: typed API client, WebSocket manager with auto-reconnect
  and topic subscriptions, auth (JWT in localStorage)
- React hooks: useAuth, useApi (query/mutation wrappers), useWebSocket
- DashboardLayout with nav tabs and StatusBar (WS connection, auth status)
- Stub pages with placeholder component layouts matching design doc

Vite proxy configured to forward /api/* to gateway at localhost:3000.
TypeScript passes with zero errors, production build succeeds.

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