From dad698d88cc4c6824d18f7ae9b7c64cbbf54643e Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Sun, 6 Sep 2026 14:25:31 +0530 Subject: [PATCH] test(update): pin the refused-receipt shape the stop_reason clause exists for update_contract writes {"outcome": "refused", "stop_reason": } with no exit_code; that is the one production receipt where the stop_reason clause in _receipt_looks_unfinished is load-bearing. The previous negative control used exit_code=1, which the exit_code branch already catches. Docstring reworded: a KeyboardInterrupt never lands on a success receipt (the boundary finalize is a no-op once the inner path finalized). --- hermes_cli/update_cmd_fleet.py | 4 ++-- tests/hermes_cli/test_update_fleet_restart_pending.py | 8 ++++++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/hermes_cli/update_cmd_fleet.py b/hermes_cli/update_cmd_fleet.py index b8ebab13f3..8aa42deeeb 100644 --- a/hermes_cli/update_cmd_fleet.py +++ b/hermes_cli/update_cmd_fleet.py @@ -81,8 +81,8 @@ def _receipt_looks_unfinished(receipt: dict) -> bool: """True when *receipt* is from an update that did not finish cleanly. ``stop_reason`` records *how* the command boundary closed the receipt - (``completed at command boundary``, ``sys.exit(0)``, even KeyboardInterrupt - on an otherwise successful run). A truthy stop_reason must not make a + (``completed at command boundary``, ``sys.exit(0)``, or a refusal code from + ``update_contract``). A truthy stop_reason must not make a successful receipt look unfinished, or the next ``hermes update`` retriggers ``fleet_restart_pending`` from pre-pull plan SHAs. """ diff --git a/tests/hermes_cli/test_update_fleet_restart_pending.py b/tests/hermes_cli/test_update_fleet_restart_pending.py index ccde52ffc7..321fa25bf8 100644 --- a/tests/hermes_cli/test_update_fleet_restart_pending.py +++ b/tests/hermes_cli/test_update_fleet_restart_pending.py @@ -312,6 +312,14 @@ def test_successful_non_boundary_stop_reasons_are_finished(receipt): assert update_cmd._receipt_looks_unfinished(receipt) is False +def test_refused_receipt_with_only_a_stop_reason_is_unfinished(): + # update_contract writes {"outcome": "refused", "stop_reason": } with no exit_code; + # the stop_reason clause is what keeps that receipt unfinished. + assert update_cmd._receipt_looks_unfinished( + {"outcome": "refused", "stop_reason": "not_updatable_in_place"} + ) is True + + def test_failed_interrupt_stop_reason_is_unfinished(): assert update_cmd._receipt_looks_unfinished( {