Papers
Topics
Authors
Recent
2000 character limit reached

Typed Web Interfaces

Updated 1 January 2026
  • Typed web interfaces are schema-driven contracts that bind structured messages to explicit types like JSON Schema and TypeScript interfaces.
  • They integrate formal specification languages with rigorous runtime validation to enforce both syntactic and semantic constraints in web communications.
  • They enable robust, type-safe interactions in diverse applications such as web world models, MPST-based apps, and cloud service pipelines.

Typed web interfaces are schema-driven contracts that bind the semantics of structured messages and state representations in web-based systems to explicit schema types, such as JSON Schema or TypeScript interfaces. They ensure that all programmatic interactions—whether between human users, LLM agents, or microservices—adhere to well-defined syntactic and semantic constraints. Typed web interfaces serve as the connective tissue uniting deterministic, code-governed logic with high-level generative or event-driven behaviors, and are foundational to both modern web world models and type-safe web communication frameworks.

1. Formalism and Core Principles

The defining characteristic of a typed web interface is the imposition of a schema language (TypeScript interface, JSON Schema, MDL) on all message or state representations exposed by web APIs or protocols. The schema specifies a set of syntactic and semantic requirements that valid payloads and states must satisfy. In the context of persistent interactive agents and web-based world models, the world state at time tt is partitioned as St=(Stϕ,Stψ)S_t = (S_t^\phi, S_t^\psi), where StϕS_t^\phi denotes a deterministic physics layer (code-governed, pure logic) and StψS_t^\psi is a stochastic imagination layer (LLM-generated, unconstrained except by schema) (Feng et al., 29 Dec 2025).

Before any step completes, generative outputs yy are validated against the schema via a predicate valid(y;Schema)∈{True,False}\mathrm{valid}(y; \mathrm{Schema}) \in \{\mathrm{True}, \mathrm{False}\}. Only schema-conformant values propagate into the system; violations trigger fallback templates or error handling. In web communication settings, the types induced by the interface ensure that endpoints can only consume, produce, or manipulate values compatible with protocol specifications, preempting a class of mismatches and runtime errors (Miu et al., 2020, Miu et al., 2021).

2. Interface Specification Languages

Several formal and practical languages are used to author and enforce typed web interfaces:

  • TypeScript Interfaces: Native to modern web development, TypeScript interfaces succinctly express the shape and types of permitted payloads. For example:
    1
    2
    3
    4
    5
    6
    
    interface Planet {
      id: string;
      biome: BiomeType;
      hazards: HazardType[];
      narrative: string;
    }
    All outputs by an imagination layer or agent must satisfy this contract (Feng et al., 29 Dec 2025).
  • JSON Schema: Independently of programming languages, JSON Schema describes allowed structures for JSON-encoded data. It is suitable for runtime validation of API inputs and outputs.
  • Message Definition Language (MDL): Used to specify extensible records, variants, and their subtyping relationships, supporting width subtyping, row polymorphism, and Boolean guards on labels. MDL terms, e.g.,

{ name(true):string,  age(p):int  ∣  r}\{\, \text{name}(true):\text{string},\; \text{age}(p):\text{int}\;|\;r \}

allow flexible service composition and automatic interface adaptation, crucial for cloud-service pipelines (Zaichenkov et al., 2016).

3. Enforcement, Validation, and Guarantees

Schema Validation

Typed web interfaces rely on systematic schema validation. For LLM-driven imagination layers, generation is constrained at the output: the engine only accepts yy if valid(y;Schema)=True\mathrm{valid}(y; \mathrm{Schema}) = \mathrm{True}, else a deterministic fallback ensures system robustness (Feng et al., 29 Dec 2025).

Compile-Time Type-Checking

In statically typed frameworks (TypeScript, PureScript), endpoint types and communication APIs are generated algorithmically from protocol specifications or service code. Only conformant implementations can be compiled and run, ensuring communication safety and deadlock-freedom by construction (Miu et al., 2020, King et al., 2019, Miu et al., 2021).

Subtyping and Extensibility

Type systems with support for row polymorphism, width subtyping, and variants enable composable, extensible interfaces. Service interfaces automatically adapt via constraint solving that ensures sender/receiver subtyping, i.e., outputs T1T_1 from service AA are validated so T1⊑T2T_1 \sqsubseteq T_2 for receiver BB's expected input type T2T_2 (Zaichenkov et al., 2016).

4. Application Domains and Case Studies

Typed web interfaces underpin a broad spectrum of frameworks and real-world systems:

System / Domain Interface Form Role of Typing
Web World Models TypeScript/JSON Schema Mediates code-physics and LLM imagination; enforces logical separation and error handling (Feng et al., 29 Dec 2025)
MPST-based Web Apps TypeScript APIs Auto-generated protocol APIs for browsers/servers; ensures message order and content (Miu et al., 2020, Miu et al., 2021)
Cloud Service Pipelines MDL Configures service links and flow-inheritance with subtyping and polymorphism (Zaichenkov et al., 2016)

Examples:

  • In the "Infinite Travel Atlas," beacons are generated as TypeScript interfaces, hashed on coordinates to ensure deterministic exploration and validated for crucial fields (e.g., itinerary) (Feng et al., 29 Dec 2025).
  • MPST toolchains like STScript and PureScript session encoders capture EFSM state transitions as host-language types and combinators: only correct usage of send/receive/branch actions will type-check, leading to communication-safe web apps (Noughts and Crosses, Battleship) (Miu et al., 2020, King et al., 2019, Miu et al., 2021).
  • Cloud service compositions leverage MDL’s subtyping and row-variable unlocking to propagate necessary data fields (flow-inheritance) along chains, configured globally but compiled safely in isolation (Zaichenkov et al., 2016).

5. Design Principles and Patterns

Several architectural and methodological principles emerge:

  1. Separation of Concerns: Deterministic code updates (physics layers, business logic) and stochastic/generative steps (imagination, LLM, or external event handling) are strictly separated. Typed interfaces encode the contract between them.
  2. Syntactic and Semantic Guardrails: Enforcement of schema types precludes runtime mismatches, missing fields, or hallucinated attributes outside the supported vocabulary. This is crucial for error prevention in both LLM-imagined worlds and statically typed communication protocols.
  3. Determinism and Object Permanence: By hashing context to LLM seeds or configuring services via topological constraints, consistency and repeatability are achieved without per-entity storage, yielding O(1)O(1) memory per request (Feng et al., 29 Dec 2025).
  4. Graceful Degradation: If validation fails or upstream generators are unreachable, fallback code-templates or default values are injected, maintaining interface invariants and continuity (Feng et al., 29 Dec 2025).
  5. Linearity and Affinity: In session-typed systems, each action (send/receive/branch) occurs exactly once (linearity on server; affinity on browser/UI endpoints), enforced by the host language’s typechecker (King et al., 2019, Miu et al., 2020).

6. Toolchains, Integration, and Developer Ergonomics

Typed web interfaces integrate with mainstream web toolchains, offering:

The approach encourages immediate iteration on interface contracts, rapid detection of model/API mismatches, and robust extensibility for infinite world or microservice scenarios.

7. Limitations and Open Challenges

There are technical boundaries that delimit current deployments:

  • On the browser, affinity (single send per UI event) is enforced, but full linearity (all branches handled in UI) is only partially captured (Miu et al., 2020).
  • Dynamic protocol reconfiguration or highly polymorphic UI flows require regeneration of type-level protocol encodings and possible manual refactoring (King et al., 2019).
  • Asynchronous event and connection lifecycle handling often requires protocol-augmented state machines or explicit hooks beyond the session-typed layer (Miu et al., 2020, Miu et al., 2021).
  • Large-scale protocols may generate many states and combinators, impacting maintainability and performance at the component level (Miu et al., 2021).

Despite these, typed web interfaces remain the principal mechanism by which correctness, robustness, and open-ended extensibility are simultaneously realizable in complex web and agentic systems.

Whiteboard

Topic to Video (Beta)

Follow Topic

Get notified by email when new papers are published related to Typed Web Interfaces.