#!/bin/bash
set -e

FILE="/opt/dyeverse/crypto_agency/sovereign_bot.py"

# Backup
cp "$FILE" "${FILE}.pre_shadow"

# Patch 1: Add rl_agent: 0.0 to strategy_weights (after knn line)
sed -i '/"knn":.*0\.8,/a\            "rl_agent":   0.0,  # SHADOW MODE: signals logged but zero weight' "$FILE"

# Patch 2: Add shadow mode detection logging (after weight assignment)
sed -i '/signal\["weight"\] = self.strategy_weights.get(name, 1.0)/a\                    # Shadow Mode Detection\n                    if name == "rl_agent" and signal["weight"] == 0.0:\n                        logger.info(f"[SHADOW MODE] RL Agent signaled: {signal['"'"'direction'"'"']:+.2f} @ conv={signal['"'"'conviction'"'"']:.2f} | Ignored by Router.")' "$FILE"

echo "[SUCCESS] Shadow mode patches applied"
