refactor(sdm): Global pass with refined 'External Only' SDM tags. Pruned redundant internal references and fixed indentation logic in injector. Verified full project compilation.

This commit is contained in:
2026-05-09 14:32:44 -04:00
parent 696c08692e
commit 8c06c1767b
142 changed files with 2352 additions and 990 deletions
+52 -14
View File
@@ -9,20 +9,29 @@ import re
from src import paths
def read_plan(track_id: str, base_dir: str = ".") -> str:
"""Reads the implementation plan (plan.md) for a track."""
"""
Reads the implementation plan (plan.md) for a track.
[C: tests/test_native_orchestrator.py:test_read_plan_nonexistent, tests/test_native_orchestrator.py:test_write_and_read_plan]
"""
plan_path = paths.get_track_state_dir(track_id, base_dir) / "plan.md"
if not plan_path.exists():
return ""
return plan_path.read_text(encoding="utf-8")
def write_plan(track_id: str, content: str, base_dir: str = ".") -> None:
"""Writes the implementation plan (plan.md) for a track."""
"""
Writes the implementation plan (plan.md) for a track.
[C: tests/test_native_orchestrator.py:test_write_and_read_plan]
"""
plan_path = paths.get_track_state_dir(track_id, base_dir) / "plan.md"
plan_path.parent.mkdir(parents=True, exist_ok=True)
plan_path.write_text(content, encoding="utf-8")
def parse_plan_tasks(content: str) -> list[dict[str, str]]:
"""Parses the tasks from a plan.md file."""
"""
Parses the tasks from a plan.md file.
[C: tests/test_native_orchestrator.py:test_parse_plan_tasks]
"""
tasks = []
for line in content.split("\n"):
stripped = line.strip()
@@ -33,24 +42,36 @@ def parse_plan_tasks(content: str) -> list[dict[str, str]]:
return tasks
def read_metadata(track_id: str, base_dir: str = ".") -> dict:
"""Reads the metadata (metadata.json) for a track."""
"""
Reads the metadata (metadata.json) for a track.
[C: tests/test_native_orchestrator.py:test_read_metadata_nonexistent, tests/test_native_orchestrator.py:test_write_and_read_metadata]
"""
meta_path = paths.get_track_state_dir(track_id, base_dir) / "metadata.json"
if not meta_path.exists():
return {}
return json.loads(meta_path.read_text(encoding="utf-8"))
def write_metadata(track_id: str, data: dict, base_dir: str = ".") -> None:
"""Writes the metadata (metadata.json) for a track."""
"""
Writes the metadata (metadata.json) for a track.
[C: tests/test_native_orchestrator.py:test_write_and_read_metadata]
"""
meta_path = paths.get_track_state_dir(track_id, base_dir) / "metadata.json"
meta_path.parent.mkdir(parents=True, exist_ok=True)
meta_path.write_text(json.dumps(data, indent=2), encoding="utf-8")
def get_track_dir(track_id: str, base_dir: str = ".") -> Path:
"""Returns the state directory for a specific track."""
"""
Returns the state directory for a specific track.
[C: tests/test_native_orchestrator.py:test_get_track_dir]
"""
return paths.get_track_state_dir(track_id, base_dir)
def get_archive_dir(base_dir: str = ".") -> Path:
"""Returns the central archive directory for completed tracks."""
"""
Returns the central archive directory for completed tracks.
[C: src/orchestrator_pm.py:get_track_history_summary, tests/test_native_orchestrator.py:test_get_archive_dir, tests/test_paths.py:test_conductor_dir_project_relative]
"""
return paths.get_archive_dir(base_dir)
class NativeOrchestrator:
@@ -59,28 +80,46 @@ class NativeOrchestrator:
self._conductor = None
def load_track(self, track_id: str) -> dict:
"""Load track from metadata.json"""
"""
Load track from metadata.json
[C: tests/test_native_orchestrator.py:test_native_orchestrator_class]
"""
return read_metadata(track_id, str(self.base_dir))
def save_track(self, track_id: str, data: dict) -> None:
"""Persist track metadata"""
"""
Persist track metadata
[C: tests/test_native_orchestrator.py:test_native_orchestrator_class]
"""
write_metadata(track_id, data, str(self.base_dir))
def load_plan(self, track_id: str) -> str:
"""Load plan.md content"""
"""
Load plan.md content
[C: tests/test_native_orchestrator.py:test_native_orchestrator_class]
"""
return read_plan(track_id, str(self.base_dir))
def save_plan(self, track_id: str, content: str) -> None:
"""Persist plan.md content"""
"""
Persist plan.md content
[C: tests/test_native_orchestrator.py:test_native_orchestrator_class]
"""
write_plan(track_id, content, str(self.base_dir))
def get_track_tasks(self, track_id: str) -> list[dict]:
"""Get parsed task list from plan.md"""
"""
Get parsed task list from plan.md
[C: tests/test_native_orchestrator.py:test_native_orchestrator_class]
"""
content = self.load_plan(track_id)
return parse_plan_tasks(content)
def generate_tickets(self, brief: str, module_skeletons: str = "") -> list[dict]:
"""Tier 2: Generate tickets from brief"""
"""
Tier 2: Generate tickets from brief
[C: tests/test_conductor_tech_lead.py:TestConductorTechLead.test_generate_tickets_retry_failure, tests/test_conductor_tech_lead.py:TestConductorTechLead.test_generate_tickets_retry_success, tests/test_conductor_tech_lead.py:TestConductorTechLead.test_generate_tickets_success, tests/test_orchestration_logic.py:test_generate_tickets]
"""
from src import conductor_tech_lead
return conductor_tech_lead.generate_tickets(brief, module_skeletons)
@@ -98,4 +137,3 @@ class NativeOrchestrator:
"""Tier 4: Generate patch for error"""
from src import ai_client
return ai_client.run_tier4_patch_generation(error, file_context)