Rivellum

Rivellum Portal

Download Wallet (Chrome)
Checking...
In Development

Mist Compiler and Runtime Design

Mist is Rivellum's public contract language. A Mist program expresses:

  • application logic,
  • application-owned state updates, and
  • requested value movements.

The Unified Value Layer (UVL) retains authority over canonical balances, custody, supply, and settlement.

This page distinguishes:

  1. what exists in the current checkout,
  2. what is wired into the active path,
  3. what has end-to-end evidence in tests, and
  4. what remains a design target.

It is intentionally explicit about uncertainty where evidence is incomplete.

Core terms

  • VIR (Value Intermediate Representation): Mist's typed intermediate program form, used by the compiler and current interpreter path.
  • PVI (Proof-Verified Invocation): a graph of economic effects and constraints that UVL verifies before settlement.
  • Restricted Move executable profile (target): a versioned subset/profile of Move VM execution intended to run Mist logic under constrained host interfaces. It is a design target, not the currently demonstrated Mist execution lane.

Current checkout audit: compile → publish → load → call → commit

Verified status matrix

AreaExists in codeWired into active pathEnd-to-end evidence in testsStill a design target
Mist frontend pipeline (parse, typecheck, VIR lowering, normalize, static analysis, conservation, fee analysis, PVI lowering, bundle)Yes (rivellum-mist-parser, rivellum-mist-compiler, rivellum-mist-spec)Yes for deploy source compilation and CLI build/compileCompiler + CLI integration testsN/A
Bundle artifacts (vir, pvi_graph, metadata, code_hash)YesYesBundle structure asserted in testsStrengthened executable/auth binding proof
Mist deploy/call RPC path (/v1/mist/deploy, /v1/mist/call/:id)YesYes via node pipelineEndpoint + runtime-unit coverage; limited full node-restart proof for Mist pathBroader scenario coverage
Active Mist execution engineVIR interpreter + runtime PVI regeneration from VIRYesRuntime tests exercise interpreter + UVL/replay determinismReplace with canonical executable path
Runtime PVI adjustment/bindingYes (metadata/party/oracle patching on runtime-produced PVI)YesRuntime tests cover patched commitments and verification checksCompiler-static PVI as sole runtime authorization source
Move components (VM/runtime surfaces, publish/call payloads)YesYes as separate Move path (MovePublish/MoveCall)Move integration tests exist for Move payload behaviorMist-authored source routed end-to-end through Move profile
Mist-authored source using Move path end-to-end (publish, later call, restart)Partial components existNot established as canonical Mist pathNot demonstrated by a dedicated end-to-end test proving that full sequenceYes
UVL verification checks + replayYes (commitment, conservation, balances, locked funds, split rounding, mint authority, oracle/fee/host ABI checks)Yes at commit boundary for receipts with Mist extensionUVL + replay testsAdditional formal assurance coverage
Single shared ordered state position across execution, binding, and UVLNot fully established by current evidenceNot provenNo explicit end-to-end proof of this invariant in current Mist path testsYes
Lane-local atomicity and persistence semantics for combined app-state+settlementPartialPartialTests cover pieces; complete combined behavior across restart is not fully demonstratedYes

What is implemented today (current path)

1) Compile and package

In the current checkout, the Mist compiler pipeline is implemented in code and exercised by tests and CLI commands.

The compiler emits a bundle that includes:

  • normalized VIR,
  • compiler-generated PVI graph,
  • metadata (name/version/entry function/optional fee and event schema metadata),
  • code_hash commitment.

Current references:

2) Deploy and call ingress

The node exposes deploy/call endpoints and submits Mist intents through the consensus pipeline:

  • POST /v1/mist/deploy
  • POST /v1/mist/call/:contract_id

Deploy can accept either:

  • a precompiled bundle, or
  • source text compiled server-side before submission.

References:

3) Load and execute

Current Mist runtime flow:

  1. load bundle/artifact,
  2. lower VIR to a runtime PVI graph,
  3. patch metadata/parties/oracle constraints from runtime context,
  4. interpret VIR to produce runtime state deltas/events,
  5. build receipt extension for commit-time verification.

References:

4) Commit-time UVL verification

For receipts carrying Mist extension data, the lane commit path invokes UVL verification before settlement deltas are accepted.

Current checks include:

  • PVI commitment match
  • fee commitment match
  • oracle commitment + staleness
  • host ABI commitment consistency
  • locked funds
  • mint authority
  • split rounding
  • negative balance prevention
  • conservation

References:

Important current-path limitations

The following are not presented as shipped guarantees beyond available evidence:

  1. Mist execution still runs through VIR interpretation in the active path.
  2. Runtime still derives/patches a PVI graph from VIR at execution time.
  3. Mist authored source is not demonstrated as running end-to-end through a restricted Move executable profile.
  4. A single enforced semantic-equivalence contract between compiler static authorization and runtime execution artifact is not yet fully established.
  5. A full proof that execution, binding, and UVL all observe one identical ordered state position is not yet demonstrated by dedicated end-to-end evidence.
  6. Combined application-state persistence + UVL outcome + restart/replay guarantees for the target architecture remain incomplete.

Mist language audit (current checkout)

This section audits Mist as a language surface, not only compiler/runtime plumbing.

Verified language status by feature family

Feature familyStatusNotes
Source model (contract/state/function/event declarations, expressions, if, for, value ops)implemented and exercisedParser + compiler tests cover accepted subset across parser, type checker, VIR lowering, and runtime execution for key constructs.
Deterministic execution constraints (while forbidden, provable loop bounds, bounded collection capacities)implemented and exercisedParser accepts while, but type checker rejects it; bounded-loop and complexity-budget tests enforce deterministic subset.
Application model (persistent state keys, typed event declarations, emitted runtime events, cross-invocation state reads/writes)partialTyped state/events and state deltas are implemented; persistence and replay behavior are exercised in runtime tests, but broader public semantics remain partially specified.
Economic model (hold/pay/release/refund/split/mint/burn, UVL settlement invariants)implemented and exercised (prototype path)Language forms compile, lower to VIR/PVI, and go through UVL verification checks in tests. Some docs still present policy semantics not implemented in source parser/type checker.
Composition model (multi-file modules/imports/libraries, user-defined function calls, synchronous cross-contract calls)open / restrictedNo import/module system; arbitrary synchronous contract-to-contract calls are not in the public Mist path; expression calls are currently builtin/intrinsic-only in type checking.
Failure and execution limitsimplemented and exercised (prototype path)Runtime/UVL failure codes and deterministic replay are implemented and tested; public semantics for caller-visible failure effects still need a single authoritative language spec.
Developer experience (compile/lint/build/fees/inspect/replay/test/deploy/call/receipt CLI surface)partialCore compile/inspect/lint/build flow works and is tested; some CLI/public-doc behavior is still prototype-oriented or inconsistent (see “Current doc/behavior conflicts”).

What developers can write today (verified path)

Source model

  • One contract per source file with state, function, and event declarations is implemented.
  • Expression syntax for literals, arithmetic/comparison/boolean operators, unary operators, and parenthesized expressions is implemented.
  • Control flow supports if/else, return, and bounded for i in start..end.
  • while parses but is explicitly rejected by type checking in the deterministic subset.
  • Value operations (hold, pay, release, refund, split, mint, burn) are parsed and type checked.

Application model

  • Application state is key/value persisted and updated by runtime-produced state deltas.
  • Event declarations are typed in compiler metadata; runtime emits serialized event payloads.
  • state_read("declared_key") is implemented and type checked; unknown keys are rejected at compile time.

Economic model

  • Source expresses requested value movement via value-op primitives.
  • Compiler emits VIR/PVI artifacts; runtime currently regenerates/patches PVI from VIR in active path.
  • UVL remains authority for settlement checks (commitment, conservation, balances, locks, split rules, mint authority, oracle/fee/host commitments).
  • Authority and delegation semantics are still partly runtime/protocol enforced rather than fully source-defined today.

Composition

  • Local sequencing inside a single function is supported.
  • No verified public support for imports/modules/libraries in current Mist source pipeline.
  • Function call expressions are currently restricted in type checking to known builtins/intrinsics; general user-defined call semantics are not part of the verified source subset.
  • Prefabs provide reusable contract templates and are compile-tested as source assets.

Failure and execution limits

  • Compile-time errors reject unsupported/non-deterministic forms in the accepted subset.
  • Runtime interpreter enforces collection capacities and bounded batch token limits during execution.
  • UVL rejects invalid settlement plans atomically; replay path verifies deterministic outcomes.

Developer experience

  • mistc supports parse/check/lint/compile/build/inspect/fees/explain/replay plus deploy/call/receipt tooling.
  • Parser, compiler, and runtime suites are present and currently passing in checkout.
  • Diagnostics are present but still mixed between language-facing and pipeline/prototype internals.

Current doc/behavior conflicts (public-safe)

These are material language-planning gaps because they blur what is normative vs prototype:

  1. Language reference examples show generic field/index syntax (obj.field, arr[index]), but parser/type checker currently reject generic field access and index access in source.
  2. Language reference presents generic function-call style (compute(x, y)), but type checking currently accepts only supported builtin/intrinsic calls in the verified source subset.
  3. Language reference mentions can_mint policy semantics, but parser/type checker do not currently implement a user-facing policy declaration surface.
  4. Toolchain docs describe mistc test as running embedded tests; current implementation compiles discovered .mist files rather than running a language-level embedded test framework.
  5. mistc init currently emits legacy sample syntax that does not pass current parser checks without manual rewrite.

Language-design work to inherit

Gap/decision table

AreaWhat exists todayWhat remains to decide or buildWhy it mattersOwnership boundary
Authoritative language subsetParser/typechecker/runtime support a practical deterministic subsetFreeze which constructs are normative language vs prototype convenience/reserved AST surfacePrevents ambiguity between docs and actual accepted programsOwns (language/compiler), with runtime awareness
Expression/call modelOperators + intrinsic/builtin call surface implemented; generic calls restrictedDecide if/when user-defined function-call semantics are first-class and how they lowerAffects composability, refactoring patterns, and optimizer designOwns
Field/index syntaxGeneric field/index nodes exist in AST, but source support is intentionally restrictedDecide whether to expose, redesign, or keep reserved in minimal profileAvoids docs promising unsupported semanticsOwns
Authorization expression modelValue ops + UVL checks exist; source-level authority policy is incompleteDefine language-level representation for authority/delegation/invocation-bound valuesCore for developer understanding of what is authorized vs only requestedShares with runtime/protocol
Error and rejection semantics contractRuntime + UVL error codes exist; toolchain explainers existDefine language-level semantics for rejected invocation outcomes and caller-visible effectsNeeded for predictable app behavior and debuggingShares with runtime/protocol
Minimal profile for first canonical pathDeterministic bounded subset already exists in practiceChoose smallest language profile required for first end-to-end canonical compiler/runtime sliceReduces risk and creates conformance targetOwns, coordinated with runtime integration milestones
Compatibility/versioningMany prefabs/examples compile today; artifacts include metadata/version fieldsDefine compatibility guarantees, migration policy, and language/profile version signalingAllows evolving semantics without breaking deployed expectationsShares with runtime/protocol on artifact/version contracts
Tooling/diagnostic contractCompile/build/lint/inspect/replay commands existSpecify what must be inspectable pre-deploy and what rejection diagnostics must explainDeveloper trust depends on explainability before and after deploymentOwns for compiler/toolchain, shares for runtime/UVL failure mapping

Explicit decision boundaries

  1. Intentional language constructs vs prototype conveniences

    • Deterministic bounded loops, typed declarations, value ops, and core intrinsics are clearly intentional and exercised.
    • Generic field/index access, broad call semantics, and policy declarations are currently prototype/reserved or partial and should be explicitly classified before expanding canonical execution.
  2. Authoritative semantics source

    • Today, semantics are split across public docs, parser/typechecker behavior, runtime interpreter behavior, and tests.
    • First needed artifact: a single normative language-semantics profile that compiler tests and runtime conformance tests both target.
  3. Smallest useful language profile for first canonical end-to-end path

    • Likely bounded subset already exercised today: declarations, typed state/events, deterministic expressions, if, bounded for, require/assert, core value ops, and minimal intrinsic set.
    • Broader features (expanded composition, richer policy surface, additional syntax) can follow after canonical compile→execute→settle proof.
  4. Compatibility and migration

    • Existing examples/prefabs that compile in current subset are strong candidates to preserve or migrate with automated tooling.
    • Open: language/profile versioning policy, deprecation windows, and artifact compatibility guarantees across compiler/runtime upgrades.
  5. What must be understandable before deploy

    • Source intent, static constraints, emitted executable/authorization artifacts, and likely rejection classes should be inspectable pre-deploy.
    • Toolchain should distinguish compile failure vs runtime execution failure vs reconciliation/UVL rejection with source-relevant diagnostics.
  6. Independent vs shared decisions

    • Independent: syntax/typing/IR choices, diagnostics UX, conformance tests for language profile.
    • Shared: invocation context model, authority binding semantics, settlement/rejection effects, state/commit ordering guarantees, and cross-lane outcomes.

Proposed starting language tasks (blocking-first)

  1. Write a compact Mist language profile v0 from implemented-and-exercised subset in checkout.
  2. Reconcile Mist Language Reference, Mist By Example, and Mist Toolchain & CLI to that profile.
  3. Promote a small set of existing programs (counter, bounded collections, escrow/value-op, oracle guard) into explicit language conformance cases for parser → typecheck → VIR lowering → runtime execution.
  4. Define compiler/runtime interface notes for rejection semantics and authority binding needed before canonical executable path replacement.
  5. Specify compatibility/versioning rules for existing prefabs/examples before widening the language surface.

Target architecture (intended path)

The intended architecture keeps Mist as the only public authoring model while moving to one canonical execution/authorization contract.

                     TARGET ARCHITECTURE (INTENDED)

Mist source
   │
   ▼
Frontend pipeline (parse, typecheck, semantic/effect checks)
   │
   ▼
Common typed semantic representation
   ├───────────────────────────────► Restricted Move executable profile artifact
   └───────────────────────────────► Static PVI authorization artifact
                                      (both bound to same committed program version)

Invocation (authenticated intent + deterministic state view)
   │
   ├─► Bind invocation-dependent slots allowed by static PVI rules
   │
   ├─► Execute restricted VM logic
   │      ├─ stage application writes
   │      └─ emit structured economic effect requests
   │
   ├─► Reconcile requested effects against bound static PVI
   │
   ├─► UVL independently verifies settlement authority/invariants
   │
   └─► Lane-local atomic commit (or reject)
           - application writes and accepted settlement effects commit together
           - rejection discards tentative writes/effects

Authority boundary in the target model

  • Source-level policy must define what may bind at invocation and under which constraints.
  • Concrete parties/assets/amounts may be invocation-dependent only when authorized by those source-level rules.
  • Execution may request effects; it does not create authorization.
  • Bound static PVI defines authorization for this invocation.
  • UVL independently validates whether authorized requested effects can settle against canonical economic state.

If authorization or validation fails, settlement is rejected. Lane-local durable behavior is all-or-nothing for that invocation outcome. Cross-lane completion semantics remain an open protocol decision.

Example (target semantics illustration)

The syntax below follows existing Mist patterns.

contract EscrowSlice
    state buyer: Address
    state seller: Address
    state escrow_vault: VaultRef
    state released: Int
    state total: Int
    state asset: Address

    function deposit(amount: Int, asset_id: Address)
        buyer = caller
        total = amount
        asset = asset_id
        released = 0
        hold escrow_vault = amount asset asset_id from caller

    function release_to_seller(amount: Int)
        require caller == buyer
        require released + amount <= total
        released = released + amount
        pay amount asset asset to seller from escrow_vault

Successful invocation (target)

release_to_seller(10):

  1. executes application logic (released increments),
  2. requests value movement (pay 10 ... from escrow_vault),
  3. reconciliation confirms request is within bound authorization for this invocation,
  4. UVL validates settlement invariants,
  5. application-state write and settlement commit together lane-locally.

Authorization/validation failure (target)

If invocation attempts an amount outside the bound authorization (or UVL invariants fail):

  • settlement is rejected,
  • tentative application writes are discarded for that invocation outcome,
  • no partial application/value effect is committed.

Protocol-defined side effects (for example fee/nonce/failure receipt behavior) are separate protocol decisions and must be explicitly specified by interface contract.

Ownership scope for the language and compiler architect

Primary ownership

  • Mist language semantics and constraints
  • compiler architecture and implementation
  • internal representation strategy (VIR or successor core/stages)
  • lowering strategy and executable emission path
  • static PVI artifact model and encoding
  • tooling ergonomics (compile, inspect, diagnostics, replay/debug surfaces)

Toolchain outcomes to make concrete

Developers should be able to:

  • compile reproducibly,
  • inspect emitted artifacts and commitments,
  • understand why invocation was rejected,
  • reproduce verification outcomes with replay inputs,
  • reason about authorization boundaries before deploying.

Current capabilities already exist for many of these via compiler artifacts, CLI outputs, and replay interfaces, but some rejection diagnostics and cross-artifact agreement proofs remain design work.

Open design choices and constraints

1) Internal representation strategy

Options:

  • retain VIR as primary internal core,
  • define a smaller typed semantic/effect core,
  • use staged lowering with multiple IR boundaries.

Constraint: executable and static PVI projections must be shown to originate from the same program meaning.

2) Executable projection strategy

Options:

  • emit restricted Move bytecode directly,
  • emit against a fixed kernel boundary,
  • use a narrow hybrid.

Constraint: deterministic behavior, profile verification, and strict host interface control.

3) Authorization model expression

Decide representation for:

  • authority/delegation conditions,
  • invocation-bound inputs,
  • inspectable developer-facing authorization rules.

Constraint: runtime binding cannot widen authorization.

4) Artifact binding and semantic agreement

Decide:

  • artifact encoding/versioning,
  • commitment structure,
  • verifier and loader checks proving artifact agreement.

Constraint: one committed program version must bind executable and static authorization.

5) Diagnostics and inspection

Decide what developers see when:

  • compile succeeds,
  • invocation executes,
  • reconciliation or UVL rejects.

Constraint: diagnostics must identify whether rejection was authorization binding, requested-effect mismatch, or UVL settlement failure.

Shared interfaces with runtime and protocol teams

Requires joint agreement before independent implementation

  • host interface surface and profile limits
  • deterministic state/context binding contract
  • structured effect-request format
  • reconciliation algorithm and required-effect semantics
  • commit/replay evidence contract
  • cross-lane outcome semantics

Can progress in parallel (within agreed boundaries)

  • language syntax/type semantics
  • frontend/typechecker/analysis architecture
  • compiler internal refactors
  • CLI and static artifact inspection tooling

Proposed implementation sequence (engineering plan)

  1. Lock semantic and interface contract
    • finalize typed semantic model and compiler/runtime boundary.
  2. Build one narrow lane-local vertical slice
    • Mist source → both committed artifacts → invocation → app-state change + settlement.
  3. Prove agreement and failure atomicity
    • show artifact agreement checks and reject-without-partial-effects behavior.
  4. Prove durability and replay
    • persist through restart and reproduce deterministic replay outcomes.
  5. Use interpreter as differential oracle where behavior is preserved
    • add explicit target-behavior tests where semantics intentionally change.
  6. Expand features/tooling after core path is proven
    • only then broaden language surface and remove interpreter from production path.

Definition of done for first useful deliverable

A first useful deliverable is complete when it demonstrates:

  • one canonical compile → execute → settle lane,
  • executable/static artifact agreement checks,
  • no partial effects on authorization/validation failure,
  • persistence across restart,
  • deterministic replay reproducibility.

Completeness check (language ownership)

With the language audit above, this page now identifies:

  • which Mist language behaviors are mature vs provisional,
  • where docs and implementation diverge,
  • which language decisions are compiler-owned vs shared with runtime/protocol, and
  • the first language decisions that block the canonical end-to-end compiler path.

This means the plan is not limited to executable lowering and PVI mechanics; it includes explicit Mist-language ownership scope and starting decisions.

Verification scope note

This page is based on direct repository inspection and currently available tests in this checkout. Where full end-to-end or restart evidence is incomplete, statements remain explicitly qualified as design target or not yet demonstrated.