Observer autosync: the restart key is observer.mjs and run.sh, not the whole tools/observer tree (an autosync.sh change restarted the observer for nothing)

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
igneum-labs 2026-10-04 20:18:32 +00:00
parent 568d6ed9cb
commit 66c0bf2a6d

View file

@ -3,7 +3,7 @@
# tools/observer or site/api is running here within five minutes (4 October 2026: the live API said "observer has
# not reported the proving layer" for an hour because the shared checkout was three commits behind origin).
# Fast-forwards only; if the shared checkout is ahead or dirty in those paths it logs and waits for a human.
# The observer is restarted whenever the checked-out tools/observer tree differs from the one the running observer
# The observer is restarted whenever the checked-out observer.mjs or run.sh differs from what the running observer
# started from, whoever moved HEAD (4 October 2026, 19:35: a pull by hand moved HEAD past an observer fix and the
# observer kept the old code for ten minutes, because only this loop's own fast-forward used to restart it).
# Loop: tools/observer/autosync.sh (log: /tmp/igneum-devnet/autosync.out)
@ -12,7 +12,9 @@ cd "$(dirname "$0")/../.." || exit 1
LOG=/tmp/igneum-devnet/autosync.out
MARK="${OBSERVER_TREE_MARK:-/tmp/igneum-devnet/observer.tree}" # tree id of tools/observer the running observer was started from
PATHS="tools/observer site/api"
observer_tree() { git rev-parse "HEAD:tools/observer" 2>/dev/null; }
# the code the running observer executes: observer.mjs and its restart loop (not autosync.sh or the README, whose
# changes used to restart it for nothing, 20:15 on 4 October 2026)
observer_tree() { git rev-parse "HEAD:tools/observer/observer.mjs" "HEAD:tools/observer/run.sh" 2>/dev/null | tr -d '\n' | shasum | cut -c1-40; }
marker() { cat "$MARK" 2>/dev/null || echo none; }
restart_due() { local t; t="$(observer_tree)"; [ -n "$t" ] && [ "$(marker)" != "$t" ]; }
restart_observer() { # <reason>