Module format

Module format 

Source
Expand description

Unified Output Format Semantics (Task 3)

This module provides a single taxonomy for output formats with:

  • Clear layer boundaries (WireFormat vs ContextFormat)
  • No lossy coercions (round-trip property preserved)
  • Explicit conversion with error handling

§Problem Solved

Previously, there were two competing format universes:

  • Client: Soch | Json | Columnar
  • Context: Soch | Json | Markdown | Text (with Text -> Soch coercion)

This created semantic drift and violated the round-trip property: decode(encode(x)) = x should hold for all formats.

§Solution

Separate format enums with explicit conversions:

  • WireFormat: For query results sent to clients
  • ContextFormat: For LLM context packaging

Conversions between them use TryFrom and can fail, making incompatibilities explicit rather than silent.

Structs§

FormatCapabilities
Capabilities of a format
FormatConversionError
Error when format conversion fails

Enums§

CanonicalFormat
Canonical format identifier for AST nodes.
ContextFormat
Output format for LLM context packaging.
WireFormat
Output format for query results sent to clients.