Technical foundation for Covenant's sovereign AI infrastructure

Model Data Language (MDL)

Type-Safe LLM Communication

Structured, validated interfaces for language models. Integrated into Conduit.


Overview

MDL transforms LLMs from string-in/string-out interfaces into type-safe, validated APIs. Define schemas in Python. MDL compiles them to model-safe specifications and validates all payloads automatically.

Key differentiator: Guaranteed structured outputs. If MDL returns an object, it conforms to your schema. No parsing errors in production.


The Problem

Traditional LLM interaction:

response = llm.chat("Extract title, author, date from this article")

# Returns: "The title is 'AI Revolution', written by John Smith on March 15, 2024"

Now you must:

  1. Parse natural language to extract fields
  2. Handle format variations ("Title:", "The title is...", etc.)
  3. Validate data types (is "March 15" a date or string?)
  4. Handle missing fields gracefully
  5. Catch malformed responses

This is fragile, error-prone, and scales poorly.


The Solution

MDL establishes a contract:

1. Define schema in Python

2. MDL compiles to model specification

3. LLM outputs conforming JSON

4. MDL validates and deserializes to typed object

from dataclasses import dataclass

from typing import List

@dataclass

class ArticleInput:

text: str

@dataclass

class ArticleOutput:

title: str

author: str

date: str

tags: List[str]

# Guaranteed valid ArticleOutput or error

result = block(

model_id="Qwen/Qwen3-4B",

input=ArticleInput(text="..."),

output=ArticleOutput,

)

print(result.title) # Typed string

print(result.tags) # Typed List[str]


How It Works

Schema Definition

Use Python dataclasses to define input and output structures:

from dataclasses import dataclass

from typing import List, Optional

@dataclass

class Input:

query: str

context: Optional[str] = None

@dataclass

class Output:

answer: str

confidence: float

sources: List[str]

Compilation

MDL compiles dataclasses into model-safe type hints:

Input schema → Prompt specification

Output schema → JSON structure specification + validation rules

The model receives clear structural requirements. MDL enforces them on response.

Validation

Every response is validated before returning:

  • Missing fields → Error raised
  • Wrong types → Error raised
  • Malformed JSON → Error raised with retry option
  • Valid response → Typed object returned

If MDL returns an object, it's guaranteed valid.


Usage with Conduit

MDL is integrated directly into Conduit's block interface:

from conduit.runtime import LMLiteBlock

block = LMLiteBlock(models=[...])

# Option 1: Typed MDL interface

result = block(

model_id="Qwen/Qwen3-4B",

input=MyInput(query="..."),

output=MyOutput,

)

# Option 2: OpenAI-style messages (no MDL)

result = block(

model_id="Qwen/Qwen3-4B",

messages=[{\"role\": \"user\", \"content\": \"Hello\"}],

)

Both interfaces work. MDL provides type safety; messages provide flexibility.


Type Support

Primitive Types

  • str, int, float, bool

Complex Types

  • List[T] - Arrays of any supported type
  • Optional[T] - Nullable fields with defaults
  • Dict[str, T] - Key-value mappings

Nested Schemas

@dataclass

class Address:

street: str

city: str

@dataclass

class Person:

name: str

address: Address # Nested dataclass


Error Handling

MDL provides structured error handling:

try:

result = block(input=inp, output=OutputSchema)

except ValidationError as e:

# Schema violation - missing field, wrong type

print(e.field, e.expected, e.received)

except ParseError as e:

# Malformed JSON from model

print(e.raw_response)

Retry Logic

For transient failures, MDL supports retry with correction prompts:

result = block(

input=inp,

output=OutputSchema,

max_retries=3,

)


Benefits

Before MDLWith MDL
String parsingTyped objects
Runtime errorsCompile-time schemas
Hope it worksGuaranteed valid
Fragile regexStructural validation
Manual extractionAutomatic deserialization

Specifications

SpecValue
Schema formatPython dataclasses
SerializationJSON
Type systemPython type hints
Model agnosticAny instruction-following LLM
ValidationAutomatic on all responses

→ Conduit Framework→ LM Lite Runtime