Files
fxhnt/scripts/dev-cockpit-local.sh
Jeroen Grusewski 1240113d33 verify(migrate): T9 cockpit + forward-track verification against migrated DB
Local cockpit (dev-cockpit-local.sh, bizworx context) serves the migrated DB
read-only; numbers cross-checked against the DB: /paper IBKR card $1,029,015
== ibkr_account_nav.nlv latest, bybit Sh 2.11 / unlock Sh 1.03 == backtest_summary.
The /paper IBKR card renders the real DU account (not the 'not connected'
empty-state that degraded in a prior session). Forward tracks intact: anchor
t0 dates are original historical inceptions, not re-incepted to today — DB-anchor
SSOT survived the migration; recon gate recomputes correctly.

Also fixed dev-cockpit-local.sh to pass --extra web --extra pg (bare uv run
failed ModuleNotFoundError: uvicorn/psycopg on a fresh env).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-18 20:28:56 +00:00

34 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Run the REAL cockpit locally against the REAL prod DB (READ-ONLY) for fast UI testing — no 9-min deploy.
#
# Why: testing cockpit UI changes against a 9-minute Argo rebuild is brutal. This port-forwards prod postgres
# and serves the real cockpit locally so you iterate in seconds, in a real browser, on real data.
#
# Notes:
# * forwards to 15432, NOT 5432 (a local postgres usually owns 5432; the forward would fail "address in use").
# * READ-ONLY: scripts/dev_cockpit_local.py constructs repos without .migrate(); no writes to prod.
# * Ctrl-C tears down the port-forward.
#
# Usage: ./scripts/dev-cockpit-local.sh then open http://127.0.0.1:8801/paper/sim?book=bybit_4edge
set -euo pipefail
NS=${NS:-foxhunt}
LPORT=${LPORT:-15432}
DEV_PORT=${FXHNT_DEV_PORT:-8801}
PW=$(kubectl get secret db-credentials -n "$NS" -o jsonpath='{.data.password}' | base64 -d)
PW_ENC=$(python3 -c "import urllib.parse,sys; print(urllib.parse.quote(sys.argv[1], safe=''))" "$PW")
echo "port-forward svc/postgres -> 127.0.0.1:${LPORT} (ns=${NS})"
kubectl port-forward -n "$NS" svc/postgres "${LPORT}:5432" >/dev/null 2>&1 &
PF=$!
trap 'kill $PF 2>/dev/null || true' EXIT
sleep 4
export FXHNT_OPERATIONAL_DSN="postgresql+psycopg://foxhunt:${PW_ENC}@127.0.0.1:${LPORT}/fxhnt"
export FXHNT_DEV_PORT="${DEV_PORT}"
echo "serving READ-ONLY cockpit against PROD data on http://127.0.0.1:${DEV_PORT}"
# --extra web (uvicorn/fastapi/jinja2) + --extra pg (psycopg) — the cockpit needs both; a bare `uv run` on a
# fresh env fails ModuleNotFoundError: uvicorn / psycopg.
uv run --extra web --extra pg python3 scripts/dev_cockpit_local.py