Private
Public Access
0
0

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:
2026-06-20 01:03:15 -04:00
parent b4a6ebc101
commit 3c752eb2ae
2 changed files with 67 additions and 8 deletions
+34 -8
View File
@@ -7299,6 +7299,29 @@ def _dag_cycle_check_result(app: "App") -> Result[bool]:
source="gui_2._dag_cycle_check_result",
original=e,
)])
def _ticket_id_max_int_result(tid: str) -> Result[int]:
"""Drain-aware variant of render_task_dag_panel ticket-ID parsing (L7315 INTERNAL_SILENT_SWALLOW).
Extracts the bare-except int(tid[2:]) parse 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). On failure (T-abc, T-, etc.),
returns Result(data=0, errors=[ErrorInfo]). The legacy loop skips
malformed tickets via the data plane (logging NOT a drain per the
user's principle 2026-06-17). The caller drains to
app._last_request_errors.
[C: src/gui_2.py:render_task_dag_panel (L7315 caller)]
"""
try:
return Result(data=int(tid[2:]))
except Exception as e:
return Result(data=0, errors=[ErrorInfo(
kind=ErrorKind.INTERNAL,
message=f"ticket id parse failed for {tid!r}: {e}",
source="gui_2._ticket_id_max_int_result",
original=e,
)])
ed.end()
# 5. Add Ticket Form
@@ -7306,18 +7329,21 @@ def _dag_cycle_check_result(app: "App") -> Result[bool]:
if imgui.button("Add Ticket"):
app._show_add_ticket_form = not app._show_add_ticket_form
if app._show_add_ticket_form:
# Default Ticket ID
# Default Ticket ID
max_id = 0
for t in app.active_tickets:
tid = t.get('id', '')
if tid.startswith('T-'):
#TODO(Ed): Exception(Review)
try: max_id = max(max_id, int(tid[2:]))
except: pass
app.ui_new_ticket_id = f"T-{max_id + 1:03d}"
app.ui_new_ticket_desc = ""
app.ui_new_ticket_target = ""
app.ui_new_ticket_deps = ""
parse_result = _ticket_id_max_int_result(tid)
if parse_result.ok:
max_id = max(max_id, parse_result.data)
else:
if not hasattr(app, '_last_request_errors'): app._last_request_errors = []
app._last_request_errors.append(("render_task_dag_panel.ticket_id_parse", parse_result.errors[0]))
app.ui_new_ticket_id = f"T-{max_id + 1:03d}"
app.ui_new_ticket_desc = ""
app.ui_new_ticket_target = ""
app.ui_new_ticket_deps = ""
if app._show_add_ticket_form:
imgui.begin_child("add_ticket_form", imgui.ImVec2(-1, 220), True)
imgui.text_colored(C_VAL(), "New Ticket Details")