cadrumo.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 without loading the bundled registry.
build_config_repair_report() composes environment checks,
WorkflowState loading,
ActiveProfileHealth profile storage
verdicts, WizardStatusReport
readiness and secure-object decryptability into a
ConfigRepairReport of DiagnosticCheck rows.
Every warn/fail DiagnosticCheck carries an application-owned
precondition_verdict whose outcome is either a canonical action reference
or an explicit no-recovery classification. 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. 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.
See also
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.
- build_cli_version_report()[source]¶
Return package identity for the CLI version surfaces.
- Return type:
- build_config_repair_report(*, ports, profile_decode_context=None)[source]¶
Return local diagnostics for the
aeat config repairsurface.Returns a
ConfigRepairReportenumerating every diagnostic check and any suggested repairs. It is restricted to actionable local configuration and secure-state 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:
ports (DiagnosticsPorts)
profile_decode_context (ProfileDecodeContext | None)
- render_config_repair_text(report)[source]¶
Render a compact human-readable repair report.
Preserves
DiagnosticCheck.audienceand never reconstructs command prose from an application-ownedDiagnosticCheck.precondition_verdict. Typed actions are resolved by the entrypoint projection; this application renderer remains a diagnosis-only view.- Return type:
- Parameters:
report (ConfigRepairReport)
- build_profile_check(report, *, profile_health=None, state=None, profile_decode_context=None)[source]¶
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)
profile_decode_context (ProfileDecodeContext | None)
- is_missing_active_bucket_session_failure(exc, *, ports)[source]¶
Classify a secure-state probe failure as a missing active bucket session.
This verdict decides whether
secure_state.loadwarns (an expected cold start) or fails (a real fault), and whether the raw exception text reaches the operator, so it reads the typed exception chain rather than rendered text.Scanning the rendered text for the class name could not survive this module’s own contract: a producer that stops passing an authored sentence positionally leaves
str(exc)degraded to a locale key which no longer contains the class name, so the scan would quietly stop matching and every cold start would report as a hard fault. It also matched in the wrong direction, classifying any unrelated failure whose message merely mentioned the class as an expected cold start, which downgrades a genuine fault to a warning and suppresses its detail.Both the
__cause__and__context__edges are followed. An explicitraise ... fromsets only the former and an incidental re-raise inside anexceptblock sets only the latter, so a chain can fork across the two; the previous single-edge walk silently abandoned the__context__branch whenever a__cause__was present. Identity marking keeps a self- or mutually-referential chain from looping.- Return type:
- Parameters:
exc (BaseException)
ports (DiagnosticsPorts)
- 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(*, ports)[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:
- Parameters:
ports (DiagnosticsPorts)
- preview_quarantine_unreadable_secure_objects(*, ports)[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:
- Parameters:
ports (DiagnosticsPorts)
- quarantine_unreadable_secure_objects(*, ports)[source]¶
Move every undecryptable secure-object row into the quarantine table.
Delegates to the injected secure-object diagnostic repository, whose storage implementation creates the quarantine archive table on first use, copies each undecryptable row’s metadata and (still encrypted) payload into the archive, then deletes the row from the active
secure_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).- Parameters:
ports (DiagnosticsPorts)