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:
ed
2026-06-18 10:21:24 -04:00
parent 7aeada953e
commit 4ab7c732b5
20 changed files with 621 additions and 422 deletions
+4 -1
View File
@@ -6,6 +6,8 @@ from dataclasses import dataclass
from pathlib import Path
from typing import List, Dict, Optional, Tuple
from src.result_types import ErrorInfo, ErrorKind, Result
@dataclass
class DiffHunk:
@@ -165,6 +167,7 @@ def apply_patch_to_file(patch_text: str, base_dir: str = ".") -> Tuple[bool, str
results.append(f"Patched: {file_path}")
except (OSError, ValueError, IndexError) as e:
return False, f"Error patching {file_path}: {e}"
_patch_err_result = Result(data=False, errors=[ErrorInfo(kind=ErrorKind.INTERNAL, message=f"Error patching {file_path}: {e}", source="diff_viewer.apply_patch_to_file", original=e)])
return _patch_err_result.data, _patch_err_result.errors[0].message
return True, "\n".join(results)