|
|
@@ -18,6 +18,18 @@ from ..contracts.models import (
|
|
|
TaskPackage,
|
|
|
ValidationReport,
|
|
|
)
|
|
|
+from .layout import (
|
|
|
+ executor_candidate_path,
|
|
|
+ executor_delivery_path,
|
|
|
+ global_data_delivery_path,
|
|
|
+ plan_json_path,
|
|
|
+ plan_mermaid_path,
|
|
|
+ run_summary_path,
|
|
|
+ stage_candidate_path,
|
|
|
+ stage_validation_report_path,
|
|
|
+ task_package_path,
|
|
|
+ validation_report_path,
|
|
|
+)
|
|
|
|
|
|
|
|
|
class VersionConflictError(RuntimeError):
|
|
|
@@ -91,12 +103,11 @@ def write_once_json(path: Path, payload: Any) -> Path:
|
|
|
|
|
|
|
|
|
def save_global_data_plan(run_dir: Path, plan: GlobalDataPlan) -> tuple[Path, Path]:
|
|
|
- plan_dir = run_dir / "plans"
|
|
|
json_path = write_once_json(
|
|
|
- plan_dir / f"global_data_dag.v{plan.plan_version}.json",
|
|
|
+ plan_json_path(run_dir, plan.plan_version),
|
|
|
plan.model_dump(mode="json"),
|
|
|
)
|
|
|
- mermaid_path = plan_dir / f"global_data_dag.v{plan.plan_version}.mmd"
|
|
|
+ mermaid_path = plan_mermaid_path(run_dir, plan.plan_version)
|
|
|
lines = ["flowchart LR"]
|
|
|
for task in plan.tasks:
|
|
|
label = f"{task.task_id}:{task.objective}".replace('"', "'")
|
|
|
@@ -110,7 +121,7 @@ def save_global_data_plan(run_dir: Path, plan: GlobalDataPlan) -> tuple[Path, Pa
|
|
|
|
|
|
def save_task_package(run_dir: Path, task: TaskPackage) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir / "tasks" / f"{task.task_id}.v{task.plan_version}.json",
|
|
|
+ task_package_path(run_dir, task.task_id, task.plan_version),
|
|
|
task.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -120,11 +131,11 @@ def save_executor_candidate(
|
|
|
candidate: ExecutorCandidate,
|
|
|
) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir
|
|
|
- / "artifacts"
|
|
|
- / candidate.task_id
|
|
|
- / f"v{candidate.plan_version}"
|
|
|
- / "executor_candidate.json",
|
|
|
+ executor_candidate_path(
|
|
|
+ run_dir,
|
|
|
+ candidate.task_id,
|
|
|
+ candidate.plan_version,
|
|
|
+ ),
|
|
|
candidate.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -161,9 +172,11 @@ def executor_delivery_artifact_text(candidate: ExecutorCandidate) -> str:
|
|
|
|
|
|
def save_executor_delivery(run_dir: Path, delivery: ExecutorDelivery) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir
|
|
|
- / "executor_results"
|
|
|
- / f"{delivery.task_id}.v{delivery.plan_version}.json",
|
|
|
+ executor_delivery_path(
|
|
|
+ run_dir,
|
|
|
+ delivery.task_id,
|
|
|
+ delivery.plan_version,
|
|
|
+ ),
|
|
|
delivery.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -173,9 +186,11 @@ def save_validation_report(
|
|
|
report: ValidationReport,
|
|
|
) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir
|
|
|
- / "validation_results"
|
|
|
- / f"{report.task_id}.v{report.plan_version}.json",
|
|
|
+ validation_report_path(
|
|
|
+ run_dir,
|
|
|
+ report.task_id,
|
|
|
+ report.plan_version,
|
|
|
+ ),
|
|
|
report.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -185,9 +200,7 @@ def save_global_data_stage_candidate(
|
|
|
candidate: GlobalDataStageCandidate,
|
|
|
) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir
|
|
|
- / "stage_candidates"
|
|
|
- / f"global_data.v{candidate.plan_version}.json",
|
|
|
+ stage_candidate_path(run_dir, candidate.plan_version),
|
|
|
candidate.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -197,9 +210,7 @@ def save_global_data_stage_validation_report(
|
|
|
report: GlobalDataStageValidationReport,
|
|
|
) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir
|
|
|
- / "stage_validation_results"
|
|
|
- / f"global_data.v{report.plan_version}.json",
|
|
|
+ stage_validation_report_path(run_dir, report.plan_version),
|
|
|
report.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -209,7 +220,7 @@ def save_global_data_stage_delivery(
|
|
|
delivery: GlobalDataStageDelivery,
|
|
|
) -> Path:
|
|
|
return write_once_json(
|
|
|
- run_dir / "global_data_stage_delivery.json",
|
|
|
+ global_data_delivery_path(run_dir),
|
|
|
delivery.model_dump(mode="json"),
|
|
|
)
|
|
|
|
|
|
@@ -228,4 +239,4 @@ def save_run_summary(
|
|
|
*list(state.get("event_log", [])),
|
|
|
*list(update.get("event_log", [])),
|
|
|
]
|
|
|
- return write_once_json(run_dir / "run_summary.json", merged)
|
|
|
+ return write_once_json(run_summary_path(run_dir), merged)
|