← back to Wallco Ai
scripts/_pull-bad-aesthetic.sh
33 lines
#!/bin/bash
# Pull the source-of-truth bad-aesthetic-patterns.jsonl from prod (where the
# Ghost Review UI's bulk-delete endpoint and learn-and-purge-flagged.js write
# it) so the local generator ticks read fresh failure data.
#
# Architecture note: cron lives on Mac2 (this box) because ComfyUI/SDXL runs
# locally. But the UI that produces the learn-from-this-failure rows runs on
# prod (Kamatera). Without this pull, the local lib/bad-aesthetic.js reads an
# empty local file and the LEARNED-AVOID addendum never fires.
#
# Fails open: if SSH hiccups or the remote file is missing, exits 0 and leaves
# whatever stale local copy exists (or nothing) intact. The generators are
# designed to tolerate a missing/empty file.
#
# Invoked from the top of generator_tick.js and drunk_animals_tick.js.
set -u # no -e; failure is acceptable
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
REMOTE_HOST="my-server"
REMOTE_PATH="/root/public-projects/wallco-ai/data/bad-aesthetic-patterns.jsonl"
LOCAL_PATH="$ROOT/data/bad-aesthetic-patterns.jsonl"
# Tight timeouts so a slow SSH session never delays a tick by more than ~6s.
rsync -az \
--timeout=5 \
-e 'ssh -o ConnectTimeout=4 -o ServerAliveInterval=2 -o BatchMode=yes' \
"${REMOTE_HOST}:${REMOTE_PATH}" \
"${LOCAL_PATH}" \
2>/dev/null
exit 0