refactor(src): Phase 10.2 batch 3 - project_manager + orchestrator_pm Result migration

project_manager.py (3 sites):
- get_all_tracks returns list[dict[str, Any]] where each dict now
  has an 'errors' field (list[ErrorInfo]) capturing per-track
  metadata recovery. The 3 SILENT_SWALLOW sites (state.from_dict,
  metadata.json, plan.md) now append to this list instead of
  silently passing.

orchestrator_pm.py (2 sites):
- get_track_history_summary returns Result[str]. The 2 SILENT_SWALLOW
  sites (metadata.json + spec.md reads) append to a scan_errors list
  that's threaded through the Result.

Tests updated to check result.ok and use result.data.
This commit is contained in:
ed
2026-06-17 22:33:57 -04:00
parent a7d8e2adfd
commit 89ce7ad770
3 changed files with 38 additions and 25 deletions
+9 -7
View File
@@ -8,14 +8,16 @@ from src import ai_client
from src import mma_prompts
from src import paths
from src import summarize
from src.result_types import Result, ErrorInfo, ErrorKind
def get_track_history_summary() -> str:
def get_track_history_summary() -> Result[str]:
"""
Scans conductor/archive/ and conductor/tracks/ to build a summary of past work.
[C: tests/test_orchestrator_pm_history.py:TestOrchestratorPMHistory.test_get_track_history_summary, tests/test_orchestrator_pm_history.py:TestOrchestratorPMHistory.test_get_track_history_summary_missing_files]
"""
summary_parts = []
scan_errors: list[ErrorInfo] = []
archive_path = paths.get_archive_dir()
tracks_path = paths.get_tracks_dir()
paths_to_scan = []
@@ -34,8 +36,8 @@ def get_track_history_summary() -> str:
meta = json.load(f)
title = meta.get("title", title)
status = meta.get("status", status)
except (OSError, json.JSONDecodeError, UnicodeDecodeError):
pass
except (OSError, json.JSONDecodeError, UnicodeDecodeError) as e:
scan_errors.append(ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e), source=f"orchestrator_pm.get_track_history_summary[{track_dir.name}].metadata", original=e))
if spec_file.exists():
try:
with open(spec_file, "r", encoding="utf-8") as f:
@@ -46,12 +48,12 @@ def get_track_history_summary() -> str:
else:
# Just take a snippet of the beginning
overview = content[:200] + "..."
except (OSError, UnicodeDecodeError):
pass
except (OSError, UnicodeDecodeError) as e:
scan_errors.append(ErrorInfo(kind=ErrorKind.INTERNAL, message=str(e), source=f"orchestrator_pm.get_track_history_summary[{track_dir.name}].spec", original=e))
summary_parts.append(f"Track: {title}\nStatus: {status}\nOverview: {overview}\n---")
if not summary_parts:
return "No previous tracks found."
return "\n".join(summary_parts)
return Result(data="No previous tracks found.", errors=scan_errors)
return Result(data="\n".join(summary_parts), errors=scan_errors)
def generate_tracks(user_request: str, project_config: dict[str, Any], file_items: list[dict[str, Any]], history_summary: Optional[str] = None) -> list[dict[str, Any]]:
"""