[object Object]

← back to Rentv Slideshow Canary

canary: auto-retire after 48h continuous OK (revert scare resets the clock)

0491e8654e5feb4b077677e48bf305ae0a88af1e · 2026-08-07 15:52:20 -0700 · Steve Abrams

A standing guard for a resolved fix is stale cruft. Self-retires (bootout + disable
its own launchd job) once the fix has held for RETIRE_HOURS; a REVERTED extends the
window. Job label + hours env-overridable; retire path sandbox-tested without touching
the live job.

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

Files touched

Diff

commit 0491e8654e5feb4b077677e48bf305ae0a88af1e
Author: Steve Abrams <steve@designerwallcoverings.com>
Date:   Fri Aug 7 15:52:20 2026 -0700

    canary: auto-retire after 48h continuous OK (revert scare resets the clock)
    
    A standing guard for a resolved fix is stale cruft. Self-retires (bootout + disable
    its own launchd job) once the fix has held for RETIRE_HOURS; a REVERTED extends the
    window. Job label + hours env-overridable; retire path sandbox-tested without touching
    the live job.
    
    Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---
 .gitignore |  2 ++
 README.md  |  3 +++
 check.sh   | 31 +++++++++++++++++++++++++++++++
 3 files changed, 36 insertions(+)

diff --git a/.gitignore b/.gitignore
index be3fd5c..07a9bf0 100644
--- a/.gitignore
+++ b/.gitignore
@@ -2,3 +2,5 @@ data/*.log
 data/latest.json
 node_modules/
 .DS_Store
+data/retire_at
+data/RETIRED
diff --git a/README.md b/README.md
index 30a9423..da9d52e 100644
--- a/README.md
+++ b/README.md
@@ -16,3 +16,6 @@ OK→REVERTED transition it alerts (tk comment/DM on TK-10357 + best-effort CNCP
 
 Run manually: `./check.sh`  ·  Dry-run alert path: `CANARY_MARKER=nope CANARY_DRYRUN=1 ./check.sh`
 Scheduled by launchd `com.steve.rentv-slideshow-canary` (StartInterval 900s).
+
+## Auto-retire
+Stays a standing guard only while useful. After 48h of continuous OK (env CANARY_RETIRE_HOURS) it logs to TK-10357, boots out its own launchd job, and disables — a REVERTED scare resets that clock so it keeps guarding after trouble. Re-arm: launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.steve.rentv-slideshow-canary.plist
diff --git a/check.sh b/check.sh
index 66db098..287eaa0 100755
--- a/check.sh
+++ b/check.sh
@@ -23,6 +23,16 @@ MARKER="${CANARY_MARKER:-return load('/consulting')}"
 DIR="$(cd "$(dirname "$0")" && pwd)"
 LATEST="$DIR/data/latest.json"
 NOW="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
+NOW_EPOCH="$(date +%s)"
+RETIRE_HOURS="${CANARY_RETIRE_HOURS:-48}"          # auto-retire after this many hours of continuous OK
+RETIRE_AT_FILE="$DIR/data/retire_at"
+JOB="${CANARY_JOB:-com.steve.rentv-slideshow-canary}"
+
+# Already retired? Ensure the launchd job is really gone, then exit (belt-and-suspenders).
+if [ -f "$DIR/data/RETIRED" ]; then
+  nohup bash -c "launchctl bootout gui/$(id -u)/$JOB 2>/dev/null; launchctl disable gui/$(id -u)/$JOB 2>/dev/null" >/dev/null 2>&1 &
+  echo "[$NOW] already RETIRED — ensuring launchd job removed"; exit 0
+fi
 
 prev="NONE"
 [ -f "$LATEST" ] && prev="$(grep -o '"status":"[A-Z]*"' "$LATEST" | head -1 | cut -d'"' -f4)"
@@ -66,3 +76,24 @@ if [ "$status" = "REVERTED" ] && [ "$prev" = "OK" ]; then
 fi
 
 echo "[$NOW] status=$status http=$code prev=$prev"
+
+# ── Auto-retire: a standing guard for a resolved fix is stale cruft. Retire after
+#    RETIRE_HOURS of continuous OK (the fix has already survived a real deploy). A
+#    REVERTED scare EXTENDS the window (keep guarding after trouble). Skip in dryrun.
+if [ "${CANARY_DRYRUN:-0}" != "1" ]; then
+  [ -f "$RETIRE_AT_FILE" ] || echo $((NOW_EPOCH + RETIRE_HOURS*3600)) > "$RETIRE_AT_FILE"
+  if [ "$status" = "REVERTED" ]; then
+    echo $((NOW_EPOCH + RETIRE_HOURS*3600)) > "$RETIRE_AT_FILE"   # reset the clock after a scare
+  elif [ "$status" = "OK" ]; then
+    deadline="$(cat "$RETIRE_AT_FILE" 2>/dev/null || echo 0)"
+    if [ "$NOW_EPOCH" -ge "$deadline" ]; then
+      touch "$DIR/data/RETIRED"
+      MSG2="✅ rentv-slideshow-canary AUTO-RETIRED at $NOW — the /consulting/slideshow fix held OK continuously for ${RETIRE_HOURS}h across >=1 real prod deploy (TK-10356). Guard no longer needed; launchd job booted out + disabled. Re-arm anytime: launchctl bootstrap gui/\$(id -u) ~/Library/LaunchAgents/$JOB.plist"
+      export TK_AGENT=canary-rentv-slideshow
+      tk comment TK-10357 "$MSG2" >/dev/null 2>&1 || true
+      # tear down our own launchd job from a detached child so this run exits cleanly first
+      nohup bash -c "sleep 3; launchctl bootout gui/$(id -u)/$JOB 2>/dev/null; launchctl disable gui/$(id -u)/$JOB 2>/dev/null" >/dev/null 2>&1 &
+      echo "[$NOW] AUTO-RETIRED (${RETIRE_HOURS}h clean) — launchd bootout scheduled"
+    fi
+  fi
+fi

← fa98cf9 rentv-slideshow-canary: read-only revert watch for the /cons  ·  back to Rentv Slideshow Canary  ·  (newest)