MindIR Compact (MIC)

🛡️ Patent Pending— STARGA Inc. US Provisional Patent Application

MIC is a family of compact serialization formats for Mind IR graphs, designed for minimal token usage, fast parsing, and deterministic output.

📐 Current canon (mindc 0.10.x, RFC 0021 steps 1–3):

  • mic@1 — canonical text serialisation of IRModule. RFC 0001 fixed-point form; the evidence-chain trace_hash is computed over mic@3 binary (RFC 0016 GAP-1, re-anchored 2026-05-31).
  • mic@3 — canonical binary serialisation of the same IRModule. Shipped behind mindc --emit-mic3; round-trips to/from mic@1.
  • mic@2 / mic@2.1 — preserved back-compat lanes; mic@2.1 carries the MAP (Metadata-Attachment-Pair) extension (RFC 0014) for evidence chains on compact IR. RFC 0021 step 5 demotes both to mind-model@2 (a model-graph artifact, no longer an IR contract).

Format Versions

mic@1 (Canonical text)

Canonical text serialisation of IRModule with explicit node IDs and verbose opcodes.

  • Explicit IDs: N0, N1, N2
  • Verbose ops: add, matmul, relu
  • Bracket syntax: [f32;3,4]

mic@2 (Back-compat dataflow text)

Compact text format for the lighter Graph dataflow shape with implicit IDs and compact opcodes. Not the compiled-artifact IR; slated for demotion to mind-model@2 (RFC 0021 step 5).

  • Implicit IDs by order of appearance
  • Compact ops: +, m, r
  • Space syntax: f32 3 4
Learn more →

MIC-B v2 (Back-compat binary)

Compact binary format for the Graph dataflow shape with ULEB128 varints. The canonical binary IR is mic@3 (below); MIC-B v2 is back-compat and slated for demotion to mind-model@2 (RFC 0021 step 5).

  • ~4x smaller than mic@2 text
  • Direct memory mapping possible
  • Deterministic byte output
Learn more →

Format Detection

Automatic format detection by magic bytes or header.

use mind::ir::detect_format;

match detect_format(data) {
    MicFormat::Mic3 => parse_mic3(..),  // canonical binary
    MicFormat::Mic2 => parse_mic2(..),  // back-compat
    MicFormat::MicB => parse_micb(..),  // back-compat
    MicFormat::Mic1 => parse_mic(..),   // canonical text
    _ => Err("unknown format"),
}

New since v0.7.0

mic@2.1 (MAP carrier)

Same on-the-wire shape as mic@2, plus a Metadata-Attachment-Pair extension that carries the evidence-chain attestation (determinism / substrate / toolchain / trace_hash).

  • Defined by spec/mic/mic2.1-spec.md (RFC 0014)
  • MAP attaches via the 0x4D sentinel epilogue
  • Consumed by mindc --emit-evidence

mic@3 (Binary IRModule)

Canonical binary serialisation of the full IRModule. Round-trip equivalent to mic@1 text. Carries an evidence MAP epilogue in the same form as mic@2.1.

  • Magic: MIC3
  • RFC 0021 steps 1–3 (shipped); 4–6 in progress
  • Emit: mindc --emit-mic3 / --emit-evidence

Format Comparison

FormatTokensBytesvs JSONParse SpeedUse Case
JSON2781,133baseline5.31 µsLegacy interchange
TOML1516071.8x137.06 µsConfig files
TOON672694.1x2.67 µsCompact text
mic@1522095.3x2.26 µsMind IR (text)
mic@22711110.3x~1.8 µsLLM prompts, git diffs
MIC-B v2-90most compact~0.5 µsStorage, network

Benchmark: 6-node neural network layer (param, matmul, add, relu). See BENCHMARK_RESULTS.md for methodology, or run mic_map_benchmark_v2.py to reproduce all numbers locally.

Feature Comparison

FeatureJSONTOONmic@1mic@2MIC-B
Human readableYesYesYesYesNo
Git-friendlyNoPartialYesYesNo
DeterministicNoNoYesYesYes
LLM-optimizedNoNoPartialYesN/A
Binary formatNoNoNoNoYes
Implicit IDsNoNoNoYesYes

Side-by-Side Example

mic@1 (120 bytes)

mic@1
T0 [f16;128,128]
T1 [f16;128]
N0 param "X" T0
N1 param "W" T0
N2 param "b" T1
N3 matmul N0 N1 T0
N4 add N3 N2 T0
N5 relu N4 T0
N6 add N5 N0 T0
O N6

mic@2 (85 bytes)

mic@2
T0 f16 128 128
T1 f16 128
a X T0
p W T0
p b T1
m 0 1
+ 3 2
r 4
+ 5 0
O 6

Key Design Principles

  • Token efficiency: Minimize LLM tokens for AI agent workflows
  • Git-friendly: One operation per line for clean diffs
  • Deterministic: Same graph always produces identical bytes
  • Lossless roundtrip: mic@2 ↔ MIC-B ↔ Mind IR
  • Security limits: Bounded inputs prevent DoS attacks

Rust API

use mind::ir::compact::v2::{
    parse_mic2, emit_mic2,      // Text format
    parse_micb, emit_micb,      // Binary format
    detect_format, MicFormat,   // Auto-detection
};

// Parse mic@2 text to Graph
let graph = parse_mic2(text)?;

// Emit Graph to mic@2 text
let text = emit_mic2(&graph);

// Parse MIC-B binary to Graph
let graph = parse_micb(&mut cursor)?;

// Emit Graph to MIC-B binary
emit_micb(&graph, &mut writer)?;

// Roundtrip is deterministic
assert_eq!(emit_mic2(&parse_mic2(&text)?), text);

Security Limits

All MIC parsers enforce strict limits to prevent denial-of-service attacks:

  • Input size: 10 MB maximum
  • Value count: 100,000 maximum
  • String count: 1,000,000 maximum (binary)
  • Shape dimensions: 32 maximum
  • String length: 64 KB maximum (binary)

Learn More

See the full specifications at star-ga/mind-spec.