cadrumo.domain.calculations.registry.remote_state_guard module

Fail-closed guard for live AEAT cross-reference surfaces.

This module uses LiveCrossReferenceDecision and RemoteOperation to enforce fail-closed access control.

class RemoteStateGuardModel(**data)[source]

Bases: BaseModel

Strict frozen base for remote-state guard records.

Parameters:

data (Any)

class RemoteStateGuardPolicy(**data)[source]

Bases: RemoteStateGuardModel

Policy attached to a live/static AEAT cross-reference decision.

id: str
evidence_tier: RemoteEvidenceTier
classification: CrossReferenceClassification
allowed_hosts: tuple[str, ...]
allowed_host_suffixes: tuple[str, ...]
allowed_read_paths: tuple[str, ...]
allowed_read_post_paths: tuple[str, ...]
allowed_browser_action_patterns: tuple[str, ...]
synthetic_data_allowed: bool
requires_authentication: bool
requires_aeat_authorization: bool
forbidden_actions: tuple[str, ...]
allows_gov_idp_hosts: bool
class RemoteOperation(**data)[source]

Bases: RemoteStateGuardModel

One candidate browser/network/local operation before execution.

kind: RemoteOperationKind
method: str | None
url: AnyUrl | None
action: str | None
class RemoteStateGuardResult(**data)[source]

Bases: RemoteStateGuardModel

Decision returned by the remote-state guard.

decision: RemoteGuardDecision
reason: str
policy_id: str
remote_state_policy_from_cross_reference(decision)[source]

Build the executable remote-state guard policy for a registry cross-reference.

A policy built here admits exactly the hosts its own surface declares and no sibling subdomains; see the note at the construction site for why the host-suffix widening is deliberately not applied to every policy.

Return type:

RemoteStateGuardPolicy

Returns:

The RemoteStateGuardPolicy derived from the cross-reference decision.

Parameters:

decision (LiveCrossReferenceDecision)

assert_remote_operation_allowed(policy, operation)[source]

Return an allowed decision or raise for forbidden AEAT remote state.

Return type:

RemoteStateGuardResult

Returns:

A RemoteStateGuardResult with an allowed decision.

Parameters:
assert_remote_operations_allowed(policy, operations, *, context='remote operation')[source]

Pre-flight an operation plan through the remote-state guard and return a tuple of RemoteOperation.

Return type:

tuple[RemoteOperation, ...]

Returns:

The validated operations as an immutable tuple.

Parameters:
evaluate_remote_operation(policy, operation)[source]

Evaluate one operation against the guard and return a RemoteStateGuardResult.

Return type:

RemoteStateGuardResult

Parameters: