cadrumo.application.auth.apoderado_flow module

The paged apoderado-representation flow hosted by the apoderado door.

Apoderamiento representation is NOT a profile fact: it persists in the ApoderadoService’s own encrypted namespace, separate from the taxpayer profile record. The CLI door therefore hosts these pages over an in-memory-only FlowState (FlowMode MODIFY, checkpointing declared UNAVAILABLE in both modes) and hands the reviewed answers to ApoderadoService.configure() at commit – the substrate never mints a profile fact for this flow, and there is no create-mode checkpoint that could write one.

Two pages compose the flow: the represented party’s tax identifier (validated through the authority-aware cadrumo.domain.calculations.registry.tax_id_runtime.validate_runtime_identity() authority, the same authority every identity page binds – never a second identifier implementation) and the granted scope set (a CHECKBOX over the live ApoderamientosCatalogue). Every copy slot is an existing locale-catalogue reference resolved at render time; the flow authors no literal prose.

APODERADO_FLOW_ID

Flow, section, and page ids. Answers key the canonical map by these bare page ids.

REPRESENTED_NIF_VALIDATOR_ID

Registered id of the per-answer represented-party identity validator.

class ApoderadoFlowAnswers(**data)[source]

Bases: BaseModel

The typed answer shape the apoderado flow collects.

Carried on the FlowDefinition as its declared answers_model. scopes is the CHECKBOX page’s canonical comma-joined token string; apoderado_answers_from_state() splits it into the scope-token tuple ApoderadoService.configure() validates.

The substrate never validates answers against this model: it is a declarative slot only, and ApoderadoService.configure remains the single validation and persistence authority for both transports.

Parameters:

data (Any)

represented_nif: str
scopes: str
build_apoderado_flow_definition(catalogue)[source]

Return the two-page apoderado representation flow for catalogue.

The scope CHECKBOX choices are derived live from the supplied ApoderamientosCatalogue, so a catalogue revision that adds a scope surfaces it as a choice without a code change here. Every page’s domain_key is None: an apoderado answer binds to no profile schema path, because representation is not a profile fact – it commits to ApoderadoService.configure().

Return type:

FlowDefinition

Parameters:

catalogue (ApoderamientosCatalogue)

apoderado_answers_from_state(state)[source]

Project a committed flow state into (represented_nif, scope_tokens).

The scopes CHECKBOX canonical answer is a comma-joined token string; it is split back into the ordered token tuple ApoderadoService.configure() validates against the catalogue. The represented-nif token is returned verbatim for the same service call – the service remains the single validation and persistence authority.

Return type:

tuple[str, tuple[str, ...]]

Parameters:

state (FlowState)

run_apoderado_flow(service, *, bucket_id, input=None, output=None)[source]

Drive one apoderado door and persist its reviewed answer atomically.

The CLI supplies the real service and leaves prompt devices unbound for an operator terminal. Headless callers bind real prompt-toolkit devices; the same line frontend, flow validators, and service writer then execute with no callback substitute or post-flow persistence step.

Return type:

ApoderadoConfiguration

Parameters: