← back to Newmor Onboard

run-a-bucket.sh

32 lines

#!/usr/bin/env bash
# TK-10670 — one-command runner for the Steve-APPROVED A-bucket Newmor Sample-variant
# SKU normalization (125 live products: 116 ACTIVE + 9 DRAFT). Fail-safe chain:
# apply (drift-guarded, verify-after-write) -> ledger the undo -> commit -> file both memos.
# If the executor detects drift or any non-clean row it exits non-zero and NOTHING
# downstream runs (no ledger, no commit, no memo move) — a partial leaves the memo in
# pending-approval and the journal at data/a-bucket-apply-journal.json for inspection.
set -euo pipefail
cd ~/Projects/newmor-onboard
LOG=~/Projects/newmor-onboard/data/a-bucket-run-$(date +%Y%m%d-%H%M%S).log
{
  echo "== A-bucket run started $(date) =="
  node scripts/apply-a-bucket-sku.mjs

  node ~/.claude/yolo-queue/executed-reversible/log-exec.mjs \
    --agent vp-dw-commerce --ticket TK-10670 \
    --action "A-bucket Newmor Sample-variant SKU normalize to {DWNM-58xxxx}-Sample (125: 116 ACTIVE + 9 DRAFT)" \
    --blast 125 \
    --undo "cd ~/Projects/newmor-onboard && node scripts/rollback-a-bucket-sku.mjs" \
    --verify "node -e \"const t=require('/Users/macstudio3/Projects/newmor-onboard/data/a-bucket-apply-journal.json').tally;process.exit((t.OK||0)+(t['ALREADY-NEW']||0)===125?0:1)\""

  git add -A && git commit -q -m "TK-10670: A-bucket SKU normalize executed (125 products)"

  mv ~/.claude/yolo-queue/pending-approval/2026-09-09-TK-10670-newmor-A-bucket-sku-normalize.md \
     ~/.claude/yolo-queue/_done/
  mv ~/.claude/yolo-queue/pending-approval/2026-09-09-TK-10670-newmor-C-bucket-disposition-decision.md \
     ~/.claude/yolo-queue/_done/2026-09-09-TK-10670-newmor-C-bucket-disposition-decision.KEEP-ARCHIVED.md

  echo "== DONE $(date) — write landed, ledgered, committed, memos filed. Vendor email left HELD. =="
  echo "== Next: tell the Newmor Claude session 'run the post-write verification' for the live collision+tally check. =="
} 2>&1 | tee "$LOG"