Skip to content

Support forward-compatible read-side validation for wire protocols #3293

@turadg

Description

@turadg

Description

Endo Patterns currently describe the shape that is valid "now". This works well for authority boundaries and exact validation, but creates friction for wire protocols and published data streams that need forward compatibility.

Consider a published status object:

 const StatusShape = M.splitRecord(
   {
     phase: M.string(),
   },
   {
     progress: M.number(),
   },
 ); 

A publisher validates against StatusShape before writing to vstorage.

Later, the publisher evolves to include a new field:

 {
   phase: 'running',
   progress: 0.5,
   estimatedCompletion: 12345,
 } 

An older client using the same pattern to validate reads may reject the object, even though it understands all fields it depends on.

For wire protocols, producers and consumers often have different compatibility requirements:

  • Producers should emit the canonical schema.
  • Consumers should accept width-compatible extensions and ignore unknown fields.

Many schema systems support this distinction through "open" vs "closed" object validation.

Proposal

Provide a way to derive or express a read-side pattern that:

  • Requires all fields described by the pattern.
  • Continues validating optional fields described by the pattern.
  • Ignores additional unknown fields.

Possible APIs:

 allowExtraProperties(StatusShape) 

or

  M.openRecord(...) 

or another mechanism consistent with the existing Pattern design.

The goal is to support forward-compatible readers for wire protocols, vstorage data, durable state snapshots, and similar evolvable data formats without requiring duplicate schema definitions.

Motivation

Patterns currently serve both:

  1. Authority/interface validation.
  2. Data protocol validation.

The first often benefits from exact validation. The second often benefits from forward-compatible width subtyping.

Providing an explicit read-side validation mode would make protocol evolution easier while preserving strict validation where desired.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions