Intermediate Form Reference

Read Core IR report fields, encoding rules, fixed identifiers, resource limits, and command exit statuses.

For complete source files and commands, follow Compile a Rule to an Intermediate Form.

Read an inspection result

The refund example in the guide produces the following inspection fields. The JSON below is an excerpt from a report.

JSON
{
  "requirements": ["explicit-input"],
  "roots": [
    {
      "column": 1,
      "index": 0,
      "line": 1,
      "normalized_core": "(define decide (lambda (days) (if (<= days (quote 30)) (quote refund) (quote review))))"
    },
    {"column": 1, "index": 1, "line": 4, "normalized_core": "(decide input)"}
  ]
}

A root is a top-level expression. The first root defines decide. The second calls it with the external value input. normalized_core shows shorthand rewritten into core forms. line and column locate each root in the source, starting at 1.

Report fieldMeaning
artifact.source_sha256Identifier of the exact source bytes
artifact.core_ir_sha256Identifier of the complete Core IR file
artifact.countsCounts of roots, nodes, bindings, functions, globals, and requirements
globalsGlobal cell IDs, names, and initial builtin procedure IDs
requirementsExplicit inputs required by the program
rootsReadable normalized expressions and source positions
execution: "not-run"This command has not executed the rule
authority: "integrity-only"The report describes file integrity

A cell is a storage location for a variable's value. A binding connects a variable to a cell. The compiler consumes the .lpxir file. The inspection report presents selected information for review.

Fixed identifiers

ItemIdentifier
artifact schemalispex.core-ir/v1
language profilelispex-profile-1.5
primitive registrylispex.primitive-registry/v1
cost modellispex.core-ir-cost/v1
producer familylispex-rust-core-ir/v1
artifact hash domainlispex/core-ir-hash/v1
registry hash domainlispex/primitive-registry-hash/v1

The primitive registry assigns stable numeric IDs to 205 executable builtin names. The normalizer rewrites shorthand without capturing user names. Its internal operations refer directly to primitive IDs. Source-visible builtins use ordinary mutable global cells initialized with those IDs. Local shadowing and top-level redefinition therefore retain their language behavior.

What the file records

Compilation reads the exact source, rewrites shorthand into Core forms, resolves bindings and closures, and encodes Core IR.

Recorded informationPurpose
Lexical and global cell IDsIdentify variables by their enclosing scope or global storage
Fixed and rest parameters, let, letrec, internal definitionsRecord where bindings are created
Forwarding definition cellsLet references reach definitions activated during execution
Closure capturesShare outer mutable cells used by functions, including cells needed by nested functions
Ordinary and tail callsPreserve the call position already determined by Core IR
Zero-, one-, and multiple-value contextsRecord the number of values each context accepts
Guards, exceptions, continuations, and dynamic-windRecord control structures
Literal data and source positionsPreserve constant values and their locations
Explicit input requirementsTell callers which external values to supply
Registry and cost-model IDsIdentify the builtin procedures and resource rules

The inspection view reconstructs the normalized Core used before conversion to Core IR. Other runtime implementations record their own implementation identifiers and execution results.

Encoding and strict reading

Canonical encoding means one prescribed byte representation for the complete recorded artifact. It includes source identity and source positions. Two programs that return the same value can therefore have different Core IR bytes.

The encoding is UTF-8 JSON with fixed field order and tagged arrays. It uses minimal nonnegative decimal integers, exact Unicode strings, and exactly one final line feed. Globals, requirements, captures, bindings, and functions follow fixed ordering and ID continuity rules.

The reader rejects duplicate, missing, unexpected, or reordered fields. It also rejects alternate number or datum spellings, unknown tags or IDs, broken references, invalid captures, and invalid tail positions. Source positions must be valid. Trailing bytes and any difference after re-encoding are rejected.

Limits and file identifiers

Limits are checked before table reads and allocation.

ItemMaximum
Source input4 MiB
Core IR file16 MiB
Expression nodes100,000
Bindings100,000
Functions100,000
Globals100,000
Structural depth1,024

source_sha256 identifies exact source bytes using the existing source hash domain. core_ir_sha256 identifies the complete canonical file using its own hash domain. A hash domain is a fixed prefix that distinguishes the kind of data being hashed. Consumers use these reported fields directly.

Commands and exit statuses

These commands are provided by Native.

CommandOutput on success
core-ir build with a named destinationFile plus lispex.core-ir-build/v1 report
core-ir build --out -Core IR bytes only on stdout
core-ir inspectlispex.core-ir-inspection/v1 report
core-ir validatelispex.core-ir-validation/v1 report with valid: true
Exit statusMeaning
0Command completed
1Source or validation error
2Usage error
3Declared resource limit, input/output failure, or file publication failure

npm, public WASM, and the Playground provide source execution through the reference runtime. See Lispex Interpreter and Lispex VM for product differences.

Meaning Graph and Lispex Vouch

Core IR records resolved cells, captures, and tail positions for the normalized language profile. Native projects these facts into Meaning Graph v1 while preserving their identifiers.

CommandFormat and behavior
lower without a version optionName-level csk.meaning-graph/v0
diff-receiptExisting v0 comparison report
lower --graph-version v1Resolved csk.meaning-graph/v1 from validated Core IR
eval-graphChooses v0 or v1 from the graph tag
meaning-diffcsk.meaning-differential-report/v1

Lispex Vouch derives Core IR again from authenticated exact source in its compiled workflow. Issuer authentication identifies the signer. Recipient policy determines trust. Source and input binding identify the request, re-execution supplies current results, and the Vouch gate records the local decision. The bytecode reference describes the separate compiled container.