cadrumo.application.user_profile.preflight module¶
Preflight service: which schema fields a given modelo/revision needs.
ProfilePreflightService inspects the schema’s model_selectors
against a UserProfileRecord and returns a
ProfilePreflightReport listing every required field that the
record does not yet carry.
- build_profile_preflight_requirement(path, *, schema, selector=None, grounding_index=None)[source]¶
Build one requirement row for a profile path, enriched with a label and grounding.
The shared builder behind every
ProfilePreflightRequirementthis package orapplication.modelo’s profile readiness gate constructs - the schema-required walk inProfilePreflightService.report(), its export-identity and conditional-requirement branches, and the modelo-work baseline/validation checks in_profile_readiness_gate.pyall route through this one function rather than maintaining parallel implementations.pathis reduced to its declaredsection.fieldform viasection_field_key()before lookup, so a repeatable-row path (activities.0.iae_epigraph) and a bare non-dotted validation code both resolve correctly. The label is the locale-catalogue operator label (falling back to the field’s declareddescription, never a raw dotted path) when the reduced path names a real schema field; otherwise it falls back toselectororpathitself. The schema-declaredlegal_refscome from the field definition; the registry-binding-derivedlegal_refsandmodeloscome fromgrounding_indexwhen the reduced path is a knownsource = "profile"binding key. A path absent from either source contributes nothing to that source - never a fabricated value.modelosis always the grounded registry union, never the modelo the caller happens to be checking - the two are different facts and must not be conflated under one field.- Return type:
- Parameters:
path (str)
schema (ProfileSchemaDefinition)
selector (str | None)
grounding_index (Mapping[str, ProfileKeyGrounding] | None)
- format_profile_preflight_requirement(requirement)[source]¶
Render one requirement row as
label (legal_ref, legal_ref).The single operator-facing rendering of a missing profile requirement, shared by every surface that names one: the modelo work readiness gate’s refusal, the overview calendar/agenda/backlog refusals, and the data inventory checklist’s unresolved-coefficient warning.
Falls back to the bare label when the field carries no legal grounding - never a raw dotted path once a label is available, and never an invented citation when none is declared.
- Return type:
- Parameters:
requirement (ProfilePreflightRequirement)
- format_profile_selector_requirements(selectors, *, schema, grounding_index=None)[source]¶
Render declared selector tokens as grounded requirement text, in order.
Bridges the surfaces that hold a
model_selectorsTOKEN - a deadline-engine gating key, a registry binding’s consumed profile key - rather than asection.fieldpath, which is whatbuild_profile_preflight_requirement()resolves.A token the schema resolves to exactly one field is rendered as that field’s operator label with its legal grounding. A token the schema does not resolve - because it names no field, because two fields declare it, or because it belongs to another namespace entirely, such as a warning code that is not a profile field at all - is passed through unchanged. Callers mix both kinds in one stream, and a token rendered verbatim is the behaviour that surface already has, whereas a guessed label would be confidently wrong.
- Return type:
- Parameters:
schema (ProfileSchemaDefinition)
grounding_index (Mapping[str, ProfileKeyGrounding] | None)
- format_profile_path_requirements(paths, *, schema, grounding_index=None)[source]¶
Render profile PATHS as grounded requirement text, in order.
The path-shaped sibling of
format_profile_selector_requirements(). The distinction is not cosmetic and the two are not interchangeable: a registry binding names the profile fact it consumes by itssection.fieldPATH, whereas the deadline engine’s completeness gate names its fields by their declaredmodel_selectorsTOKEN. Routing binding keys through the selector lookup resolves nothing, so every key passes through unchanged and the rendering is silently a no-op.build_profile_preflight_requirement()already reduces a path to its declared form, so a row-indexed path resolves here too. A path naming no schema field - a derived-selector pattern expanded for a filing year, for instance - keeps its own text, since there is no label to show for it.- Return type:
- Parameters:
schema (ProfileSchemaDefinition)
grounding_index (Mapping[str, ProfileKeyGrounding] | None)
- class ProfilePreflightService(*, schema)[source]¶
Bases:
objectResolve required profile selectors for a given
(modelo, revision, year, period).The service inspects the loaded schema’s
model_selectorsandschedule_predicatesdeclarations. Today every required field whosemodel_selectorsreference the target modelo is considered required; revision-specific filtering will land alongside the registry-time selector inventory work.- Parameters:
schema (ProfileSchemaDefinition)
- report(*, record, modelo, revision_id, period, revision=None, operation=None)[source]¶
Compute missing required profile fields for the given filing context.
Walks every section and field in the schema. A field is considered required for this filing when
field.requiredis true and at least one of itsmodel_selectorshas the prefixmodelo_<modelo>. Facts already present onrecordare excluded from the missing list.- Parameters:
record (
UserProfileRecord) – The caller’s currentUserProfileRecord.modelo (
str) – Numeric modelo identifier (e.g."303").revision_id (
TypeAliasType) – Revision tag from the registry (e.g."2024-0A").period (
Period) – Typed filing period.revision (
ModeloRevision|None) – OptionalModeloRevisionwhose export layouts contribute filing-grade declarant identity requirements.operation (
PinnedAuthorityOperation|None) – Optional pinned authority operation used to union each missing field’s grounding with every consumingsource = "profile"registry binding’slegal_refsand modelos, viabuild_profile_grounding_index(). When omitted, grounding falls back to the schema field’s ownlegal_refsonly - nothing is invented.
- Return type:
- Returns:
A
ProfilePreflightReportwithready=Truewhen all required fields are present, orready=Falsewith themissinglist populated.per_operation_requirements_assessedreports whether the per-modelo walk described above selected any field at all. The shipped schema declares groundedmodelo_selectors only for Modelo 036, 100 and 303, and among those onlyidentity.tax_id(Modelo 100) is also schema-required- every other tokenised field is optional, so it is never selected by this walk. The flag is therefore true for Modelo 100 and false for every other modelo, including 036 and 303, wherereadyreflects only the export-identity and conditional checks. A false value means nothing schema-required was examined for that modelo; it MUST NOT be rendered as a clean bill of health.