[object Object]

← back to Rentv 2026

RENTV: corpus→Kamatera hourly sync script (keeps live /closings fresh, no restart via mtime re-read, shrink-guarded) — TK-10254 follow-up

72bdf1694fba6999026575bc13b7ee97c58640cc · 2026-08-05 14:11:47 -0700 · Steve Abrams

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

Files touched

Diff

commit 72bdf1694fba6999026575bc13b7ee97c58640cc
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Wed Aug 5 14:11:47 2026 -0700

    RENTV: corpus→Kamatera hourly sync script (keeps live /closings fresh, no restart via mtime re-read, shrink-guarded) — TK-10254 follow-up
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 scripts/sync-corpus-to-kamatera.sh | 43 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)

diff --git a/scripts/sync-corpus-to-kamatera.sh b/scripts/sync-corpus-to-kamatera.sh
new file mode 100755
index 00000000..c0dfe027
--- /dev/null
+++ b/scripts/sync-corpus-to-kamatera.sh
@@ -0,0 +1,43 @@
+#!/bin/zsh
+# ─────────────────────────────────────────────────────────────────────────────
+# sync-corpus-to-kamatera.sh  (TK-10254 follow-up)
+#
+# Ships the Mac2-grown RENTV article corpus (data/articles-corpus.jsonl) to the
+# LIVE Kamatera box so /closings stays fresh. The rentv server re-reads the
+# corpus by MTIME (corpus() cache in server.js), so a plain file copy refreshes
+# the merged closings feed with NO pm2 restart.
+#
+# SAFETY GUARD: never ship a SMALLER corpus than what's already live — protects
+# against a mid-crawl FRESH=1 truncation (pull-archive.mjs blanks the file then
+# re-appends) from wiping the live archive.
+#
+# Idempotent, read-only on the source, single tiny file (<1 MB). $0.
+# Drafted for Steve's approval — the launchd install is gated.
+# ─────────────────────────────────────────────────────────────────────────────
+set -euo pipefail
+
+SRC="$HOME/Projects/rentv/data/articles-corpus.jsonl"
+HOST="root@45.61.58.125"
+RPATH="/root/public-projects/rentv/data/articles-corpus.jsonl"
+KEY="$HOME/.ssh/id_ed25519_wallco_20260530"
+SSHOPTS="-i $KEY -o ConnectTimeout=15 -o StrictHostKeyChecking=accept-new -o BatchMode=yes"
+LOG="$HOME/Projects/rentv/logs/corpus-sync.log"
+stamp() { date -u +%FT%TZ }
+
+[ -f "$SRC" ] || { echo "$(stamp) SKIP: no local corpus" >> "$LOG"; exit 0 }
+
+LOCAL_N=$(wc -l < "$SRC" | tr -d ' ')
+REMOTE_N=$(ssh $SSHOPTS "$HOST" "wc -l < '$RPATH' 2>/dev/null" 2>/dev/null | tr -d ' ' || echo 0)
+REMOTE_N=${REMOTE_N:-0}
+
+if [ "$LOCAL_N" -lt "$REMOTE_N" ]; then
+  echo "$(stamp) SKIP: local($LOCAL_N) < remote($REMOTE_N) — refusing to shrink live corpus" >> "$LOG"
+  exit 0
+fi
+
+if rsync -az --checksum -e "ssh $SSHOPTS" "$SRC" "$HOST:$RPATH" >> "$LOG" 2>&1; then
+  echo "$(stamp) OK: synced $LOCAL_N lines (was $REMOTE_N live)" >> "$LOG"
+else
+  echo "$(stamp) FAIL: rsync error" >> "$LOG"
+  exit 1
+fi

← ba1e3bf2 fix: KPI card links inherit text color (was rendering number  ·  back to Rentv 2026  ·  auto-save: 2026-08-05T14:12:38 (7 files) — data/deals-regist 8911db12 →