cadrumo.application.modelo.profile_readiness_gate module¶
Profile readiness gate for filing-grade modelo work.
Loads the active domain.user_profile.values.UserProfileRecord, builds a
application.user_profile.commands.ProfilePreflightReport, projects
local-work applicability through domain.deadlines.models.TaxpayerProfile,
and raises application.modelo.action_errors.ModeloProfileReadinessError before
filing-grade work proceeds when required profile facts are missing. The
revision-specific preflight branch may receive a ModeloRevision that
has already been resolved by an operator-facing readiness surface. The same gate
also refuses Modelo 130 and Modelo 303 target periods whose date span ends
before the profile’s censo.activity_start_date; those pre-activity periods
have no filing obligation and must not produce stale work, calculation,
verification, filing, or export state.
See also
require_profile_ready_for_work_unit():Replays the same readiness checks for an existing
WorkUnit.application.user_profile.commands.ProfilePreflightReport:User-profile preflight result consumed by this application gate.
- BLOCKING_APPLICABILITY_VERDICTS¶
Shared with
work_create_policy, which runs the same applicability block ahead of work-unit provisioning; kept public so that cross-module use is a declared contract rather than a private-symbol reach.
- modelo_work_profile_baseline_missing_paths(record, *, modelo=None)[source]¶
Return profile facts required before filing-grade work for a target.
Without a target this returns the profile-status baseline: every non-natural entity, an economically active natural person, and an incompletely declared natural person need an activity description. A natural person with declared non-business income needs only a tax id. Targeted Modelo 100 checks use the same distinction; all other targets retain the existing censo-activity baseline.
- Parameters:
record (
UserProfileRecord) – Activedomain.user_profile.values.UserProfileRecordprojected into schema-path values.modelo (
str|None) – Optional target modelo used to resolve conditional baseline requirements.
- Return type:
- modelo_work_profile_baseline_validation_issues(record)[source]¶
Return profile-status issues for universal modelo-work baseline fields.
- Parameters:
record (
UserProfileRecord) – Activedomain.user_profile.values.UserProfileRecordchecked against the filing-grade baseline.- Return type:
- Returns:
Tuple of
application.user_profile.commands.ProfileValidationIssueinstances for missing filing-grade baseline facts.
- modelo_work_profile_preflight_report(*, record, modelo, revision_id, filing_year, period, revision=None, resolve_revision_when_missing=True, profile_decode_context, operation)[source]¶
Return the profile-field report enforced by the modelo work creation gate.
This combines the filing-grade baseline that every modelo work unit needs with the modelo/revision-specific profile selectors. Public readiness surfaces consume this function so they cannot claim profile readiness before
application.modelo.work_lifecycle.create_work_unit()would reject the same active profile.- Parameters:
record (
UserProfileRecord) – Activedomain.user_profile.values.UserProfileRecord.modelo (
str) – Modelo code being checked.revision_id (
TypeAliasType) – Registry revision identifier for the target modelo work.filing_year (
int) – Filing year for the target period.period (
Period) – Targetcore.period.Periodused for registry revision resolution and profile selector evaluation.revision (
ModeloRevision|None) – OptionalModeloRevisionsupplied when the caller has already resolved the target revision.resolve_revision_when_missing (
bool) – Whether to resolve the registry revision whenrevisionis not supplied.profile_decode_context (
ProfileDecodeContext) – Decode context from the caller-held authority operation used to interpret the encrypted profile.operation (
PinnedAuthorityOperation) – Caller-held pinned authority operation used to select the target revision and profile schema.
- Return type:
- Returns:
application.user_profile.commands.ProfilePreflightReportcombining baseline, validation, and modelo/revision-specific missing requirements.
- profile_activity_start_date(record)[source]¶
Read the effective
censo.activity_start_datethrough the canonical projection.Which of several live facts at one path is effective is owned by
application.user_profile.projections.record_to_path_values(), which orders them byvalid_fromso the chronologically last window wins. Scanning declaration order answers a different question: a record whose later window was declared first resolves to the earlier date, and because this value decides whether a target period is refused as pre-activity, the disagreement fails open — a period before the effective activity start is admitted for work.Core types:
UserProfileRecord.- Return type:
- Parameters:
record (UserProfileRecord)
- modelo_applicability_refusal(*, record, bucket_id, modelo, operation)[source]¶
Return the local-work applicability refusal for a target, if any.
- Parameters:
record (
UserProfileRecord) – Activedomain.user_profile.values.UserProfileRecordprojected into taxpayer facts for the modelo applicability check.bucket_id (
str) – Active profile bucket identifier included in the refusal context.modelo (
str) – Modelo code being checked.operation (
PinnedAuthorityOperation) – Caller-held pinned operation for applicability facts.
- Return type:
- pre_activity_period_refusal(*, record, bucket_id, modelo, filing_year, period)[source]¶
Return the pre-activity lifecycle refusal for a target, if any.
- Parameters:
record (
UserProfileRecord) – Activedomain.user_profile.values.UserProfileRecordcarrying the profile facts used to resolvecenso.activity_start_date.bucket_id (
str) – Active profile bucket identifier included in the refusal context.modelo (
str) – Modelo code being checked.filing_year (
int) – Filing year for the target period.period (
Period) – Targetcore.period.Periodwhose date span is compared against the profile activity-start date.
- Return type:
- load_modelo_work_profile(*, bucket_id, profile_decode_context)[source]¶
Load the bucket’s profile for modelo work, or
Nonewhen no session serves it.- Return type:
- Parameters:
bucket_id (str)
profile_decode_context (ProfileDecodeContext)
- require_profile_ready_for_modelo_work(*, bucket_id, modelo, revision_id, filing_year, period, enforce_applicability=True, profile_decode_context, operation, profile=None)[source]¶
Refuse filing-grade modelo work when the active profile is not eligible.
Loads the bucket’s
domain.user_profile.values.UserProfileRecord, evaluates modelo-specific profile requirements throughapplication.user_profile.commands.ProfilePreflightReport, and then applies the pre-activity period check for lifecycle modelos whose obligation starts atcenso.activity_start_date. Unlikerequire_existing_profile_baseline_ready_for_modelo_work(), this gate passes the live registry authority through both the baseline/validation refusal and the full preflight report, so a raisedModeloProfileReadinessErrorcarries reallegal_refsfor every missing field the registry grounds - the memoisedbuild_profile_grounding_indexkeeps the added per-call cost bounded on this hot path.profileis the record the calling command already loaded for this target; when omitted the gate loads it. Returns the record the gate checked, so a caller that let the gate load it passes that same record on instead of decrypting it again.- Return type:
- Parameters:
bucket_id (str)
modelo (str)
revision_id (RevisionId)
filing_year (int)
period (Period)
enforce_applicability (bool)
profile_decode_context (ProfileDecodeContext)
operation (PinnedAuthorityOperation)
profile (ModeloWorkProfile | None)
- require_existing_profile_baseline_ready_for_modelo_work(*, bucket_id, modelo, filing_year, period, enforce_applicability=True, profile_decode_context, operation, profile=None)[source]¶
Refuse plainly incomplete existing profiles before registry work.
This early gate is used by
application.modelo.work_lifecycle.create_work_unit()before the registry revision and period are validated. It catches missing baseline profile facts, local-work applicability refusals, and pre-activity lifecycle periods without requiring a resolvableModeloRevision. Missing profiles still pass through so the later full readiness gate can raise the canonical missing-profile error.profileis the record the calling command already loaded; when omitted the gate loads it.- Return type:
- Parameters:
bucket_id (str)
modelo (str)
filing_year (int)
period (Period)
enforce_applicability (bool)
profile_decode_context (ProfileDecodeContext)
operation (PinnedAuthorityOperation)
profile (ModeloWorkProfile | None)
- require_profile_ready_for_work_unit(work_unit, *, enforce_applicability=True, profile_decode_context, operation, profile=None)[source]¶
Run the profile readiness gate for an existing work unit.
Calculation, verification, filing, and export services call this wrapper so a previously created
WorkUnitis rechecked against the currentdomain.user_profile.values.UserProfileRecordbefore any filing-grade mutation proceeds. Returns the checked record.- Return type:
- Parameters:
work_unit (WorkUnit)
enforce_applicability (bool)
profile_decode_context (ProfileDecodeContext)
operation (PinnedAuthorityOperation)
profile (ModeloWorkProfile | None)