TIER-2 READ conductor/code_styleguides/error_handling.md end-to-end before Phase 10: refactor(gui_2): migrate L7315 render_task_dag_panel ticket_id_parse to Result[T] (Phase 10 site 13)

Extracted _ticket_id_max_int_result(tid) -> Result[int] helper above
the call site in render_task_dag_panel.
ANTI-SLIMING: full Result[T] propagation (NO bare-except+pass). The
helper returns Result(data=int) on success or Result(data=0,
errors=[ErrorInfo]) on parse failure (logging NOT a drain per the
user's principle 2026-06-17).

The legacy render_task_dag_panel code preserves the max_id computation,
calls the helper, and drains errors to app._last_request_errors.

Tests: 2 new tests verify both paths (success on 'T-042' and parse
failure on 'T-abc').

Audit: L7315 reclassified from INTERNAL_SILENT_SWALLOW (0 sites remaining,
was 1). New helper L7315 is INTERNAL_COMPLIANT.
This commit is contained in:
ed
2026-06-20 01:03:15 -04:00
parent b4a6ebc101
commit 3c752eb2ae
2 changed files with 67 additions and 8 deletions
+33
View File
@@ -2267,4 +2267,37 @@ def test_phase_10_l7271_dag_cycle_check_result_failure():
assert "dag engine failure" in err.message
def test_phase_10_l7315_ticket_id_max_int_result_success():
"""
L7315 _ticket_id_max_int_result returns Result(data=int) on success.
The helper extracts the int(tid[2:]) parsing from the ticket-ID loop
in render_task_dag_panel into a Result-returning helper. On success
(valid T-XXX id), returns Result(data=int). The legacy loop continues
with the maximum value.
"""
import src.gui_2 as gui2_mod
result = gui2_mod._ticket_id_max_int_result("T-042")
assert result.ok, f"Expected ok=True on success, got errors: {result.errors}"
assert result.data == 42
def test_phase_10_l7315_ticket_id_max_int_result_failure():
"""
L7315 _ticket_id_max_int_result returns Result(data=0, errors=[ErrorInfo]) on failure.
When tid[2:] is not parseable as int (e.g., "T-abc", "T-"), the helper
converts to ErrorInfo. The legacy loop skips this ticket and continues
with the current max. The caller drains to app._last_request_errors.
"""
import src.gui_2 as gui2_mod
result = gui2_mod._ticket_id_max_int_result("T-abc")
assert not result.ok, f"Expected ok=False on failure, got data: {result.data}"
assert result.data == 0
assert result.errors, "Expected at least one error on failure"
err = result.errors[0]
assert err.source == "gui_2._ticket_id_max_int_result"
assert "invalid literal" in err.message or "T-abc" in err.message