feat(perception): publish immutable lab session instances
This commit is contained in:
@@ -28,6 +28,35 @@ class LayoutConflictError(SessionStoreError):
|
||||
"""A workspace layout revision changed since the caller loaded it."""
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class LabSessionBinding:
|
||||
"""Immutable provenance for one derived laboratory replay."""
|
||||
|
||||
session_id: str
|
||||
source_session_id: str
|
||||
lab_id: str
|
||||
result_kind: str
|
||||
result_id: str
|
||||
source_result_id: str | None
|
||||
config_sha256: str | None
|
||||
run_created_at_utc: str
|
||||
published_at_utc: str
|
||||
provenance: dict[str, Any]
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
"lab_id": self.lab_id,
|
||||
"source_session_id": self.source_session_id,
|
||||
"result_kind": self.result_kind,
|
||||
"result_id": self.result_id,
|
||||
"source_result_id": self.source_result_id,
|
||||
"config_sha256": self.config_sha256,
|
||||
"run_created_at_utc": self.run_created_at_utc,
|
||||
"published_at_utc": self.published_at_utc,
|
||||
"provenance": self.provenance,
|
||||
}
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
class SessionSource:
|
||||
source_id: str
|
||||
@@ -81,9 +110,10 @@ class SessionSummary:
|
||||
total_bytes: int
|
||||
replayable: bool
|
||||
origin: str
|
||||
lab: LabSessionBinding | None = None
|
||||
|
||||
def as_dict(self) -> dict[str, Any]:
|
||||
return {
|
||||
document: dict[str, Any] = {
|
||||
"schema_version": "missioncore.observation-session-summary/v1",
|
||||
"session_id": self.session_id,
|
||||
"display_name": self.display_name,
|
||||
@@ -97,6 +127,9 @@ class SessionSummary:
|
||||
"replayable": self.replayable,
|
||||
"origin": self.origin,
|
||||
}
|
||||
if self.lab is not None:
|
||||
document["lab"] = self.lab.as_dict()
|
||||
return document
|
||||
|
||||
|
||||
@dataclass(frozen=True, slots=True)
|
||||
|
||||
Reference in New Issue
Block a user