From 0aafad5f2cfced33a9eaaf571bf4bd2b676cfdbc Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 7 Oct 2026 02:44:48 -0700 Subject: [PATCH] fix(kld-then-calib): SKIP_KLD resume + rows-50235 receipt gate MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The KLD engine exited clean with the record complete (kld.json rows: 50235, 24 GiB, 5 files), but the wrapper died rc=127: a mid-run scp of the calib-shape edit shifted bash's lazy-read offset — the fleet's own script-swap law, biting on the same class as the autoresearch collision. Resume path: SKIP_KLD=1 verifies the receipt (rows + size + files) and goes straight to calib. Never scp a script a running process owns. --- scripts/kld-then-calib.sh | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/scripts/kld-then-calib.sh b/scripts/kld-then-calib.sh index 8754c7f..b75e641 100755 --- a/scripts/kld-then-calib.sh +++ b/scripts/kld-then-calib.sh @@ -6,16 +6,20 @@ set -u KLOG=/home/dank/logs/swift15-kld-driver.log CLOG=/home/dank/logs/swift15-calib-driver.log -S=/home/dank/serverAppConfigs-swift15/scripts - -# Phase 1: KLD record. -while ! grep -q "exited rc=" "$KLOG" 2>/dev/null; do sleep 60; done -RC=$(grep -o "exited rc=[0-9]*" "$KLOG" | tail -1) -if [ "$RC" != "exited rc=0" ]; then echo "KLD FAILED ($RC); calib NOT started"; exit 1; fi +# Phase 1: KLD record (SKIP_KLD=1 when the record is already complete — +# kld.json's rows count is the receipt; a mid-run script swap can kill the +# wrapper with rc=127 after the engine exited clean). +if [ "${SKIP_KLD:-0}" != 1 ]; then + while ! grep -q "exited rc=" "$KLOG" 2>/dev/null; do sleep 60; done + RC=$(grep -o "exited rc=[0-9]*" "$KLOG" | tail -1) + if [ "$RC" != "exited rc=0" ]; then echo "KLD FAILED ($RC); calib NOT started"; exit 1; fi +fi N=$(find /home/dank/corpora/kld-ref -type f | wc -l) SZ=$(du -sm /home/dank/corpora/kld-ref | cut -f1) echo "KLD OK files=$N size_mib=$SZ" -[ "$N" -ge 1 ] && [ "$SZ" -ge 1000 ] || { echo "kld-ref looks thin; calib NOT started"; exit 1; } +[ "$N" -ge 5 ] && [ "$SZ" -ge 1000 ] || { echo "kld-ref looks thin; calib NOT started"; exit 1; } +grep -q '"rows": 50235' /home/dank/corpora/kld-ref/kld.json || { + echo "kld.json rows != 50235; calib NOT started"; exit 1; } # Phase 2: calibration serve (1.2.0) + corpus push. nohup bash "$S/run-swift15-bf16.sh" calib > "$CLOG" 2>&1 &