Expand description
The canonical, version-agnostic IR.
§What this is for
Application code and user handlers see these types. They do not see a revision’s wire types, and they never choose a version at compile time. T08 adds per-revision codecs that lift the wire into this IR and lower it back out, so the same handler serves every revision and the bridge between them is pure data.
§The three properties everything here is built around
Superset. Every revision’s types are a subset of these. Fields a newer
revision added are Option and absent on older ones, so a 2024-11-05
value and a 2026-07-28 value are both representable, and the difference is
visible rather than typed away.
Self-describing requirements. Every value can report what it needs to be
expressed through required_features(). Lowering asks that question rather
than pattern-matching on a version, so adding a revision does not mean
touching every encoder — a new revision turns on the features it defines,
and the existing gates do the rest.
Lossless. Unmodelled fields land in an Extensions bag instead of
being dropped, and an unparseable value lands as Raw rather than
disappearing. The bridge’s lift(v, lower(v, ir)) == ir claim is only
meaningful because of this, and it is the property the crate exists for.
§The layering
mod features; // FeatureSet — what a value needs
mod json; // JsonObject — arbitrary JSON, validated once
mod extensions; // Extensions — the passthrough bag
mod content; // Content — content blocks
mod message; // IrMessage — the envelope
mod tool; // ToolResult — and the downgrade fallbackEach file holds one concern, and the dependency direction is downward:
content, tool, codec and lower use features, json and
extensions, and nothing uses content. message sits above the rest
and is the only place they are assembled. codec and lower are public
because the adapter layer implements their traits and a bridge reads the
reports those traits produce.
Re-exports§
pub use loglevel::Level as LogLevel;pub use loglevel::LevelError as LogLevelError;pub use lower::DegradeRule;pub use lower::Loss;pub use lower::LowerError;pub use lower::Lowering;pub use lower::TranslationReport;pub use lower::TranslationStep;
Modules§
- loglevel
LogLevel— the severity ladder anotifications/messagerecord carries.- lower
- Lowering — making an IR value expressible at a target revision, or refusing.
Structs§
- Annotations
- Annotations, added in
2025-03-26(PR #185). - Audio
Content - The audio block,
2025-03-26and later. - Downgrade
- A change lowering made to make a value expressible.
- Embedded
Resource - A resource’s contents, inline.
- Extensions
- Unmodelled fields, in
serde_json::Maporder. - Feature
Set - A set of features.
- GetPrompt
Result - What
prompts/getanswers with. - Image
Content {"type": "image", "data": "...", "mimeType": "..."}.- IrError
- An error result.
- IrNotification
- A notification. Never has an id, never gets a reply.
- IrParams
- The parameters of a request or notification.
- IrRequest
- A request. Expects exactly one result or error.
- IrResult
- A successful result.
- Json
Object - A JSON object, validated on construction.
- Method
Name - A method name, validated.
- Prompt
Message - One message of a
prompts/getresult. - Resource
Contents - One entry of a
resources/readresult’scontentsarray. - Resource
Icon - An icon for a resource link.
2025-11-25, SEP-973. - Resource
Link Content - A link to a resource,
2025-06-18and later (PR #603). - Text
Content {"type": "text", "text": "..."}.- Tool
Result - The result of calling a tool.
- Unknown
Content - A content block whose
typethis build does not know. - Unknown
Role - A role this build does not recognise.
Enums§
- Content
- A content block.
- Envelope
Error - An envelope this build could not lift.
- Extension
Value - The value of an unmodelled field.
- IrError
Code - A JSON-RPC error code.
- IrMessage
- Any message in either direction.
- Json
Object Error - Why a string is not a
JsonObject. - Method
Name Error - Why a method name is not a
MethodName. - Resource
Body - A resource’s body.
- Role
- Who a content block is meant for.
Traits§
- Codec
- Translates between one revision’s wire type and the canonical IR.
Functions§
- lift_
envelope - Lifts one wire envelope into the IR.
- lower_
envelope - Re-emits an IR message as a wire envelope.