Developers need one bootstrap target that is immediately runnable and easy to modify. Use a single generated project containing contract, CLI client, configuration, and deployment scripts. Single-template onboarding is very simple.
The workflow should be discoverable for new developers. Expose one CLI surface with subcommands for init, build, deploy, and interact. One CLI improves onboarding but makes it hard to maintain backward-compatibility.
Local development should work without requiring manually managed external node setup. Provide embedded localnet lifecycle commands as part of scaffold workflow. The scaffolded toolchain can start, stop, and reset a localnet environment that supports deploy and wallet-based interaction for the generated example contract.
Contract compilation should align with Rust ecosystem standards and avoid unnecessary abstraction. Use native Cargo-based build flow as the primary compilation path.
Developers need explicit, editable environment targeting for local and DevNet workflows. Use environment-file based network configuration as the default model. Generated projects include env files for local and DevNet, wallet interaction settings used by deploy and wallet-based interaction commands. Env files are familiar and automation-friendly, but require strict handling to avoid credential leakage.
The decision above anticipated local and DevNet env files. What shipped is local only.
Network targeting lives in scaffold.toml ([localnet].port) and the wallet config under
[wallet].home_dir, which commands read directly. The generated .env.local carries only
RUST_LOG and RISC0_DEV_MODE. A DevNet target, when it lands, should be recorded as its
own decision rather than inherited from this one.
The .#lgx-portable output exists to load into a released basecamp AppImage — a
different delivery path with different XDG paths and a different install mechanism
than the scaffold-managed alice/bob profiles. basecamp build-portable targets
that output and stops once the artefacts exist; it never invokes lgpm, never
mutates profile state, and never touches basecamp.state. This keeps the two
delivery flows strictly separate, trading a slight command-surface duplication for
clean boundaries.
basecamp build-portable produces .lgx artefacts in the nix store — paths
like /nix/store/xxx-source/foo.lgx. Operators then load those into a
basecamp AppImage via its "install lgx" file picker, which opens in the
filesystem. Browsing to /nix/store/ by hand through a file dialog is
painful: the hashes are opaque, there's no ordering, and the user has to
mentally reconstruct which artefact belongs to which module.
build-portable now writes a mirror of each built artefact as a symlink
under <project>/.scaffold/basecamp/portable/<NN>-<module_name>.lgx
(or <NN>-<module_name>-<stem>.lgx when a source emits multiple outputs).
The NN prefix is a two-digit zero-padded load-order index, so the
directory lists the artefacts in the exact order basecamp needs to load
them — modules with no project-internal deps first, modules that depend
on them afterwards. Ordering is derived from each source's metadata.json
dependencies array via a topological sort among the captured
role = "project" modules; non-project deps are ignored because they're
resolved at runtime via the basecamp preinstall or package-manager
catalog, not at hand-load time.
The symlink directory is wiped and recreated on every build-portable
run. That keeps re-runs idempotent: removing a module via basecamp modules and re-running build-portable leaves no stale symlinks. The
symlinks point at live nix-store paths; the store entries themselves are
retained by their result-lgx-portable GC root at each flake root, so
scaffold's symlink does not itself pin the artefacts.
Tradeoffs: scaffold writes under .scaffold/basecamp/portable/ at
build-portable time, relaxing an earlier design goal that
build-portable never touch .scaffold/. The upside is operator
ergonomics for the one actual friction point in the AppImage test
flow — no more hunting through the nix store in a file picker.
build-portable could have tried to auto-locate a basecamp AppImage and copy
artefacts into its module directory. It does not. The scaffold does not know the
AppImage's install location, and probing filesystem heuristics would be unreliable
across Linux distributions and macOS bundles. Instead, scaffold produces the .lgx
artefacts and prints their absolute store paths; the developer copies them into
whatever AppImage they are testing against. The tradeoff is an extra manual step;
the upside is no fragile heuristics and no surprise writes into user-managed
locations.
Runtime IPC composition means a module declares dependencies on other modules by
name (in metadata.json's dependencies array). Scaffold needs a mapping from
those names to concrete flake refs in the captured module set — otherwise
basecamp install cannot know which flake provides delivery_module when a
project source declares that dep.
scaffold.toml carries a top-level [modules] table keyed by module_name
with explicit flake and role (project | dependency) fields.
basecamp modules writes the table at capture time; dep resolution at
build time is a key lookup against that table. scaffold.toml is the
sole human-readable source of truth for the captured module set;
basecamp.state is reduced to pin-artefact metadata only. (Originally
nested under [basecamp.modules.*]; lifted to top level in schema 0.2.0
because modules are project-level Logos artifacts and basecamp is one
consumer of them, not their owner.)
Populating module_name on capture:
path:flake sources — read directly from the source'smetadata.json.name(the source tree is on the local filesystem).github:flake sources —metadata.jsonis only available after building, so scaffold derives a best-guess name from the repo slug (striplogos-prefix,-→_) and prints a one-line assumption note at capture time inviting the user to editscaffold.tomlif wrong.
The tradeoff: basecamp modules now writes to scaffold.toml, widening its
write surface beyond the derived basecamp.state. The upside is that the
captured module set becomes reviewable in version control and diff tooling
(a single TOML section, not a line-oriented state file), and dep-resolution
lookups become deterministic key matches — the "is this dep covered by
something I already captured?" question has an unambiguous answer.
[repos.basecamp], [repos.lgpm], BASECAMP_DEPENDENCIES and
BASECAMP_PREINSTALLED_MODULES look like four independent knobs. They are one.
Scaffold installs modules by shelling out to the lgpm CLI it builds from
[repos.lgpm], and basecamp then scans and loads what landed in the profile
using logos-package-manager-module — which is built from the same
logos-package-manager source, at whatever rev the basecamp release locks. The
writer and the reader are two builds of one library. Letting the two pins drift
means the installer and the app disagree about package format, validation and
install layout, and the failure mode is a profile that comes up with zero
modules rather than an error at install time.
The rule, therefore: scaffold's default lgpm pin is the rev the default
basecamp pin locks, read out of that release's flake.lock rather than chosen
independently. Two corollaries follow from the same coupling:
- Companion pins are release-scoped too. The pinned
lgpmvalidates package structure and Merkle content hashes on install, so a companion module whose.lgxpredates that tooling stops installing.BASECAMP_DEPENDENCIESentries move with the pair. - The bundled-module list is read off the release. Which modules basecamp
ships itself changes between releases (0.2.x dropped
counter,counter_qmlandwebview_appand addedpackage_downloader; 0.3.0 foldedmain_uiinto the app and addedmodules_state), and dep resolution skips exactly those names. A stale list either sendsbasecamp moduleshunting for a flake that does not exist, or captures a module basecamp already provides.
Rejected alternative: pinning lgpm to the last pre-validation rev so older
.lgx files keep installing. It buys nothing — the validating library is inside
the basecamp binary either way, so a package that fails validation at install
time would fail to load at runtime instead, with less signal. For the same
reason scaffold does not pass --allow-unsigned: silencing the installer's copy
of a check the app also performs converts a clear error into a mystery. install
turns the validation failure into a hint naming the rebuild instead.
Cost: a basecamp bump is never a one-line change, and the pins cannot be updated
by a dependency bot that treats each repo separately. That is the honest shape of
the dependency, and the dogfooding spec (.dogfooding/index.md) re-opens every
basecamp scenario when any member of the set changes.
Until 0.2.3 scaffold kept compatibility code for every basecamp generation it
had ever pinned: two launcher names (bin/logos-basecamp for 0.1.x,
bin/LogosBasecamp for 0.2.x), two data-tree env vars (LOGOS_DATA_DIR and
LOGOS_USER_DIR, gated differently per host and stack), and a process-name
table mapping each generation's launcher onto what it execs. None of it was
exercised: the B series only ever runs against the default pin, and a
compatibility branch nobody runs is a claim, not a feature.
With the move to basecamp 0.3.0 scaffold supports exactly one basecamp
release — the one DEFAULT_BASECAMP_PIN names. Launcher resolution, the
process-name candidates, the exported env and the bundled-module list describe
that release and nothing older. A project may still pin another rev (a fork,
an unreleased commit); scaffold builds it, and basecamp doctor names the
release it actually supports, but it carries no code for the difference.
That only works if projects do not silently stay behind. new, init and
setup write the literal default pins into scaffold.toml, and basecamp modules writes default companion flakes into [modules], so a pin bump alone
never reaches an existing project. Scaffold therefore keeps a short table of
the retired defaults it wrote (RETIRED_BASECAMP_PIN_SETS,
RETIRED_DEPENDENCY_FLAKES): basecamp setup rewrites a value that is exactly
one of them to the current default and prints each rewrite, and basecamp doctor warns until it has. The line is drawn at rev equality, not intent:
scaffold records no provenance, so a user who deliberately pins basecamp 0.2.3
with its matching lgpm is indistinguishable from one an old default left
behind, and both get moved (per the rejected alternative below, such a user
stays on the scaffold release that shipped with 0.2.3). Any pin that is not
exactly a retired default from scaffold's default source is left alone.
Rejected alternative: keep the compat branches "because they are cheap". They were not: each one came with its own doc paragraph, test and DOGFOODING caveat, and the 0.2.x → 0.3.0 research had to re-verify every one before it could be trusted or deleted. The cost of the rule is that a user who deliberately stays on an older basecamp gets no help from scaffold with its quirks; that user can stay on the scaffold release that shipped with it.
Multi-sub-flake projects rely on --override-input <input> path:<sibling-abs> so a sub-flake's path:../<sibling> inputs resolve to the developer's working tree instead of whatever github: ref is in its lock. The first implementation keyed overrides by the sibling directory name on disk — a convention where input names are expected to match directory names. Two problems:
- Projects with snake_case input names and kebab-case directory names (e.g.
inputs.tictactoe_solo_ai.url = "path:../logos-tictactoe-solo-ai") fail: nix emitsinput has an override for a non-existent input <dirname>, drops the override, falls through to the originalpath:..URL, and errors out under pure-eval. - The convention isn't visible at call sites: there's no error telling the developer to rename either the input or the directory; the break appears as a nix lock-resolution error from inside the store copy.
Scaffold now reads the target sub-flake's flake.nix at both probe time (basecamp modules) and build time (basecamp install / build-portable), looking for <name>.url = "path:../<sibling>" patterns, and emits --override-input <name> path:<sibling-abs> — keyed by the declared input name, not the directory name. Directory and input names no longer need to match.
The parser is line-level and recognizes the common single-line declarative forms (<name>.url = "…" and inputs.<name>.url = "…"). Multi-line nested-attrset forms (inputs.x = { url = "…"; flake = false; }; split across lines) are out of scope — they fall through silently and the probe or build may fail with the raw pure-eval error. Widening the parser is cheaper than adding a nix-based input enumerator, since the latter also hits pure-eval constraints on the very inputs we're trying to unstick.
The tradeoff: adding a minimal flake.nix text parser to scaffold. The upside: one less convention the user has to learn to get their project building, and the error mode goes away for legitimate non-convention projects. Build-time filtering via flake_declared_inputs (nix flake metadata) remains as defense-in-depth; after this change, the parser's output is already constrained to declared names, so the filter is redundant on the common path and only fires when the metadata fetch itself succeeded against some nix setup the parser didn't.
install and build-portable share a single source-resolution routine that is
parameterized on the flake attribute name (lgx vs lgx-portable). Hardcoding two
parallel resolvers would duplicate the precedence rules (explicit → root flake →
sub-flakes → targeted failure) and bug-surface the sibling path-input override
logic. The tradeoff is one extra argument on an internal helper; the upside is
that any resolver fix automatically applies to both commands, and the "only
.#lgx-portable found" and "only .#lgx found" error paths are symmetric by
construction.
--template spel delegates project generation to spel init, which raised the
question of where that binary comes from. The first implementation looked it up
on PATH and failed with an install hint when absent, with a version probe to
warn on mismatch.
That was wrong in the same way for every user: it made the ambient spel the
one that scaffolds the project, while scaffold.toml recorded DEFAULT_SPEL.
The two can disagree, and the probe could not even detect it — no spel release
implements --version, so the check compared against an empty string and warned
on every run.
Scaffold now clones DEFAULT_SPEL.sha into the cache (<cache>/repos/spel/<sha>)
and builds the CLI there, exactly as it already bootstraps LEZ, basecamp and
lgpm. Consequences:
- Nothing has to be installed first; a
spelonPATHis irrelevant. - The pin is the only version that can be used, so "scaffolded with one spel,
pinned to another" stops being a failure mode rather than being detected.
find_spel_on_pathandcheck_spel_versionwere deleted with it. - For cache-managed projects it is the same checkout and target directory
setupuses, so a laterlgs setupreuses the build instead of repeating it. With--vendor-depsit is not:scaffold.tomlthen pointssetupat the project-local clone, which has no build in it, so the CLI is built a second time there. That is a deliberate trade — the cache'starget/is about 1.7 GB, too much to copy into every vendored project to save one build.
Ordering matters and is easy to get wrong: spel init refuses to write into a
directory that already exists, so nothing may be created under the project
directory before the delegation — including the vendored repo for
--vendor-deps, which is therefore cloned after spel init returns.
Placement is the other trap. spel init resolves the name it is given against
its own working directory, so the invocation is derived from the target path
alone: its parent as the working directory, its final component as the name.
Deriving either half from anything else splits the project — scaffold's overlay
in one directory, the spel project in another, with exit 0. It went wrong twice
this way: running in the process cwd broke api::create_project, which takes
an explicit parent, and passing the typed name broke names with a path
separator (nested/sub-app became nested/nested/sub-app).
The two placement constraints, and the general rule that nothing may exist at
the project path before delegating, are held by tests that drive
finish_spel_project with a stub spel which, like the real one, refuses an
existing directory and resolves names against its own cwd. The --vendor-deps
ordering itself is not: those tests run with vendor_deps: false, because the
vendoring step does a real network clone. Moving that block above
run_spel_init would not fail the suite.
deploy needs to print the deployed program's on-chain ID (the risc0 image
ID) so the user can hand it to a client without rerunning a separate tool.
Three options were considered:
- Compute the image ID in-process by depending on a risc0 crate
(
risc0-binfmt/risc0-zkvm). - Re-implement the SHA-256 + page-tree construction directly in scaffold.
- Shell out to
spel program-idand parse its output.
Option (1) ties scaffold's image-ID computation to a specific risc0 release; version skew with the user's project's risc0 dependency would silently produce wrong IDs. It also pulls a sizable risc0 dep tree into scaffold's own build. Option (2) is even more brittle — any upstream change to the construction silently produces wrong IDs.
Scaffold vendors spel per project the same way it vendors LEZ: clone
logos-co/spel into the project, pin a commit (DEFAULT_SPEL_PIN,
currently tag v0.2.0-rc.5), build it during setup, and invoke the
project-local binary from deploy. spel itself depends on the same
risc0 crate the user's project does, so the image ID it computes is
byte-for-byte the value the sequencer will use. The pin is a scaffold-
shipped default overridable via [repos.spel].pin in scaffold.toml;
doctor reports drift the same way it does for LEZ.
LEZ-version alignment. Spel itself vendors LEZ as a Cargo dependency
for its sequencer-RPC client and wallet helpers. Picking a spel pin
whose spel-cli/Cargo.toml references a different LEZ commit than
scaffold's own DEFAULT_LEZ_PIN is a latent footgun: spel and the
scaffold-built sequencer would speak different versions of the
sequencer protocol, breaking lgs spel -- ... subcommands that hit
the network. Image-ID computation is unaffected (it's purely guest-ELF
- risc0-zkvm), but other spel surfaces would silently diverge.
We pick DEFAULT_SPEL_PIN to satisfy this alignment at every bump
(currently v0.2.0-rc.5, which pins LEZ via tag = "v0.2.0-rc1" —
the same commit DEFAULT_LEZ_PIN resolves to). The counter-intuitive
naming — v0.2.0-rc.5 is newer than the unsuffixed v0.2.0 tag —
is upstream's choice and a maintenance hazard worth flagging when
revising the pin. doctor enforces alignment at runtime by reading
<spel.path>/spel-cli/Cargo.toml and warning if neither
DEFAULT_LEZ_PIN nor DEFAULT_LEZ_TAG appears in spel's dependency
declarations.
The image ID is computed locally from the submitted ELF — scaffold does not (yet) verify on-chain inclusion. LEZ wallet/RPC don't currently surface deploy receipts; once they do, scaffold can add an inclusion check after submission and the human-output caveat note can retire. Until then, the deploy summary explicitly distinguishes "wallet accepted" from "chain confirmed."
The tradeoff is that setup now does an extra multi-minute build on first
run and the deploy path forks a subprocess to recover a value that could
in principle be computed inline. The upside: scaffold has zero risc0 dep
of its own, the program ID always matches what the sequencer sees, and a
logos-scaffold spel -- <args> proxy falls out for free so users can run
any spel subcommand without a global install. extract_program_id is
bounded by a wall-clock timeout and falls back to a non-fatal "unavailable"
hint so a broken or hung spel can never gate a successful deploy.
"Vendors per project" now means pinned per project, not cloned into each project. Like
LEZ, spel is checked out at <cache_root>/repos/spel/<pin> by default, with
[repos.spel].path empty (see "Pin-Only Storage, Path Derived at Runtime"). It lands in
.scaffold/repos/spel only for --vendor-deps projects. The pins quoted above are history.
Scaffold 0.4.1 ships spel v0.7.0 (DEFAULT_SPEL) and LEZ v0.2.4 (DEFAULT_LEZ), chosen
under the same alignment rule, which doctor still enforces.
When [repos.spel] was first added, every scaffolded project had a
config lacking it. The original solution: hard-fail in the parser with
a targeted error pointing at init, which appends the missing section
in place. Default-filling silently was rejected because the warning
would fire on every invocation forever (deploy, doctor, localnet,
wallet, spel, report all parse) and would corrupt
machine-parseable outputs (doctor --json, deploy --json).
The 0.2.0 schema migration generalizes that pattern. init is the
single migration entry point for any pre-0.2.0 scaffold.toml shape:
- pre-spel files (no
[repos.spel]) - legacy
urlfield on[repos.{lez,spel}] [basecamp].pin/.source/.lgpm_flake(moved to[repos.basecamp]/[repos.lgpm])[basecamp.modules.*](moved to top-level[modules.*])
init walks the file via toml_edit so comments, key ordering, and
unrelated sections survive the rewrite. It bumps [scaffold].version
to 0.2.0, prints a one-line summary of what changed, and refuses
already-migrated files. Pre-0.2.0 lgpm flake refs of the form
github:owner/repo/<sha>#attr are split into source/pin/attr
automatically; unparseable refs trigger a hand-edit hint with a
default pin written in place so the file is at least valid.
Every other command — deploy, doctor, setup, localnet,
wallet, spel, report, basecamp * — refuses pre-0.2.0 files
with a single line: "scaffold.toml uses an old schema (...). Run
logos-scaffold init to migrate to v0.2.0; existing settings are
preserved." JSON consumers stay clean.
Schema version 0.2.0 ([scaffold].version = "0.2.0") factors the file
into three orthogonal namespaces:
[repos.<name>]— every pinned external git dependency. One schema for all four:lez,spel,basecamp,lgpm. Fields:source(clone URL or flake source),pin(git SHA), optionalbuild("cargo"default,"nix-flake"for nix-built deps), optionalattr(flake output attribute), optionalpathoverride. Adding a fifth dep is a one-section addition with no code dispatch on section name.[modules.<name>]— Logos modules the project ships.flakerole. Basecamp consumes them viabasecamp install/launch/build-portable, but they're not basecamp's property — a future test harness or alternative loader can pick them up the same way.
[<feature>]— runtime config per feature:[scaffold],[wallet],[framework],[localnet],[basecamp](launch env and profiles;port_base/port_strideare reserved and unused).
Earlier schemas (pre-0.2.0) mixed all three: [basecamp] carried
pin / source / lgpm_flake / modules together with port_base, and
[repos.{lez,spel}] carried both url and source. Migration is via
logos-scaffold init, which detects any old-shape signal (pre-0.2.0
version stamp, url field, [basecamp].pin/.source/.lgpm_flake,
[basecamp.modules.*]) and rewrites in place via toml_edit so
comments and key ordering survive.
For every [repos.<name>], scaffold.toml stores pin and
source only; the on-disk clone location is derived at runtime from
resolve_cache_root() + "repos/<name>/" + pin. The file is therefore
portable across machines and CI by default — nothing in it depends on
the host's $HOME or cache layout. The cache_root chain
(env → [scaffold].cache_root → XDG default) decides where the clone
lands; the pin decides which commit is checked out.
[repos.lez] and [repos.spel] carry an additional optional path
field that [repos.basecamp] and [repos.lgpm] don't need. When set
it's authoritative — used literally if absolute, joined to
project.root if relative — and exists for two cases:
--vendor-depsprojects, wherenewwrites the relative literal.scaffold/repos/{lez,spel}so the clone lives inside the project tree.- Pre-portability
scaffold.tomlfiles in the wild that still carry an absolute cache path; the loader honors them verbatim so no migration is forced for that one field. Settingpath = ""and re-runningsetupopts back into portability.
setup decides sync mode from the same field: empty path →
cache-managed → auto-reclone on origin mismatch; non-empty path →
vendored or user-overridden → fail-on-mismatch so a developer's
checkout is never silently rewritten.
[repos.<name>].build is a discriminator with two values:
"cargo"(default; emitted only when the user opts into a non- default elsewhere).setupbuilds the clone viacargo build --release -p <hardcoded target>. Targets stay code-side; making them data-driven didn't earn its complexity."nix-flake".basecamp setupbuilds vianix build <source>/<pin>#<attr>.attris required.
The two paths share resolve_repo_path for the on-disk location and
source / pin storage; they diverge only in the build command they
issue.
The parser refuses to load any pre-0.2.0 file. The error names the
specific stale shape (e.g. [basecamp].lgpm_flake (moved to [repos.lgpm])) and points at init. Re-running init migrates and
the user proceeds. Default-filling the missing fields with a stderr
warning was rejected because the warning would corrupt
machine-parseable outputs (doctor --json, deploy --json) and
because users would never get nudged hard enough to actually
migrate. Hard-fail + targeted hint is the same model as the original
[repos.spel] migration.
The dev's "change → build → deploy → interact" cycle was multiple commands
(build, localnet start, wallet topup, deploy, then ad-hoc post-deploy
calls). Scaffold could have stayed at primitives and let projects script the
sequence themselves; instead, lgs run collapses the sequence into one
command with numbered step headers and optional post-deploy hooks.
Tradeoff: scaffold takes on responsibility for the pipeline shape. Adding or
reordering steps becomes a coordinated change across cmd_run, cli args,
serializer, and the dogfooding doc. Upside: every project gets the same
discoverable inner-loop story without per-project shell-script drift, and
the env contract that hooks see is uniform across projects.
The pipeline composes the existing primitives (cmd_build_shortcut,
build_idl_for_current_project, cmd_localnet, cmd_wallet_topup_inner,
cmd_deploy) — no parallel implementation. Step ordering is fixed: a new
step joins the chain rather than being sequenced by configuration.
Individual steps may, however, expose a boolean skip — deploy = false
(step 5) and topup = false (step 4) both do. The boundary is ownership,
not convenience: a step becomes skippable only when the project can
legitimately own that concern itself (it deploys from a post_deploy hook;
its demo binary claims from the faucet at runtime), and never to work around
a scaffold bug. Three constraints keep the pipeline shape visible even when
a step is skipped:
- The step header still prints, in its own slot, saying it was skipped and
why —
total_stepsdoes not shrink and the remaining steps are not renumbered. - The skip defaults to not skipping, written as a hand-rolled
Defaultrather thanderive(Default), so an existing project's behavior cannot change by adding the field. - The decision is exported to hooks (below), so a project that took over a concern can tell whether scaffold acted on this run.
A step whose skip cannot satisfy all three does not get a knob.
Post-deploy hooks run via sh -c with cwd at the project root. The env
they see is stable, documented in README, and validated by unit and
integration tests:
SEQUENCER_URL/NSSA_WALLET_HOME_DIR/LEE_WALLET_HOME_DIR/SCAFFOLD_PROJECT_ROOT/SCAFFOLD_IDL_DIR— pipeline state. The two wallet-home vars always carry the same path.SCAFFOLD_TOPUP_SKIPPED/SCAFFOLD_DEPLOY_SKIPPED— run-level outcome of the two skippable steps,1or0. Always set, never absent: a hook that had to treat "unset" as "scaffold did it" could not distinguish that from an older scaffold that cannot report. Each is produced by the same expression that executes or skips its step, so what a hook is told cannot drift from what ran. Both describe the run rather than a program;SCAFFOLD_TOPUP_SKIPPEDhas no per-program form at all, and the deploy one's suffixed spelling is not an independent per-program signal (below).SCAFFOLD_DEPLOY_SKIPPED_<name>— the run-levelSCAFFOLD_DEPLOY_SKIPPEDvalue repeated under each program's suffix, so the per-program family (SCAFFOLD_PROGRAMS/SCAFFOLD_PROGRAM_ID_<name>/SCAFFOLD_GUEST_BIN_<name>) stays parallel and a hook iterating$SCAFFOLD_PROGRAMSnever hits a missing var. Deploy is skipped for the whole invocation or none of it, so every program's copy carries the same value — do not read a per-program outcome into it.SCAFFOLD_PROGRAM_ID/SCAFFOLD_GUEST_BIN— single-program shortcuts. Set only when exactly one program is deployable; absent for multi-program projects so hooks fail loudly rather than silently picking up the wrong program.
The wallet home is exported under its upstream-wallet names rather than
under a SCAFFOLD_* prefix: hooks that exec the wallet binary (directly
or via cargo run --bin run_*) need the var under the name the binary's
WalletCore::from_env() reads. Renaming for hook ergonomics would
silently break those hooks. That reasoning is unchanged — but upstream
now has two such names. LEZ v0.2.0 renamed NSSA_WALLET_HOME_DIR to
LEE_WALLET_HOME_DIR, and a v0.2.0 wallet that sees only the old name
does not error: it falls back to ~/.lee/wallet. Scaffold therefore
sets both names, to the same path, on every wallet subprocess that
touches the wallet home and on every hook — the exception is doctor's
wallet --version probe, which only reads the binary's version string.
The list lives in WALLET_HOME_ENV_VARS (constants.rs); wallet
subprocesses apply it through set_wallet_home_env. Follow that
pattern for any future rename: add the new name, keep the old one,
never swap.
The single-program metadata is resolved once per lgs run invocation
and reused across every hook so multiple hooks don't multiply the cost
of spel program-id.
The deploy command must work for any scaffolded project regardless of its name.
Binary discovery should derive paths from the actual project structure, not assume the template's naming.
The implementation walks four roots — target/riscv-guest-docker/ (scaffold's deterministic
build), target/riscv-guest/ (the canonical risc0 layout used by the scaffold template),
methods/target/ (the sub-crate workspace layout) and methods/guest/target/ (where
cargo risczero build, and so a spel project's make build, writes) — matching <program>.bin
files whose path components include a riscv32im* target triple. A docker directory directly
under the triple ranks first, but only inside the one root the project kind owns
(target/riscv-guest-docker/ for default, methods/guest/target/ for spel): that is the tree
the last lgs build wrote, and lgs build never clears the others, so a docker/ leftover there
would otherwise win every later deploy with bytes the last build did not produce. deploy names
such a leftover on stderr instead of shipping it. Release builds come next; if only a debug build
exists, that is used as a fallback. When multiple matches exist within a rank, the shallowest
path wins. This keeps the scaffold general and avoids
coupling to a specific project name or workspace layout.
The deploy-side discovery above only works if guest binaries actually exist on disk. Risc0
guest crates target riscv32im-risc0-zkvm-elf and are intentionally excluded from the parent
workspace in real projects (the scaffold template lists them as members for ergonomics, but
projects that grew their own workspace — for example to add unrelated host crates — typically
exclude methods and methods/guest so cargo build --workspace doesn't try to build them
for the host triple).
build therefore probes for methods/Cargo.toml after the workspace build and, when present,
runs cargo build --release --manifest-path methods/Cargo.toml so the guest crate compiles
regardless of whether it is a workspace member. The probe is a single stat; absence is a no-op,
so non-Risc0 projects pay nothing. Release mode is chosen so the produced .bin lands in the
same release/ path component the deploy-side discovery requires — the two halves are designed
together. The shared methods directory name lives in crate::constants::METHODS_DIR.
The above describes the default template. spel projects do not build their
guest this way, for two independent reasons:
cargo build --workspacepanics on aspel init-generated project. Itsmethods/Cargo.tomlrunsrisc0_build::embed_methods()from a build script but carries no[package.metadata.risc0]section, which that function unwraps (reported upstream as logos-co/spel#287).- More fundamentally, a host
cargo builddoes not produce the artefact that gets deployed.make buildrunscargo risczero build, whose Docker output undermethods/guest/target/<triple>/docker/<name>.binis the reproducible binary whose ImageID is the ProgramId. A host-side build never creates it.
So build delegates spel projects to their own Makefile, and discovery gained a
third search root (methods/guest/target) and spel's make build output lands under a
docker path component, which discovery ranks above release (see "Deterministic
Guest Builds are the Default" below).
The invariant is unchanged and still designed as a pair — there are simply now
two producers, and both land somewhere discovery looks.
The same reasoning applies to IDL and FFI generation: spel generate-idl writes
to stdout, and the Makefile's idl: recipe is what redirects it to the file
spel.toml names; spel-client-gen is a separate binary with no spel
subcommand. Scaffold drives make idl / make ffi-gen rather than restating
either layout, pointing SPEL_CLIENT_GEN at the vendored build so the project
never depends on what happens to be on PATH.
risc0_build::embed_methods() — what "Guest Build Discovery" above describes — compiles the
guest against the host's Rust and clang. The ELF it emits, and therefore the risc0 image ID that
becomes the deployed program_id, is not guaranteed to be bit-identical across machines, OS
versions, or toolchain versions. That defeats the purpose of a program_id as a stable,
verifiable identifier for deployed bytecode (scaffold#259).
The reproducible alternative is the one lssa uses for the artefacts it ships: cargo risczero build, which compiles the guest inside a pinned risczero/risc0-guest-builder:<tag> container.
Same source plus same tag gives the same bytes on every machine.
Scaffold offers both, selected by [build].guest in scaffold.toml ("docker" | "local",
overridable per invocation with lgs build --guest), and defaults to docker. An earlier
revision defaulted to the host toolchain and only warned; review rejected that, because a default
whose failure mode is a silently non-portable program_id is a footgun — the damage shows up
later, on someone else's machine, after the ID has been published. Requiring Docker is a loud,
immediate, one-line-fixable failure; a wrong program_id is neither. So:
- the default is the safe one, and
localis an explicit opt-out for machines without Docker or for inner-loop speed on a program whoseprogram_iddoes not matter yet; - the missing-toolchain failure is made as cheap as possible:
lgs buildcheckscargo-risczero,docker, and the daemon beforesetupcan spend minutes compiling, and each error names the[build].guest = "local"escape hatch;lgs doctorreports the same condition as a FAIL; - a project that sets
guest = "local"has made the choice deliberately, solgs buildno longer nags;lgs doctorstill reports the active strategy and says it is not reproducible.
The two modes write to disjoint trees — embed_methods() owns target/riscv-guest/, the
deterministic build gets target/riscv-guest-docker/ via CARGO_TARGET_DIR. Deploy-side
discovery ranks a docker path component above release, and a local build deletes
target/riscv-guest-docker/ before it runs. Together those give one invariant: the last lgs build decides what lgs deploy ships. Without the delete, switching back to local would
leave a deterministic .bin on disk that outranks the fresh local one and would keep being
deployed; without the ranking, the reverse. The pin itself (DEFAULT_RISC0_DOCKER_TAG) is a
scaffold constant, not risc0's default, so the emitted ELF never depends on which
cargo-risczero version happens to be installed.
Reproducibility is a claim, so CI checks it rather than asserting it: the Guest Build
Reproducibility workflow renders a project, builds its guests through the container
twice from a clean tree, and fails on any digest difference. This mirrors what lssa
does by rebuilding and diffing its committed artifacts/. Without it, the pinned tag
could drift or a future risc0 release could reintroduce nondeterminism and nothing
would notice — the unit tests only pin the invocation, and Template E2E exercises the
host-toolchain path (--guest local).
LEZ's proving and verification crates read the logos-blockchain-circuits release at
compile and run time. Scaffold used to rely on whatever release sat in the developer's
environment (~/.logos-blockchain-circuits/). A mismatched release silently produces
incompatible verifier keys, and nothing in the project said which release it needed.
scaffold.toml now carries a [circuits] table (version, download template, install dir),
and every command that needs circuits resolves it from there. That covers setup, build,
build idl, localnet and test-node startup. The release is downloaded once into
[circuits].install_dir, which defaults to the project-local .scaffold/circuits.
LOGOS_BLOCKCHAIN_CIRCUITS remains an explicit override for a local checkout. The ambient
home-directory location is no longer consulted. doctor checks the installed VERSION
against the table and warns when the table drifts from the release the LEZ pin expects.
The tradeoff is one download per project rather than one per machine. The upside is that
the circuits release is pinned, reviewable and portable like every other dependency, and a
mismatch is caught by doctor instead of at proof time.
Integration tests need many short-lived sequencers, often in parallel. localnet is the
opposite shape: one long-lived developer sequencer per project, on a fixed port. Stretching
localnet to cover tests would have made every test fight over one port and one database.
test-node is therefore a separate surface. Each node gets its own port (--port 0 picks a
free one), config, database, log and runtime dir under .scaffold/test-nodes/<id>. It never
touches the developer localnet or the LEZ checkout. Nodes follow the caller project's pins,
and every resolved value is reported with its origin: CLI override, then scaffold.toml,
then the scaffold default. A caller-provided checkout ([repos.lez].path, or a local
--lez-source directory) is validated as a clean worktree at the requested commit and
never reset or force-checked-out. Only cache-managed checkouts are synced. RPC observations
are typed and give explicit outcomes. A transaction ends as exactly one of committed,
rejected, timeout, transport_error or wire_mismatch. A stateful rejection requires
multi-block observation plus a chain scan, never a single sleep.
The tradeoff is a second, overlapping command surface, with its own pins/prepare/doctor
alongside setup/doctor. The upside is that tests are isolated and parallel, and they
cannot mutate a developer's working checkout. A transport failure is never mistaken for a
business rejection.
The pinned LEZ settles each block as a single bedrock inscription with a payload cap of about 896 KiB, and it panics fatally when a block exceeds it. A deployment ELF is about 370 KiB, so submitting several programs back to back can put them in one block and kill the sequencer.
deploy waits for a new block past the previous submission before sending the next program.
Pacing fails closed. A stalled head, or a post-submission baseline it cannot read, aborts the
remaining submissions with a non-zero exit rather than sending them unpaced.
LOGOS_SCAFFOLD_DEPLOY_PACING_TIMEOUT_MS raises the ceiling for slow block intervals.
The cost is roughly one block interval (about 15 s by default) per extra program. If the upstream cap is lifted, the pacing becomes dead weight and should be removed.
setup --prebuilt saves the multi-minute sequencer_service build by downloading a
published binary. A downloaded executable that lands in target/release/ is
indistinguishable from one scaffold built, so it has to be at least as trustworthy.
The download is installed only if it matches the sequencer_service.sha256 published next
to it. A missing, unfetchable, empty or malformed checksum prints a warning and falls back to
the source build. A digest mismatch is a hard error. wallet is always built from source.
The tradeoff is that a release without a checksum gives no speed-up. The upside is that
--prebuilt can never install an unverified binary.
Agents working in a scaffolded project kept rediscovering how to drive lgs. Scaffold keeps
the canonical instructions in skills/ and installs the four skills (lgs-cli,
lez-template, spel-template, basecamp) into every project that new,
new --template spel or init touches. They go to .claude/skills/<name>/SKILL.md,
.cursor/rules/<name>.mdc (frontmatter rewritten for Cursor) and an AGENTS.md index.
The files are version-controlled in the generated project, never gitignored, so a team sees
and reviews what its agents are told. Re-running init refreshes them idempotently and owns
only those four names, so team-authored skills beside them survive. The tradeoff is that
init is no longer a no-op on an already-migrated project. It now always refreshes skills,
and a skill update reaches existing projects only when someone re-runs init.
Working on a project means juggling the inner loop across terminals: one for
lgs run, one tailing the sequencer log, one for localnet status and
wallet checks, with the state that answers "is my latest build deployed?"
buried in .scaffold/state/. LEZ developers already reach for a dashboard
for this (jzaki's prog-tui in jz-progs drives a bare LEZ checkout the
same way). lgs tui is that dashboard for a scaffold project.
Decisions:
- A subcommand of the same binary, not a separate crate. The dashboard
reads
.scaffold/state, the run cache and the discovery rules directly, so a separate release would drift from the formats it reads. - Status in process, actions out of process. Status comes from the same
functions
localnet status,deploydiscovery and therundeploy cache use, polled on a background thread. Every action spawnscurrent_exe() <args>in the project root and streams its stdout/stderr into the Output pane. Thecmd_*functions print to stdout and block, so calling them in process would corrupt the screen or need a second, output-capturing implementation of each command; a child process gives exactly the CLI's behaviour and output for free. The cost is a process spawn per action, which is nothing next to a build. - One job at a time, like one terminal: two commands never race on the
same project state. Each job runs in its own session: with no controlling
terminal, a tool that writes to
/dev/tty(risc0's guest build does) cannot draw over the screen, and as group leaderx(and quitting) stops cargo, docker and the rest of its tree.localnet startdaemonizes the sequencer into its own session, so the localnet outlives the dashboard exactly as it outlives a shell. - Scope is the inner loop:
run,run --watch,build,deploy,localnet start/stop/reset,wallet topup,doctor, and the sequencer log. Notbasecamp(launches desktop apps),test-node(for test harnesses), or thewallet --/spel --passthroughs (arbitrary arguments belong in a shell). Destructivelocalnet resetasks first and never takes the wallet with it. - "Deployed" means what
lgs run's cache means: the recorded build hash matches and the sequencer is the one deployed to. Nothing else records a deploy, so a barelgs deploy(d) does not set it; the pane title says "deployed by last run" for that reason. - No machine-readable mode. It refuses to start without a terminal; scripts and agents use the commands it wraps.
Tradeoff: ratatui (with its crossterm backend) becomes a dependency of
every install. Pinned to 0.29, the last release within the crate's
rust-version.