aeat.application.config_reset module

Scoped reset service for aeat config reset.

Removes one or more pieces of operator-local state behind an explicit --yes confirmation gate and the CLI requires an explicit --scope. Four ConfigResetScope values are supported and returned through the typed ConfigResetReport:

  • PROFILE: clears every operator profile pointer and deletes each persisted profile bucket.

  • AUTH: clears the persisted auth session and provider metadata.

  • DATA: quarantines undecryptable secure-object rows only. It does not delete readable ledger data; bucket-local ledger reset is owned by the ledger backend so finalized modelo protections can run.

  • ALL: combines the three scopes above.

The service runs through the normal runtime storage routes. WorkflowStateRepository loads the typed WorkflowState, profile removal goes through UserProfileLifecycleRepository plus remove_profile_bucket_directory(), and DATA reset delegates to quarantine_unreadable_secure_objects() for a SecureObjectIntegrityReport. It does not bypass runtime readiness or directly erase readable ledger data.

Each scope writes one log line through the project’s standard core.logging channel so post-mortem analysis of an operator’s reset history is possible without an extra audit-only backend. The function rejects calls without explicit confirmation and raises ConfigResetUnconfirmedError with a registered translated message key.

See also

reset_workflow_state()

Narrow aeat config repair reset-progress route that deletes the saved workflow-state envelope after producing a WorkflowStateResetFingerprint.

SecureObjectIntegrityReport

DATA-scope quarantine summary returned by the diagnostics pipeline.

application.repair_integrity

Policy registry for repair surfaces, including the metadata-only workflow-state reset plan.

class ConfigResetScope(*values)[source]

Bases: StrEnum

Closed catalogue of operator-driven reset scopes.

The enum is the shared application/CLI contract: CLI tokens are parsed by parse_config_reset_scope() from CONFIG_RESET_SCOPE_CLI_VALUES before reset_config() runs, and ConfigResetReport echoes the applied scope.

PROFILE
AUTH
DATA
ALL
CONFIG_RESET_SCOPE_CLI_VALUES: tuple[str, ...]

Lowercase ConfigResetScope tokens accepted by aeat config reset --scope.

parse_config_reset_scope(raw)[source]

Parse a CLI reset-scope token into the ConfigResetScope member.

The CLI renders CONFIG_RESET_SCOPE_CLI_VALUES as the accepted token set, then delegates normalization here before calling reset_config().

Return type:

ConfigResetScope

Parameters:

raw (str)

exception ConfigResetUnconfirmedError(message=None, *, context=None, suggestion=None, translated_message=None)[source]

Bases: AeatError

Raised when reset_config() is called without confirmed=True.

The error carries errors.refused.refused_config_reset_unconfirmed and the refused ConfigResetScope value in structured context so the CLI/error envelope renders through the registered ErrorEnvelope refusal catalogue.

Parameters:
  • message (str | None)

  • context (Mapping[str, object] | None)

  • suggestion (str | None)

  • translated_message (str | None)

Return type:

None

code: ClassVar[ErrorCode]
class ConfigResetReport(**data)[source]

Bases: BaseModel

Outcome of a scoped reset.

Variables:
  • scope – The ConfigResetScope that was applied.

  • removed_profile_ids – Sorted tuple of profile UUIDs cleared from the profile lifecycle repository and then removed from their bucket directories. Empty when the scope did not touch profiles.

  • removed_auth_session – True when the auth session was reset.

  • quarantined_namespace_count – Number of secure-object namespaces whose unreadable rows were archived to the quarantine table during the DATA reset via SecureObjectIntegrityReport.

Parameters:
scope: ConfigResetScope
removed_profile_ids: tuple[str, ...]
removed_auth_session: bool
quarantined_namespace_count: int
reset_config(scope, *, confirmed)[source]

Apply the scoped reset and return a ConfigResetReport.

The operation is destructive and therefore refuses unless confirmed=True. Confirmed PROFILE / ALL resets enumerate profile manifests via list_profile_buckets(), delete each profile through UserProfileLifecycleRepository, and then remove bucket directories after disposing cached SQL engines. AUTH resets replace auth state inside WorkflowState. DATA resets call quarantine_unreadable_secure_objects() for unreadable secure-object rows only. This broad reset surface is separate from reset_workflow_state(), which only clears the workflow-state envelope for aeat config repair reset-progress.

Parameters:
Return type:

ConfigResetReport

Returns:

A ConfigResetReport summarising what was cleared.

Raises:

ConfigResetUnconfirmedError – When confirmed is False.