llw-livive-net

no_std Migration Inventory

Status: historical analysis plus current-boundary notes. See CONCEPTS.md for the canonical architecture.

This document inventories areas that were outside the Rust no_std boundary during the migration experiment, ordered from easiest to hardest. Several items listed here have since moved into no_std:

The current core modules are:

lodalite-web-rs/src/contract.rs
lodalite-web-rs/src/engine.rs
lodalite-web-rs/src/gc.rs
lodalite-web-rs/src/heap.rs
lodalite-web-rs/src/machine.rs
lodalite-web-rs/src/policy.rs
lodalite-web-rs/src/render.rs
lodalite-web-rs/src/scenario.rs
lodalite-web-rs/src/screen.rs
lodalite-web-rs/src/storage.rs
lodalite-web-rs/src/telemetry.rs
lodalite-web-rs/src/text.rs
lodalite-web-rs/src/time.rs

The matrix below remains useful as a record of the original boundary and the seams that were evaluated.


Current boundary

The no_std core is:

lodalite-web-rs/src/
├── lib.rs        # #![no_std]
├── machine.rs    # scenario model, phases, events, reducer
├── render.rs     # view text rendering
├── scenario.rs   # static, pre-reduced fixture
└── text.rs       # fixed-buffer UTF-8 sink + money formatting

The core owns:

The core does not own:


Migration matrix

Ordered from easiest to hardest to replace.

# Area Current location no_std target Limitations Main challenges Effort
1 Text output destination src/bin/play.rs: std::fs, println! Write through a fmt::Write or byte sink supplied by the host no_std cannot open files, allocate paths, or print to a console Mostly already abstracted; only the host adapter needs to stay outside Low
2 State inspection serialization src/bin/play.rs: format!("{:#?}", state) write!(sink, "{:#?}", state) or an explicit Inspect impl No heap allocation with format!; no serde unless added Debug formatting itself is core, but JSON/structured output requires manual writing Low
3 Golden snapshot storage golden/*.txt + include_str! include_str! or a host-provided &str fixture Fixed at compile time unless the host supplies bytes Changing goldens requires rebuild, or a host pointer/slice interface Low
4 Test harness tests/snapshots.rs, cargo test Keep a std test crate around the no_std library Bare-metal has no test runner or filesystem cargo test is host-only; embedded testing needs a custom harness Low–moderate
5 Date/time formatting Python format_date; fixture dates preformatted Parse ISO-8601 and format civil dates in Rust no_std has no clock, timezone database, or locale data Local time conversion and locale abbreviations are not portable; UTC/fixed-zone or preformatted dates are the practical options Moderate
6 Scenario fixture generation Hand-written scenario.rs; Python script produces the reference data Build-time generator or a compact fixture parser no_std cannot read external files at runtime without host help Choosing a fixture format, validating it, and deciding whether to parse or generate Rust constants Moderate
7 Login/session cookie handling Python urllib, manual sid extraction Small auth state plus a host transport result No HTTP client, cookie jar, TLS, or secure-cookie policy in core Cookie semantics are simple; the exchange is not. Real login needs the transport stack Moderate–high
8 JSON parsing Python json A no_std parser or typed decoder No allocations by default; serde_json typically needs alloc; error handling is more verbose Robust parsing, borrowed vs owned strings, numeric parsing, schema validation High
9 HTTP transport Python urllib Host adapter, or embedded-nal/embassy-net on embedded targets No sockets, DNS, TLS, HTTP framing, or async runtime in bare no_std Platform-specific I/O; request/response lifecycle; timeouts; redirects; CSRF headers Very high
10 TLS Python urllib/system TLS Host TLS or an embedded TLS stack Certificate validation, entropy, clock, trust store, and crypto are difficult without an OS Secure-cookie handling, certificate storage, RNG, verification, and error handling Very high
11 Backend/database lifecycle Python --start-server; Node + SQLite Not appropriate for no_std Requires process spawning, filesystem, ports, SQLite, and OS services no_std has no OS; this belongs in the host or CI environment Out of scope
12 Browser/CI toolchain Node, Vite, Playwright, Chromium, PDF/Pages Not appropriate for no_std Screenshots, DOM layout, browser rendering, and PDF generation are inherently platform services Replacing this would mean replacing browsers and PDF engines, not moving code into no_std Out of scope

Detailed notes

1. Text output destination

Current: the library writes into TextSink<N>; the std binary writes that buffer to files with std::fs::write and prints paths with println!.

Why it is outside: no_std has no filesystem or console abstraction.

Easiest replacement: define a host-owned output interface:

pub trait Output {
    fn write(&mut self, bytes: &[u8]) -> Result<(), ()>;
}

The core can keep using core::fmt::Write. A std wrapper writes to files; an embedded wrapper writes to UART, a ring buffer, or shared memory.

Limitations: output lifetime, buffering, and error propagation are host concerns.

2. State inspection serialization

Current: format!("{:#?}\n", machine.state()) in src/bin/play.rs.

Why it is outside: format! allocates and belongs to std; the state itself is already Debug + PartialEq.

Easiest replacement: write Debug output directly to a core::fmt::Write sink. A JSON representation would require manual field writing or a serializer dependency.

Limitations: no_std JSON output needs an explicit escaping and field-order policy.

3. Golden snapshot storage

Current: six files in golden/, loaded with include_str!.

Why it is outside: the data is compile-time input, not runtime processing.

Easiest replacement: none required. include_str! works in no_std. If runtime-supplied goldens are needed, pass a &str or byte slice from the host.

Limitations: rebuilding is required to change embedded fixtures.

4. Test harness

Current: cargo test runs tests/snapshots.rs on the host.

Why it is outside: the test harness, filesystem, and panic reporting are std services.

Easiest replacement: keep the test crate on the host and test the no_std library through its public API. For bare-metal, add a custom runner or a host-side emulator.

Limitations: no standard test harness on no_std targets; assertions and diffs must run somewhere with an OS.

5. Date/time formatting

Current: Python formats ISO timestamps into strings like Dec 5, 2026, 03:23 AM; the Rust fixture stores those strings directly.

Why it is outside: no_std has no clock, local timezone, locale, or platform date formatting.

Replacement path:

Limitations:

Challenge: preserving exact output across locales and DST without bringing in a timezone library.

6. Scenario fixture generation

Current: scenario.rs is hand-written for the specific demo scenario. The Python script can produce equivalent text but does not currently emit Rust.

Why it is outside: the transformation from API JSON to static Rust constants is a host-side generation step.

Replacement path:

Limitations: runtime parsing needs a parser; compile-time generation needs a rebuild and a generator.

Challenge: deciding which fields are reduced on the host versus modelled in Rust.

Current: Python performs POST /auth/login, extracts sid from Set-Cookie, and re-adds it manually because the cookie is marked Secure over plain HTTP.

Why it is outside: it requires HTTP transport, cookie policy, and TLS semantics.

Replacement path: model auth as a host result:

Event::Authenticated { user, session_token }

or add a small auth state machine with a host-provided transport.

Limitations: no_std can store the token string but cannot perform the exchange or enforce cookie security.

Challenge: the cookie workaround is a property of the environment, not the state machine.

8. JSON parsing

Current: Python json.loads.

Why it is outside: the Rust fixture is already reduced; no parser exists in the core.

Replacement path:

Limitations: no alloc by default; escaped strings, Unicode, numbers, and error positions are non-trivial.

Challenge: maintaining exact field semantics and error handling without pulling in a large dependency tree.

9. HTTP transport

Current: Python urllib.request.

Why it is outside: bare no_std has no sockets, DNS, timers, or async runtime.

Replacement path:

Limitations: blocking vs async, timeouts, redirects, connection reuse, headers, CSRF behavior, and error mapping all vary by platform.

Challenge: this is an integration boundary, not a reducer concern.

10. TLS

Current: handled by Python/system TLS.

Why it is outside: TLS requires entropy, certificate validation, a clock, and a trust store.

Replacement path: host TLS, or an embedded TLS stack with provisioned certificates.

Limitations: certificate validation without a clock is problematic; trust store storage is large; crypto implementations must be audited.

Challenge: security correctness. This is the least attractive part of the stack to move into the core.

11. Backend/database lifecycle

Current: Python starts node src/index.js with a temporary SQLite database and polls /health.

Why it is outside: process spawning, ports, filesystems, and SQLite are OS services.

Replacement path: none for no_std. This remains a host/CI responsibility.

12. Browser/CI toolchain

Current: Node, Vite, Playwright, Chromium, PDF rendering, GitHub Pages.

Why it is outside: these are full platform services, not state-machine logic.

Replacement path: none for no_std. Keep the browser pipeline as the reference/oracle, or replace it with separate host tooling.


Summary of the natural boundary

The portable core is the reducer and renderer:

event script
    ↓
no_std state machine
    ↓
text renderer
    ↓
fixed buffer

The non-portable edge is:

backend + database
    ↓
HTTP + TLS
    ↓
JSON
    ↓
date/locale formatting
    ↓
reduced fixture
    ↓
no_std core

Areas 1–4 are mostly plumbing and can be moved without changing the core’s architecture. Areas 5–6 require decisions about time and fixture ownership. Areas 7–10 require a transport host or embedded networking stack. Areas 11–12 are not reasonable no_std targets.