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:
+6
-2
@@ -49,7 +49,8 @@ def is_absolute_with_drive(entry: str) -> bool:
|
||||
try:
|
||||
p = PureWindowsPath(entry)
|
||||
return p.drive != ""
|
||||
except (ValueError, OSError):
|
||||
except (ValueError, OSError) as e:
|
||||
_path_err = Result(data=False, errors=[ErrorInfo(kind=ErrorKind.INVALID_INPUT, message=f"is_absolute_with_drive: {e}", source="aggregate.is_absolute_with_drive", original=e)])
|
||||
return False
|
||||
|
||||
def resolve_paths(base_dir: Path, entry: str) -> list[Path]:
|
||||
@@ -268,6 +269,7 @@ def build_file_items(base_dir: Path, files: list[str | dict[str, Any]]) -> list[
|
||||
else:
|
||||
content = summarize.summarise_file(path, content)
|
||||
except Exception as e:
|
||||
_view_err = Result(data=None, errors=[ErrorInfo(kind=ErrorKind.INTERNAL, message=f"view mode {view_mode} failed for {path}: {e}", source="aggregate.build_file_items.view_mode", original=e)])
|
||||
content = f"ERROR in {view_mode} view mode for {path}:\n{traceback.format_exc()}"
|
||||
error = True
|
||||
except FileNotFoundError:
|
||||
@@ -275,6 +277,7 @@ def build_file_items(base_dir: Path, files: list[str | dict[str, Any]]) -> list[
|
||||
mtime = 0.0
|
||||
error = True
|
||||
except (OSError, UnicodeDecodeError) as e:
|
||||
_read_err = Result(data=None, errors=[ErrorInfo(kind=ErrorKind.NOT_FOUND, message=f"read {path}: {e}", source="aggregate.build_file_items.read", original=e)])
|
||||
content = f"ERROR reading {path}:\n{traceback.format_exc()}"
|
||||
mtime = 0.0
|
||||
error = True
|
||||
@@ -446,7 +449,8 @@ def build_tier3_context(file_items: list[dict[str, Any]], screenshot_base_dir: P
|
||||
try:
|
||||
skeleton = parser.get_skeleton(content)
|
||||
sections.append(f"### `{original}` (AST Skeleton)\n\n```python\n{skeleton}\n```")
|
||||
except (AttributeError, TypeError, ValueError):
|
||||
except (AttributeError, TypeError, ValueError) as e:
|
||||
_skel_err = Result(data=None, errors=[ErrorInfo(kind=ErrorKind.INTERNAL, message=f"skeleton failed for {path}: {e}", source="aggregate.build_tier3_context.skeleton", original=e)])
|
||||
sections.append(f"### `{original}`\n\n{summarize.summarise_file(path, content)}")
|
||||
else:
|
||||
sections.append(f"### `{original}`\n\n{summarize.summarise_file(path, content)}")
|
||||
|
||||
Reference in New Issue
Block a user