aeat.application.repair_integrity module¶
Secure-object repair diagnostics, remediation decisions, and policy coverage.
The read side of this module produces metadata-only reports over encrypted
secure-object rows. Integrity sweeps iterate namespaces in a
SecureObjectRepository and return
per-namespace
SecureObjectNamespaceIntegrity
counts; inventory rows expose row metadata and HMAC digests, never natural
keys or payload bytes. These reports
back the repair integrity surface and the quarantine dry-run path without
emitting bucket events.
The write side is deliberately narrow: RepairRemediationDecision
records persist non-destructive preserve / quarantine / rebuild /
export-required planning outcomes as encrypted AUDIT-class rows. A decision
record is evidence for a later operator workflow, not mutation authority.
The policy catalog returned by
build_repair_policy_command_surface_catalog() mirrors repair, recovery,
import, export, and bucket-history command surfaces against registered
SecureObjectNamespaceDefinition metadata. Tests use it as a drift gate
so new maintenance surfaces cannot appear without an explicit namespace policy.
See also
aeat.application.diagnosticsBuilds the user-facing repair report and delegates quarantine preview / commit flows through this module’s active-bucket repair session.
SecureObjectRepositoryEncrypted SQL repository whose namespace integrity probes and quarantine operation supply the repair data.
STORAGE_NAMESPACE_REGISTRYCentral registry copied into repair-policy namespace rows.
aeat.entrypoints.cli._config._repair_cliCLI command surface that renders these reports and policy-backed repair actions.
- exception RepairIntegrityError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
CoreErrorBase error for secure-object integrity and repair-remediation failures.
Raised by the repair-integrity application layer when an integrity invariant or remediation contract is violated. Inherits from
aeat.core.errors.CoreErrorso callers can catch either the specific subclass or the broad domain base without importing the full repair-integrity module.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- exception RepairDecisionNotFoundError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
RepairIntegrityErrorRaised when a repair-remediation decision lookup misses its target.
Fired by
RepairRemediationDecisionRepository.load_decision()when no row exists for the requesteddecision_id. Distinct from a generic not-found so the CLI can produce an actionable hint (e.g. list existing decisions) without catching broad exception classes.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class RepairIntegrityReport(**data)[source]¶
Bases:
BaseModelMetadata-only secure-object integrity report.
namespacescarries oneSecureObjectNamespaceIntegrityper probed namespace.checkis the aggregateDiagnosticCheckrow used by repair renderers; failing reports carry the quarantine command as the next action.See also
build_repair_integrity_report()Producer that fills this report from real secure-object decryptability probes.
SecureObjectIntegrityReportConfig-repair rollup that uses the same namespace integrity shape.
- Parameters:
namespaces (tuple[SecureObjectNamespaceIntegrity, ...])
readable_total (int)
unreadable_total (int)
check (DiagnosticCheck)
- namespaces: tuple[SecureObjectNamespaceIntegrity, ...]¶
- readable_total: int¶
- unreadable_total: int¶
- check: DiagnosticCheck¶
- class RepairListRow(**data)[source]¶
Bases:
BaseModelOne metadata row in the secure-object repair inventory.
Rows are projected from
SecureObjectDecryptabilityRowvalues returned byiter_namespace_decryptability().object_key_digestis the stored HMAC digest, not the natural object key.reasonis populated only for unreadable rows and must remain a diagnostic class of failure rather than decrypted payload context.- Parameters:
- namespace: str¶
- object_key_digest: str¶
- readable: bool | None¶
- row_id: int | None¶
- classification: str | None¶
- schema_version: int | None¶
- written_at: datetime | None¶
- reason: str | None¶
- class RepairListReport(**data)[source]¶
Bases:
BaseModelInternal secure-object inventory report for one namespace.
The report combines the namespace’s
SecureObjectNamespaceIntegritycounts with metadata-onlyRepairListRowentries. Operator-facing repair commands render aggregate integrity and quarantine previews rather than exposing a broad raw list command.- Parameters:
namespace (str)
integrity (SecureObjectNamespaceIntegrity)
rows (tuple[RepairListRow, ...])
rows_total (int)
filter_mode (str)
- namespace: str¶
- integrity: SecureObjectNamespaceIntegrity¶
- rows: tuple[RepairListRow, ...]¶
- rows_total: int¶
- filter_mode: str¶
- build_repair_integrity_report(*, namespace=None, repository=None)[source]¶
Probe secure-object decryptability and return a
RepairIntegrityReport.When
namespaceis set, only that namespace is probed; otherwise every namespace currently present in the repository is scanned. Without an injected repository, the probe opens the active bucket repair session before resolving the runtime-boundSecureObjectRepository.- Return type:
- Parameters:
namespace (str | None)
repository (_SecureObjectRepositoryProtocol | None)
- active_bucket_repair_session()[source]¶
Best-effort session opener for active-bucket repair diagnostics.
Repair integrity and quarantine previews need to test decryptability under the active bucket key, but they are bootstrap-adjacent diagnostics rather than profile enrollment flows. If a session is already active it is reused; otherwise the configured master-key provider is entered for the span. A provider failure is logged and the caller still observes the normal repository/runtime readiness result.
See also
preview_quarantine_unreadable_secure_objects()Dry-run repair flow that uses this context before probing decryptability.
quarantine_unreadable_secure_objects()Commit flow that uses this context before calling
quarantine_unreadable_rows().
- build_repair_list_report(*, namespace, include_all=False, only_unreadable=False, repository=None)[source]¶
List secure-object metadata stored under
namespace.--allreturns every key;--unreadablefilters to only the rows whose payload cannot be decrypted under the current master key. Default behaviour (both flags False) returns the full key set but caps the inventory at the integrity-readable count for bandwidth control on large namespaces — same as--allfor namespaces with no integrity issues.Returns a
RepairListReportenumerating matching HMAC digests and their decryptability status. The report never exposes natural object keys or payload bytes. Without an injected repository, the list path entersactive_bucket_repair_session()before resolving the activeSecureObjectRepository.- Return type:
- Parameters:
- class RepairRemediationDecision(**data)[source]¶
Bases:
BaseModelNon-destructive planning record for a repair-remediation outcome.
Decision records persist preserve / quarantine / rebuild / export-required planning outcomes without authorising mutation.
mutation_authorizedis hard-typed toFalseso a decision record can never be mistaken for an execute order. The policy catalog keeps these records visible throughRepairPolicyCommandSurfacedecision-trail anchors.The
decision_idis content-bound viarepair_remediation_decision_id()to every other field, so persisting an arbitrary sha-shaped key for a different remediation target or evidence requirement set is rejected at load time by the re-derivation guard.See also
RepairRemediationDecisionRepositoryProfile-local encrypted persistence for these decision records.
REPAIR_INTEGRITY_DECISION_NAMESPACESecure-object namespace used to store the decisions.
- Parameters:
- decision_id: str¶
- target_namespace: str¶
- target_object_key_digest: str | None¶
- outcome: _RepairDecisionOutcome¶
- decided_at: datetime¶
- decided_by: str¶
- reason: str¶
- likely_origin: str¶
- replacement_evidence_requirements: tuple[str, ...]¶
- verified_replacement_evidence_refs: tuple[str, ...]¶
- mutation_authorized: Literal[False]¶
- schema_version: str¶
- repair_remediation_decision_id(*, target_namespace, target_object_key_digest, outcome, decided_at, decided_by, reason, likely_origin, replacement_evidence_requirements, verified_replacement_evidence_refs)[source]¶
Return the deterministic SHA-256 id for a repair-remediation decision.
Content-bound to every payload field including
decided_atso two structurally identical re-runs at the same instant produce the same id; differing payloads produce different ids. The hash domain matches theRepairRemediationDecisionfield set exactly so the load-time re-derivation guard catches any payload mutation that bypassed the constructor.
- class RepairRemediationDecisionRepository(repository=None)[source]¶
Bases:
objectProfile-local persistence for
RepairRemediationDecisionrecords.Decisions are persisted through
SecureObjectRepositoryas encrypted AUDIT-class secure-object rows under the active profile’s bucket. The object key is the decision’s content-addresseddecision_id; the payload is the decision’s JSON model dump. Listing returns rows in decision-time descending order.The repository accepts an optional
SecureObjectRepositoryinjection for tests; the no-arg constructor resolves the active bucket’s secure-object repository via the standard runtime path.- Parameters:
repository (SecureObjectRepository | None)
- save_decision(decision)[source]¶
Persist one decision as an encrypted AUDIT-class secure-object row.
- Return type:
- Parameters:
decision (RepairRemediationDecision)
- load_decision(decision_id)[source]¶
Load one decision by its content-addressed id; re-derives + checks the id.
Returns the
RepairRemediationDecisionmatchingdecision_idafter verifying its content-addressed identity.- Return type:
- Parameters:
decision_id (str)
- list_decisions()[source]¶
Return every persisted
RepairRemediationDecisionin decision-time descending order.- Return type:
- class RepairPolicyNamespaceClassification(**data)[source]¶
Bases:
BaseModelMinimal namespace classification attached to a repair-policy surface.
Embedded in
RepairPolicyNamespacePolicyso command catalog rows can describe non-registered bundle / filing / ledger surfaces and registered secure-object namespace scopes with the same shape.- Parameters:
role (str)
- role: str¶
- class RepairPolicyNamespacePolicy(**data)[source]¶
Bases:
BaseModelPolicy metadata for one namespace governed by a command surface.
Registered secure-object namespaces copy owner, sensitivity, schema version, and scope from
SecureObjectNamespaceDefinitionso repair and recovery surfaces stay tied to the namespace registry instead of parallel role markers.RepairPolicyCommandSurfaceattaches these rows to every CLI surface that can inspect, repair, import, export, or recover namespace-owned data.- Parameters:
namespace_classification (RepairPolicyNamespaceClassification)
owner_domain (str)
repair_policy (str)
recovery_policy (str)
mutation_authority (str)
registered_namespace_key (str | None)
registered_namespace (str | None)
registered_owner (str | None)
registered_sensitivity (str | None)
registered_schema_version (int | None)
registered_scope (str | None)
- namespace_classification: RepairPolicyNamespaceClassification¶
- owner_domain: str¶
- repair_policy: str¶
- recovery_policy: str¶
- mutation_authority: str¶
- registered_namespace_key: str | None¶
- registered_namespace: str | None¶
- registered_owner: str | None¶
- registered_sensitivity: str | None¶
- registered_schema_version: int | None¶
- registered_scope: str | None¶
- class RepairPolicyCommandSurface(**data)[source]¶
Bases:
BaseModelOne catalogued repair-policy CLI command surface.
Each row links a command path to its owner domains, decision-trail anchors, and the namespace policies that constrain any repair or recovery behavior reachable from that command family.
See also
RepairPolicyNamespacePolicyPer-namespace policy rows attached to a command surface.
build_repair_policy_command_surface_catalog()Executable catalog that mirrors the repair and recovery CLI surface.
- Parameters:
- command_path: str¶
The canonical CLI command path (e.g.
config repair integrity objects).
- command_family: str¶
- owner_domains: tuple[str, ...]¶
- decision_links: tuple[str, ...]¶
- namespace_policies: tuple[RepairPolicyNamespacePolicy, ...]¶
- build_repair_policy_command_surface_catalog()[source]¶
Return the
RepairPolicyCommandSurfacecatalog for repair-policy CLI surfaces.The catalog mirrors the Typer command registry for repair, recovery, import, export, and bucket-history surfaces. It is used as an executable drift gate: adding a new command in those families requires a policy row here, and secure-object rows must derive their metadata from the central namespace registry. Each row also carries decision links for
RepairRemediationDecisiongovernance.See also
STORAGE_NAMESPACE_REGISTRYSource of secure-object namespace metadata copied into catalog policies.
SecureObjectNamespaceDefinitionRegistered namespace declaration projected into policy rows.
- Return type: