Never undo settings applied on the page: sync from NA Ingest, rebase stale drafts, guard the installer

- config.json is NA Ingest's live settings: the READY hours (Tue 14-22, Wed 9-19, Sun 5-14) and the
  auto-fix hours (Tue 14-22, Wed 9-21, Sun 6:30-14) set on the settings page.
- Settings page: a draft carries what its page started from. A tab that loaded the settings before
  they changed (an Apply elsewhere, a program update) now has only its own edits put on top of the
  live settings; before, it saved its whole older copy and Apply quietly undid the newer values
  (it took ready.prop_host out twice today).
- install.sh refuses (exit 4) to replace live settings that came from an Apply (their fingerprint is
  a history entry's sha_after) unless --replace-config; --keep-config still updates code only.
- Tests pin their own auto-fix and READY hours, so the campus can change its own; the exit-timeout
  test expects 310 s (the Tascam outlet power-cycle).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 15:02:17 -04:00
co-authored by Claude Opus 5.5
parent c9ffbc6828
commit 98739bd041
8 changed files with 1702 additions and 1613 deletions
+27
View File
@@ -4,6 +4,7 @@
#
# zsh install.sh install / update and (re)start
# zsh install.sh --keep-config update the code but leave the live config.json as it is
# zsh install.sh --replace-config replace the live config even when it came from an Apply on the settings page
# zsh install.sh --site <id> first install of a campus: its config from sites/<id>/, else sites/_template/
# zsh install.sh --rollback put the previous code back (kept in prev/) and restart
# zsh install.sh --remove stop it and remove the LaunchAgent (files stay)
@@ -26,6 +27,7 @@ for arg in "$@"; do
if [[ $SITE_NEXT == 1 ]]; then SITE="$arg"; SITE_NEXT=0; continue; fi
case "$arg" in
--keep-config) KEEP_CONFIG=1 ;;
--replace-config) REPLACE_CONFIG=1 ;;
--site) SITE_NEXT=1 ;;
--remove|--rollback|--now) ;;
*) echo "unknown option $arg" >&2; exit 2 ;;
@@ -151,6 +153,31 @@ then
exit 3
fi
# 0b. Never undo an Apply. Live settings that came from the settings page (their fingerprint is the
# "sha_after" of an entry in history/) and differ from the config this would install were changed on
# the page since this folder was made: replacing them would quietly undo that (2026-10-15: READY hours
# set on the page went back to the folder's defaults). Copy them into the folder first, or say so.
if [[ $KEEP_CONFIG == 0 && ${REPLACE_CONFIG:-0} == 0 && -f "$DEST/config.json" && -d "$DEST/history" ]] \
&& ! cmp -s "${SRC_CONFIG:-$SRC/config.json}" "$DEST/config.json" \
&& /usr/bin/python3 -c '
import glob, hashlib, json, os, sys
d = sys.argv[1]
live = hashlib.sha256(open(os.path.join(d, "config.json"), "rb").read()).hexdigest()
for m in glob.glob(os.path.join(d, "history", "*.meta.json")):
try:
meta = json.load(open(m))
except ValueError:
continue
if meta.get("sha_after") == live:
print("the live settings come from the settings page (%s, %s): not replacing them." % (meta.get("by", "?"), os.path.basename(m)[:15]))
sys.exit(0)
sys.exit(1)' "$DEST"
then
echo "Copy them into this folder first (scp checklist-ingest:'Library/Application Support/status-panel/config.json' config.json)," >&2
echo "or run with --keep-config (code only) or --replace-config (overwrite them)." >&2
exit 4
fi
# 1. The config that will run, checked with the code that will run it.
mkdir -p "$DEST"
if [[ $KEEP_CONFIG == 1 && -f "$DEST/config.json" ]]; then