The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): a raising fleet restart in the takeover child is owed, not exit 1
Teknium20ccf65500d4
diff --git a/hermes_cli/update_finish.py b/hermes_cli/update_finish.pyindex acb56066c93..e1aae542c89 100644--- a/hermes_cli/update_finish.py+++ b/hermes_cli/update_finish.py@@ -11,17 +11,19 @@ def finish_update(*, root, assume_yes, gateway_mode, pre_update_snapshot_id,plan, windows_resume, followups=None) -> None:"""Finish the selected checkout; never fetch, switch branches or restore a stash.- Same contract as the current completion (C3): the code is committed, so a failed build or- maintenance step is owed work, never a failed update. ``followups`` carries the steps that- already failed (the product build); while any is owed the install stamp is withheld, the- source-update tail stays pending for the next launch, and the gateway topology is left- alone. An unsafe SQLite runtime is reported by maintenance and vetoes migration only.+ Same contract as the current completion (C3): the code is committed, so a failed build,+ maintenance step or fleet restart/verification is owed work, never a failed update.+ ``followups`` carries the steps that already failed (the product build); while any is owed+ the install stamp is withheld, the source-update tail stays pending for the next launch, and+ the gateway topology is left alone. An unsafe SQLite runtime is reported by maintenance and+ vetoes migration only."""from hermes_cli.update_cmd import (_run_post_update_maintenance,_restart_gateway_fleet_after_update, _verify_fleet_after_update,_write_gateway_update_exit_code, _resume_windows_gateways_and_merge_outcome,)+ from hermes_cli import update_receiptfrom hermes_cli.update_receipt import TAIL_FOLLOWUPS, record_build_stage, record_followupowed = followups if followups is not None else []@@ -53,10 +55,18 @@ def finish_update(*, root, assume_yes, gateway_mode, pre_update_snapshot_id,# committed, so the watcher sees success; owed work is on the receipt.if gateway_mode:_write_gateway_update_exit_code(True)- restarted = _restart_gateway_fleet_after_update(plan, gateway_mode)- _resume_windows_gateways_and_merge_outcome(restarted, windows_resume, gateway_mode)- _verify_fleet_after_update(restarted, _pre_update_plan=plan, _windows_gateway_resume=windows_resume,- update_complete=bool(runtime_safe) and not tail_owed)+ run = update_receipt._current.get()+ update_id = run.data.get("update_id") if run is not None else None+ try:+ restarted = _restart_gateway_fleet_after_update(plan, gateway_mode)+ _resume_windows_gateways_and_merge_outcome(restarted, windows_resume, gateway_mode)+ _verify_fleet_after_update(restarted, _pre_update_plan=plan, _windows_gateway_resume=windows_resume,+ update_complete=bool(runtime_safe) and not tail_owed)+ except (Exception, SystemExit) as exc: # health: allow BLE001 -- the code is committed (C3): the fleet obligation stays armed+ reason = str(exc) or type(exc).__name__+ record_followup("gateway_restart", reason)+ if update_receipt._current.get() is None and update_id: # verification already finalized the run+ update_receipt.amend_terminal_followup(update_id, "gateway_restart", reason)def _restore_plan(data):diff --git a/tests/hermes_cli/test_update_finish.py b/tests/hermes_cli/test_update_finish.pyindex c244330e63e..23fe4eceb5c 100644--- a/tests/hermes_cli/test_update_finish.py+++ b/tests/hermes_cli/test_update_finish.py@@ -203,6 +203,8 @@ def completion(tmp_path, monkeypatch):update._surviving_pre_update_serve_runtimes = lambda plan: []fleet_verify._collect_fleet_snapshot = lambda *args: []def restart(plan, gateway_mode):+ if fault == 'restart':+ raise RuntimeError('systemctl restart timed out')assert isinstance(plan, UpdatePlan)assert isinstance(plan.runtimes[0], RuntimeRecord)assert plan.to_dict() == request['plan'] | {@@ -302,6 +304,25 @@ def test_refused_gateway_resume_after_commit_is_a_followup_not_exit_1(completionassert json.loads(result.read_text())["resume_handled"] is True[email protected]("posix")+def test_raising_fleet_restart_after_commit_is_a_followup_not_exit_1(completion):+ """Review P3 (invariant 3): the takeover child's restart/verify run after the commit point, so+ a raising fleet restart is an owed ``gateway_restart`` follow-up and exit 0, never exit 1 with a+ ``failed`` receipt and a gateway watcher told 1."""+ source, home, request, context, result, run = completion+ request["gateway_mode"] = True+ request["receipt"]["started_at"] = "2026-10-04T12:00:00+00:00"+ context.write_text(json.dumps(request), encoding="utf-8")+ child = run("restart")+ assert child.returncode == 0, child.stdout + child.stderr+ receipt = json.loads((home / "logs/update_receipts/latest.json").read_text())+ assert receipt["update_id"] == request["update_id"]+ assert receipt["outcome"] == "success"+ owed = {row["step"]: row["reason"] for row in receipt["followups"]}+ assert "systemctl restart timed out" in owed.get("gateway_restart", ""), child.stdout + child.stderr+ assert (home / ".update_exit_code").read_text().strip() == "0"++@pytest.mark.platforms("posix")@pytest.mark.parametrize("captured, installed, expected", [(None, None, False),