#!/usr/bin/env bash
# 5-policy comparison in BOTH dispatch modes on the SAME ttp-annotated trace,
# so the only variable is dispatch-mode (tracets vs thinktime). Fresh vLLM
# (cold APC) per arm via run_5policy_600s.sh -> b3_isolated_policy.sh.
set -uo pipefail
ROOT="${ROOT:-/home/admin/cpfs/wjh/agentic-kv}"
TRACE_FILE="${TRACE_FILE:-$ROOT/traces/w600_r0.0015_st30_first600s_ttp.jsonl}"
RUN5="$ROOT/microbench/connector_tax/cache_sweep/run_5policy_600s.sh"
DATE="$(date +%Y%m%d_%H%M)"

echo "=== 5policy x {tracets,thinktime} | trace=$(basename "$TRACE_FILE") | $DATE ==="
for MODE in tracets thinktime; do
    OUT="$ROOT/outputs/policy5_600s_${MODE}_${DATE}"
    echo "############ MODE=$MODE  OUT=$OUT  $(date) ############"
    TRACE="$TRACE_FILE" REPLAY_DISPATCH_MODE="$MODE" OUTROOT="$OUT" \
        bash "$RUN5"
    echo "dispatch_mode=$MODE" >> "$OUT/RUNINFO.txt"
    echo "trace=$TRACE_FILE" >> "$OUT/RUNINFO.txt"
done
echo "=== ALL DONE (both modes) $(date) ==="
