cadrumo.core._config_validation module¶
Private Settings validator implementations; decorators remain in config.
- resolve_database_url_for_active_profile(settings, *, pointer_observation)[source]¶
Resolve
cadrumo_database_urlthrough 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:
settings.cadrumo_active_profile(the in-process override the--profileflag andoverride_settingswrite; no environment variable reaches it).<cadrumo_local_storage_root>/active-profileplaintext pointer file written byprofile create/config login.
When neither rung resolves, the field derives a root-level fallback at
sqlite:///<cadrumo_local_storage_root>/cadrumo.dbso the two storage settings stay coherent: settingCADRUMO_LOCAL_STORAGE_ROOTalone never leavescadrumo_database_urlempty. 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:
- Parameters:
settings (Settings)
pointer_observation (tuple[Path, BucketPointer] | None)
- 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_ROOTscopes, 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-relativevar/...default carries on an installed distribution. A developer who wants the tree inside their checkout setsCADRUMO_LOCAL_STORAGE_ROOT.An explicit per-field env override (
CADRUMO_TOKEN_DIR,CADRUMO_RUNS_DIR, …) or a value supplied via anoverride_settingsblock registers the field inmodel_fields_setand 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"guaranteescadrumo_local_storage_rootis already populated when this runs.
- empty_optional_paths_are_none(value)[source]¶
Treat blank env vars for optional path fields as unset.
- empty_optional_secrets_are_none(value)[source]¶
Treat blank env vars for optional secret fields as unset.
- detail_url_template_has_expediente_id(value)[source]¶
Reject templates that omit the
{expediente_id}placeholder.
- empty_optional_clave_fields_are_none(value)[source]¶
Treat blank env vars for optional Cl@ve identity/password fields as unset.
- clave_dni_fecha_is_iso_date(value)[source]¶
Reject DNI validity dates that are not canonical
YYYY-MM-DD.Python 3.11’s
date.fromisoformatalso accepts the compactYYYYMMDDform and ISO week dates, but AEAT’s Cl@ve MóvilFECHAinput expects the hyphenated canonical form. The regex rejects anything else before we delegate the semantic check to the stdlib parser.