sched: route manual runs through durable admission before dispatch (T06)
This commit is contained in:
+34
-13
@@ -31,6 +31,8 @@ from .run_lifecycle import (
|
||||
has_blocking_diagnostics,
|
||||
load_stored_run,
|
||||
mark_resume_blocked,
|
||||
materialize_admitted_view,
|
||||
persist_admission,
|
||||
persist_stopped_run,
|
||||
restore_interrupted_run,
|
||||
validate_pinned_resume_environment,
|
||||
@@ -98,27 +100,46 @@ class WorkflowRunApi:
|
||||
max_steps=limits.max_steps,
|
||||
)
|
||||
|
||||
plan = raw_plan_from_artifact(artifact)
|
||||
run = await self.context.runtime.run_workflow_from_plan(
|
||||
plan,
|
||||
workflow_input,
|
||||
# Durable admission ordering: recheck -> allocate/freeze -> persist
|
||||
# admission -> materialize view -> dispatch captured -> persist
|
||||
# stopped -> reconcile. A failed durable admission never dispatches,
|
||||
# and dispatch never re-resolves the deployment.
|
||||
store = self._run_store()
|
||||
run_id = store.allocate_run_id()
|
||||
environment = create_pinned_environment(
|
||||
deployment=deployment,
|
||||
artifact=artifact,
|
||||
saved_subgraph_tree=tree,
|
||||
tree=tree,
|
||||
)
|
||||
admission = persist_admission(
|
||||
store=store,
|
||||
run_id=run_id,
|
||||
environment=environment,
|
||||
resolved_input=workflow_input,
|
||||
max_steps=limits.max_steps,
|
||||
)
|
||||
materialize_admitted_view(store=store, admission=admission)
|
||||
plan = raw_plan_from_artifact(admission.environment.root_artifact)
|
||||
captured_tree = saved_subgraph_tree_from_snapshots(
|
||||
admission.environment.child_artifacts
|
||||
)
|
||||
run = await self.context.runtime.run_workflow_from_plan(
|
||||
plan,
|
||||
dict(admission.resolved_input),
|
||||
deployment=admission.environment.deployment,
|
||||
artifact=admission.environment.root_artifact,
|
||||
saved_subgraph_tree=captured_tree,
|
||||
limits=limits,
|
||||
)
|
||||
record = persist_stopped_run(
|
||||
store=self._run_store(),
|
||||
environment=create_pinned_environment(
|
||||
deployment=deployment,
|
||||
artifact=artifact,
|
||||
tree=tree,
|
||||
),
|
||||
store=store,
|
||||
environment=admission.environment,
|
||||
run=run,
|
||||
run_id=run_id,
|
||||
)
|
||||
return _run_payload(
|
||||
deployment=deployment,
|
||||
artifact=artifact,
|
||||
deployment=admission.environment.deployment,
|
||||
artifact=admission.environment.root_artifact,
|
||||
status=run.status.value,
|
||||
run_id=record.id,
|
||||
resume_readiness=record.resume_readiness.value,
|
||||
|
||||
Reference in New Issue
Block a user