Building and Inspecting Core IR

Use the Native CLI to turn exact Lispex source into canonical, resolved Core IR, then validate or inspect the artifact without executing it.

Build without running

Start with a source file such as refund-window.lspx:

SH
lispex core-ir build \
  --source refund-window.lspx \
  --out refund-window.lpxir

The command reads and normalizes the exact source, resolves names to cells, marks tail calls, records closure captures, and writes canonical lispex.core-ir/v1 bytes. It does not evaluate the rule. The JSON report names the source hash, Core IR hash, primitive-registry hash, semantic profile, and bounded counts.

The destination must be new. Lispex will not overwrite an existing artifact. For a pipeline, - means standard input or output:

SH
cat refund-window.lspx |
  lispex core-ir build --source - --out - >refund-window.lpxir

When --out - is used, stdout contains only canonical artifact bytes. Diagnostics stay on stderr.

Validate before storing or comparing

SH
lispex core-ir validate --ir refund-window.lpxir

Validation checks the byte limit, JSON shape, fixed schema/profile/registry identities, source anchors, resolved references, captures, tail positions, canonical datum text, ordering, and exact re-encoding. A harmless-looking whitespace or field-order change is rejected because one meaning artifact has one accepted byte representation.

Inspect the resolved meaning

SH
lispex core-ir inspect --ir refund-window.lpxir

The inspection report includes:

  • source_sha256 for the exact input source bytes;
  • core_ir_sha256 for the complete canonical artifact;
  • counts for globals, requirements, roots, nodes, bindings, and functions;
  • resolved global cells and their initial primitive identities;
  • required explicit host inputs; and
  • readable normalized-Core roots with source positions.

The report says execution: "not-run" and authority: "integrity-only". Inspection is useful for review and deterministic comparison, but the report is not a replacement artifact and cannot be executed.

Continue into verified bytecode

Core IR itself remains non-executable. When you need the Native compiled route, lower the strictly validated artifact to bytecode:

SH
lispex bytecode build \
  --ir refund-window.lpxir \
  --out refund-window.lpxbc
lispex bytecode validate --bytecode refund-window.lpxbc

The separate lispex.bytecode/v1 artifact has its own binary identity, verifier, resource model, and Rust VM. It does not turn a Core IR inspection report into executable input.

Core IR and Meaning Graph are different

lispex lower still emits the older csk.meaning-graph/v0 checked-subset graph. Keep using it with eval-graph and diff-receipt where those workflows call for it. The core-ir family covers the complete current profile and records resolved cells, captures, and tail positions; it does not change or silently migrate Meaning Graph receipts.

Choose the right surface

Core IR and bytecode commands are available in the Native product. npm, public WASM, and Playground do not accept Core IR or bytecode bytes and do not provide a JavaScript reader or VM. Use those surfaces for their documented source, image, and Vouch capabilities.

A common mistake

A matching hash or valid artifact proves integrity and canonical structure, not who produced the source, whether the rule is trustworthy, which request was intended, or whether a decision was executed. Core IR cannot issue a Vouch envelope, satisfy trust policy, bind source and input, re-execute a request, or grant a gate decision.

Keep going

Use the contract reference for the exact format and the CLI reference for automation and exit boundaries.

Run Verified Bytecode · Core IR Contract · Native CLI