LLM-Structured Diagnostic Schema (LSDS).
Per ADR-006 §9, LSDS is the primary compiler diagnostic format. Renderers
(terminal, LSP, MCP) consume LSDS and produce human-readable / machine-
readable output. LSDS is the source of truth — text strings, LSP
Diagnostic payloads, and MCP tool responses are all derived from it.
Crate layout
- [
Diagnostic] — the canonical struct. JSON-serializable. Stable across versions per the ADR. - [
Severity], [Location], [TypeWitness], [SuggestedFix], [ContextWindow] — sub-structures referenced fromDiagnostic. - [
render] — built-in renderers. Currently:- [
render::terminal] — human-readable text output. LSP and MCP renderers are reserved for subsequent Phase 2 sessions.
- [
Stability contract
Field names in [Diagnostic] (and nested types) are part of the public
wire format. They must not be renamed or reordered without bumping the
schema version. Add new optional fields only; never remove or rename
existing ones.
The schema version is exposed as [SCHEMA_VERSION].
Cross-references
- ADR-006 §9 (
docs/adr/006-value-and-memory-model.md) — binding spec. - ADR-006 §13.5 success metric — average payload ≤500 cl100k tokens.
crates/shape-vm/src/mir/analysis.rs—BorrowError/BorrowErrorKind/BorrowErrorCode, the source for the B-series diagnostics.