cadrumo.core.config_state_root module¶
The platform user-data storage root.
The central settings facade (Settings) roots the
encrypted profile store at cadrumo_local_storage_root, from which the
token, log, secret, blob and audit roots derive. This module resolves that
default, and resolves it to exactly one place: the platform user-data
directory (%LOCALAPPDATA% on Windows, $XDG_DATA_HOME with the
~/.local/share fallback on Linux, ~/Library/Application Support on
macOS).
It does NOT classify how the process was installed. Cadrumo is a tax-filing
product; a repository is a development artefact with no runtime meaning, so
production code never inspects the filesystem for a pyproject.toml or a
.git marker. An earlier revision did exactly that and branched on the
answer to choose between a checkout-local var/storage and the platform
directory — which meant a source-layout guess decided where a taxpayer’s
regulated financial state was written. Detection is gone; only the platform
answer remains.
The dev loop is served by configuration, not by detection: a developer who
wants the store inside their checkout sets CADRUMO_LOCAL_STORAGE_ROOT
(the justfile does), and an explicit operator override wins over this
default like any other setting.
Every input the resolution reads — the platform string, the environment
mapping, and the home directory — is captured in the frozen
StateRootInputs seam, so resolution is a pure function of its
argument and testable without mutating the ambient process.
default_storage_root() is the live entry point
Settings binds as its cadrumo_local_storage_root
default factory.
See also
SettingsCentral settings aggregate whose storage-root default is resolved here.
StateRootInputsFrozen seam that captures every environmental input used by resolution.
resolve_state_root()Pure resolver that returns the effective storage root.
default_storage_root()Live default factory bound into the settings model.
- BUCKETS_DIRNAME¶
Bucket container directory name, read from the one core storage authority.
- BUCKET_DB_DIRNAME¶
Per-bucket database directory name, read from the one core storage authority.
- PRODUCT_DATABASE_FILENAME¶
Canonical SQLite filename, read from the one core storage authority.
- FORMER_PRODUCT_DATABASE_FILENAME¶
Retired
aeatdatabase filename inspected only for refusal.
- exception FormerProductStateError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
CoreErrorRaised when installed Cadrumo detects a retired
aeatstate root.Detection is refusal-only. The resolver does not open, read, move, re-key, delete, or adopt anything below the retired
aeatapplication directory.- Parameters:
- Return type:
None
- code¶
- refuse_former_product_database(storage_root, *, bucket_id=None)[source]¶
Refuse a recognizable retired
aeatdatabase without opening it.Only filesystem metadata is inspected. The retired database is never connected to, read, copied, moved, deleted, or adopted.
- class StateRootInputs(**data)[source]¶
Bases:
BaseModelInjectable, frozen seam for state-root resolution.
Capturing every environmental input as an explicit field makes both
platform_user_data_root()andresolve_state_root()pure functions of its argument, so a test constructs a deterministic platform context rather than mutatingos.environor patchingsys.platform.- platform: str¶
- environ: dict[str, str]¶
- home: Path¶
- class StateRootResolution(**data)[source]¶
Bases:
BaseModelTyped outcome of resolving the storage state root.
Carries the platform user-data base and the effective
storage_rootthatSettingsdefaultscadrumo_local_storage_rootto. No run-mode or repository concept appears here: the product does not classify its own installation.- Parameters:
data (Any)
- platform_user_data_root: Path¶
- storage_root: Path¶
- live_state_root_inputs()[source]¶
Capture the running process’s state-root inputs.
Snapshots
platform, a copy ofos.environ, and the user’s home directory into a frozenStateRootInputsforresolve_state_root().- Return type:
- platform_user_data_root(inputs)[source]¶
Resolve the Cadrumo platform user-data directory for the given inputs.
Windows resolves under
%LOCALAPPDATA%(~/AppData/Localwhen the variable is unset or not absolute); macOS under~/Library/Application Support; every other platform under$XDG_DATA_HOME(~/.local/sharewhen unset or not absolute). The canonical product application directory name is appended to the resolved base.- Return type:
Path- Parameters:
inputs (StateRootInputs)
- resolve_state_root(inputs)[source]¶
Resolve the effective storage state root.
Unconditional: the store always lands under the platform user-data directory. Cadrumo is a tax-filing product and is blind to how it was installed — it never inspects the filesystem for a
pyproject.tomlor a.gitmarker to decide where a taxpayer’s encrypted state belongs. A repository is a development artefact with no meaning at runtime, and branching on one put regulated financial data in a location chosen by a source-layout guess.A developer who wants the store inside their checkout sets
CADRUMO_LOCAL_STORAGE_ROOT(the justfile does this), which wins over this default like any other operator override. That keeps the dev loop working through the ordinary configuration channel instead of through product code that detects its own environment.- Return type:
- Parameters:
inputs (StateRootInputs)
- default_storage_root()[source]¶
Return the
cadrumo_local_storage_rootdefault for the live process.Bound as the
Settingscadrumo_local_storage_rootdefault factory. Always the platform user-data storage directory — the product does not classify its installation. A developer overrides it withCADRUMO_LOCAL_STORAGE_ROOT.- Return type:
Path