Source code for cadrumo.entrypoints.diagnostics_run_health_composition
"""Outer composition for diagnostic run-health telemetry."""from__future__importannotationsfromtypingimportoverridefrom..application.auth.certificate_secret_backendimportCertificateSecretBackendFactoryfrom..application.auth.operator_probe_portsimportOperatorProbePortsfrom..application.auth.operator_scope_portsimportOperatorScopePortsfrom..application.diagnostics_run_health_portsimport(DiagnosticAuthProbePort,DiagnosticAuthProbeResult,DiagnosticRunTelemetryPort,)from..application.state_projection_portsimportStateProjectionReadPortsfrom..domain.calculations.registry.authorityimportPinnedAuthorityOperationclass_DiagnosticsAuthProbeAdapter(DiagnosticAuthProbePort):"""Adapt the canonical auth application result to diagnostics-safe facts."""def__init__(self,read_ports:StateProjectionReadPorts,certificate_secret_backend_factory:CertificateSecretBackendFactory,operator_probe_ports:OperatorProbePorts,operator_scope_ports:OperatorScopePorts,operation:PinnedAuthorityOperation,)->None:self._read_ports=read_portsself._certificate_secret_backend_factory=certificate_secret_backend_factoryself._operator_probe_ports=operator_probe_portsself._operator_scope_ports=operator_scope_portsself._operation=operation@overridedefprobe(self)->DiagnosticAuthProbeResult:"""Read auth readiness through the root-composed state projection ports."""from..application.auth.operatorimporttest_operator_authresult=test_operator_auth(certificate_secret_backend_factory=self._certificate_secret_backend_factory,operator_probe_ports=self._operator_probe_ports,operator_scope_ports=self._operator_scope_ports,read_ports=self._read_ports,operation=self._operation,)returnDiagnosticAuthProbeResult(provider=result.provider,configured=result.configured,persisted_session_present=result.persisted_session_present,persisted_session_expired=result.persisted_session_expired,persisted_session_state=result.persisted_session_state,probe_summary=result.probe_summary,)
[docs]defcompose_diagnostics_run_health_port()->DiagnosticRunTelemetryPort:"""Bind the diagnostic read port to encrypted local run telemetry."""from..adapters.persistence.llm.run_telemetryimport(LLMRunTelemetryDiagnosticsAdapter,LLMRunTelemetryRecorder,)returnLLMRunTelemetryDiagnosticsAdapter(LLMRunTelemetryRecorder())
[docs]defcompose_diagnostics_auth_probe_port(*,certificate_secret_backend_factory:CertificateSecretBackendFactory,operator_probe_ports:OperatorProbePorts,operator_scope_ports:OperatorScopePorts,read_ports:StateProjectionReadPorts,operation:PinnedAuthorityOperation,)->DiagnosticAuthProbePort:"""Bind the diagnostics auth probe to the root-composed state projection."""return_DiagnosticsAuthProbeAdapter(read_ports,certificate_secret_backend_factory,operator_probe_ports,operator_scope_ports,operation,)