From 6f84d8e248e7b6dd3e91f43d5d8d4ec1818e7f1a Mon Sep 17 00:00:00 2001 From: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> Date: Thu, 26 Nov 2026 22:57:34 +0800 Subject: [PATCH 1/3] feat(agy): add reboot-survival launchd watchdog and guarded heartbeat-tick Add heartbeat-tick and install-launchd to loopx.agy_goal_mode.host_runtime (with LaunchAgent plist lifecycle in launchd_watchdog.py) so bound resident Antigravity conversations survive OS/LS restarts without waking active swarm_wait or in-session schedule sleeps, gated by Core quota should-run --scheduler-observation and an exclusive cooldown lock before SendUserCascadeMessage. Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com> --- loopx/agy_goal_mode/README.md | 27 ++ loopx/agy_goal_mode/__init__.py | 33 ++ loopx/agy_goal_mode/host_runtime.py | 262 ++++++++++- loopx/agy_goal_mode/launchd_watchdog.py | 264 ++++++++++++ tests/test_agy_goal_mode_host_runtime.py | 526 +++++++++++++++++++++++ 5 files changed, 1104 insertions(+), 8 deletions(-) create mode 100644 loopx/agy_goal_mode/launchd_watchdog.py create mode 100644 tests/test_agy_goal_mode_host_runtime.py diff --git a/loopx/agy_goal_mode/README.md b/loopx/agy_goal_mode/README.md index 91959f4ddf..0606bafe3d 100644 --- a/loopx/agy_goal_mode/README.md +++ b/loopx/agy_goal_mode/README.md @@ -81,8 +81,35 @@ and audit-continuation) with `quota should-run` (advisory guidance; LoopX does not intercept native host continuations), and arm the next bounded wake with the native `schedule` tool only when quota allows more work. +## Reboot-Survival Watchdog (`antigravity-app` on macOS) + +In-session `schedule(...)` timers suspend while Antigravity is running, so an +OS reboot or Antigravity Language Server restart clears in-memory timers. +`loopx.agy_goal_mode.host_runtime` provides two guarded subcommands for +surviving restarts without disturbing healthy `swarm_wait` or `schedule` sleeps: + +- `heartbeat-tick`: discovers the running Antigravity Language Server, reads + `trajectorySummaries[]` (`status` and `lastModifiedTime`) + and `ps -o lstart= -p `, checks Core admission (`quota should-run --scheduler-observation`) + only when eligible, acquires an exclusive file lock before sending + `SendUserCascadeMessage`, and wakes **only** when `status == "CASCADE_RUN_STATUS_IDLE"` and either: + 1. `ls_start_epoch > last_modified_epoch + 5.0` (proven OS reboot or LS restart + since the last turn, deduped once per `last_woken_ls_pid`), **or** + 2. `now - last_modified_epoch >= long_idle_seconds` (default `2400`s / 40m + stall fallback, bounded by `>= 1800`s cooldown). +- `install-launchd`: previews (default dry-run) or installs/unloads a + `~/Library/LaunchAgents/