Repository navigation
feat(agy): add reboot-survival launchd watchdog and guarded heartbeat-tick - #9491
Conversation
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 卸载成功前确认 watchdog 已停。卸载忽略 launchctl 的非零结果。独立入口测试中 bootout 被拒,已加载作业仍在;命令给出 exit 0 和 uninstalled=true,且删除用于恢复的 plist。操作者依回执会认为周期唤醒已停止。 在删除 plist 和报告卸载成功前,向 launchd 确认目标已卸载或确实不存在。若仍加载或结果无法核实,保留可重试状态并返回明确错误。覆盖已不存在、成功卸载及 bootout 失败仍在加载三条路径。 源码
动机 / Motivation
新增经明确安装的 macOS Antigravity 看门狗,让丢失内存定时器的会话可重新唤醒,并提供可信停用。 基线的 Antigravity 定时唤醒属于会话本身,重启后需要恢复,宿主 CLI 仅提供 Stop hook。 显式安装或停用 Antigravity 定时看门狗的 macOS 会话维护者。
可持续执行的看门狗必须能够可靠停用。假成功可能在操作者停止自动唤醒后仍继续运行。 真实 CLI 预览无目录或 plist 写入,显式 --execute --no-load 生成与预览一致的 plist 且不启动作业。定向看门狗测试覆盖短时健康等待、重启去重、Core 拒绝和失败冷却。 新的看门狗专项 9 项通过。隔离回环 Core 与替身 LS 所属的唤醒边界、行为和正向安装预览通过。独立公开 CLI 的卸载失败探针复现错误成功。git diff --check 与 merge-tree 通过。 通过当前源码执行 CLI、临时目录 plist 和 Core 夹具,launchctl 与宿主 RPC 采用隔离替身。真实 macOS 作业、安装发布版、重启及远端 CI 未核验。 基线契约
改动思路 / Approach
该改动沿用 python -m loopx.agy_goal_mode.host_runtime install-launchd / heartbeat-tick。会话观察通过原 LS,配额用原 Core scheduler observation。新 LaunchAgent 的安装、停用状态应由同一个 launchd 状态读回确认。 新 CLI 的预览、加载和运行 gate 保留现有 owner。卸载分支只发 bootout,忽略返回码,且少了加载分支已使用的独立状态读回。 保留现有 launchctl helper 和 plist 写入。复用载入时的状态读回来确认卸载或暴露可重试失败。
具体改动 / Changes
精确提交 c23b731,本次对照目标 a9c2750。5 个文件,+1104/-8,覆盖宿主入口、LaunchAgent、文档和测试。
关键代码讲解
-
heartbeat_tick。验证 IDLE 和时间,观察 Core 准入并通过本地 reservation 去重。 源码 -
_reload_launchd_agent。执行 bootstrap,随后 print 验证目标已加载。 源码 -
install_launchd:卸载分支。实际卸载忽略 bootout 结果,然后删除 plist 并报告成功。 源码 -
macos-watchdog-uninstall-readback(partial)。显式卸载的成功回执要与 launchd 实际已停止或原本不存在的状态一致;失败保持可恢复。
对主干的风险 / Risks
在临时 plist 上通过真实命令入口模拟已加载作业的 bootout 被拒绝。候选仅调用 bootout,然后删掉 plist,返回 exit 0、ok=true、uninstalled=true。模拟作业仍在 loaded 状态,未发生独立 shutdown readback。 对可定时发送唤醒的作业,磁盘配置是否存在和作业是否仍在当前 launchd 域内运行可能分离。对非零 bootout 一律报成功,会隐藏仍加载以及权限或状态不明的情况。用户会失去可靠的停机凭证。成功、已不存在与仍存活需要分别测试。 在删除 plist 和报告卸载成功前,向 launchd 确认目标已卸载或确实不存在。若仍加载或结果无法核实,保留可重试状态并返回明确错误。覆盖已不存在、成功卸载及 bootout 失败仍在加载三条路径。
语义与 CI 对齐
在临时 plist 上通过真实命令入口模拟已加载作业的 bootout 被拒绝。候选仅调用 bootout,然后删掉 plist,返回 exit 0、ok=true、uninstalled=true。模拟作业仍在 loaded 状态,未发生独立 shutdown readback。 在删除 plist 和报告卸载成功前,向 launchd 确认目标已卸载或确实不存在。若仍加载或结果无法核实,保留可重试状态并返回明确错误。覆盖已不存在、成功卸载及 bootout 失败仍在加载三条路径。
我的整体评价 / Verdict
REQUEST_CHANGES。 先修复卸载失败时的错误回执,再复审精确提交。看门狗启用和停用都需要可回读的宿主状态。 可靠停用维持用户对长期自动唤醒的控制和可验证的回执。
English verdict: REQUEST_CHANGES at c23b731. Request changes. Failed launchctl bootout is ignored: the uninstall reports success and deletes its plist even though the watchdog job remains registered.
…-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>
…ootout Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
c23b731 to
0a68925
Compare
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Request changes conclusion (author-owned PR; GitHub blocks formal self-review)
[P2] 保留读回失败时的 LaunchAgent 配置。隔离的真实 CLI 进程调用 launchctl 替身。bootout 返回 0,而 print 返回 1 和 IPC 错误,命令仍退出 0、报告 loaded=false,随后删除 plist。这个组合缺少独立的目标不存在证据。 只允许 launchctl print 的已知目标不存在回执确认停用。读回不明确时返回 launchctl_readback_failed,保留 plist 以便重试,并覆盖 bootout 成功、print 不可读的组合。 源码
动机 / Motivation
让明确启用的 macOS Antigravity 看门狗在进程重启后恢复丢失的 in-session 定时器,并让操作者可读回启停状态。 基线只支持进程内调度和 Stop hook,无 LaunchAgent 卸载入口。上一评审版本卸载分支忽略 bootout,并无状态读回。 使用 Antigravity 并显式安装或停用 LaunchAgent 的 macOS 用户。
回执无法从现有证据验证,却删除了用于重试或核实的安装文件。 新候选修复了上一头的一个分支。bootout 被拒且 print 确认仍加载时,CLI 非零退出并保留 plist;print 明确确认不存在时,CLI 成功删除 plist。 精确候选安装匹配的本地源环境后,36 项定向 pytest 通过。独立脚本在精确提交运行三组替身 launchctl 入口核验,重复结果与独立 worktree 相同;git diff --check 和 merge-tree 通过。 基线 CLI、真实候选 CLI、临时 plist 和隔离的 launchctl 边界已验证。真实 GUI 会话、系统重启、作业管理域和远程 CI 未核验。 基线契约
改动思路 / Approach
该改动沿用 python -m loopx.agy_goal_mode.host_runtime install-launchd --uninstall --execute。沿用 Core scheduler observation 和宿主 RPC,启用动作经单独入口。作业卸载判断集中于已有 launchctl 生命周期助手。 同一 helper 先请求 bootout,再以 print 观测。对 print 返回明确目标缺失的分支可删除;当前分支同时把 bootout 成功当成 print 可验证的结果。 收紧现有卸载分类的成功条件,无需增加第二个看门狗或触发逻辑。
具体改动 / Changes
精确提交 0a68925,本次对照目标 ddcfca5。5 个文件,新增 1,472 行、删除 8 行,涉及显式宿主入口、launchd 和测试。
关键代码讲解
-
_uninstall_launchd_agent。调用 launchctl bootout 和 print,读回作业生命周期。 源码 -
absent_confirmed。以 bootout 退出码替代不可用的 print,构成此次未覆盖的误报分支。 源码 -
install_launchd。根据卸载 helper 的结果保留或移除原 plist。 源码 -
heartbeat_tick。只有在合格 IDLE 观察与 Core 允许时才准备发送唤醒。 源码 -
verified-watchdog-uninstall-readback(partial)。请求卸载与观测已卸载是两个阶段。确认目标停止或不存在后再删除配置,状态不明则保留恢复证据。
对主干的风险 / Risks
隔离的真实 CLI 进程调用 launchctl 替身。bootout 返回 0,而 print 返回 1 和 IPC 错误,命令仍退出 0、报告 loaded=false,随后删除 plist。这个组合缺少独立的目标不存在证据。 命令结果目前把一次动作的成功混作后置观测,无法区分相继发生的状态读回故障。 只允许 launchctl print 的已知目标不存在回执确认停用。读回不明确时返回 launchctl_readback_failed,保留 plist 以便重试,并覆盖 bootout 成功、print 不可读的组合。
语义与 CI 对齐
隔离的真实 CLI 进程调用 launchctl 替身。bootout 返回 0,而 print 返回 1 和 IPC 错误,命令仍退出 0、报告 loaded=false,随后删除 plist。这个组合缺少独立的目标不存在证据。 只允许 launchctl print 的已知目标不存在回执确认停用。读回不明确时返回 launchctl_readback_failed,保留 plist 以便重试,并覆盖 bootout 成功、print 不可读的组合。
我的整体评价 / Verdict
REQUEST_CHANGES。 先修复读取不可用时的卸载成功误报。前次反馈的仍加载分支已独立读回通过。 持久自动唤醒需要用户可验证的停机与可恢复的局部失败。
English verdict: REQUEST_CHANGES at 0a68925. Request changes. An acknowledged bootout followed by an inconclusive print is still reported as a confirmed uninstall and deletes the plist.
Signed-off-by: LoopX Agent <337587101+loopx-agent@users.noreply.github.com>
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gemini-3.1-pro · Google · self_reported · effort_unavailable
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
本次独立核查针对精确提交 7ac3636310957f6ac9c6064bbf0ced2726e15cf1(对比合并基线 5947dc87ec1395b8aee3e73db649841e6d5391f7,5 个文件,+1547/-8;干净 merge-tree c664f81f0b),重点复核之前两轮外审指出的 launchd 卸载状态读回缺陷,确认两者已在 7ac3636310957f6ac9c6064bbf0ced2726e15cf1 闭环修复且不改变默认隔离策略。
动机 / Motivation
在 macOS 上运行 Antigravity App 并依赖会话内 schedule 定时器续航固定会话的运维人员与 Agent 会话。 旧路径中,OS 重启或 Antigravity Language Server 重启会清空内存级 schedule 定时器,导致长程会话停在 CASCADE_RUN_STATUS_IDLE;而在早期候选中,launchctl bootout 失败或 print 返回不可读错误时仍报告卸载成功并删除恢复用 plist。新路径通过显式安装的 LaunchAgent 执行 guarded heartbeat-tick(仅在 LS 启动晚于最近消息、或长时卡滞超冷却阈值,且经过 Core 配额准入与文件锁防重后发送恢复指令),并在卸载前要求 launchctl print 明确返回目标不存在回执后才移除 plist。 在精确提交 7ac3636 下,运行中会话与健康 swarm_wait/schedule 等待均不惊扰且零写盘,LS 重启后每个新 LS 实例仅唤醒一次,install-launchd 默认只做 dry-run 预览,卸载仅在 launchctl print 确认未加载或不存在时才删除 plist。 不改变核心 Quota/Scheduler 决策所有权,不在非 macOS 平台声明 LaunchAgent 运行态支持,也不在普通 activation 流程中自动安装或加载系统常驻作业。
规格依据方面,对照未改动的 docs/architecture/rfcs/single-owner-local-daemon-v0.md(固定基线修订 5947dc87ec1395b8aee3e73db649841e6d5391f7)核对 DAEMON-FAIL-CLOSED、DAEMON-QUOTA-GATE 与 DAEMON-MACOS-LAUNCHD 三项约束:非 macOS 或 launchctl print 读回不明时 fail-closed 并保留配置;唤醒前须经 Core --scheduler-observation 准入;真机未经过完整实机重启回归边界则如实披露。
改动思路 / Approach
看门狗策略、Core 配额准入与 LaunchAgent 生命周期沿用既有的单所有权分层:host_runtime 仅读取 Language Server 摘要、核验 ps 启动时间并用 exclusive_file_lock 预订冷却状态,准入裁决仍归 Core quota should-run --scheduler-observation 所有;LaunchAgent 构建与 bootout/print 状态读回集中在 launchd_watchdog,activation 仅渲染显式安装命令模板而不隐式写盘。
本 PR 边界限于显式调用 install-launchd/heartbeat-tick CLI 与 activation 元数据提示,保留既有 Stop hook 与默认关闭隔离,未声称覆盖真实 OS 重启或未插桩的系统 launchctl bootstrap 实机测试(真实 macOS launchctl print 不存在返回码 113 已核验)。
| 触发条件与分支 | 判定条件(精确提交 7ac3636310957f6ac9c6064bbf0ced2726e15cf1) |
动作与失败回退 |
|---|---|---|
| 会话运行中或缺少时间戳 | status != CASCADE_RUN_STATUS_IDLE 或 lastModifiedTime 缺失 |
跳过(not_idle / missing_last_modified_time),不调用 Core 且不写状态 |
| 同 LS 健康等待期 | 同 ls_pid/ls_start_epoch 且未满 long_idle_seconds(默认 2400s)或未过 1800s 冷却 |
跳过(active_wait_or_cooldown),不惊扰 swarm_wait / schedule |
| LS 重启或 OS 重启 | ls_start_epoch > last_modified_epoch + 5.0 且未对当前 ls_pid/ls_start_epoch 唤醒过 |
经 Core 准入 + 二次状态核验 + exclusive_file_lock 预占位后唤醒一次(ls_restarted_since_last_turn) |
卸载 install-launchd --uninstall --execute |
先 launchctl bootout,再强制读回 launchctl print 验证 rc == 113 或 "could not find service" |
确认缺席才删 .plist;仍加载报 launchctl_bootout_failed/launchctl_still_loaded,读回不明报 launchctl_readback_failed 并保留 .plist |
具体改动 / Changes
- 守护心跳与重启去重:
host_runtime.py#L277-L451新增_process_start_epoch、_discover_endpoint、_probe_cascade_summary、_wake_reason与heartbeat_tick。实测 live SQLite 夹具调用_admitted(loopx --format json quota should-run --scheduler-observation --runtime-profile antigravity_app)耗时1.051s(低于10s上限),并在 TOCTOU 二次确认IDLE与文件锁预占后才调用SendUserCascadeMessage,RPC 异常时保留冷却占位防止重试风暴。 - LaunchAgent 构筑、安装与强验证卸载:
launchd_watchdog.py#L94-L385提供确定性标签验证、@host-global保留、相对路径.resolve()归一化、冷启动PATH(含node、Python 与 CLI 目录)+-E -P执行参数以及默认 dry-run;_uninstall_launchd_agent(#L189-L226)在提交7ac3636310957f6ac9c6064bbf0ced2726e15cf1严格要求launchctl print返回113或"could not find service"方可移除.plist(本机 macOS 实测launchctl print gui/501/...返回LAUNCHCTL_PRINT_RC=113与Could not find service)。 - Activation 与说明文档:
__init__.py#L292-L426暴露build_antigravity_launchd_command并在antigravity_app_activation_extras增加提示字段reboot_watchdog_command;README.md#L84-L118补充了运行门槛与安装/卸载说明。 - 回归测试覆盖:
tests/test_agy_goal_mode_host_runtime.py#L123-L845覆盖 11 组测试(含同 LS 跳过、多次重启去重、1800s 冷却下限、TOCTOU 状态跳变、真实 SQLite Core 配额与daemon_discovery、cwd="/"冷启动ProgramArguments与 CLI 环境变量执行、以及涵盖bootout=0/3搭配print=1IPC 报错的真实子进程launchctl替身读回测试)。
实测验证矩阵(精确提交 7ac3636310957f6ac9c6064bbf0ced2726e15cf1)
- 定向与相邻架构套件:
pytest -n 4 -v覆盖test_agy_goal_mode_host_runtime.py、test_agy_host_surface.py、test_antigravity_*.py、test_top_level_module_budget.py、test_package_kernel_import_ratchet.py、test_semantic_vocabulary_drift.py与test_maintainability_ratchet.py,383 passed in 69.68s(0 失败,0 跳过)。 - 静态与边界门禁:
ruff check0 问题;mypy --strict --follow-imports=silent(4 变更文件)0 问题;mypy --no-incremental --follow-imports=silent(17 仓库受控文件)0 问题;npm run typecheck:control-plane通过;scripts/check_rfc_bilingual.py通过;干净HOME执行semantic-vocabulary-drift-smoke.py(conflicting_values_semantic=0/0)与control-plane-maintainability-ratchet-smoke.py(unreviewed_count=0)通过;loopx check(5 文件)errors=0, warnings=0。 - Standard Canary Premerge:
canary premerge --tier standard --from-git-diff --git-diff-base 5947dc87ec1395b8aee3e73db649841e6d5391f7执行完成:selected=15, failures=0(direct 4/4、py_compile 1/1、catalog 6/6、risk_profile 8/8、public_boundary 1/1、manual_hold_count=0)。 - 实机与孤立 CLI 探针:
launchctl print对未注册 service 实测返回LAUNCHCTL_PRINT_RC=113;独立进程install-launchddry-run 预览不创建目录与文件,--execute --no-load在隔离目录写盘成功;_admitted连接隔离 SQLite Goal 实测1.051s返回True。
对主干的风险 / Risks
- 非阻塞
[P3]观察(不阻塞合并,供后续清理):_reload_launchd_agent(launchd_watchdog.py#L229-L241)在调用_run_launchctl时未像_uninstall_launchd_agent一样局部捕获(OSError, subprocess.SubprocessError);经由 CLImain()入口会被兜底捕获并返回 exit1JSON 错误,但直接以 Python 函数调用install_launchd时异常会直接向上抛出。_state(host_runtime.py#L124-L129)直接假定已存在状态文件反序列化为dict(不同于_read_state#L119-L120的类型守卫);若状态文件被外部损坏为非字典 JSON,同样由main()fail-closed 报错但缺乏针对性恢复提示。此外bootstrap_prompt(host_runtime.py#L92-L106)复用"Do not replay the failed user request..."提示词(重启/卡滞场景同样指向全新heartbeat-prompt --thin读回,语义无冲突)。
- 验证边界披露:测试中的
launchctl bootstrap/bootout写入与 Antigravity Language ServerSendUserCascadeMessage发送使用进程替身或函数桩代替真实用户 GUI 会话与真机 OS 重启循环;该未测真实边界不影响现有功能默认关闭隔离。
我的整体评价 / Verdict
APPROVE(Author-owned PR 以 COMMENTED 发布)。 两项历史 [P2] 卸载安全隐患(忽略非零 bootout 与缺少 launchctl print 缺席强验证)已在提交 7ac3636310957f6ac9c6064bbf0ced2726e15cf1 彻底修妥并通过真实子进程替身及本地 macOS launchctl print 实测;所有静态检查、383 项 Pytest 与 15 项 Canary Premerge 全部绿灯,无阻断级问题,剩余仅为两处局部健壮性 [P3] 提示。
English verdict: APPROVE at 7ac3636. Verified all prior LaunchAgent uninstall readback fixes, guarded LS-restart vs. active-wait separation, cold-boot relative-path and PATH resolution, 383 passing tests, 15/15 standard premerge canary checks, and strict type/boundary gates with only minor non-blocking [P3] observations.
loopx-agent
left a comment
There was a problem hiding this comment.
Reviewer: model_agent · gpt-6.2-sol · OpenAI · runtime_reported · xhigh
Approval conclusion (author-owned PR; GitHub blocks formal self-approval)
动机 / Motivation
Antigravity App 的内存 schedule 在进程重启后会消失。显式安装的 watchdog 可补唤醒,卸载时要按同一已绑定 job 的 launchctl print 状态决定是否可删除持久 plist。 主干仅提供 stop-hook,未提供新的两个动作;上个评审头 0a689251de 在 bootout 成功或自称无进程而读回不明确时仍返回卸载成功并删除 plist。 上一版评审 使用 Antigravity App 的已绑定 Goal/Agent 与运维者。
无法确认的卸载曾清除原 plist,可能丢失后续恢复、确认或重新加载所需的持久配置。 精确候选经真实 Python CLI、隔离的 launchctl 进程和实际本地 plist,在两种不明确读回下退出 1,launchctl_readback_failed、loaded=null,plist 字节不变。真实只读 launchctl print 查询未注册的测试标签返回 113,符合候选所用的明确缺失信号。 精确候选运行 24 项 Antigravity host/runtime 定向用例,两条真实 CLI 路径分别覆盖主干/候选与上一版/候选的 7 种子进程输出。已有测试以隔离 SQLite 实际运行 Core 的 scheduler observation。 未安装真实 LaunchAgent、未重启主机或向已存在的 Antigravity 会话发送。排除了会探测本机 LS 的 cold-boot 测试,未查询托管 CI;watchdog 在真实 reboot 后恢复仍需现场验收。 基线契约
改动思路 / Approach
该改动沿用 python -m loopx.agy_goal_mode.host_runtime install-launchd --uninstall --execute,以及该模块的默认 preview、heartbeat-tick 和既有 stop-hook。。原会话状态预检、Core scheduler observation 和持久预约先于唤醒。LaunchAgent 的显式路径及结果走独立 plist helper。 状态结论基于 print 的明确存在、明确不存在或未知。bootout 的结果只分类诊断。新 watchdog 的 timed wake 复用现有 Goal/Agent 与 Core admission,保留默认预览和显式安装。 保留唯一 readback 决策点、既有 bootout/print 次序和 CLI 标志。新分支无需额外卸载状态或第二个 owner。
具体改动 / Changes
精确提交 7ac3636,本次对照目标 ddcfca5。五个文件 +1547/−8,相对上一评审头只改卸载分支与其回归。项目原入口外加 Watchdog、host sidecar 配置和测试。
关键代码讲解
-
_uninstall_launchd_agent。同一 gui UID 和 label 的print结果拥有最终卸载判断,bootout只分类失败。 源码 -
install_launchd。从 typed 三态结果决定是否保留 plist,CLI 对不可确认状态退出失败。 源码 -
heartbeat_tick。仅在当前状态允许时观察 Core admission,随后复核和预约唤醒。 源码 -
build_antigravity_launchd_command。复用注册的 Antigravity App host adapter 构造显式安装命令。 源码 -
agy-native-bounded-host-continuation(implemented)。继续复用本机绑定与 quota gate。Watchdog 补充显式 host 活动;无法确认卸载时保留原配置并清晰回报。
对主干的风险 / Risks
同样的 CLI 矩阵确认仍加载时返回失败并保留 plist,print 超时同样保留;只有读回明确找不到服务时正常卸载并删除文件。普通主干入口对新动作拒绝参数,无文件或执行副作用。 真实 GUI session 和系统重启的组合尚未在隔离以外执行。scheduler observation 不替代现场 restart 验收。 候选只接受 print 的明确缺失证据,其余返回 typed 失败留存原件。
我的整体评价 / Verdict
APPROVE。 上一评审头的 P2 在这个提交关闭,确认卸载和仍加载/未知三种分支均有本地回读证据。 卸载在确证前可恢复;已覆盖本次固定的实际 CLI 和 readback 条件。真正重启后的恢复收益尚待验证。
English verdict: APPROVE at 7ac3636. Approve the reviewed head. Uninstall preserves the plist when launchctl readback is inconclusive, still loaded, or times out; confirmed absence still succeeds. Paired CLI checks cover both prior false-success cases. Live reboot remains unverified.
Goal & Root Cause
In-session
schedule(...)timers on Antigravity App suspend only while the IDE / Language Server process stays alive, so an OS reboot or Antigravity Language Server restart clears pending in-memory wake timers and leaves a resident LoopX conversation stuckCASCADE_RUN_STATUS_IDLE. Conversely, a naive watchdog that wakes wheneverstatus == CASCADE_RUN_STATUS_IDLE && should_run == truefalse-triggers every 5 minutes during healthyswarm_waitor in-sessionschedule(...)sleeps.This PR adds guarded
heartbeat-tickandinstall-launchdsubcommands onloopx.agy_goal_mode.host_runtime(backed bylaunchd_watchdog.py) so macOSLaunchAgentticks survive restarts while keeping active waits undisturbed.Summary of Changes
loopx/agy_goal_mode/host_runtime.py):discover_antigravity_language_server(Url,csrf_token,pid), inspectsGetAllCascadeTrajectories(trajectorySummaries[conversation_id]statusandlastModifiedTime), and checksps -o lstart= -p <ls_pid>(LC_ALL=C).status == "CASCADE_RUN_STATUS_IDLE"and either:ls_start_epoch > last_modified_epoch + 5.0(proven OS reboot or Antigravity LS restart since last turn, deduped once perlast_woken_ls_pid/last_woken_ls_start_epoch), ornow - last_modified_epoch >= long_idle_seconds(default2400s stall fallback, bounded by>= 1800s minimum cooldown).quota should-run --scheduler-observation --runtime-profile antigravity_app, re-checks unchangedIDLE+lastModifiedTimeagainst TOCTOU races, reserves cooldown/PID state atomically underexclusive_file_lockbefore invokingSendUserCascadeMessage, and handles RPC failures safely without retry storms.loopx/agy_goal_mode/launchd_watchdog.py):build_antigravity_launchd_plistcreates a deterministic, label-validatedLaunchAgent(RunAtLoad=true,StartInterval>=60, default300s, stdout/stderr logs) executingpython -E -P -m loopx.agy_goal_mode.host_runtime heartbeat-tick, preservingPATH(includingnode, Python, and CLI executable directories alongsideLOOPX_USAGE_PING=0) so cold-bootlaunchdjobs passprobe_node()fromcwd="/".--registry(preserving@host-global),--runtime-root,--state-dir,--log-dir, and--launch-agents-dirpaths via.expanduser().resolve()so LaunchAgents do not depend on a working directory.install_launchddefaults to dry-run preview, supports--no-load, atomic plist writes under--execute, macOSlaunchctl bootout/bootstrap/printverification,--uninstallwithlaunchctl printreadback confirming the job is unloaded/absent (preserving the plist and returning non-zero error status ifbootoutfails or state cannot be verified), and fail-closed non-macOS guards.loopx/agy_goal_mode/__init__.py,loopx/agy_goal_mode/README.md):build_antigravity_launchd_command(surfaced asreboot_watchdog_commandinsideantigravity_app_activation_extras) and documented usage and safety invariants inREADME.md.tests/test_agy_goal_mode_host_runtime.py):RUNNINGskip, healthyswarm_wait/scheduleIDLEsame-LS skip, LS-restart/reboot wake + per-PID dedup + second reboot re-wake,long_idle_secondsstall fallback +1800s minimum cooldown floor,not_admittedquota denial, missinglastModifiedTime, TOCTOUIDLE -> RUNNINGabort,SendUserCascadeMessagefailure cooldown preservation, daemon LS +ps -o lstart=+ live Corequota should-run --scheduler-observationintegration,install-launchdpreview/write/reload/non-darwin guards, alllaunchctluninstall readback paths (already absent, clean bootout, bootout refused while still loaded preserving plist, inconclusive readback preserving plist), relative path resolution +@host-globalpreservation + cold-bootcwd="/"quota &ProgramArgumentsexecution underEnvironmentVariables, and CLI JSON exit codes.Verification (
0a689251de42ca08a22fbff754ceebd2462e0877onorigin/mainddcfca586a03)ruff check loopx/agy_goal_mode/ tests/test_agy_goal_mode_host_runtime.py: all checks passed (0issues).mypy --strict --follow-imports=silent loopx/agy_goal_mode/__init__.py loopx/agy_goal_mode/host_runtime.py loopx/agy_goal_mode/launchd_watchdog.py tests/test_agy_goal_mode_host_runtime.py:Success: no issues found in 4 source files.npm run typecheck:control-plane,scripts/check_rfc_bilingual.py --base origin/main --head HEAD, clean-HOMEexamples/semantic-vocabulary-drift-smoke.py, clean-HOMEexamples/control_plane/control-plane-maintainability-ratchet-smoke.py: all passed (0unreviewed regressions).pytest -n 4 -q tests/test_agy_goal_mode_host_runtime.py tests/test_agy_host_surface.py tests/test_antigravity_activity.py tests/test_antigravity_adapter_contract.py tests/test_antigravity_host_runtime.py tests/test_antigravity_steward_adapter.py tests/architecture/test_top_level_module_budget.py tests/architecture/test_package_kernel_import_ratchet.py tests/canary/test_maintainability_ratchet.py: 259 passed in 103.34s (0failures,0skips;11/11intest_agy_goal_mode_host_runtime.py).loopx check(0errors /0warnings across all5changed files) and Goalcanary premerge --tier standard --from-git-diff --git-diff-base origin/main:gate.status="passed",merge_gate_passed=true,6/6catalog checks,8/8risk-profile smokes,4/4direct checks,1/1boundary check,0failures/manual holds.