#!/bin/bash
# 2026-11-03 ablation: #81 recipe (trim) WITHOUT the whole-scroll Lasagna auto set (strip-auto-* strips, auto_<digits>
# fibers and the 1,932 manual-fiber links into them; dataset built by work/build_nolas.py), two seeds, plus the #81
# recipe on seed 2 as the paired control. Frozen code, same stage()/valid() as chain_trim; every Vb rescored on the
# trimmed records (scores_trim.json).
#   chain_nolas.sh FROZEN_DIR     stop file: work/chain_s1.stop
set -u -o pipefail
D=/media/djosey/nvme4/spiral_0332; F=${1:?frozen dir}; PY=/home/djosey/Documents/villa/spiral-fitting/.venv/bin/python
rm -f $D/work/chain_s1.stop
echo $$ > $D/work/chain_nolas.pid
source <(sed -e '/chain_s1.pid/d' -e '/chain_dt done/d' -e '/^for ARM_TAG/,$d' $F/work/s1/chain_s1.sh) $F
export FIT_CACHE=$D/cache_nolas
rescore() { R=$(rundir $1); [ -n "$R" ] && [ -f $R/checkpoint_fitted.ckpt ] || return 0
  [ -f $R/scores_trim.json ] || CUDA_VISIBLE_DEVICES= $PY $F/work/s1/s1_score.py $R --out $R/scores_trim.json \
    --train-records $D/work/s1_trim/anchors_train_records.json --held-records $D/work/s1_trim/anchors_held_records.json > $D/work/s1/scoretrim_$1.log 2>&1
  echo "$(date) rescored $1 on trimmed records"; }
for L in "trimnolas trimnolas" "trimnolas_s2 trimnolas" "trim_s2 trim"; do
  set -- $L; T=$1; A=$2
  stop && break
  stage Va_hub1030h_${T}_10k $A 10000 || continue
  stop && break
  stage Vb_hub1030h_${T}_25k $A 25000 Va_hub1030h_${T}_10k || continue
  rescore Vb_hub1030h_${T}_25k
done
echo "$(date) chain_nolas done"
