← back to Dw Sku Integrity

fire-staging-link.sh

19 lines

#!/usr/bin/env bash
# TK-10896 — GATED staging-link fire (Carnegie 2,000). STEVE runs this.
# preflight (GO) -> apply -> verify -> ledger. shopify_id-keyed, blank-guarded,
# recover-existing-code (no mint), reversible via apply-plans-staging-link/carnegie/undo.sql.
set -uo pipefail
cd ~/Projects/dw-sku-integrity
export DWSKU_PSQL='ssh root@45.61.58.125 psql dw_unified'
V=carnegie
PV=$(node preflight-check.mjs --plan-dir apply-plans-staging-link --vendor "$V" 2>/dev/null | python3 -c "import sys,json;print(json.load(sys.stdin)['verdict'])")
echo "preflight: $PV"; [ "$PV" != GO ] && { echo "NOT GO — abort"; exit 1; }
AP=$(ssh root@45.61.58.125 "psql dw_unified" < "apply-plans-staging-link/$V/apply.sql" 2>&1 | grep -c '^UPDATE'); echo "applied: $AP UPDATE stmts"
VF=$(node preflight-check.mjs --plan-dir apply-plans-staging-link --vendor "$V" --mode verify 2>/dev/null)
VV=$(echo "$VF" | python3 -c "import sys,json;print(json.load(sys.stdin)['verdict'])")
AT=$(echo "$VF" | python3 -c "import sys,json;print(json.load(sys.stdin)['ALREADY_TARGET'])")
echo "verify: $VV ($AT rows now == candidate)"
TS=$(node -e "console.log(new Date().toISOString())")
printf '{"ts":"%s","agent":"steve-fired","ticket":"TK-10896","action":"staging-link canonical dw_sku carnegie (%s rows, mfr->catalog, no mint)","blast_radius":%s,"undo_cmd":"ssh root@45.61.58.125 \\"psql dw_unified\\" < ~/Projects/dw-sku-integrity/apply-plans-staging-link/carnegie/undo.sql","verify":"mode=verify %s"}\n' "$TS" "$AT" "$AT" "$VV" >> ~/.claude/yolo-queue/executed-reversible/ledger.jsonl
echo "--- done. undo: ssh root@45.61.58.125 \"psql dw_unified\" < apply-plans-staging-link/carnegie/undo.sql ---"