fix(k1): allow explicit reset after terminal start fault

This commit is contained in:
DCCONSTRUCTIONS
2026-08-14 21:01:52 +03:00
parent 72a2f37c03
commit 986ea69610
2 changed files with 86 additions and 0 deletions
@@ -8477,6 +8477,7 @@ class XgridsK1CompatibilityService:
acquisition_id=(
acquisition.acquisition_id if acquisition is not None else None
),
allow_terminal_failure_retirement=True,
)
)
self._supersede_control_bootstrap_continuation()
@@ -27415,6 +27416,7 @@ class XgridsK1CompatibilityService:
self,
*,
acquisition_id: str | None,
allow_terminal_failure_retirement: bool = False,
) -> tuple[_LocalStopRetirementDisposition, str | None]:
"""Cancel the local worker under the exact publish fence.
@@ -27450,6 +27452,24 @@ class XgridsK1CompatibilityService:
)
self._application_control_session.close()
retired_control = dict(self._application_control_session.snapshot())
if (
allow_terminal_failure_retirement
and retired_control.get("state") == "failed"
):
# ``can_open`` deliberately remains false after an ambiguous
# START/STOP failure even when the socket worker has already
# exited. That is the correct admission policy for an
# ordinary retry, but an explicit scenario reset is a
# different operation: retire only the dead local owner while
# the durable physical ledger below preserves the ambiguous
# device outcome. ``retire_for_network_change`` still checks
# that the thread and transport are actually gone, so a live
# publisher cannot be detached by this path.
with suppress(AttributeError, RuntimeError):
self._retire_application_control_for_network_change(
allow_terminal_failure=True,
)
retired_control = dict(self._application_control_session.snapshot())
if (
retired_control.get("state")
not in {"idle", "completed", "closed", "failed"}