aeat.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.

class RemoteStateGuardPolicy(**data)[source]

Bases: RemoteStateGuardModel

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

Parameters:
  • id (str)

  • evidence_tier (Literal['official_source_guidance', 'executable_parity_evidence', 'layout_authority'])

  • classification (Literal['open_simulator', 'integration_test_service', 'public_read_surface', 'authenticated_read_surface', 'static_official_only', 'forbidden_stateful_surface'])

  • allowed_hosts (tuple[str, ...])

  • allowed_host_suffixes (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, ...])

id: str
evidence_tier: RemoteEvidenceTier
classification: CrossReferenceClassification
allowed_hosts: tuple[str, ...]
allowed_host_suffixes: 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, ...]
class RemoteOperation(**data)[source]

Bases: RemoteStateGuardModel

One candidate browser/network/local operation before execution.

Parameters:
  • kind (Literal['http', 'browser_action', 'local_workbook'])

  • method (str | None)

  • url (AnyUrl | None)

  • action (str | None)

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

Bases: RemoteStateGuardModel

Decision returned by the remote-state guard.

Parameters:
  • decision (Literal['allowed', 'blocked'])

  • reason (str)

  • policy_id (str)

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.

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: