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-progressroute that deletes the saved workflow-state envelope after producing aWorkflowStateResetFingerprint.SecureObjectIntegrityReportDATA-scope quarantine summary returned by the diagnostics pipeline.
application.repair_integrityPolicy registry for repair surfaces, including the metadata-only workflow-state reset plan.
- class ConfigResetScope(*values)[source]¶
Bases:
StrEnumClosed catalogue of operator-driven reset scopes.
The enum is the shared application/CLI contract: CLI tokens are parsed by
parse_config_reset_scope()fromCONFIG_RESET_SCOPE_CLI_VALUESbeforereset_config()runs, andConfigResetReportechoes the applied scope.- PROFILE¶
- AUTH¶
- DATA¶
- ALL¶
- CONFIG_RESET_SCOPE_CLI_VALUES: tuple[str, ...]¶
Lowercase
ConfigResetScopetokens accepted byaeat config reset --scope.
- parse_config_reset_scope(raw)[source]¶
Parse a CLI reset-scope token into the
ConfigResetScopemember.The CLI renders
CONFIG_RESET_SCOPE_CLI_VALUESas the accepted token set, then delegates normalization here before callingreset_config().- Return type:
- Parameters:
raw (str)
- exception ConfigResetUnconfirmedError(message=None, *, context=None, suggestion=None, translated_message=None)[source]¶
Bases:
AeatErrorRaised when
reset_config()is called withoutconfirmed=True.The error carries
errors.refused.refused_config_reset_unconfirmedand the refusedConfigResetScopevalue in structured context so the CLI/error envelope renders through the registeredErrorEnveloperefusal catalogue.- Parameters:
- Return type:
None
- code: ClassVar[ErrorCode]¶
- class ConfigResetReport(**data)[source]¶
Bases:
BaseModelOutcome of a scoped reset.
- Variables:
scope – The
ConfigResetScopethat 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_auth_session (bool)
quarantined_namespace_count (int)
- 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 vialist_profile_buckets(), delete each profile throughUserProfileLifecycleRepository, and then remove bucket directories after disposing cached SQL engines. AUTH resets replace auth state insideWorkflowState. DATA resets callquarantine_unreadable_secure_objects()for unreadable secure-object rows only. This broad reset surface is separate fromreset_workflow_state(), which only clears the workflow-state envelope foraeat config repair reset-progress.- Parameters:
scope (
ConfigResetScope) – TheConfigResetScopeto apply.confirmed (
bool) – Explicit--yesflag from the CLI surface. The function refuses without it.
- Return type:
- Returns:
A
ConfigResetReportsummarising what was cleared.- Raises:
ConfigResetUnconfirmedError – When
confirmedisFalse.