Skip to content
laststatePublic

About

LastState CLI for embedded crash reporting — Latch → LEP → Relay → Trace

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

21 Commits

Folders and files

Repository files navigation

LastState CLI

One command line for the Latch → LEP → Relay → Trace loop: scaffold the Latch integration, build and flash firmware, run the stack locally, and decode captured envelopes.

CI workflow status on master Licensed under Apache-2.0 Requires Node 18 or newer

Status: v1.2.0, CI green on master. The first tagged release is pending; until it ships, install from source. Hardware evidence lives in the Latch repository.

What it does

  • Firmware: init scaffolds the Latch integration files for ESP32, Cortex-M, RISC-V, Zephyr, Arduino or host; build drives CMake and ctest; flash calls idf.py, west or OpenOCD.
  • Stack: up starts the LastState compose stack, sim runs a virtual fleet, and mock serves Trace/Relay endpoints without Docker.
  • Evidence: test checks the integration against LEP vectors; ingest, analyze and symbolicate move and decode captures.
  • Operations: config and doctor keep endpoints, secrets and toolchains honest.

The CLI is glue: it drives the component repos' public commands and APIs, and prints - when it cannot verify something.

Install

Node 18+.

From source (works today)

git clone https://github.com/laststate/cli.git
cd cli
npm ci
npm run build
npm link          # exposes `laststate` and `ls`
laststate doctor

From npm (pending first release)

# 404 until the first tagged release is published
npm install -g laststate-cli

The package is not on the registry yet; the first tagged release will publish it. Until then, use the source install above.

Quickstart

laststate is a driver, not a project generator: it runs against your firmware checkout and the LastState stack.

Check the environment

laststate doctor

doctor reports tools, config, secrets and live endpoints. It prints - for anything it cannot check (a stack that is not running, for example) and exits nonzero only when a required check fails.

Run the stack

git clone --recurse-submodules https://github.com/laststate/laststate.git
cd laststate
laststate up --open
laststate sim run --scenario crash-storm
laststate status
laststate down

up runs docker compose from the repo root, waits for health and can open the Trace UI. --appliance uses docker-compose.appliance.yml; --no-sim skips the simulator. sim run accepts demo, steady, crash-storm, outage, recovery or boot-loop.

Add Latch to firmware

laststate init --project-name Demo --target cortex-m --yes

init creates Demo/ with laststate.yaml, a Latch main.c, .gitignore and CMakeLists.patch.txt (plus partition.csv for ESP32). It does not create a buildable project: merge the patch into your own CMakeLists.txt, add Latch under third_party/latch, and provide the CMake preset that build will use. Latch's own CMakePresets.json is the reference for host-debug, arm-cortex-m4, riscv32 and riscv64.

With those in place, laststate build, laststate flash and laststate test run against your project. test probes includes, ls_boot() wiring and the LEP vectors it can find; anything it cannot verify prints -, never a false pass.

The generated laststate.yaml carries a local-only dev- ingest token. Replace it before sharing the project or pointing it at a shared Relay; laststate config generate-secrets writes strong values to .env, which take precedence over the project file.

Inspect a capture

laststate analyze capture.lep
laststate analyze capture.lep --output-format json
laststate ingest capture.lep --to relay --url http://localhost:8384

analyze accepts .lep, .hex and .bin, checks the header and CRCs, walks TLVs and can deframe raw, latch-stream or cobs. A protocol vector works as a known-good input: laststate analyze ../protocol/test-vectors/valid/lep-v2-basic.hex.

ingest posts to Relay or Trace with a rate/ETA bar and reports the event ID. symbolicate upload-artifact stores an ELF in Trace; symbolicate resolve uses llvm-symbolizer or addr2line locally.

Common commands

Firmware

Command What it does
laststate init Scaffold Latch integration files for esp32, cortex-m, riscv, riscv64, zephyr, arduino or host.
laststate build Configure and build with CMake presets, then run ctest.
laststate flash Flash through idf.py, west or OpenOCD.
laststate test Static integration probes plus LEP vectors; ✓/✗/- per check.

Stack

Command What it does
laststate up / down / ps / logs / status Start, stop, list, tail or health-check the compose stack.
laststate sim run / sim stop Run the virtual fleet with a named scenario.
laststate deploy Secrets, preflight and compose up for local, production, appliance or k8s.
laststate doctor Audit tools, config, secrets and live endpoints.
laststate mock Serve Trace/Relay endpoints for development without Docker.

Captures and config

Command What it does
laststate ingest (alias send) POST .lep files to Relay or Trace.
laststate analyze Decode header, CRCs, TLVs and framing; text or JSON.
laststate symbolicate upload-artifact to Trace or resolve addresses locally.
laststate config list, get, set, paths, generate-secrets, preflight.
laststate billing status, checkout, portal, watch against billing-service.
laststate update Check for a newer CLI version.

Per-command flags: laststate <command> --help. Global flags on every command:

--json --yes --verbose --quiet --no-color --no-banner --profile <name>

--json disables colors, banners and spinners and emits machine-readable output. CI=true also disables the banner.

Configuration

Precedence: --flag > env > laststate.yaml > global conf > default. Common environment names are TRACE_URL, RELAY_URL and LASTSTATE_*_TOKEN.

laststate config list
laststate config get trace_url
laststate config set trace_url http://localhost:8080
laststate config generate-secrets --only-missing
laststate config preflight --deploy-env production
laststate config paths

config generate-secrets fills only missing or weak values. config preflight fails on REPLACE_ME placeholders and weak secrets before a production deploy.

Development

npm ci
npm test        # vitest: LEP codec, config, validation, wiring, tasks, UI
npm run build   # tsc -> dist/
npm run lint

To release, push a vX.Y.Z tag equal to package.json. The release workflow builds and tests, publishes to npm (OIDC trusted publishing or NPM_TOKEN), packs the tarball, smoke-tests the published package and creates the GitHub release.

Documentation

Topic Where
Latch runtime and HIL evidence laststate/latch
LEP wire format and vectors laststate/protocol
Relay gateway laststate/relay
Trace backend and UI laststate/trace
Full self-hosted stack laststate/laststate
Billing realtime contract docs/BILLING_REALTIME.md

License

Apache-2.0. See LICENSE.

About

LastState CLI for embedded crash reporting — Latch → LEP → Relay → Trace

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages