In this section: Hands-On Examples

Chapter 6 UMA code example

UMA portability lab tutorial

This tutorial proves portability through observable behavior. The native runner and WASI runner emit the same image.analyzed payload while target-specific telemetry remains explicit.

Tutorial route

Use the links up front so the portability path feels like a guided sequence instead of a footer scavenger hunt.

What you will learn

  • how one contract drives native and WASI execution
  • why parity should be checked through emitted events
  • how native-only capabilities stay outside the portable path

Prerequisites

  • Rust 1.77 or newer
  • rustup target add wasm32-wasip1
  • Wasmtime 20 or newer
  • jq

Run this setup command before the lab if your machine does not already have the target installed.

rustup target add wasm32-wasip1

Full tutorial

  1. Enter the example
    cd chapter-06-portability-lab
  2. List the guided labs
    ./scripts/list_labs.sh
  3. Compare native and WASI events
    ./scripts/run_lab.sh lab1-native-wasm-parity
  4. Compute shared payload digests
    ./scripts/run_lab.sh lab2-shared-payload-digest
  5. Exercise failure paths and capability gates
    ./scripts/run_lab.sh lab3-failure-paths-and-capability-gates
  6. Check Rust and TypeScript reference parity
    ./scripts/run_lab.sh lab4-rust-ts-reference-parity
  7. Run the chapter smoke path
    ./scripts/smoke_portability_labs.sh

What to inspect

After each command, look for these proof points. They are the signals that connect the code example back to the UMA architecture claim.

  • identical image.analyzed payloads
  • matching shared payload digests
  • gpu.telemetry.reported only on the native path

Acceptance check

The chapter-level validation path is:

./scripts/smoke_portability_labs.sh

Return to the repository root for the final acceptance gate:

cd ..
./scripts/smoke_reader_paths.sh

Where to go next

Chapter 7 uses contracts and events to create orchestration.