aeat.application.diagnostics module¶
Application-owned diagnostics, version reports, and repair probes.
build_cli_version_report() and render_cli_version_text() back the
root aeat --version surface. They keep the fast path import-light unless the
caller requests registry detail.
build_config_repair_report() composes environment checks,
WorkflowState loading,
ActiveProfileHealth profile storage
verdicts, WizardStatusReport
readiness, registry summaries, and secure-object decryptability into a
ConfigRepairReport of DiagnosticCheck rows. The full registry
integrity probe is intentionally opt-in through RegistryIntegrityReport;
it loads the registry authority only for repair commands that ask for that
validation.
Every warn/fail DiagnosticCheck is actionable by construction: it must
carry either next_action or dead_end and the validator raises
DiagnosticModelError if a row is silent or
ambiguous. Renderers and CLI payloads can therefore treat the repair report as a
typed contract, not a best-effort text scan.
Secure-object repair helpers return SecureObjectIntegrityReport
instances shared with application.repair_integrity. Dry-run preview
and quarantine use the same decryptability probe so the committed mutation has
the same namespace counts the operator saw before confirming it. Registry
validation routes through
ValidatedRegistryAuthority and the
core Modelo identifier enum only on the explicit
repair-integrity path.
See also
application.repair_integrity owns metadata-only repair
decisions and active-bucket repair sessions.
application.workflow._profile_health supplies the redacted
active-profile health verdict when secure workflow state is readable or
degraded.
application.wizard._status supplies semantic profile/auth
readiness once the workflow state has loaded.
entrypoints.cli._config._repair_cli wires these reports into
aeat config repair commands.
- class RegistryVersionSummary(**data)[source]¶
Bases:
BaseModelStable registry summary suitable for version and repair surfaces.
Built from
ValidatedRegistryAuthoritywhen registry detail is requested, then embedded in bothCliVersionReportandConfigRepairReport.- Parameters:
- available: bool¶
- registry_root: str¶
- modelo_count: int¶
- revision_count: int¶
- casilla_count: int¶
- formula_count: int¶
- revision_ids: tuple[str, ...]¶
- error: str | None¶
- class CliVersionReport(**data)[source]¶
Bases:
BaseModelVersion payload rendered by root CLI version surfaces.
build_cli_version_report()fills theRegistryVersionSummaryfield, andrender_cli_version_text()renders the text form used by the rootaeat --versioncommand.- Parameters:
package_name (str)
package_version (str)
registry (RegistryVersionSummary)
- package_name: str¶
- package_version: str¶
- registry: RegistryVersionSummary¶
- DiagnosticAudience¶
Who can act on a check.
operatorrows describe a state the taxpayer can themselves resolve (an incomplete profile, a missing certificate).internalrows describe an application-side defect the taxpayer cannot fix (a registry-integrity regression). The renderer words the two distinctly so a taxpayer is never alarmed into thinking an internal bug is a field they forgot to fill in.alias of
Literal[‘operator’, ‘internal’]
- class DiagnosticFinding(**data)[source]¶
Bases:
BaseModelOne concrete, named sub-finding inside a
DiagnosticCheck.A bare counter (
31/40) or a one-word verdict (warn) tells the operator that something is wrong but never what. Each finding names one specific cause in operator language and, where an automated route exists, the exactaeat ...command that resolves it. The profile-keys check emits one finding per unset key; a failing check emits one finding per concrete cause. Findings are explanatory children, not a replacement for the parent row’s requirednext_actionordead_endrecovery channel.- Parameters:
- summary: str¶
- detail: str | None¶
- next_action: str | None¶
- requirement: Literal['required', 'optional'] | None¶
- class DiagnosticCheck(**data)[source]¶
Bases:
BaseModelOne concrete config repair check.
A failing or warning row MUST carry exactly one of
next_action(an exactaeat ...command string the operator can run) ordead_end(a short explanation of why no automated route exists). A row that supplies neither, or both, is apydantic.ValidationErrorat construction time by raisingDiagnosticModelError.okrows MUST carry neither.findingscarries the per-cause breakdown: the specific keys that are unset, the specific reasons a check failed.audiencerecords whether the operator can act on the row or whether it reports an internal application defect.render_config_repair_text()andConfigRepairReportpreserve this distinction.- Parameters:
- name: str¶
- status: DiagnosticStatus¶
- summary: str¶
- detail: str | None¶
- next_action: str | None¶
- dead_end: str | None¶
- audience: DiagnosticAudience¶
- findings: tuple[DiagnosticFinding, ...]¶
- class SecureObjectIntegrityReport(**data)[source]¶
Bases:
BaseModelAggregated decryptability counts across every populated namespace.
Surfaces how many rows of the local
secure_objectstable can be decrypted under the current master key. A non-zerounreadabletotal almost always means the keychain master-key entry was rotated or regenerated since the affected rows were written; the plaintexts are cryptographically unrecoverable from this process.namespacescarriesSecureObjectNamespaceIntegrityrows produced by the encryptedSecureObjectRepository. The same aggregate shape is shared byConfigRepairReport,RepairIntegrityReport,preview_quarantine_unreadable_secure_objects(), andquarantine_unreadable_secure_objects().- Parameters:
namespaces (tuple[SecureObjectNamespaceIntegrity, ...])
readable_total (int)
unreadable_total (int)
- namespaces: tuple[SecureObjectNamespaceIntegrity, ...]¶
- readable_total: int¶
- unreadable_total: int¶
- class ConfigRepairReport(**data)[source]¶
Bases:
BaseModelComposite report rendered by the bare
aeat config repaircommand.The report combines the public
RegistryVersionSummary, the secure-objectSecureObjectIntegrityReport, and orderedDiagnosticCheckrows into one operator-facing health payload.setupis a redactedWizardStatusReportwhenWorkflowStatecan be loaded.build_config_repair_report()is the producer, andrender_config_repair_text()is the compact text renderer.- Parameters:
overall (Literal['ok', 'warn', 'fail'])
package_name (str)
package_version (str)
python_version (str)
log_file (str)
registry (RegistryVersionSummary)
setup (WizardStatusReport | None)
secure_objects (SecureObjectIntegrityReport)
checks (tuple[DiagnosticCheck, ...])
- overall: DiagnosticStatus¶
- package_name: str¶
- package_version: str¶
- python_version: str¶
- log_file: str¶
- registry: RegistryVersionSummary¶
- setup: WizardStatusReport | None¶
- secure_objects: SecureObjectIntegrityReport¶
- checks: tuple[DiagnosticCheck, ...]¶
- class RegistryIntegrityReport(**data)[source]¶
Bases:
BaseModelResult of the opt-in full registry-validation probe.
Disaster ADR Ruling 4 moves the full registry TOML parse + cross-domain referential-integrity gate off the
--versionand bare-invocation surfaces into the explicitaeat config repair integrity registryverb. This typed report is what that verb renders: aRegistryVersionSummaryplus the aggregateDiagnosticCheckfrom_registry_cross_domain_integrity_check().- Parameters:
registry (RegistryVersionSummary)
check (DiagnosticCheck)
- registry: RegistryVersionSummary¶
- check: DiagnosticCheck¶
- build_cli_version_report(registry_root=None, *, with_registry=True)[source]¶
Return the package and registry summary for CLI version surfaces.
The
with_registryflag controls whether the full registry TOML load fires. The CLI root callback passeswith_registry=Falsefor bareaeat --versioninvocations (the fast-path mandated by disaster ADR Ruling 4 — the operator must see name + version in under a second on cold start). When--detailis on, the caller re-invokes withwith_registry=Trueto populate the registry summary.Returns a
CliVersionReportwhose registry field is either the fast-path emptyRegistryVersionSummaryor the detailed summary fromValidatedRegistryAuthority.- Return type:
- Parameters:
- build_config_repair_report(registry_root=None)[source]¶
Return local diagnostics for the
aeat config repairsurface.Returns a
ConfigRepairReportenumerating every diagnostic check and any suggested repairs. Expensive registry validation beyond the rollup check remains inbuild_registry_integrity_report(), so the bare repair command stays focused on actionable local health.The secure-state branch reads
WorkflowState, derivesActiveProfileHealth, and builds aWizardStatusReport. If that load fails, the report still emits profile and auth rows from the redacted health verdict so repair remains usable on a cold or degraded storage root. Each emitted warning/failure row is validated byDiagnosticCheckso the caller never receives a silent repair finding.- Return type:
- Parameters:
registry_root (Path | None)
- probe_browser_connectivity(settings=None)[source]¶
Probe the configured AEAT browser target through the browser adapter.
Returns a
SiteHealthStatus.- Return type:
- Parameters:
settings (Settings | None)
- render_browser_connectivity_text(status)[source]¶
Render one site-health status as compact repair output.
- Return type:
- Parameters:
status (SiteHealthStatus)
- render_config_repair_text(report)[source]¶
Render a compact human-readable repair report.
Preserves
DiagnosticCheck.audienceand the mutually exclusivenext_action/dead_endcontract so operator-actionable rows and internal application defects are visibly different in text output.- Return type:
- Parameters:
report (ConfigRepairReport)
- build_registry_integrity_report(registry_root=None)[source]¶
Run the full registry validation as a standalone
RegistryIntegrityReportprobe.Backs the
aeat config repair integrity registryverb. Bundles the registry version summary with the cross-domain referential-integrity check so the engineer-facing verb can render both the registry’s identity and its validation verdict. Disaster ADR Ruling 4 keeps this off every fast-path surface.- Return type:
- Parameters:
registry_root (Path | None)
- render_cli_version_text(report)[source]¶
Render a compact text line for human-facing version output.
- Return type:
- Parameters:
report (CliVersionReport)
- secure_object_unreadable_total()[source]¶
Return the count of rows the current master key cannot decrypt.
Lightweight wrapper over
_probe_secure_objects_integrity()for consumers (notablyaeat app overview status) that want to surface a concise “N rows unreadable” pointer towardsaeat config repairwithout rendering the per-namespace breakdown themselves. The full breakdown remains the authority ofConfigRepairReport.- Return type:
- preview_quarantine_unreadable_secure_objects()[source]¶
Report the rows
repair quarantinewould move, mutating nothing.Backs the
aeat config repair quarantine --dry-runpreview. Runs the same per-namespace decryptability probe thatquarantine_unreadable_secure_objects()uses to decide which rows to archive, but performs no copy and no delete: thesecure_objectstable is left exactly as found. The returnedSecureObjectIntegrityReportcarries, per namespace, theunreadablecount (= rows the non-dry-run verb would quarantine) and thereadablecount (= rows it would retain), so the operator can confirm the blast radius before committing - the same preview shapereset-progress --dry-runalready offers.- Return type:
- quarantine_unreadable_secure_objects()[source]¶
Move every undecryptable secure-object row into the quarantine table.
Delegates to
quarantine_unreadable_rows(), which creates thesecure_objects_quarantinearchive table on first use, copies each undecryptable row’s metadata and (still encrypted) payload into the archive, then deletes the row from the activesecure_objectstable. Decryptable rows are not touched.The user’s ciphertext is preserved in the archive; nothing is auto-deleted. If a missing master key is later recovered (e.g. restored from a recovery-key backup), the operator can manually re-import rows from the quarantine table.
- Return type:
- Returns:
A
SecureObjectIntegrityReportwhosenamespacesreport carries per-namespaceunreadablecounts (= rows moved to quarantine) andreadablecounts (= rows retained insecure_objects).
- ensure_models_rebuilt()¶
Resolve the deferred forward references on the heavy report models.
SecureObjectIntegrityReportandConfigRepairReportcarry fields typed bySecureObjectNamespaceIntegrityandWizardStatusReport. Those names are imported lazily so theaeat --versionfast path never pulls the heavy secure-object and wizard-status import subtrees. The two models are only ever constructed by the diagnostics functions below — never by the version path — so their forward references are resolved here, on first use of a heavy function, when the real types are imported anyway. Idempotent: the rebuild runs once per process.- Return type:
- profile_check(report, *, profile_health=None, state=None)¶
Render semantic profile readiness from wizard status plus workflow state.
reportsupplies theWizardStatusReportcounters and next action.profile_healthcan override the row whenActiveProfileHealthsays the active profile bucket is unavailable.statelets the check expand missing profile keys fromWorkflowStateinto per-keyDiagnosticFindingrows.- Return type:
- Parameters:
report (WizardStatusReport)
profile_health (ActiveProfileHealth | None)
state (WorkflowState | None)
- registry_cross_domain_integrity_check(registry_root)¶
Cross-domain integrity check by exercising the snapshot-build gate.
Loads
ValidatedRegistryAuthority(which runsvalidate_registryat construction time) and attempts to build a representative snapshot forModelomemberM100. The snapshot-build path wires_check_all_id_references()(typed-ID existence checks + renta first-slice routing target check + per-binding selector- shape gate); any divergence between code-side typed contracts and registry data surfaces here as a typed failure.A failure routes the operator to a structured diagnostic rather than a runtime KeyError mid-calculation.
- Return type:
- Parameters:
registry_root (Path)