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.

Canonical IR contract: IRModule (control flow included)

mic@1text
  • full IRModule, explicit IDs
  • RFC 0001 fixed-point form
round-trip
mic@3binary
  • magic MIC3, emit with --emit-mic3
  • the trace_hash anchor

Back-compat lineage: Graph dataflow shape (demoted, never the compiled-artifact IR)

mic@2 / mic@2.1text
  • implicit IDs, compact opcodes
  • mic@2.1 adds the MAP (RFC 0014)
lossless
MIC-B v2binary
  • magic MICB, ULEB128 varints
  • Graph shape, binary
mind-model@2model-exchange artifact, byte-preserving renamePending
Solid boxes are the canonical IR contract; dashed boxes are the back-compat lineage. mindc 0.10.x, RFC 0021.

mic@1: canonical text

mic@1 is the 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

mic@3 is the canonical binary serialisation of the same IRModule. Shipped behind mindc --emit-mic3; round-trips to/from mic@1.

mic@2 / mic@2.1: demoted

The legacy dataflow lineage, kept for back-compat only and never the current or canonical compiled-artifact IR. mic@2.1 carries the MAP (Metadata-Attachment-Pair) extension (RFC 0014). RFC 0021 step 5 renames the lineage to mind-model@2 (a model-graph artifact, no longer an IR contract) as a byte-preserving migration that is still pending.

Consumers: verify and inspect

mindc verify <artifact> peels the evidence_chain.* MAP, recomputes the canonical mic@3 trace_hash over the parsed IR body, and reports whether it matches; mindc inspect <artifact> decodes a mic@3 binary and pretty-prints the IR body plus a structural summary (instruction count, SSA value count, exports, byte size).

RFC 0021 (canonical-IR unification) progress

  1. Step 1Shipped
  2. Step 2Shipped
  3. Step 3Shipped
  4. Step 4Shipped
  5. Step 5Pending
  6. Step 6Pending
  • Step 3: emit mic@3 with mindc --emit-mic3 (shipped).
  • Step 5: rename the mic@2 lineage to mind-model@2 (pending).

Both consumers on a real artifact, captured with mindc 0.10.2 on the repository's hello_tensor.mind:

captured: mindc 0.10.2 (inspect output trimmed)
$ mindc hello_tensor.mind --emit-evidence a.mic3
Wrote mic@3 evidence artifact: a.mic3 (316 bytes, self-check ok)
$ mindc inspect a.mic3
artifact:         a.mic3
bytes:            316
instrs:           3
ssa_next_id:      1
exports:          0
attested:         YES
trace_hash:       7a2e5f47435c8ae55a8c1288ffa47ffdd73f89ad5e19c872f95fd8bd3e5673bc
determinism:      deterministic
fp_mode:          strict
$ mindc verify a.mic3
artifact:         a.mic3
substrate:        cpu
determinism:      deterministic
toolchain:        0.10.2
parent:           (root)
trace_hash:       7a2e5f47435c8ae55a8c1288ffa47ffdd73f89ad5e19c872f95fd8bd3e5673bc
trace_hash_kind:  mic3-bytes
trace_hash_valid: yes
ssa_valid:        yes
signature:        absent
verified: IR body attested (tamper-evident) — trace_hash matches the re-emitted canonical IR
verified: IR body is SSA well-formed
note: artifact carries no signature (unsigned but attested)
note: provenance (substrate/toolchain/parent) is NOT authenticated — these MAP fields sit outside trace_hash; sign the artifact and pin --signer-pubkey to authenticate them

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–4 (shipped); 5–6 pending
  • 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

Bytes for the same 6-node layer (linear scale)

  • JSON1,133
  • TOML607
  • TOON269
  • mic@1209
  • mic@2111
  • MIC-B v290

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

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:

10 MBInput size, maximum
100,000Value count, maximum
1,000,000String count, maximum (binary)
32Shape dimensions, maximum
64 KBString length, maximum (binary)

Learn More

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