cadrumo.application.preflight module

Workstation preflight health probes for aeat config check.

This module is the read-only doctor surface for the health dimensions that sit beside the external-dependency probes in application.provisioning: per-auth-provider certificate / Cl@ve Móvil configuration health, secure-storage and bundled-corpus reachability, key configuration sanity, and portal-registry assembly health. Each probe answers one health question and returns a typed PreflightCheck — it never raises; a broken dimension is report data (an error severity row with typed facts and a precondition verdict), not an exception path, so the doctor reports status rather than crashing on a red row.

The certificate / Cl@ve Móvil rows reuse probe_provider_configuration() (the pure-local per-provider probe that opens the .p12 and classifies expiry via evaluate_loaded_certificate_health(), or classifies the configured DNI/NIE). aeat config check renders these rows through CheckPreflightPayload beside the capability posture and dependency probes.

class HealthSeverity(*values)[source]

Bases: StrEnum

Closed severity catalogue for a PreflightCheck row.

OK — the dimension is healthy (or a not-configured optional provider, which is not a fault). WARN — a non-blocking advisory (a certificate inside its pre-expiry window; no master-key passphrase configured). ERROR — a real breakage the operator must fix (an expired / corrupt certificate, an unreachable storage root, a missing bundled corpus, a dangling registry reference).

OK
WARN
ERROR
class PreflightCondition(*values)[source]

Bases: StrEnum

Closed failed-condition identities for workstation health probes.

AUTH_PROVIDER_HEALTHY
STORAGE_ROOT_WRITABLE
CORPUS_PRESENT
WINDOWS_PATH_FITS
PORTAL_REGISTRY_HEALTHY
class PreflightCheck(**data)[source]

Bases: BaseModel

One typed workstation-preflight health row.

check is the stable row id shown by aeat config check (e.g. auth-provider:certificate, storage:local-root, corpus:normatives). healthy is the boolean verdict and severity grades it. facts carries only locale-neutral observations. An unhealthy row owns one typed precondition verdict; a healthy row owns none.

Parameters:

data (Any)

check: str
healthy: bool
severity: HealthSeverity
facts: dict[str, str | int | bool]
precondition_verdict: PreconditionVerdict | None
grade_provider_probe_result(provider, result)[source]

Grade one ProviderProbeResult value into a doctor verdict.

The four declared bands partition ProviderProbeResult: a real misconfiguration is ERROR, a pre-expiry certificate is WARN, and a sound or not-configured-optional provider is OK.

A value in none of them is graded ERROR rather than passed. It reports a defect in this mapping — most likely a probe result added without a band — and not a verdict about the operator’s workstation; a doctor that renders an ungraded state green gives the one answer an operator cannot act on.

Parameters:
Return type:

tuple[HealthSeverity, bool]

Returns:

The severity and the healthy verdict.

probe_auth_providers(*, operator_probe_ports, settings=None)[source]

Probe each auth provider’s local certificate / Cl@ve Móvil configuration.

Runs the pure-local per-provider probe for every AuthProviderKind (no network, no active-profile session) and maps its typed ProviderProbeResult onto a PreflightCheck. A not-configured optional provider is OK (not a fault); an expired / corrupt / unreadable certificate or an invalid Cl@ve identity is ERROR; a certificate inside its pre-expiry window is WARN. A result belonging to none of the four declared bands is itself reported ERROR, because an ungraded state rendered green is the one doctor answer an operator cannot act on. The probe never raises.

Return type:

tuple[PreflightCheck, ...]

Parameters:
probe_storage_corpus_env(*, object_path_suffix_length, settings=None)[source]

Probe secure-storage reachability, bundled-corpus presence, and config sanity.

Returns one PreflightCheck per dimension: the local secure-storage root is writable (an existing ancestor accepts writes), the bundled legal-normatives and Manual-práctico corpora are present, and the deployment Settings loaded with a coherent master-key posture. Each probe is a read-only filesystem / configuration inspection — it never writes into the operator’s storage root and never raises.

Return type:

tuple[PreflightCheck, ...]

Parameters:
  • object_path_suffix_length (int)

  • settings (Settings | None)

probe_portal_registry_health()[source]

Report portal-registry assembly health.

Read-only and offline: this probe never contacts AEAT. It confirms the bundled PORTAL_REGISTRY assembled (a PortalIntegrityError at import is caught and reported as an error row). It performs no network access and makes no claim about live portal availability or drift.

Return type:

PreflightCheck

Returns:

One PreflightCheck row with id portal-registry:health.

run_preflight_checks(*, object_path_suffix_length, operator_probe_ports, settings=None)[source]

Run every workstation-preflight probe and return the typed PreflightCheck rows.

Concatenates the per-auth-provider certificate / Cl@ve Móvil health rows, the secure-storage / bundled-corpus / configuration rows, and the portal-registry health / recorded-drift row. Every probe catches its own failures and reports them as error rows, so the aggregate never raises. The portal-drift row runs with the offline default (no recorded drift), reporting registered state rather than a live probe.

Return type:

tuple[PreflightCheck, ...]

Parameters: