← back to Homesonspec
auto-save: 2026-07-27T20:24:23 (1 files) — scripts/build-loop.sh
76c1d27565e09166045f3625e548c465c6aa2f25 · 2026-07-27 20:24:30 -0700 · Steve Abrams
Files touched
Diff
commit 76c1d27565e09166045f3625e548c465c6aa2f25
Author: Steve Abrams <steve@designerwallcoverings.com>
Date: Mon Jul 27 20:24:30 2026 -0700
auto-save: 2026-07-27T20:24:23 (1 files) — scripts/build-loop.sh
---
scripts/build-loop.sh | 33 ++++++++++++++++++---------------
1 file changed, 18 insertions(+), 15 deletions(-)
diff --git a/scripts/build-loop.sh b/scripts/build-loop.sh
index 1d6ae4c..e2eb6b6 100644
--- a/scripts/build-loop.sh
+++ b/scripts/build-loop.sh
@@ -5,6 +5,7 @@
# sweeps until a STOP file appears or MAX_SWEEPS is hit. Facts-only, robots-
# enforced (LiveFetcher), LOCAL DB only — the public Kamatera go-live stays gated.
# Idempotent: re-sweeps of unchanged data are cheap no-ops (contentHash dedup).
+# bash-3.2 safe (macOS system bash) — no associative arrays.
# Stop anytime: touch ~/Projects/homesonspec/tmp/BUILD-LOOP-STOP
set -uo pipefail
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
@@ -18,15 +19,17 @@ LOG() { echo "[$(date '+%m-%d %H:%M:%S')] $*"; }
PSQL() { psql "$DATABASE_URL" -tAc "$1" 2>/dev/null; }
CLI() { npx tsx src/cli.ts --adapter="$1" 2>&1 | grep -E '"published"|"pages"|Error|error|inactive|blocked|disallow' | head -3; }
-# state formats per adapter
-declare -A KB=( [CA]=CA [TX]=TX [FL]=FL [AZ]=AZ [NV]=NV [CO]=CO [GA]=GA [NC]=NC [SC]=SC [TN]=TN [WA]=WA [UT]=UT )
-declare -A DRH=( [CA]=california [TX]=texas [FL]=florida [AZ]=arizona [NV]=nevada [CO]=colorado [GA]=georgia [NC]="north-carolina" [SC]="south-carolina" [TN]=tennessee [WA]=washington [UT]=utah )
-declare -A PLT=( [CA]=California [TX]=Texas [FL]=Florida [AZ]=Arizona [NV]=Nevada [CO]=Colorado [GA]=Georgia [NC]="North Carolina" [SC]="South Carolina" [TN]=Tennessee [WA]=Washington [UT]=Utah )
-declare -A TRI=( [CA]=ca [TX]=tx [FL]=fl [AZ]=az [NV]=nv [CO]=co [GA]=ga [NC]=nc [SC]=sc [TN]=tn [WA]=wa [UT]=ut )
-STATES=(CA TX FL AZ NV CO GA NC SC TN WA UT)
+STATES="CA TX FL AZ NV CO GA NC SC TN WA UT"
+fullname() { case "$1" in
+ CA) echo "California";; TX) echo "Texas";; FL) echo "Florida";; AZ) echo "Arizona";;
+ NV) echo "Nevada";; CO) echo "Colorado";; GA) echo "Georgia";; NC) echo "North Carolina";;
+ SC) echo "South Carolina";; TN) echo "Tennessee";; WA) echo "Washington";; UT) echo "Utah";;
+ *) echo "$1";; esac; }
+lc() { echo "$1" | tr '[:upper:]' '[:lower:]'; }
+slug() { fullname "$1" | tr '[:upper:] ' '[:lower:]-'; } # "North Carolina" -> north-carolina
# wait until no other adapter run is in flight (avoid same-source races)
-while pgrep -f "cli.ts --adapter" | grep -qv $$ 2>/dev/null; do sleep 20; done
+while pgrep -f "cli.ts --adapter" 2>/dev/null | grep -qv "^$$\$"; do sleep 20; done
for k in dr-horton-site kb-home-site pultegroup-site tri-pointe-site; do
PSQL "update \"SourceRegistry\" set active=true, health='HEALTHY', \"consecutiveFailures\"=0 where key='$k';" >/dev/null
@@ -38,13 +41,13 @@ while [ ! -f "$STOP" ] && [ "$sweep" -lt "$MAX_SWEEPS" ]; do
s0=$(PSQL "select count(*) from \"InventoryHome\" where status='PUBLISHED';")
b0=$(PSQL "select count(distinct \"builderId\") from \"InventoryHome\" where status='PUBLISHED';")
LOG "===== SWEEP $sweep/$MAX_SWEEPS start: $s0 homes / $b0 builders ====="
- for S in "${STATES[@]}"; do
+ for S in $STATES; do
[ -f "$STOP" ] && break
LOG "-- $S --"
- KBHOME_STATE="${KB[$S]}" CLI kb-home-site 2>&1 | sed "s/^/ kb $S /"
- DRHORTON_STATE="${DRH[$S]}" DRHORTON_PAGE_LIMIT=40 CLI dr-horton-site 2>&1 | sed "s/^/ drh $S /"
- PULTE_STATE="${PLT[$S]}" PULTE_PAGE_LIMIT=40 CLI pultegroup-site 2>&1 | sed "s/^/ plt $S /"
- TRIPOINTE_STATE="${TRI[$S]}" TRIPOINTE_PAGE_LIMIT=40 CLI tri-pointe-site 2>&1 | sed "s/^/ tri $S /"
+ KBHOME_STATE="$S" CLI kb-home-site | sed "s/^/ kb $S: /"
+ DRHORTON_STATE="$(slug "$S")" DRHORTON_PAGE_LIMIT=40 CLI dr-horton-site | sed "s/^/ drh $S: /"
+ PULTE_STATE="$(fullname "$S")" PULTE_PAGE_LIMIT=40 CLI pultegroup-site | sed "s/^/ plt $S: /"
+ TRIPOINTE_STATE="$(lc "$S")" TRIPOINTE_PAGE_LIMIT=40 CLI tri-pointe-site | sed "s/^/ tri $S: /"
done
# drain enrichment queue
for i in $(seq 1 40); do
@@ -56,8 +59,8 @@ while [ ! -f "$STOP" ] && [ "$sweep" -lt "$MAX_SWEEPS" ]; do
s1=$(PSQL "select count(*) from \"InventoryHome\" where status='PUBLISHED';")
b1=$(PSQL "select count(distinct \"builderId\") from \"InventoryHome\" where status='PUBLISHED';")
enr=$(PSQL "select count(*) from \"Community\" where amenities is not null;")
- LOG "===== SWEEP $sweep done: $s1 homes / $b1 builders (+$((s1-s0)) homes) · $enr communities enriched ====="
+ LOG "===== SWEEP $sweep done: $s1 homes / $b1 builders (+$((s1-s0))) · $enr communities enriched ====="
[ -f "$STOP" ] && break
- [ "$sweep" -lt "$MAX_SWEEPS" ] && { LOG "sleeping ${SWEEP_SLEEP}s before next freshness sweep"; sleep "$SWEEP_SLEEP"; }
+ [ "$sweep" -lt "$MAX_SWEEPS" ] && { LOG "sleeping ${SWEEP_SLEEP}s"; sleep "$SWEEP_SLEEP"; }
done
-LOG "BUILD LOOP EXIT (sweeps=$sweep, stop=$( [ -f "$STOP" ] && echo yes || echo no ))"
+LOG "BUILD LOOP EXIT (sweeps=$sweep)"
← 48110bc scripts: all-night autonomous build-loop (ingest x states +
·
back to Homesonspec
·
workers: register 29 Pacific-region regional builders as onb fbd5fc6 →