Skip to content

contract

Encode the stable semantic-analysis phases, required metadata, host input constraints, and phase error boundaries that IRx guarantees before backend lowering begins.

Classes:

Functions:

PhaseErrorBoundary dataclass

PhaseErrorBoundary(
    phase: str,
    raises: str,
    surfaces: tuple[str, ...],
    summary: str,
)

Describe which category of failure belongs to which pipeline phase and how callers should interpret it. attributes: phase: type: str raises: type: str surfaces: type: tuple[str, Ellipsis] summary: type: str

SemanticContract dataclass

SemanticContract(
    stable_phases: tuple[SemanticPhase, ...],
    required_node_semantic_fields: tuple[str, ...],
    required_session_fields: tuple[str, ...],
    allowed_host_entrypoints: tuple[str, ...],
    allowed_host_inputs: tuple[str, ...],
    phase_error_boundaries: tuple[PhaseErrorBoundary, ...],
)

Collect the semantic phases, metadata requirements, host input constraints, and error boundaries that analysis guarantees to lowering and host compilers. attributes: stable_phases: type: tuple[SemanticPhase, Ellipsis] required_node_semantic_fields: type: tuple[str, Ellipsis] required_session_fields: type: tuple[str, Ellipsis] allowed_host_entrypoints: type: tuple[str, Ellipsis] allowed_host_inputs: type: tuple[str, Ellipsis] phase_error_boundaries: type: tuple[PhaseErrorBoundary, Ellipsis]

SemanticPhase dataclass

SemanticPhase(
    name: str,
    entrypoints: tuple[str, ...],
    guarantees: tuple[str, ...],
)

Describe one externally-visible stage in the semantic pipeline and the guarantees it establishes for later lowering. attributes: name: type: str entrypoints: type: tuple[str, Ellipsis] guarantees: type: tuple[str, Ellipsis]

get_semantic_contract

get_semantic_contract() -> SemanticContract

Expose the semantic contract that hosts and backend lowering may rely on before code generation begins. returns: type: SemanticContract

Source code in src/irx/analysis/contract.py
258
259
260
261
262
263
264
265
266
267
268
269
@public
@typechecked
def get_semantic_contract() -> SemanticContract:
    """
    title: Return the stable public semantic contract.
    summary: >-
      Expose the semantic contract that hosts and backend lowering may rely on
      before code generation begins.
    returns:
      type: SemanticContract
    """
    return _SEMANTIC_CONTRACT