COVENANT LABS · THE KERNEL · MODEL DATA LANGUAGE

Model Data Language

Type-safe model programming. If MDL returns an object, it conforms to your schema.

K.1

The problem

A raw model call takes a string and returns a string.

response = llm.chat("Extract title, author, date from this article")
# "The title is 'AI Revolution', written by John Smith on March 15, 2024"

The caller is left to parse prose: extract fields from natural language, absorb format drift ("Title:", "The title is..."), decide whether "March 15" is a date or a string, handle missing fields, catch malformed responses. It is fragile and it does not scale.

K.2

The contract

MDL replaces parsing with a contract. Schemas are Python dataclasses. MDL compiles them to model-safe specifications and validates every payload.

1. Define the schema in Python
2. MDL compiles it to a model specification
3. The model outputs conforming JSON
4. MDL validates and deserializes to a 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 an error
result = block(
    model_id="Qwen/Qwen3-4B",
    input=ArticleInput(text="..."),
    output=ArticleOutput,
)

print(result.title)  # typed str
print(result.tags)   # typed List[str]

K.3

Compilation and validation

input schema  → prompt specification
output schema → JSON structure specification + validation rules

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

RESPONSERESULT
Missing fieldError raised
Wrong typeError raised
Malformed JSONError raised, retry available
Valid responseTyped object returned

K.4

Type system

TYPESUPPORT
str, int, float, boolPrimitives
List[T]Arrays of any supported type
Optional[T]Nullable fields with defaults
Dict[str, T]Key-value mappings
dataclassNested schemas, fields may be schemas themselves
@dataclass
class Address:
    street: str
    city: str

@dataclass
class Person:
    name: str
    address: Address  # nested dataclass

K.5

Inside 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.

CONDUIT · OUTPUT 003 →

K.6

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 the model
    print(e.raw_response)

For transient failures, MDL retries with correction prompts.

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

K.7

Specifications

SPECVALUE
Schema formatPython dataclasses
SerializationJSON
Type systemPython type hints
Model supportAny instruction-following model
ValidationAutomatic on every response