From 1d1e3ca9f9e0a7eac8d865de93e3f0c7271067c6 Mon Sep 17 00:00:00 2001 From: Ed_ Date: Wed, 17 Jun 2026 22:39:18 -0400 Subject: [PATCH] refactor(src): Phase 10.2 batch 5 - log_registry + models + multi_agent_conductor + theme_2 For these 4 sites, the Result migration cascades badly (the function returns a non-Result type that's used in many places). Per the audit's heuristic #19 (catch + log = INTERNAL_COMPLIANT), we convert the SILENT_SWALLOW to narrow-catch + sys.stderr.write. This satisfies the no-silent-recovery principle while keeping the public API stable. log_registry.py:249 (2 sites - inner + outer try/except for OSError on session path scan and comms.log read) models.py:508 (datetime.fromisoformat ValueError; field stays as string on parse failure; logs the parse error to stderr) multi_agent_conductor.py:317 (PersonaManager.load_all fallback for ticket.persona_id lookup; logs the failure to stderr) theme_2.py:282 (markdown_helper.get_renderer().clear_cache; logs the import/attribute error to stderr) Tests verified: - tests/test_log_registry.py (5 tests) PASS - tests/test_logging_e2e.py (1 test) PASS - tests/test_auto_whitelist.py (4 tests) PASS - tests/test_orchestration_logic.py (8 tests) PASS - tests/test_mma_tier_usage_reset_fix.py (4 tests) PASS --- src/log_registry.py | 10 ++++++---- src/models.py | 5 +++-- src/multi_agent_conductor.py | 5 +++-- src/theme_2.py | 5 +++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/log_registry.py b/src/log_registry.py index 2bf5344b..5ee346fe 100644 --- a/src/log_registry.py +++ b/src/log_registry.py @@ -244,10 +244,12 @@ class LogRegistry: for kw in keywords_to_check: if kw in line and kw not in found_keywords: found_keywords.append(kw) - except OSError: - pass - except OSError: - pass + except OSError as e: + import sys + sys.stderr.write(f"[LogRegistry] read comms.log entry failed: {e}\n") + except OSError as e: + import sys + sys.stderr.write(f"[LogRegistry] scan session_path failed: {e}\n") size_kb = total_size_bytes / 1024 whitelisted = False reason = "" diff --git a/src/models.py b/src/models.py index 06c4998f..e4b896a7 100644 --- a/src/models.py +++ b/src/models.py @@ -505,8 +505,9 @@ class TrackState: if isinstance(ts, str): try: new_item["ts"] = datetime.datetime.fromisoformat(ts) - except ValueError: - pass + except ValueError as e: + import sys + sys.stderr.write(f"[models] fromisoformat failed for ts={ts!r}: {e}\n") parsed_discussion.append(new_item) else: parsed_discussion.append(item) diff --git a/src/multi_agent_conductor.py b/src/multi_agent_conductor.py index 9d0c3a24..05f93425 100644 --- a/src/multi_agent_conductor.py +++ b/src/multi_agent_conductor.py @@ -314,8 +314,9 @@ class ConductorEngine: persona = personas[ticket.persona_id] if persona.preferred_models: models_list = persona.preferred_models - except (OSError, KeyError, AttributeError, TypeError): - pass # Fall back to default list + except (OSError, KeyError, AttributeError, TypeError) as e: + import sys + sys.stderr.write(f"[ConductorEngine] persona load fallback (ticket={ticket.id}): {e}\n") model_idx = min(ticket.retry_count, len(models_list) - 1) model_name = models_list[model_idx] diff --git a/src/theme_2.py b/src/theme_2.py index fa05dd3b..ac398ed2 100644 --- a/src/theme_2.py +++ b/src/theme_2.py @@ -279,8 +279,9 @@ def apply(palette_name: str) -> None: try: import src.markdown_helper src.markdown_helper.get_renderer().clear_cache() - except (ImportError, AttributeError): - pass + except (ImportError, AttributeError) as e: + import sys + sys.stderr.write(f"[theme_2] markdown_helper cache clear failed: {e}\n") def apply_current() -> None: """Apply the loaded palette and scale."""