cadrumo.core._config_validation module

Private Settings validator implementations; decorators remain in config.

validate_live_iva_timeout_hierarchy(settings)[source]
Return type:

Settings

Parameters:

settings (Settings)

resolve_database_url_for_active_profile(settings, *, pointer_observation)[source]

Resolve cadrumo_database_url through the active-profile chain.

When the field is left empty (the production default), this validator computes the per-bucket SQLite URL at sqlite:///<cadrumo_local_storage_root>/buckets/<bucket-id>/db/cadrumo.db. Tests that pass an explicit URL bypass the resolution — the validator only fires the computation when the field is empty.

Active-profile resolution honours the operator-facing precedence chain:

  1. settings.cadrumo_active_profile (the in-process override the --profile flag and override_settings write; no environment variable reaches it).

  2. <cadrumo_local_storage_root>/active-profile plaintext pointer file written by profile create / config login.

When neither rung resolves, the field derives a root-level fallback at sqlite:///<cadrumo_local_storage_root>/cadrumo.db so the two storage settings stay coherent: setting CADRUMO_LOCAL_STORAGE_ROOT alone never leaves cadrumo_database_url empty. Cold-start commands still refuse before touching this fallback database — every profile-scoped path checks for an active profile first — so the fallback database is a placeholder that real per-profile data never lands in.

Return type:

Settings

Parameters:
resolve_output_dirs_under_storage_root(settings)[source]

Root every derived output directory under cadrumo_local_storage_root.

Auth tokens, the diagnostic log, the encrypted-store substrate (secret, blob, audit), the append-only telemetry logs, the regenerable caches, and the durable generated-output directories all default to a subpath under the one state root that CADRUMO_LOCAL_STORAGE_ROOT scopes, per the core storage taxonomy. That root is the platform user-data location in every run mode, never inside a virtualenv or uv cache — the hazard a checkout-relative var/... default carries on an installed distribution. A developer who wants the tree inside their checkout sets CADRUMO_LOCAL_STORAGE_ROOT.

An explicit per-field env override (CADRUMO_TOKEN_DIR, CADRUMO_RUNS_DIR, …) or a value supplied via an override_settings block registers the field in model_fields_set and wins: the validator only computes the derived path when the field was left at its placeholder default. The validator only computes paths; provider factories and custody loaders decide how those directories are opened.

Which fields those are, and what subpath each takes, is not decided here: the typed declaration is iterated directly so this validator cannot drift from it by carrying a table of its own. Members whose field is a deliberate opt-in override are excluded by the declaration rather than by a special case here – deriving a default into one would silently retire the branch that selects on the field being unset.

mode="after" guarantees cadrumo_local_storage_root is already populated when this runs.

Return type:

Settings

Parameters:

settings (Settings)

empty_optional_paths_are_none(value)[source]

Treat blank env vars for optional path fields as unset.

Return type:

Optional[TypeVar(ValueT)]

Parameters:

value (ValueT)

empty_optional_secrets_are_none(value)[source]

Treat blank env vars for optional secret fields as unset.

Return type:

Optional[TypeVar(ValueT)]

Parameters:

value (ValueT)

detail_url_template_has_expediente_id(value)[source]

Reject templates that omit the {expediente_id} placeholder.

Return type:

str

Parameters:

value (str)

empty_optional_clave_fields_are_none(value)[source]

Treat blank env vars for optional Cl@ve identity/password fields as unset.

Return type:

Optional[TypeVar(ValueT)]

Parameters:

value (ValueT)

clave_dni_fecha_is_iso_date(value)[source]

Reject DNI validity dates that are not canonical YYYY-MM-DD.

Python 3.11’s date.fromisoformat also accepts the compact YYYYMMDD form and ISO week dates, but AEAT’s Cl@ve Móvil FECHA input expects the hyphenated canonical form. The regex rejects anything else before we delegate the semantic check to the stdlib parser.

Return type:

str | None

Parameters:

value (str | None)

clave_sede_access_url_template_has_target(value)[source]

Reject templates that omit the {target} placeholder.

Return type:

str

Parameters:

value (str)

normalize_repo_relative_paths(value, *, normalizer)[source]

Anchor repo-relative path settings to the application data root.

Return type:

Path | None

Parameters: