cadrumo.core.config_support module

Support types and defaults for the central settings facade.

This module holds the closed settings enums and derived records consumed by Settings: LLM provider selection (LLMProvider), and database routing via StorageRouteKind and StorageRouteClassification.

The route records are produced by classify_storage_route(); output language strings are coerced to OutputLanguage; and AEAT URL defaults are read from load_external_constants().

AEAT_CERTIFICATE_PROTECTED_ORIGIN

Exact Playwright client-certificate origin for AEAT certificate authentication.

AEAT_CERTIFICATE_PROTECTED_PATH

Exact protected AEAT resource path used to prove certificate authentication.

AEAT_CERTIFICATE_PROTECTED_URL

Canonical protected navigation URL for certificate authentication.

assert_canonical_protected_resource(value, *, subject)[source]

Return value if it is the canonical protected resource, else raise.

Certificate authentication is proved by reaching one specific AEAT resource, so a record claiming proof against any other URL is not evidence of anything. Both the persisted proof and the live session detail assert this, and they asserted it with separate copies of the comparison until this became its one home — beside the constant it is about, where a change to the route and a change to the rule cannot separate.

Parameters:
  • value (str) – The protected-resource URL the record carries.

  • subject (str) – What is being validated, for the refusal message — the two call sites name different records and the operator needs to know which one refused.

Return type:

str

Returns:

value unchanged.

Raises:

ValueError – value is not the canonical protected resource. A plain ValueError because both call sites are pydantic validators, which fold it into the model’s own ValidationError.

class TuiAppearance(*values)[source]

Bases: StrEnum

Supported appearances for the full-screen terminal surfaces.

Settings exposes this closed set through cadrumo_tui_appearance so the profile manager, the paged flow frontend, and the read-only status page share one spelling for the operator’s light/dark preference. AUTO defers to the host terminal rather than pinning an appearance.

AUTO
LIGHT
DARK
unwrap_optional_secret(value)[source]

Return the cleartext of an optional pydantic.SecretStr.

Optional Cl@ve and certificate settings use this helper at adapter boundaries so unset secrets materialise as "" rather than leaking pydantic.SecretStr wrappers into string handling.

Return type:

str

Parameters:

value (SecretStr | None)

class LLMProvider(*values)[source]

Bases: StrEnum

The closed set of model-transport identities, declared once, here.

Canonical home for the value set, not a settings-only convenience. Two byte-identical copies of it existed – this one and a second in the inference package’s request models – so a reader could not tell which was authoritative and a value added to one would silently not exist in the other.

It lives in core because a closed value set is declared in core by the architecture boundary, and because the direction is forced: the inference package may import core (inward), while core importing the optional inference package is refused by contract. The package consumes this enum; it does not redeclare it.

ANTHROPIC
OPENAI
GEMINI
LOCAL
class StorageRouteKind(*values)[source]

Bases: StrEnum

Resolved primary database route classification.

Members distinguish operator-supplied database URLs from computed active bucket routes and cold root-fallback routes. The storage write policy consumes this value through inspect_storage_write_policy().

EXPLICIT_DATABASE_URL
ACTIVE_BUCKET_DATABASE
ROOT_FALLBACK_DATABASE
class StorageRouteClassification(**data)[source]

Bases: BaseModel

Strict classification of the effective primary database route.

Instances are returned by classify_storage_route() and carry the effective StorageRouteKind, original database URL, SQLite path when derivable, and active bucket id for bucket-attached routes.

Parameters:

data (Any)

kind: StorageRouteKind
database_url: str
database_path: Path | None
bucket_id: BucketId | None
default_clave_sede_access_url_template()[source]

Return the configured Cl@ve Movil selector access URL template.

Return type:

str

default_clave_permanente_sede_access_url_template()[source]

Return the configured Cl@ve Permanente selector access URL template.

Return type:

str

default_sede_expedientes_path()[source]

Return the configured AEAT Sede expedientes summary path.

Return type:

str

default_status_detail_url_template()[source]

Return the configured AEAT expediente status detail URL template.

Return type:

str

default_status_notificaciones_path()[source]

Return the configured AEAT notifications status path.

Return type:

str

default_aeat_sede_origin()[source]

Return the configured AEAT Sede origin.

Return type:

str

default_aeat_sede_origin_with_slash()[source]

Return the configured AEAT Sede origin with a trailing slash.

Return type:

str

class JustificanteParserBackendSetting(*values)[source]

Bases: StrEnum

Settings-shape selector for the justificante PDF parsing backend.

PDFPLUMBER
coerce_output_language_setting(value)[source]

Coerce an env-var output-language string to an OutputLanguage.

Returns None for invalid input so Settings validation can decide how to fall back or report the bad value. A non-string value (e.g. a bare bool, which is a subtype of int and would otherwise reach .lower()) is invalid input, not a crash.

Return type:

OutputLanguage | None

Parameters:

value (str)