The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(update): an unwritable gateway status never fails a settled commit
Teknium6731134fb144
diff --git a/hermes_cli/update_completion.py b/hermes_cli/update_completion.pyindex 26d4f567a73..e64b8b6bd1c 100644--- a/hermes_cli/update_completion.py+++ b/hermes_cli/update_completion.py@@ -183,6 +183,21 @@ def _record_owed_user_action(request: dict) -> bool:return notice is None+def _publish_gateway_success(request: dict) -> None:+ """The gateway /update watcher's status: the code is committed (same as _complete_selected).++ Guarded like ``update_cmd_fleet._write_gateway_update_exit_code`` (which this stdlib-only+ process cannot import): an unwritable home must not turn the committed run into an error+ before its result is written (review P1). The watcher then falls back to its own timeout.+ """+ if not request.get("gateway_mode"):+ return+ try:+ (Path(request["home"]) / ".update_exit_code").write_text("0", encoding="utf-8")+ except OSError as exc:+ print(f" ⚠ Could not publish the gateway's update status: {exc}")++def _settle_after_commit(request: dict, result_path: Path, step: str, reason: str) -> int:"""The tree already moved, so a failure here is owed work, never a failed update (C3, A6).@@ -210,9 +225,8 @@ def _settle_after_commit(request: dict, result_path: Path, step: str, reason: stupdate_receipt.finalize_pending_update_receipt(0, f"{step} owed after the code was updated")receipt = _read_terminal_receipt(request)code = 0 if receipt is not None and receipt.get("outcome") == "success" else 1- if code == 0 and request["gateway_mode"]:- # The gateway's /update watcher reads this; the code is committed (same as _complete_selected).- (Path(request["home"]) / ".update_exit_code").write_text("0", encoding="utf-8")+ if code == 0:+ _publish_gateway_success(request)return _write_bootstrap_result(request, result_path, code, receipt)diff --git a/tests/hermes_cli/test_update_completion_process.py b/tests/hermes_cli/test_update_completion_process.pyindex a5f7610288a..8f8ed40c176 100644--- a/tests/hermes_cli/test_update_completion_process.py+++ b/tests/hermes_cli/test_update_completion_process.py@@ -280,6 +280,24 @@ def test_missing_child_result_fails_boundary_receipt_and_releases_lock(transitiolock.release()+def test_unwritable_gateway_status_never_fails_a_settled_commit(tmp_path, monkeypatch):+ """Review P1: the bootstrap's gateway status write is best effort, like+ ``_write_gateway_update_exit_code``; the committed run still answers its result with exit 0."""+ from hermes_cli import venv_sync++ monkeypatch.setattr(venv_sync, "arm_completion", lambda root: None)+ receipt = {"update_id": "u1", "outcome": "success", "finished_at": "now"}+ monkeypatch.setattr(update_completion, "_read_terminal_receipt", lambda request: receipt)+ home = tmp_path / "home-is-a-file"+ home.write_text("x", encoding="utf-8")+ result = tmp_path / "result.json"+ request = {"source": str(tmp_path), "receipt": {"update_id": "u1"}, "gateway_mode": True,+ "home": str(home), "pm_receipt": None}+ assert update_completion._settle_after_commit(request, result, "dependencies", "pip failed") == 0+ answer = json.loads(result.read_text(encoding="utf-8"))+ assert answer["exit_code"] == 0 and answer["receipt"] == receipt++@pytest.mark.parametrize("cleanup_failure", [None, "kill", "wait"])def test_interrupt_after_child_success_demotes_gateway_marker_at_boundary(transition, monkeypatch, cleanup_failure):import io