← back to Hollywood Import
hollywood wrapper: refund unused upload grant on 429/partial slots, phase-1 + phase-2 (DTD-A)
7c8532dc872cdce74830fab9fa35aaa4c328f462 · 2026-06-20 09:15:56 -0700 · Steve
Files touched
M hollywood-create-resume.sh
Diff
commit 7c8532dc872cdce74830fab9fa35aaa4c328f462
Author: Steve <steve@designerwallcoverings.com>
Date: Sat Jun 20 09:15:56 2026 -0700
hollywood wrapper: refund unused upload grant on 429/partial slots, phase-1 + phase-2 (DTD-A)
---
hollywood-create-resume.sh | 37 +++++++++++++++++++++++++++++++++++--
1 file changed, 35 insertions(+), 2 deletions(-)
diff --git a/hollywood-create-resume.sh b/hollywood-create-resume.sh
index ed6862f..58a9a42 100755
--- a/hollywood-create-resume.sh
+++ b/hollywood-create-resume.sh
@@ -25,9 +25,26 @@ if [ "${HW_PRODUCTS:-0}" -lt 1 ]; then
fi
echo "=== $ts budget grant=$HW_VARS variants → create up to $HW_PRODUCTS products ===" >> hollywood-create.log
# Phase 1: create the absent products (cap-aborts exit 3 → resume tomorrow), capped at the grant.
-/usr/bin/env node hollywood-create.mjs --apply --limit="$HW_PRODUCTS" >> hollywood-create.log 2>&1
+HW_P1_OUT=$(/usr/bin/env node hollywood-create.mjs --apply --limit="$HW_PRODUCTS" 2>&1)
p1=$?
+echo "$HW_P1_OUT" >> hollywood-create.log
echo "=== $ts phase1 (create) exit $p1 ===" >> hollywood-create.log
+
+# ── refund the unused phase-1 upload grant (budget-integrity, 2026-06-20; DTD verdict A) ──
+# We took HW_VARS variants UP FRONT to size --limit, but hollywood-create.mjs consumes 2 variants
+# (Roll + Sample) per product actually CREATED. It prints 'DONE: created=N' on clean exit and
+# 'CAP-ABORT: created=N this run' on the exit-3 cap, so N is reliable either way; a 429/cap slot
+# creates 0 (refund whole grant), a partial slot fewer. GUARD: refund ONLY when one of those count
+# lines was found (HW_P1_CREATED non-empty) — a crash with no summary keeps its debit (conservative).
+HW_P1_CREATED=$(printf '%s' "$HW_P1_OUT" | grep -oE '(created=[0-9]+|CAP-ABORT: created=[0-9]+)' | grep -oE '[0-9]+' | tail -1)
+if [ -n "$HW_P1_CREATED" ]; then
+ HW_P1_USED=$(( HW_P1_CREATED * 2 ))
+ HW_P1_REFUND=$(( HW_VARS - HW_P1_USED ))
+ if [ "$HW_P1_REFUND" -gt 0 ]; then
+ HW_P1_GOT=$(node "$BUDGET" refund upload "$HW_P1_REFUND" 2>/dev/null || echo 0)
+ echo "=== $ts phase1 budget refund: grant=$HW_VARS used=$HW_P1_USED (created $HW_P1_CREATED×2) → refunded $HW_P1_GOT upload variants ===" >> hollywood-create.log
+ fi
+fi
# Phase 2 ONLY after Phase 1 fully done (exit 0) — both share the daily variant cap.
# 2026-06-19 (budget fix): phase-2 (yard add = 1 variant/product) was previously UNBUDGETED —
# no --limit, no budget take — so once the create backlog cleared it could add variants ABOVE the
@@ -40,8 +57,24 @@ if [ "$p1" -eq 0 ]; then
echo "=== $ts phase2 (add-yard) skipped — no variant budget (grant=$P2_VARS) ===" >> hollywood-create.log
else
echo "=== $ts phase2 (add-yard) budget grant=$P2_VARS variants → --limit=$P2_VARS ===" >> hollywood-create.log
- /usr/bin/env node hollywood-add-yard.mjs --apply --limit="$P2_VARS" >> hollywood-create.log 2>&1
+ HW_P2_OUT=$(/usr/bin/env node hollywood-add-yard.mjs --apply --limit="$P2_VARS" 2>&1)
+ echo "$HW_P2_OUT" >> hollywood-create.log
echo "=== $ts phase2 (add-yard) exit $? ===" >> hollywood-create.log
+
+ # ── refund the unused phase-2 upload grant (budget-integrity, 2026-06-20; DTD verdict A) ──
+ # We took P2_VARS variants UP FRONT, but hollywood-add-yard.mjs adds only 1 yard variant per
+ # product. It prints 'DONE: added=N' on clean exit and 'CAP-ABORT: added=N this run' on exit 3,
+ # so N is reliable; an empty/cap slot adds 0 (refund whole grant), a partial slot fewer. GUARD:
+ # refund ONLY when one of those count lines was found (HW_P2_ADDED non-empty) — no summary →
+ # keep the debit (conservative; never over-refunds → never over-grants).
+ HW_P2_ADDED=$(printf '%s' "$HW_P2_OUT" | grep -oE '(added=[0-9]+|CAP-ABORT: added=[0-9]+)' | grep -oE '[0-9]+' | tail -1)
+ if [ -n "$HW_P2_ADDED" ]; then
+ HW_P2_REFUND=$(( P2_VARS - HW_P2_ADDED )) # 1 yard variant per product added
+ if [ "$HW_P2_REFUND" -gt 0 ]; then
+ HW_P2_GOT=$(node "$BUDGET" refund upload "$HW_P2_REFUND" 2>/dev/null || echo 0)
+ echo "=== $ts phase2 budget refund: grant=$P2_VARS used=$HW_P2_ADDED (added×1) → refunded $HW_P2_GOT upload variants ===" >> hollywood-create.log
+ fi
+ fi
fi
fi
exit 0
← 3f08fb5 fix: budget-take + --limit on hollywood phase-2 (add-yard) s
·
back to Hollywood Import
·
auto-save: 2026-06-21T18:53:00 (2 files) — hollywood-create- ca5bd28 →