Source code for cadrumo.application.diagnostics_run_health_ports
"""Application-owned contract for local diagnostic run telemetry.The run-health use cases aggregate timing and outcome facts, but they do notchoose where those facts are stored. ``DiagnosticRunTelemetryPort`` keeps theapplication independent of the outbound LLM recorder while``DiagnosticRunRecord`` gives every diagnostic projection one validated shape.The outbound adapter translates its storage record and failures at thecomposition boundary."""from__future__importannotationsfromdatetimeimportdatefromtypingimportProtocolfrompydanticimportBaseModel,Field,NonNegativeIntfrom..core.errors.hierarchyimportCadrumoErrorfrom..core.modelsimportSTRICT_FROZEN_CONFIGfrom..core.time.utcimportUtcInstant
[docs]classDiagnosticRunRecord(BaseModel):"""One timing/outcome fact supplied to the diagnostic run-health service."""model_config=STRICT_FROZEN_CONFIGrun_id:str=Field(min_length=1)caller:str=Field(min_length=1)provider:str=Field(min_length=1)model:str=""duration_ms:NonNegativeIntsucceeded:boolerror_kind:str=""started_at:UtcInstant
[docs]classDiagnosticRunTelemetryError(CadrumoError):"""A diagnostic telemetry read failed at the outbound boundary."""
[docs]classDiagnosticAuthProbeResult(BaseModel):"""Safe auth-readiness facts needed by the run-health projection."""model_config=STRICT_FROZEN_CONFIGprovider:str=""configured:bool=Falsepersisted_session_present:bool=Falsepersisted_session_expired:bool|None=Nonepersisted_session_state:str=""probe_summary:str=""
[docs]classDiagnosticAuthProbePort(Protocol):"""Read-only auth probe required by the diagnostic run-health service."""
[docs]defprobe(self)->DiagnosticAuthProbeResult:"""Return the redacted local auth-readiness facts for diagnostics."""...
[docs]classDiagnosticRunTelemetryPort(Protocol):"""Read-only local run telemetry required by diagnostic projections."""
[docs]defload_records(self,*,since:date|None,until:date|None,)->tuple[DiagnosticRunRecord,...]:"""Return validated run facts within the inclusive date window."""...