[object Object]

← back to Wallco Ai

Add settlement-guard sweep: event-driven removal-only compliance net for live BLOCK designs

e7466ba65b433530d70cc6197d7585d54fdff999 · 2026-05-30 20:31:34 -0700 · Steve Abrams

Files touched

Diff

commit e7466ba65b433530d70cc6197d7585d54fdff999
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Sat May 30 20:31:34 2026 -0700

    Add settlement-guard sweep: event-driven removal-only compliance net for live BLOCK designs
---
 scripts/settlement-guard-sweep.sh | 62 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 62 insertions(+)

diff --git a/scripts/settlement-guard-sweep.sh b/scripts/settlement-guard-sweep.sh
new file mode 100755
index 0000000..5670e61
--- /dev/null
+++ b/scripts/settlement-guard-sweep.sh
@@ -0,0 +1,62 @@
+#!/usr/bin/env bash
+# settlement-guard-sweep.sh — standing compliance guard for wallco.ai.
+#
+# A background settlement re-scan flips already-live designs to settlement_verdict='BLOCK'
+# (or 'REVIEW-VISION-ERROR%', the fail-closed vision verdict) WITHOUT unpublishing them,
+# so legally-blocked patterns can silently reappear on the live grid. This guard sweeps
+# for any such rows and unpublishes them.
+#
+# SAFE BY CONSTRUCTION: it ONLY ever sets is_published=FALSE on genuine settlement LEGAL
+# blocks. It NEVER publishes anything, and it LEAVES the BLEED_GHOST_* quality verdicts
+# alone (those are bleed/ghost-layer image-quality flags, not the settlement legal gate).
+# Event-driven: if it finds 0 violations (the normal case) it does nothing and exits.
+#
+# Codified 2026-05-30 after the 5/29 publish surfaced 31 settlement-blocked designs live.
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+cd "$ROOT"
+LOG="$ROOT/logs/settlement-guard.log"
+mkdir -p "$ROOT/logs"
+REMOTE="root@45.61.58.125"
+REMOTE_JSON="/root/public-projects/wallco-ai/data/designs.json"
+PM2_NAME="wallco-ai"
+ts() { date '+%Y-%m-%d %H:%M:%S'; }
+
+# Predicate for a genuine settlement LEGAL block (NOT the BLEED_GHOST quality family).
+PRED="is_published=TRUE AND (settlement_verdict='BLOCK' OR settlement_verdict LIKE 'REVIEW-VISION-ERROR%')"
+
+N=$(psql dw_unified -At -c "SELECT count(*) FROM all_designs WHERE $PRED;" 2>>"$LOG")
+
+if [ "${N:-0}" -eq 0 ]; then
+  echo "$(ts) clean — 0 settlement-legal-block designs published" >> "$LOG"
+  exit 0
+fi
+
+echo "$(ts) FOUND $N settlement-legal-block designs published — unpublishing" >> "$LOG"
+psql dw_unified >>"$LOG" 2>&1 <<SQL
+BEGIN;
+UPDATE all_designs SET
+    is_published = FALSE,
+    web_viewer   = FALSE,
+    tags  = array_remove(COALESCE(tags,ARRAY[]::text[]),'curator-force-publish'),
+    notes = COALESCE(notes,'') || ' | UNPUBLISHED settlement-guard ' || to_char(now(),'YYYY-MM-DD')
+WHERE $PRED;
+UPDATE spoon_all_designs s SET
+    is_published = FALSE,
+    tags = array_remove(COALESCE(s.tags,ARRAY[]::text[]),'curator-force-publish')
+FROM all_designs a
+WHERE s.id = a.id
+  AND (a.settlement_verdict='BLOCK' OR a.settlement_verdict LIKE 'REVIEW-VISION-ERROR%');
+COMMIT;
+SQL
+
+# Rebuild the live snapshot and push it (only reached when something actually changed).
+python3 scripts/refresh_designs_snapshot.py >>"$LOG" 2>&1
+if rsync -az data/designs.json "$REMOTE:$REMOTE_JSON" >>"$LOG" 2>&1; then
+  ssh "$REMOTE" "pm2 reload $PM2_NAME --update-env >/dev/null 2>&1" >>"$LOG" 2>&1 \
+    && echo "$(ts) shipped + reloaded prod ($N unpublished)" >> "$LOG" \
+    || echo "$(ts) WARN: prod reload failed (Mac2 already corrected)" >> "$LOG"
+else
+  echo "$(ts) WARN: prod unreachable — Mac2 corrected, prod will catch up next sweep/deploy" >> "$LOG"
+fi

← 6bc0857 publish next-5 settlement-clean drunk-animals batch2 (Steve  ·  back to Wallco Ai  ·  generate_room_mockups: platform-aware psql (sudo -u postgres ade7c0b →