|
|
@@ -6,8 +6,9 @@ from typing import Any
|
|
|
|
|
|
from agent.orchestration import DecisionAction, OperationStatus, TaskStatus
|
|
|
|
|
|
-from script_build_host.domain.artifacts import ArtifactKind, ArtifactState
|
|
|
+from script_build_host.domain.artifacts import ArtifactKind, ArtifactState, DirectionArtifact
|
|
|
from script_build_host.domain.errors import PhaseTwoBoundaryNotReady, ScriptBuildError
|
|
|
+from script_build_host.domain.goal_coverage import validate_goal_coverage
|
|
|
from script_build_host.domain.phase_two_artifacts import (
|
|
|
CandidatePortfolioArtifactV1,
|
|
|
StructuredScriptArtifactV1,
|
|
|
@@ -205,6 +206,25 @@ class ScriptPhaseTwoBoundaryVerifier:
|
|
|
raise PhaseTwoBoundaryNotReady(
|
|
|
"adopted StructuredScript is not backed by an adopted ACCEPT decision"
|
|
|
)
|
|
|
+ binding = await self._bindings.get_by_build(script_build_id)
|
|
|
+ direction_version_id = binding.active_direction_artifact_version_id
|
|
|
+ if direction_version_id is None:
|
|
|
+ raise PhaseTwoBoundaryNotReady("active Direction is missing")
|
|
|
+ direction_version = await self._artifacts.get_by_id(
|
|
|
+ direction_version_id, script_build_id=script_build_id
|
|
|
+ )
|
|
|
+ if not isinstance(direction_version.artifact, DirectionArtifact):
|
|
|
+ raise PhaseTwoBoundaryNotReady("active Direction has the wrong artifact type")
|
|
|
+ structured = adopted[0].artifact
|
|
|
+ if not isinstance(structured, StructuredScriptArtifactV1):
|
|
|
+ raise PhaseTwoBoundaryNotReady("adopted StructuredScript has the wrong type")
|
|
|
+ if structured.direction_ref != _artifact_uri(direction_version_id):
|
|
|
+ raise PhaseTwoBoundaryNotReady("StructuredScript uses a stale Direction")
|
|
|
+ validate_goal_coverage(
|
|
|
+ direction_goal_ids=tuple(item.goal_id for item in direction_version.artifact.goals),
|
|
|
+ coverage=structured.goal_coverage,
|
|
|
+ adopted_source_refs=structured.source_artifact_refs,
|
|
|
+ )
|
|
|
if any(item.status in _ACTIVE_OPERATIONS for item in ledger.operations.values()):
|
|
|
raise PhaseTwoBoundaryNotReady("active or stopping Operations prevent checkpoint")
|
|
|
|