Datasets:
File size: 3,696 Bytes
8ca7ba0 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | from __future__ import annotations
from datetime import UTC, datetime
from typing import Any, Literal
from pydantic import BaseModel, ConfigDict, Field, model_validator
from packages.core.contracts.scene import RobotStart, SceneBundle
class _StrictModel(BaseModel):
model_config = ConfigDict(extra="forbid", validate_assignment=True)
class RobotInjectionSpec(_StrictModel):
schema_version: Literal["1.0"] = "1.0"
scene_bundle_id: str
scene_bundle_sha256: str = Field(pattern=r"^[0-9a-f]{64}$")
robot_id: str
robot_asset_uri: str
robot_asset_sha256: str = Field(pattern=r"^[0-9a-f]{64}$")
robot_profile_version: str
spawn: RobotStart
injection_layer_uri: str
@classmethod
def for_bundle(
cls,
bundle: SceneBundle,
**values: Any,
) -> RobotInjectionSpec:
if bundle.content_hash is None:
raise ValueError("SceneBundle must be sealed before robot injection")
return cls(
scene_bundle_id=bundle.bundle_id,
scene_bundle_sha256=bundle.content_hash,
spawn=bundle.robot_start,
**values,
)
class IsaacValidationPlan(_StrictModel):
schema_version: Literal["1.0"] = "1.0"
validators: list[
Literal[
"asset",
"layout",
"navigation",
"reachability",
"physics",
"task",
"safety",
]
] = Field(min_length=7)
require_oracle_replay: Literal[True] = True
require_no_op_control: Literal[True] = True
require_random_control: Literal[True] = True
require_goal_false_initially: Literal[True] = True
warm_process_required: bool = True
gpu_lease_required: bool = True
@model_validator(mode="after")
def require_full_gate(self) -> IsaacValidationPlan:
required = {
"asset",
"layout",
"navigation",
"reachability",
"physics",
"task",
"safety",
}
if set(self.validators) != required:
raise ValueError("Isaac validation plan must include every production hard gate")
return self
class IsaacRunManifest(_StrictModel):
schema_version: Literal["1.0"] = "1.0"
run_id: str
scene_bundle_sha256: str = Field(pattern=r"^[0-9a-f]{64}$")
robot_injection_sha256: str = Field(pattern=r"^[0-9a-f]{64}$")
isaac_sim_version: str
isaac_lab_arena_version: str
seed: int
started_at: datetime = Field(default_factory=lambda: datetime.now(UTC))
completed_at: datetime | None = None
validator_reports: dict[str, str] = Field(default_factory=dict)
oracle_replay_uri: str | None = None
negative_control_report_uri: str | None = None
passed: bool = False
failure_reasons: list[str] = Field(default_factory=list)
@model_validator(mode="after")
def validate_release(self) -> IsaacRunManifest:
if self.passed:
required = {
"asset",
"layout",
"navigation",
"reachability",
"physics",
"task",
"safety",
}
if set(self.validator_reports) != required:
raise ValueError("passed Isaac run requires every validator report")
if not self.oracle_replay_uri or not self.negative_control_report_uri:
raise ValueError("passed Isaac run requires replay and negative-control evidence")
if self.completed_at is None or self.failure_reasons:
raise ValueError("passed Isaac run must be complete and failure-free")
return self
|