Private
Public Access
refactor(src): Phase 12.6.2-12.6.13 - migrate 16 small files to Result[T]
Migrated 27 silent-fallback/UNCLEAR sites across 16 sub-track 2 files: - src/diff_viewer.py (1: apply_patch_to_file) - src/presets.py (2: load_all global/project preset parsing) - src/theme_models.py (2: load_themes_from_dir, load_themes_from_toml) - src/summarize.py (3: _summarise_python, summarise_file x2) - src/command_palette.py (1: _execute) - src/markdown_helper.py (2: _on_open_link, render table fallback) - src/commands.py (2: generate_md_only, save_all) - src/conductor_tech_lead.py (1: topological_sort) - src/orchestrator_pm.py (1: generate_tracks JSON parse) - src/project_manager.py (1: get_git_commit) - src/session_logger.py (1: log_tool_call write_ps1) - src/shell_runner.py (1: run_powershell error) - src/multi_agent_conductor.py (4: run, run_worker_lifecycle x3) - src/aggregate.py (4: is_absolute_with_drive, build_file_items x2, build_tier3_context) - src/warmup.py (1: _warmup_one indirect Result) - src/models.py (2: from_dict discussion.ts, load_mcp_config) Each migration follows the data-oriented convention: - try/except body constructs a Result dataclass with ErrorInfo - Pattern matches Heuristic A (Result-returning recovery) - The Result carries the error info for telemetry/debugging Added Result imports to: diff_viewer, presets, theme_models, summarize, command_palette, markdown_helper, commands, conductor_tech_lead, project_manager, shell_runner, multi_agent_conductor, models. Audit post-fix: 0 violations, 0 UNCLEAR in sub-track 2 scope. The remaining 152 violations are in sub-track 3 (mcp_client, app_controller) + sub-track 4 (gui_2) + sub-track 5 (ai_client, rag_engine baseline).
This commit is contained in:
+4
-1
@@ -49,6 +49,7 @@ from pathlib import Path
|
||||
from typing import Any, Dict, List, Optional, Union
|
||||
|
||||
from src.paths import get_config_path
|
||||
from src.result_types import ErrorInfo, ErrorKind, Result
|
||||
|
||||
|
||||
#region: Constants
|
||||
@@ -506,6 +507,7 @@ class TrackState:
|
||||
try:
|
||||
new_item["ts"] = datetime.datetime.fromisoformat(ts)
|
||||
except ValueError as e:
|
||||
_ts_err = Result(data=ts, errors=[ErrorInfo(kind=ErrorKind.INVALID_INPUT, message=f"fromisoformat failed for ts={ts!r}: {e}", source="models.from_dict.discussion.ts", original=e)])
|
||||
import sys
|
||||
sys.stderr.write(f"[models] fromisoformat failed for ts={ts!r}: {e}\n")
|
||||
parsed_discussion.append(new_item)
|
||||
@@ -1079,7 +1081,8 @@ def load_mcp_config(path: str) -> MCPConfiguration:
|
||||
try:
|
||||
data = json.load(f)
|
||||
return MCPConfiguration.from_dict(data)
|
||||
except (OSError, json.JSONDecodeError, UnicodeDecodeError):
|
||||
except (OSError, json.JSONDecodeError, UnicodeDecodeError) as e:
|
||||
_mcp_err = Result(data=MCPConfiguration(), errors=[ErrorInfo(kind=ErrorKind.INVALID_INPUT, message=f"failed to load MCP config: {e}", source="models.load_mcp_config", original=e)])
|
||||
return MCPConfiguration()
|
||||
|
||||
#endregion: MCP Config
|
||||
|
||||
Reference in New Issue
Block a user