TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L6908 render_tier_stream_panel scroll_sync to Result[T] (Phase 10 site 11)

Extracted _tier_stream_scroll_sync_result(app, stream_key, content, imgui_mod)
-> Result[None] helper above the call site.
ANTI-SLIMING: full Result[T] propagation (NO narrowing+pass). The helper
returns Result(data=None) on success or Result(data=None, errors=[ErrorInfo])
on exception (logging NOT a drain per the user's principle 2026-06-17).

The legacy render_tier_stream_panel code preserves the imgui.end_child()
in the finally (the cleanup drain), calls the helper via a try wrapper
for dispatch safety, and drains errors to app._last_request_errors.

Tests: 2 new tests verify both paths (success and AttributeError).

Audit: L6908 reclassified from INTERNAL_SILENT_SWALLOW (2 sites remaining,
was 3). New helper L6908 is INTERNAL_COMPLIANT.
This commit is contained in:
ed
2026-06-20 01:00:31 -04:00
parent 602c1b48e7
commit e2d2105b16
2 changed files with 79 additions and 5 deletions
+44
View File
@@ -2158,4 +2158,48 @@ def test_phase_10_l4911_on_warmup_complete_callback_result_failure():
assert "status dict corrupted" in err.message
def test_phase_10_l6908_tier_stream_scroll_sync_result_success():
"""
L6908 _tier_stream_scroll_sync_result returns Result(data=None) on success.
The helper extracts the imgui.set_scroll_here_y + _tier_stream_last_len
update try/except from render_tier_stream_panel into a Result-returning
helper. On success, returns Result(data=None). The caller continues
the render loop normally.
"""
from unittest.mock import MagicMock
import src.gui_2 as gui2_mod
app = MagicMock()
len_map = MagicMock()
len_map.get.return_value = 0
app._tier_stream_last_len = len_map
mock_imgui = MagicMock()
result = gui2_mod._tier_stream_scroll_sync_result(app, "stream_key", "content here", mock_imgui)
assert result.ok, f"Expected ok=True on success, got errors: {result.errors}"
assert result.data is None
def test_phase_10_l6908_tier_stream_scroll_sync_result_failure():
"""
L6908 _tier_stream_scroll_sync_result returns Result(data=None, errors=[ErrorInfo]) on failure.
When the comparison or imgui.set_scroll_here_y raises (TypeError on
bad content, AttributeError on missing key), the helper converts to
ErrorInfo. The caller drains to app._last_request_errors.
"""
from unittest.mock import MagicMock
import src.gui_2 as gui2_mod
app = MagicMock()
bad_app = MagicMock()
bad_app._tier_stream_last_len.get.side_effect = AttributeError("missing key")
mock_imgui = MagicMock()
result = gui2_mod._tier_stream_scroll_sync_result(bad_app, "stream_key", "content", mock_imgui)
assert not result.ok, f"Expected ok=False on failure, got data: {result.data}"
assert result.data is None
assert result.errors, "Expected at least one error on failure"
err = result.errors[0]
assert err.source == "gui_2._tier_stream_scroll_sync_result"
assert "missing key" in err.message