Files
foxhunt/.claude/helpers/foxhunt-statusline.sh
jgrusewski 12fdd18223 refactor: remove entire CPU training path — 5,307 lines of dead code
Deleted:
- DQN::compute_loss_internal (280 lines) — old Candle forward+loss
- DQN::train_step (55 lines) — old Candle training step
- DQN::compute_gradients (47 lines) — old gradient accumulation
- ComputeLossResult struct — only used by deleted functions
- RegimeConditionalDQN::train_step (65 lines) — old dispatch
- RegimeConditionalDQN::train_step_gpu_regime (100 lines) — old GPU path
- RegimeConditionalDQN::compute_gradients_gpu (130 lines) — old regime gradients
- RegimeConditionalDQN::compute_gradients (92 lines) — old dispatch
- DQNAgentType::train_step dispatch — dead
- DQNAgentType::compute_gradients dispatch — dead
- GpuDqnTrainer::upload_batch (71 lines) — old CPU→GPU upload
- train_step.rs (500 lines) — entire module including ensure_fused_ctx
- dqn_benchmark.rs — used old train_step
- examples.rs — used old train_step
- validation/adapters.rs (289 lines) — used old train_step
- dqn/trainable_adapter.rs — used old train_step
- gpu_smoketest.rs — tested old train_step
- Gradient accumulation path in training_loop.rs (144 lines)
- IQN d_h_s2().clone() → raw pointer (zero alloc)
- Causal intervention format! string alloc removed
- Dead HER relabel functions (320 lines)

Kept:
- ensure_fused_ctx logic inlined into training_loop.rs
- set_noise_sigma_scale re-added to RegimeConditionalDQN

Fixed:
- GpuReplayBuffer max_batch_size wired from batch_size parameter
  (was hardcoded 1024, blocking batch_size=8192)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-02 09:06:23 +02:00

198 lines
6.6 KiB
Bash
Executable File

#!/bin/bash
# Foxhunt statusline — git, build, argo, GPU nodes, ruflo session
# K8s data cached to /tmp to avoid slow kubectl on every refresh
set -euo pipefail
INPUT=$(cat)
CWD=$(echo "$INPUT" | jq -r '.workspace.current_dir // .cwd')
cd "$CWD" 2>/dev/null || exit 0
# --- Colors ---
R='\033[0m' B='\033[1m' DIM='\033[2m'
RED='\033[31m' GRN='\033[32m' YEL='\033[33m' BLU='\033[34m' MAG='\033[35m' CYN='\033[36m'
# --- K8s cache (refresh every 30s) ---
K8S_CACHE="/tmp/.foxhunt-statusline-k8s"
K8S_AGE=999
[ -f "$K8S_CACHE" ] && K8S_AGE=$(( $(date +%s) - $(stat -c %Y "$K8S_CACHE") ))
if [ "$K8S_AGE" -gt 60 ]; then
{
# Argo: latest workflow
WF=$(argo list -n foxhunt --no-headers 2>/dev/null | head -1)
WF_NAME=$(echo "$WF" | awk '{print $1}')
WF_STATUS=$(echo "$WF" | awk '{print $2}')
WF_AGE=$(echo "$WF" | awk '{print $3}')
# GPU nodes by pool name
H100=$(kubectl get nodes -l k8s.scaleway.com/pool-name=ci-training-h100 --no-headers 2>/dev/null | wc -l | tr -d ' ')
L40S=$(kubectl get nodes -l k8s.scaleway.com/pool-name=ci-training --no-headers 2>/dev/null | wc -l | tr -d ' ')
PLATFORM=$(kubectl get nodes -l k8s.scaleway.com/pool-name=platform --no-headers 2>/dev/null | wc -l | tr -d ' ')
# Ruflo daemon: parse status table for daemon state + active workers
RUFLO_RAW=$(timeout 5 npx ruflo@latest daemon status 2>/dev/null || echo "")
RUFLO_DAEMON="off"
RUFLO_WORKERS_ON=0
RUFLO_WORKERS_TOTAL=0
RUFLO_WORKERS_RUNNING=""
if echo "$RUFLO_RAW" | grep -q "RUNNING"; then
RUFLO_DAEMON="on"
fi
# Count enabled workers and collect running ones
while IFS='|' read -r _ name on status _ _ _ _; do
name=$(echo "$name" | tr -d ' ')
on=$(echo "$on" | tr -d ' ')
status=$(echo "$status" | tr -d ' ')
[ -z "$name" ] || [ "$name" = "Worker" ] && continue
RUFLO_WORKERS_TOTAL=$((RUFLO_WORKERS_TOTAL + 1))
if [ "$on" = "✓" ]; then
RUFLO_WORKERS_ON=$((RUFLO_WORKERS_ON + 1))
if [ "$status" = "running" ]; then
RUFLO_WORKERS_RUNNING="${RUFLO_WORKERS_RUNNING}${name},"
fi
fi
done <<< "$(echo "$RUFLO_RAW" | grep '|' | grep -v '^+' | grep -v 'Worker')"
echo "WF_NAME=$WF_NAME"
echo "WF_STATUS=$WF_STATUS"
echo "WF_AGE=$WF_AGE"
echo "H100=$H100"
echo "L40S=$L40S"
echo "PLATFORM=$PLATFORM"
echo "RUFLO_DAEMON=$RUFLO_DAEMON"
echo "RUFLO_WORKERS_ON=$RUFLO_WORKERS_ON"
echo "RUFLO_WORKERS_TOTAL=$RUFLO_WORKERS_TOTAL"
echo "RUFLO_WORKERS_RUNNING=$RUFLO_WORKERS_RUNNING"
} > "$K8S_CACHE" 2>/dev/null || true
fi
source "$K8S_CACHE" 2>/dev/null || true
# --- Git ---
BRANCH=$(git branch --show-current 2>/dev/null || echo "")
DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
# --- Build freshness ---
BUILD_AGE=""
for profile in dev-release release; do
STAMP=$(find "target/$profile" -name '*.d' -newer Cargo.lock -print -quit 2>/dev/null)
if [ -n "$STAMP" ]; then
MTIME=$(stat -c %Y "$STAMP" 2>/dev/null || echo 0)
MINS=$(( ($(date +%s) - MTIME) / 60 ))
if [ "$MINS" -lt 60 ]; then BUILD_AGE="${MINS}m"
elif [ "$MINS" -lt 1440 ]; then BUILD_AGE="$(( MINS / 60 ))h"
else BUILD_AGE="$(( MINS / 1440 ))d"; fi
break
fi
done
# --- Service binaries ---
BINS=0
for svc in api trading_service ml_training_service backtesting_service broker_gateway_service data_acquisition_service trading_agent_service fxt; do
{ [ -f "target/release/$svc" ] || [ -f "target/dev-release/$svc" ]; } && BINS=$((BINS + 1))
done
# --- Ruflo session ---
SESSION_FILE="$CWD/.claude-flow/sessions/current.json"
S_EDITS=0 S_CMDS=0 S_TASKS=0 S_ERRS=0
if [ -f "$SESSION_FILE" ]; then
S_EDITS=$(jq -r '.metrics.edits // 0' "$SESSION_FILE" 2>/dev/null)
S_CMDS=$(jq -r '.metrics.commands // 0' "$SESSION_FILE" 2>/dev/null)
S_TASKS=$(jq -r '.metrics.tasks // 0' "$SESSION_FILE" 2>/dev/null)
S_ERRS=$(jq -r '.metrics.errors // 0' "$SESSION_FILE" 2>/dev/null)
fi
# --- Ruflo agents ---
AGENTS_FILE="$CWD/.claude-flow/metrics/swarm-activity.json"
AGENT_COUNT=0 SWARM_ACTIVE=""
if [ -f "$AGENTS_FILE" ]; then
AGENT_COUNT=$(jq -r '.processes.estimated_agents // 0' "$AGENTS_FILE" 2>/dev/null)
SA=$(jq -r '.swarm.active // false' "$AGENTS_FILE" 2>/dev/null)
[ "$SA" = "true" ] && SWARM_ACTIVE="1"
fi
# --- Ruflo learning ---
LEARN_FILE="$CWD/.claude-flow/metrics/learning.json"
PATTERNS=0
if [ -f "$LEARN_FILE" ]; then
ST=$(jq -r '.patterns.shortTerm // 0' "$LEARN_FILE" 2>/dev/null)
LT=$(jq -r '.patterns.longTerm // 0' "$LEARN_FILE" 2>/dev/null)
PATTERNS=$((ST + LT))
fi
# ============= OUTPUT =============
# Git
printf "${B}foxhunt${R}"
[ -n "$BRANCH" ] && printf " ${YEL}$BRANCH${R}"
[ "$DIRTY" -gt 0 ] && printf " ${RED}${DIRTY}d${R}"
# Build
printf " ${DIM}|${R}"
if [ -n "$BUILD_AGE" ]; then
printf " ${GRN}build:${BUILD_AGE}${R}"
else
printf " ${DIM}no build${R}"
fi
printf " ${CYN}${BINS}/8svc${R}"
# Argo workflow
printf " ${DIM}|${R}"
if [ -n "${WF_STATUS:-}" ] && [ "$WF_STATUS" != "" ]; then
case "$WF_STATUS" in
Succeeded) printf " ${GRN}argo:ok${R}" ;;
Running) printf " ${YEL}argo:run${R}" ;;
Failed) printf " ${RED}argo:FAIL${R}" ;;
Pending) printf " ${YEL}argo:wait${R}" ;;
*) printf " ${DIM}argo:${WF_STATUS}${R}" ;;
esac
[ -n "${WF_AGE:-}" ] && printf "${DIM}(${WF_AGE})${R}"
else
printf " ${DIM}argo:--${R}"
fi
# GPU nodes
printf " ${DIM}|${R}"
if [ "${H100:-0}" -gt 0 ]; then
printf " ${GRN}H100:${H100}${R}"
else
printf " ${DIM}H100:0${R}"
fi
if [ "${L40S:-0}" -gt 0 ]; then
printf " ${GRN}L40S:${L40S}${R}"
else
printf " ${DIM}L40S:0${R}"
fi
printf " ${CYN}cpu:${PLATFORM:-?}${R}"
# Ruflo daemon + workers
printf " ${DIM}|${R}"
if [ "${RUFLO_DAEMON:-off}" = "on" ]; then
printf " ${GRN}ruflo${R}"
# Show running workers or idle count
if [ -n "${RUFLO_WORKERS_RUNNING:-}" ]; then
RUNNING_LIST=$(echo "$RUFLO_WORKERS_RUNNING" | sed 's/,$//' | tr ',' ' ')
printf "${DIM}(${R}${YEL}${RUNNING_LIST}${R}${DIM})${R}"
else
printf "${DIM}(${RUFLO_WORKERS_ON:-0}w idle)${R}"
fi
else
printf " ${RED}ruflo:off${R}"
fi
# Ruflo session activity + swarm
if [ "$((S_EDITS + S_CMDS + S_TASKS))" -gt 0 ] || [ -n "$SWARM_ACTIVE" ] || [ "$AGENT_COUNT" -gt 0 ] || [ "$PATTERNS" -gt 0 ]; then
[ "$S_EDITS" -gt 0 ] && printf " ${MAG}${S_EDITS}ed${R}"
[ "$S_CMDS" -gt 0 ] && printf " ${CYN}${S_CMDS}cmd${R}"
[ "$S_TASKS" -gt 0 ] && printf " ${GRN}${S_TASKS}task${R}"
[ "$S_ERRS" -gt 0 ] && printf " ${RED}${S_ERRS}err${R}"
if [ -n "$SWARM_ACTIVE" ]; then
printf " ${MAG}swarm:${AGENT_COUNT}ag${R}"
elif [ "$AGENT_COUNT" -gt 0 ]; then
printf " ${DIM}${AGENT_COUNT}ag${R}"
fi
[ "$PATTERNS" -gt 0 ] && printf " ${MAG}${PATTERNS}pat${R}"
fi
echo