feat: add hub runtime and extension contract
This commit is contained in:
parent
fce19f193f
commit
7e1ec03f0c
44 changed files with 3875 additions and 84 deletions
72
hub_core/runtime/models.py
Normal file
72
hub_core/runtime/models.py
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
from __future__ import annotations
|
||||
|
||||
from datetime import datetime
|
||||
from typing import Any, Literal
|
||||
from uuid import UUID
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field
|
||||
|
||||
|
||||
class RuntimeModel(BaseModel):
|
||||
model_config = ConfigDict(extra="forbid")
|
||||
|
||||
|
||||
class RegistryRegistration(RuntimeModel):
|
||||
descriptor: dict[str, Any]
|
||||
manifest: dict[str, Any]
|
||||
|
||||
|
||||
class MessageCommand(RuntimeModel):
|
||||
schema_version: str
|
||||
correlation_id: UUID
|
||||
conversation_id: UUID | None = None
|
||||
from_address: str = Field(min_length=1)
|
||||
to_addresses: list[str] = Field(min_length=1)
|
||||
body: str = Field(min_length=1)
|
||||
subject_refs: dict[str, str] = Field(default_factory=dict)
|
||||
|
||||
|
||||
class EventCommand(RuntimeModel):
|
||||
schema_version: str
|
||||
correlation_id: UUID
|
||||
event_type: str = Field(pattern=r"^[a-z][a-z0-9]*(?:[.-][a-z0-9][a-z0-9-]*)+$")
|
||||
occurred_at: datetime
|
||||
subject_refs: dict[str, str] = Field(default_factory=dict)
|
||||
payload: dict[str, Any]
|
||||
|
||||
|
||||
class Provenance(RuntimeModel):
|
||||
source_system: str
|
||||
source_ref: str
|
||||
schema_version: str
|
||||
content_hash: str | None = None
|
||||
indexed_at: datetime
|
||||
|
||||
|
||||
class PortRecord(RuntimeModel):
|
||||
id: str
|
||||
data: dict[str, Any]
|
||||
provenance: Provenance
|
||||
|
||||
|
||||
class PortCollection(RuntimeModel):
|
||||
items: list[PortRecord]
|
||||
next_cursor: str | None = None
|
||||
|
||||
|
||||
class PortAccepted(RuntimeModel):
|
||||
id: str
|
||||
status: Literal["accepted", "duplicate"]
|
||||
correlation_id: UUID
|
||||
|
||||
|
||||
class HealthResponse(RuntimeModel):
|
||||
service: str = "hub-core"
|
||||
status: Literal["ok"] = "ok"
|
||||
version: str
|
||||
|
||||
|
||||
class ReadinessResponse(RuntimeModel):
|
||||
service: str = "hub-core"
|
||||
status: Literal["ok", "degraded"]
|
||||
checks: dict[str, str]
|
||||
Loading…
Add table
Add a link
Reference in a new issue