sched: add durable admission record and admitted run view (T05)
This commit is contained in:
@@ -25,8 +25,13 @@ def ensure_run_id(run_id: str) -> str:
|
||||
|
||||
|
||||
class StoredRunStatus(StrEnum):
|
||||
"""Stopped runtime statuses supported by durable run persistence."""
|
||||
"""Durable run statuses including pre-dispatch admission.
|
||||
|
||||
``ADMITTED`` marks a durably admitted run with no stopped checkpoint yet.
|
||||
Never fabricate a checkpoint, trace, output, or step count for such runs.
|
||||
"""
|
||||
|
||||
ADMITTED = "admitted"
|
||||
INTERRUPTED = "interrupted"
|
||||
COMPLETED = "completed"
|
||||
FAILED = "failed"
|
||||
@@ -67,12 +72,35 @@ class WorkflowRunRecord(BaseModel):
|
||||
status: StoredRunStatus
|
||||
resume_readiness: ResumeReadiness
|
||||
environment: PinnedRunEnvironment
|
||||
latest_checkpoint_id: str = Field(pattern=RUN_ID_PATTERN)
|
||||
latest_checkpoint_id: str | None = Field(default=None, pattern=RUN_ID_PATTERN)
|
||||
diagnostics: list[DependencyDiagnostic] = Field(default_factory=list)
|
||||
created_at: datetime
|
||||
updated_at: datetime
|
||||
|
||||
|
||||
class RunAdmission(BaseModel):
|
||||
"""Authoritative admission record persisted before dispatch.
|
||||
|
||||
The admission freezes the invocation (pinned environment, resolved input,
|
||||
limits, deployment/schedule revisions, resolved UTC instant) under a
|
||||
preassigned run identity. It is the recovery authority for partial
|
||||
multi-file writes: the run view (``WorkflowRunRecord``) is materialized
|
||||
from this same identity, and dispatch uses only the captured invocation.
|
||||
"""
|
||||
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
id: str = Field(pattern=RUN_ID_PATTERN)
|
||||
environment: PinnedRunEnvironment
|
||||
resolved_input: dict[str, Any]
|
||||
max_steps: int | None = None
|
||||
scheduled_at: datetime | None = None
|
||||
schedule_id: str | None = None
|
||||
schedule_revision: int | None = None
|
||||
deployment_revision: int | None = None
|
||||
created_at: datetime
|
||||
|
||||
|
||||
class VersionedCheckpointState(BaseModel):
|
||||
"""Lenient read envelope for stopped-run checkpoints.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user