refactor(api): remove dead code paths in serve/remote layer

Delete code paths that never executed in the serve/API/remote stack:

- BridgeCancelledError: raised but never caught; replace raises with RuntimeError and drop the class.
- InputBridge.error setter and _error field: written at the handler layer, never read (session.auth_error is the surfaced channel).
- cancel_event param and _check_cancel inner fn on _perform_download: the only caller always passed None (the live job.cancel_event is untouched).
- result_with_progress monkeypatch: its status pings were redundant with the file-polled progress_sink, which is now the sole path.
- session param on _resolve_manifest_data: unused in the body.

Reconcile SessionStore's hardcoded 600s auth-state TTL into a shared AUTH_INPUT_TIMEOUT constant referenced by both the InputBridge input timeout and the store, removing the magic number without changing the longer grace window.

Update input_bridge/session_store tests for the new channels and add an assertion that auth-state entries expire at the single rule.
This commit is contained in:
imSp4rky
2026-06-21 13:07:45 -06:00
parent 40eafce17b
commit 8a9a1e1bdc
8 changed files with 36 additions and 65 deletions
+6 -10
View File
@@ -7,7 +7,7 @@ import time
import pytest
from unshackle.core.api.input_bridge import AuthStatus, BridgeCancelledError, InputBridge
from unshackle.core.api.input_bridge import AuthStatus, InputBridge
pytestmark = pytest.mark.unit
@@ -16,7 +16,6 @@ def test_initial_status_is_authenticating() -> None:
bridge = InputBridge()
assert bridge.status is AuthStatus.AUTHENTICATING
assert bridge.get_pending_prompt() is None
assert bridge.error is None
def test_submit_response_returns_false_when_no_prompt_pending() -> None:
@@ -49,16 +48,15 @@ def test_request_input_blocks_until_submit() -> None:
def test_request_input_times_out() -> None:
bridge = InputBridge()
with pytest.raises(TimeoutError):
with pytest.raises(TimeoutError, match="No client response"):
bridge.request_input("hello", timeout=0.6)
assert bridge.status is AuthStatus.FAILED
assert "timed out" in (bridge.error or "")
def test_cancel_before_request_raises_immediately() -> None:
bridge = InputBridge()
bridge.cancel()
with pytest.raises(BridgeCancelledError):
with pytest.raises(RuntimeError, match="cancelled"):
bridge.request_input("hello", timeout=5)
assert bridge.status is AuthStatus.FAILED
@@ -70,7 +68,7 @@ def test_cancel_unblocks_pending_request() -> None:
def worker() -> None:
try:
bridge.request_input("OTP?", timeout=5)
except BridgeCancelledError as e:
except RuntimeError as e:
exc.append(e)
t = threading.Thread(target=worker)
@@ -82,7 +80,7 @@ def test_cancel_unblocks_pending_request() -> None:
bridge.cancel()
t.join(timeout=2)
assert exc and isinstance(exc[0], BridgeCancelledError)
assert exc and isinstance(exc[0], RuntimeError)
assert bridge.status is AuthStatus.FAILED
@@ -92,9 +90,7 @@ def test_get_pending_prompt_returns_none_outside_pending_state() -> None:
assert bridge.get_pending_prompt() is None
def test_status_and_error_setters() -> None:
def test_status_setter() -> None:
bridge = InputBridge()
bridge.status = AuthStatus.AUTHENTICATED
bridge.error = "boom"
assert bridge.status is AuthStatus.AUTHENTICATED
assert bridge.error == "boom"