Developer Documentation
Last verified against commit 109a89e (2026-06-26).
# 1. Executive Summary
Tyu is a concatenative, stack-based systems language and toolchain for embedded and simulation targets. This repository contains the compiler front end, semantic checker, IR, target-specific code generators, module packer/signing/encryption tools, loader/runtime support, and the tyu project driver that orchestrates build, run, test, and deploy workflows.
It solves a fairly specific problem: building small, verifiable system images from .mod sources, linking them with a target runtime, packaging them into .lmod containers, and then loading or executing them under a trust model that can range from fully trusted firmware to re-derived untrusted modules.
Main consumers:
- Language/runtime developers working on the compiler, loader, or semantics.
- Embedded engineers building images for x86_64, ARM Cortex-M3, or RISC-V 32-bit targets.
- Test and CI authors maintaining the corpus and integration suites.
- Tooling integrators who need to extend the loader, runner, or deployment path.
What a new developer should learn first:
tyuis the orchestrator,langcis the compiler, and thelmod-*binaries are post-processing helpers.frontendparses source,semanticstypechecks and lowers to IR,irdefines the load-bearing representation, andcodegen-*backends emit target code.- Targets, features, and trust tiers are distinct concepts. A target triple is not the same as a feature profile or a loader trust level.
- The runtime boundary is encoded in the module ABI hash. Changing layout, runtime ABI, or module metadata invalidates previously built modules.
Big gotchas:
--emit=asminlangcis inspection-only;--emit=objis the production path.tyudefaults tox86_64-unknown-linux-gnuif no target is provided in common paths.- Loader trust is expressed through
LoaderPlatform::trust_level();verify_sigis a required trait method with no default, so every platform must state its verification behavior explicitly. tyubuild caching is fingerprint-based; changes to the compiler binary mtime andCODEGEN_REVintentionally invalidate cached objects.
# 2. High-Level Architecture
The repository is a modular monorepo with a layered compilation and deployment pipeline.
Major layers:
frontend: tokenization, parsing, AST structures, spans, and syntax recovery.semantics: typechecking, effect/capability checking, resource and borrow analysis, MMIO validation, and IR generation.ir: the intermediate representation and contract types shared by compiler and backends.codegen-core: target descriptions, feature/target metadata, backend traits, and shared codegen errors.codegen-x86_64,codegen-arm,codegen-riscv: ISA-specific code generators.langc: the single-module compiler CLI and driver.lmod:.lmodcontainer/header/modinfo/signature/encryption data structures and codecs.lmod-pack,lmod-sign,lmod-encrypt: container post-processing helpers.loader-core: the target-independent loader algorithm and platform abstraction.hosted: host-side runtime glue, loader platform implementation, and host wrappers.harness-core: execution-output parsing and ELF high-water scanning shared bytyuand test suites.tyu: project-level build/run/test/deploy driver.
Main runtime processes:
langccompiles one module to AST/IR/assembly/object output.tyu buildcompiles a module graph, assembles runtime units, and links an image.tyu runbuilds and executes an image, then classifies the result from harness output.tyu testdiscovers fixtures, builds the right artifacts, runs them across one or more targets, and checks corpus expectations.tyu deploybuilds, packs, optionally encrypts/signs, and runs the deploy artifact pipeline.lmod-pack,lmod-sign, andlmod-encryptare standalone utilities for the packaging stage.lang-assembleis a wrapper around assembler invocation; it is partially implemented for FASM and returns explicit diagnostics for unsupported backends.
Data flow:
.modor.defsource is parsed into an AST.- Semantic analysis turns source into typed IR and verifies stack/effect/borrow/contract constraints.
- Target backends lower IR to assembly or object code.
tyu buildlinks a static image directly, or — in dynamic mode (--mode=dynamic, the default for QEMU-capable targets) — packs the objects into.lmodcontainers vialmod-pack, then optionally encrypts (lmod-encrypt) and signs (lmod-sign) them.- In dynamic mode the on-device/host loader (
loader-core, entered vialoader_core::boot::__lang_load_and_runon bare-metal) validates, verifies, decrypts (platform-providedunwrap_cek), relocates, and maps each container. tyuandharness-coreinterpret execution output and diagnostics.
Architectural style:
- Modular monolith with strong internal layering.
no_stdcore crates for portability.- Host-side orchestration and tooling around the core compiler/runtime.
- Clear separation between “inspection” outputs and “production” outputs.
- The module ABI is an explicit contract boundary.
Intentional vs accidental structure:
- Intentional: target metadata lives in
TargetSpec; compiler backends are selected through a trait; loader trust tiers are explicit; runtime units are target-specific assembly files. - Intentional: the repository uses fixed capacities (
FixedVec) andno_stdin core crates to keep allocations and runtime dependencies controlled. - Likely accidental/legacy: the parser still contains migration handling for older syntax forms; some test guards and comments reference old phases and stale version numbers.
flowchart LR
A[.mod / .def] --> B[frontend]
B --> C[semantics]
C --> D[ir]
D --> E[codegen-core]
E --> F[codegen-x86_64 / arm / riscv]
F --> G[object .o]
G --> H[lmod-pack]
H --> I[.lmod]
I --> J[lmod-sign / lmod-encrypt]
J --> K[loader-core]
K --> L[hosted runtime / device]
L --> M[harness-core / tyu output parsing]# 3. Repository Map
| Path | Purpose | Important Notes |
|---|---|---|
Cargo.toml |
Workspace manifest | Declares all crates. Dev/test behavior is controlled at the workspace level. |
README.md |
Front door summary | Points to the tracked docs and lists the main build prerequisites. |
docs/DOCS.md |
Documentation index | Treat this as the tracked docs map. Add new docs here. |
SETUP.md |
Setup and local development | Tracked, CI-executed setup reference (tiers, source installer, first build). |
docs/TROUBLESHOOTING.md |
Known failure modes | Good reference for loader, diagnostic, and toolchain failures. |
docs/GLOSSARY.md |
Shared vocabulary | Useful for matching parser/IR/loader terminology. |
ci-lint.sh |
Test lint gate | Enforces test-quality conventions and a few repository-specific invariants. |
ci/guards.sh |
Test delivery gate | Checks that crates with #[test] actually execute tests. |
rust-toolchain.toml |
Toolchain pin | Pins nightly Rust with rust-src and the riscv32im-unknown-none-elf target. |
platforms/ |
Platform packs | Per-target platform.toml packs (x86_64, armv7m, riscv32, rp2350) discovered by tyu platform. |
fuzz/ |
cargo-fuzz targets | modinfo_decode and parse_container; excluded from the workspace but run by CI (fuzz_smoke job). |
runtime/ |
Per-target runtime assembly/link scripts | Target-specific runtime units are assembled and linked by tyu build. |
sysroot/ |
Standard library sources | Used by the compiler and test suites as the language sysroot. |
test-goldens/ |
Checked-in artifact goldens | Used for binary and assembly golden tests. |
memory/ |
Design notes / memory-model docs | Not part of the main build pipeline, but useful as background. |
crates/frontend |
Lexer/parser/AST | Source of truth for syntax and declaration forms. |
crates/semantics |
Typechecker and IR generation | Encodes the language’s safety model, resource model, and stack discipline. |
crates/ir |
IR and contracts | Shared between semantics and code generators. |
crates/codegen-core |
Target metadata and backend traits | Central place for target selection and codegen constraints. |
crates/codegen-x86_64 |
x86_64 backend | Emits x86_64 assembly/object logic. |
crates/codegen-arm |
ARM backend | Emits ARM Thumb code for Cortex-M style targets. |
crates/codegen-riscv |
RISC-V backend | Emits RV32 code for bare-metal targets. |
crates/langc |
Compiler CLI | Single-module compiler driver and langc binary. |
crates/loader-core |
Loader algorithm | Core .lmod loader and platform abstraction. |
crates/lmod |
.lmod format |
Header, modinfo, relocations, signatures, encryption, and validation. |
crates/lmod-pack |
Packager CLI | Converts object files to .lmod. |
crates/lmod-sign |
Signing CLI/library | Appends HMAC-SHA256 trailers. |
crates/lmod-encrypt |
Encryption CLI/library | Encrypts payload sections with ChaCha20-Poly1305. |
crates/hosted |
Host-side runtime glue | Implements LoaderPlatform on Linux/x86_64 and provides helper wrappers. |
crates/hosted-rt |
Startup/runtime entry macro support | Used by langc and lang-assemble no_std binaries. |
crates/harness-core |
Shared harness logic | Parses execution output and re-derives high-water bounds. |
crates/rsp-client |
GDB Remote Serial Protocol client | Used by debug escalation against QEMU gdbstub. |
crates/tyu |
Build/test/deploy orchestrator | The main entry point for project-level workflows. |
crates/lang-assemble |
Assembler wrapper | Thin CLI around assembler invocation. |
crates/lang-symtab-gen |
Symbol table generator | Generates runtime symbol tables from ELF objects. |
crates/device-loader-archive |
Static device-loader image | Excluded from the workspace; builds the on-device loader image whose entry is loader_core::boot::__lang_load_and_run. Used for dynamic-mode .lmod loading on bare-metal targets. |
crates/diag-core |
Runtime diagnostic protocol | Fixed 35-byte DiagRecord, trap-to-claim mapping, and host decoder. |
crates/execution-tests |
End-to-end execution tests | Runs target-specific assembly/QEMU suites. |
crates/tooling-tests |
Corpus-driven tooling tests | Verifies diagnostics, effects, encryption, loader behavior, and corpus expectations. |
Arith.asm |
Unknown/legacy root assembly file | The repository does not clearly document its role. Treat as unresolved. |
# 4. Core Concepts and Domain Model
# Module
Plain-English: a compilation unit. Source modules are .mod; interface-only modules are .def.
Implemented in:
crates/frontend/src/parse/mod.rscrates/frontend/src/parse/ast.rscrates/langc/src/iface.rscrates/tyu/src/graph.rs
Relations:
- Modules contain imports, declarations, and exports.
langccan compile a module alone, whiletyuresolves a module graph rooted at a main module.
Example:
frontend::parse::ModuleAstis the parsed representation.tyu::graph::resolve_graph()topologically sorts modules before build.
# Word
Plain-English: a named stack transformer with a signature, effects, required capabilities, and a stack bound.
Implemented in:
crates/frontend/src/parse/decl.rscrates/semantics/src/types.rscrates/ir/src/lib.rs
Relations:
- Parsed
DeclAstbecomesWordEntryin the semantic environment and thenir::Word. - Words can be imported, exported, or generated from builtins.
Example:
WordSigcontains up to 8 inputs and 8 outputs.WordEntryaddsperforms,requires, andbound.
# Signature
Plain-English: a typed stack effect of the form inputs -- outputs.
Implemented in:
crates/semantics/src/types.rscrates/semantics/src/typecheck/parse.rscrates/semantics/src/typecheck/mod.rs
Relations:
- Signatures are parsed from source spans and become the basis for typechecking and codegen.
- The parser accepts type atoms and composed forms such as pointer and array-like constructs.
# Effects, capabilities, and context
Plain-English: effects describe what a word does; capabilities are grants required to do it; context frames model the ambient environment during checking.
Implemented in:
crates/ir/src/contract.rscrates/semantics/src/typecheck/context.rscrates/semantics/src/typecheck/error.rs
Relations:
EffectSetandCapSetare bitsets in the IR contract.ContextStackfolds context frames to decide if a word is legal under the current environment.- The context matrix in
context.rsis the normative row-based model used by tests.
# Type atoms
Plain-English: fixed-size type names and compound type expressions encoded as atoms.
Implemented in:
crates/semantics/src/types.rscrates/ir/src/lib.rs
Relations:
- Builtins such as
i64,bool,ptr,ptr_mut,mmio,quot,resource, andscopedare predeclared atoms. - The parser and typechecker treat these as canonical names.
# Target / TargetSpec / FeatureSet
Plain-English: target triples control ABI, assembler, linker, and runtime behavior; features control image-level capabilities such as concurrency and module loading.
Implemented in:
crates/codegen-core/src/target.rscrates/codegen-core/src/emit_mode.rscrates/tyu/src/project.rs
Relations:
TargetSpecis the single source of truth for slot width, calling convention, assembler, linker, QEMU invocation, and capabilities.FeatureSetcomes fromtyu.tomlprofiles orlangc --features=....
# StackBound
Plain-English: the net and peak stack usage of a word or module.
Implemented in:
crates/ir/src/contract.rscrates/loader-core/src/rederive.rscrates/diag-core/src/decode.rs
Relations:
StackBound { net, high }is used by the semantics checker and loader verification.High::Topmeans the bound is not finitely derivable.
# ABI hash
Plain-English: a compatibility checksum that prevents loading modules compiled against a different runtime contract.
Implemented in:
crates/lmod/src/abi_hash.rscrates/lmod/src/modinfo.rscrates/loader-core/src/load.rs
Relations:
- It depends on slot width, word width, runtime ABI version, modinfo version, and the hash recipe version.
langcandtyu buildboth compute it using the target spec.
#
.lmod container
Plain-English: the deployable unit that packages module code, metadata, relocation information, and optional signature/encryption data.
Implemented in:
crates/lmod/src/header.rscrates/lmod/src/modinfo.rscrates/lmod/src/reloc.rscrates/lmod/src/validate.rscrates/lmod/src/sig.rscrates/lmod/src/enc.rs
Relations:
lmod-packcreates it from an ELF object.lmod-signappends a trailer.lmod-encryptadds an encryption envelope.loader-corevalidates and loads it.
# Trust tier
Plain-English: a module loading policy that controls how much the loader trusts incoming modules.
Implemented in:
crates/loader-core/src/platform.rscrates/loader-core/src/load.rs
Relations:
- Tier 0 trusts the platform baseline.
- Tier 1 requires per-module signature checks.
- Tier 2 requires stronger re-derivation and untrusted-module handling.
# 5. Application Flow and Request Lifecycle
# Startup / initialization
Triggered by:
tyuprocess startup.langcprocess startup viahosted_rt::entry!.
What happens:
tyu::main()reads the current directory and tries to findtyu.toml.- The manifest is parsed into
ProjectManifest. - CLI arguments are parsed into
args::Command. - Project settings are merged into the command-specific args.
- The selected subcommand runs.
Failure points:
- Missing or invalid
tyu.toml. - Unknown target triple.
- Invalid profile or feature name.
Debugging:
- Run
tyu toolchain check <target>. - Print the resolved manifest with
eprintln!output fromtyu main.
sequenceDiagram
participant Shell
participant Tyu as tyu::main
participant Manifest as tyu::project
participant Args as tyu::args
Shell->>Tyu: tyu build|run|test|deploy
Tyu->>Manifest: find_manifest + parse_project_manifest
Tyu->>Args: parse()
Tyu->>Tyu: apply_project_* + resolve_profile
Tyu->>Subcommand: build/run/test/deploy/toolchain_check# Build pipeline
Triggered by:
tyu buildtyu runandtyu deploycall into the same build pipeline first.
What happens:
- Resolve the module graph with
tyu::graph::resolve_graph. - Compute the target ABI hash using
lmod::abi_hash::compute_abi_hash. - Load the build cache (
target/tyu/build.json). - Compile each module with
langc. - Assemble required runtime units from
runtime/<triple>(or the platform pack underplatforms/<name>/). - Static mode: link the resulting object files into an ELF image. Dynamic mode: pack modules into
.lmodcontainers, then optionally encrypt (lmod-encrypt) and sign (lmod-sign). - Persist the build cache.
Failure points:
- Graph resolution failures and cycles.
- Missing tools on PATH.
langccompilation failure.- Runtime unit missing for the selected target.
- Linker or assembler failure.
Debugging:
- Inspect
target/tyu/<triple>/build.json. - Use
langc --emit=iror--emit=asmto narrow down where the compiler diverges.
#
Main request handling path for langc
Triggered by:
- Running the
langcbinary directly.
What happens:
- Parse CLI flags in
crates/langc/src/args.rs. - Read source bytes and parse the module AST.
- Resolve imports and interfaces in
iface.rs. - Build the semantic environment and check the module.
- Emit AST, IR, stackcheck output, assembly, or object code depending on
EmitMode.
Failure points:
- Parse errors, missing input, invalid emit mode, or
--emit=objwithout--target. - Semantic/typecheck errors.
- Backend unsupported-op or malformed-output errors.
# Run / execution lifecycle
Triggered by:
tyu runtyu test
What happens:
- Build the image.
- Select a runner:
- native host execution,
- QEMU system-mode,
- QEMU gdbstub escalation,
- or device runner via OpenOCD.
- Execute the image with a timeout.
- Parse stdout/stderr markers via
harness_core::parse_output. - Classify results as hang, no completion, failure marker, or exit-code mismatch.
Failure points:
- Runner selection mismatch.
- Missing QEMU or native execution environment.
- Missing
S,F,H,P, orDmarkers. - Exit code mismatch for the platform’s expected pass convention.
# Background job execution
The repository does not have a general-purpose async worker queue. Background-ish work happens via:
tyu buildcompiling modules and runtime units.tyu testiterating fixtures and targets.tyu debug_escalateattaching to QEMU gdbstub when diagnostics are missing.
# Event handling / diagnostics
Events are mostly execution-output records:
Ffailure marker.Scompletion marker.Hhigh-water marker.Passertion count marker.Ddiagnostic record.
These are parsed in harness-core and fed into the test and escalation flows.
# Data persistence
Persistent outputs:
target/tyu/build.jsonbuild cache.- produced
.o,.lmod, and image artifacts inout_dir. - test goldens and corpus fixtures in the repo.
# Error handling
The codebase uses explicit error enums and stable numeric codes across major surfaces:
TyuErrorCodegenErrorTcErrorLoadErrorPackError,SignError,EncError
Most user-facing commands print a diagnostic to stderr and exit non-zero rather than bubbling panics.
# Logging and observability
Logging is mostly stderr text with a few structured diagnostics:
langcemits parsed error codes viadiag::error_simple.tyuprints manifest selection, profile resolution, and execution outcome summaries.- test corpus and escalation paths emit detailed diagnostic comparisons.
# External service calls
tyushells out to assemblers, linkers, QEMU, and OpenOCD.debug_escalateconnects to QEMU’s gdbstub using the RSP client.
# Shutdown / cleanup
tyu cleanremovestarget/tyu.- Runner processes are terminated by timeout or completion logic.
# 6. Public APIs and Interfaces
# CLI binaries
| Command | Purpose | Location | Inputs | Output | Notes |
|---|---|---|---|---|---|
langc |
Compile a single module | crates/langc/src/main.rs |
Source file, flags from crates/langc/src/args.rs |
AST/IR/asm/object/stdout diagnostics | no_std, no_main, hosted entry macro. |
tyu |
Project driver | crates/tyu/src/main.rs |
Subcommands build, run, test, deploy, platform, toolchain check, clean |
Build outputs, execution results, toolchain report | The main orchestration interface. |
lmod-pack |
Pack ELF object to .lmod |
crates/lmod-pack/src/main.rs |
Input .o, output .lmod |
Packed container | Uses lmod_pack::pack. |
lmod-sign |
Append HMAC signature | crates/lmod-sign/src/main.rs |
Input .lmod, output .lmod, --key=<hex> |
Signed container | Requires 32-byte key. |
lmod-encrypt |
Encrypt payload sections | crates/lmod-encrypt/src/main.rs |
Input .lmod, output .lmod, mode-specific key material |
Encrypted container | Supports fleet/device modes. |
lang-assemble |
Assembler wrapper | crates/lang-assemble/src/main.rs |
Assembly input, output path, target | Object file or diagnostic | FASM is implemented; GAS backends report unsupported. |
#
tyu subcommands
| Method | Path | Purpose | Auth | Request | Response | Implementation |
|---|---|---|---|---|---|---|
build |
tyu build |
Compile/link an image | None | --target, --profile, --sysroot, --out-dir, -I |
Path to image | crates/tyu/src/build.rs |
run |
tyu run |
Build and execute an image | None | Build args + --timeout, --runner |
Exit classification, stdout parsing | crates/tyu/src/run_cmd.rs |
test |
tyu test |
Discover and run fixtures | None | --target, --all-targets, --filter, --manifest |
Per-fixture result reporting | crates/tyu/src/test_cmd.rs |
deploy |
tyu deploy |
Build, pack, encrypt, sign, and execute | None, but key material required for secure modes | Build args + encrypt/sign/device options | Deploy artifacts and verification summary | crates/tyu/src/deploy.rs |
platform |
tyu platform <sub> |
Inspect/scaffold platform packs | None | list, info <name> [--isa=], lint <name> [--all], new <name> |
Pack listing, details, lint report | crates/tyu/src/platform/ (config.rs, lint.rs, linker_script.rs) |
toolchain check |
tyu toolchain check <target> |
Resolve compiler/tool paths | None | Target alias or triple | Human-readable tool report | crates/tyu/src/toolchain.rs |
# Core traits and internal interfaces
| Interface | Location | Purpose | Extension Guidance |
|---|---|---|---|
CodegenBackend |
crates/codegen-core/src/backend.rs |
Target backend contract | Implement for a new ISA/backend pair. |
LoaderPlatform |
crates/loader-core/src/platform.rs |
Platform abstraction for memory allocation and verification | Implement for a new runtime/host/device. |
Output |
crates/frontend/src/parse/ast.rs and semantics re-exports |
Text output sink for parsers/emitters | Use for inspection output. |
TypecheckObserver |
crates/semantics/src/typecheck/irgen/observer.rs |
Inspect typechecker/IR-gen events | Use to observe or test typechecking. |
Runner |
crates/tyu/src/runner.rs |
Execution backend selector | Add new execution modes here. |
#
langc compiler flags
--emit=ast|ir|tc|asm|obj--lib-g-I <path>--checks=off|contracts|all--allow-raw-casts--features=<csv>--no-default-features--sysroot=<path>--out-dir=<path>--target=<triple>
langc also parses --unsafe-allow-5031, which is intentionally not listed in --help. As of the last verification it is stored in Args but not yet consumed by the driver (diagnostic 5031 is TcError::ResourceSharedUnlocked); treat it as reserved.
#
tyu command-line options
Common (build/run/test/deploy):
--target=<triple>--platform=<name>(select a platform pack)--isa=<arch>(ISA filter for platform packs)--profile=<name>--mode=static|dynamic(link/load mode; defaults to dynamic for QEMU-capable targets)--sysroot=<dir>--out-dir=<dir>-I <dir>
Run-specific:
--timeout=<secs>(default: 10)--runner=native|qemu(default: auto)
Test-specific:
--all-targets,--all-platforms--filter=<pat>--manifest=<path>--qualify(fail when required coverage axes are uncovered)--format=human|json--report-out=<path>
Deploy/metal options:
--encrypt=none|fleet|device--key-encrypt=<keyref>,--key-sign=<keyref>,--device-keys=<dir>,--sign--commit-otp(guarded irreversible OTP path; requiresTYU_ALLOW_OTP=1andTYU_OTP_READBACK=verified)--metal-sign-key=<keyref>(provision Tier-1 firmware HMAC key)--metal-kek=<keyref>(encrypt dynamic.lmodwith a firmware KEK)--metal-encrypt=fleet|device(default: fleet)
Key references (<keyref>) accept file:<path>, env:<VAR>, and fd:<n>; bare hex on the command line is rejected by tyu::keys (note: the standalone lmod-sign CLI still takes --key=<hex> directly).
# 7. Configuration and Environment
Config files:
rust-toolchain.tomltyu.tomlproject manifestsplatforms/<name>/platform.tomlplatform packs (discovered bytyu platform)fixtures/manifest.tomlas the default test-manifest path fortyu test(relative to CWD; pass--manifestexplicitly at the repo root)
Environment variables:
| Name | Required | Default | Used By | Description |
|---|---|---|---|---|
TYU_BIN_DIR |
No | none | tyu tests and integration helpers |
Points to a directory containing built host binaries. |
TYU_<ROLE>_<TRIPLE> |
No | none | tyu::toolchain |
Overrides a specific tool for a target triple. |
PATH |
Yes in practice | system PATH | tyu, host tools, tests |
Used to resolve assemblers, linkers, QEMU, OpenOCD, and langc. |
CI |
No | unset | tests/guards | Changes missing-tool behavior from skip to hard failure in some suites. |
TYU_TEST_KEY |
No | test-only | crates/tyu/src/keys.rs tests |
Demonstrates safe env-based key loading. |
TYU_SIGN_KEY / TYU_ENC_KEK |
No | none | tyu deploy/tyu build |
Key material for key_sign = "env:TYU_SIGN_KEY" and key_encrypt = "env:TYU_ENC_KEK" manifest keyrefs. |
TYU_ALLOW_OTP |
Only for --commit-otp |
unset | crates/tyu/src/deploy.rs |
Must be 1 to unlock the manual OTP-commit board procedure. |
TYU_OTP_READBACK |
Only for --commit-otp |
unset | crates/tyu/src/deploy.rs |
Must be verified before any irreversible OTP write. |
TYU_TEST_ENCRYPT_WITH_KEK |
No | unset | tyu build test paths |
Test-only hook forcing KEK-based encryption in build tests. |
TYU_TEST_MUTATE_LMOD |
No | unset | tyu build test paths |
Test-only hook that mutates a packed .lmod to exercise loader rejection. |
Project manifest sections:
[project]: main module and module roots.[targets.<name>]: alias to a target triple plus optional runner.[toolchain.<triple>]: assembler, linker, and QEMU overrides.[deploy.<name>]: deployment settings.[profile.<name>]: feature lists (concurrency,module-loading).
Defaulting rules:
tyubuild/run defaults tox86_64-unknown-linux-gnuif no target is provided.tyu testdefaults tofixtures/manifest.tomlrelative to the current working directory; no such file exists at the repo root, so pass--manifest=crates/execution-tests/fixtures/manifest.toml(as CI does).- Link/load mode defaults to dynamic for QEMU-capable targets, static otherwise.
tyubuild/run output defaults totarget/tyu/<triple>.- If no
profileis set and a manifest contains[profile.dev], that profile is used; otherwise the feature set defaults to all enabled intyu. langcdefaults toFeatureSet::all()unless overridden by flags or project resolution.
Dangerous values:
- Changing target slot width, target ABI, or
MODINFO_VERinvalidates cached and prebuilt artifacts. - Changing trust-tier assumptions alters signature verification behavior.
- Changing runtime assembly paths or toolchain overrides affects the whole build pipeline.
# 8. Data Model and Persistence
This repository does not use a general-purpose database. Its persistence model is file-based.
Stored artifacts:
.modand.defsource files..ointermediate objects produced bylangc..lmodcontainers produced bylmod-pack,lmod-sign, andlmod-encrypt.target/tyu/build.jsonbuild cache.test-goldens/*.lmodandtest-goldens/asm/*golden outputs.
Major structured formats:
frontend::parse::ModuleAstcaptures module syntax.ir::Module,ir::Word,ir::Block, andir::Opcapture compiler IR.lmod::header::LmodHeadercaptures container layout.lmod::modinfo::LangModInfoencodes exported/imported symbol metadata and resource metadata.loader-core::symbols::SymMaptracks exported names at load time.tyu::cache::BuildCachepersists compiler artifact fingerprints and object paths.
Relationships:
- A module contains words, imports, structs, enums, subtypes, resources, and metadata.
- The container header points to
modinfo, code, rodata, data, relocation, and signature regions. - The loader binds exports into a flat symbol map and prevents duplicate names and hash collisions.
erDiagram
MODULE ||--o{ WORD : contains
MODULE ||--o{ IMPORT : imports
MODULE ||--o{ STRUCT : defines
MODULE ||--o{ ENUM : defines
MODULE ||--o{ RESOURCE : defines
LMOD_HEADER ||--|| LMOD_CONTAINER : describes
LMOD_CONTAINER ||--|| MODINFO : embeds
LMOD_CONTAINER ||--o{ RELOC : has
LMOD_CONTAINER ||--o| SIG_TRAILER : optionalImportant constraints:
lmod::validate::Container::parse()rejects malformed containers before accessors can be used.tyu::cache::BuildCacheversion2is the only recognized cache schema; unreadable or wrong-version files are treated as empty.SymMapis fixed-capacity and O(n) lookup by design; that is acceptable for small embedded symbol counts.
# 9. External Services and Integrations
| Service | Purpose | Code Location | Config | Failure Handling |
|---|---|---|---|---|
fasm |
Assemble x86_64 runtime and objects | crates/tyu/src/build.rs, crates/lang-assemble/src/driver.rs |
PATH or tyu.toml toolchain override |
Hard error if missing or non-zero exit. |
arm-none-eabi-as / arm-none-eabi-ld |
ARM bare-metal assembly/linking | crates/tyu/src/build.rs |
PATH or [toolchain.<triple>] |
Hard error. |
riscv32-unknown-elf-as / riscv32-unknown-elf-ld |
RISC-V bare-metal assembly/linking | crates/tyu/src/build.rs |
PATH or [toolchain.<triple>] |
Hard error. |
ld |
Hosted x86_64 linking | crates/tyu/src/build.rs |
PATH or manifest override | Hard error. |
qemu-system-x86_64, qemu-system-arm, qemu-system-riscv32 |
Execution backend for tests and run modes | crates/tyu/src/runner.rs, crates/execution-tests/tests/* |
PATH or toolchain override | Timeout, exit-code mismatch, or skip when unavailable outside CI. |
OpenOCD |
Physical device flashing | crates/tyu/src/runner.rs |
Runner configuration | Flash failure becomes a TyuError::Runner/build error. |
| QEMU gdbstub | A-side escalation debugging | crates/tyu/src/debug_escalate.rs |
QEMU -gdb/-S flow |
Escalation returns a diagnostic string or an error string. |
Host OS syscalls (mmap, mprotect, munmap) |
Host loader memory management | crates/hosted/src/loader.rs |
Platform implementation | Wrapped into loader error codes. |
| RSP over TCP | Debugger transport | crates/rsp-client/src/lib.rs |
Ephemeral local TCP port | Connection/packet failures are returned as I/O errors. |
How to test integrations locally:
- Use
tyu toolchain check <target>to verify tool discovery. - Use
cargo test -p rsp-clientandcargo test -p loader-corefor lower-level behavior. - Use
tyu run --runner=nativeor--runner=qemuto isolate execution backends. - Use the
execution-testsandtooling-testssuites for end-to-end validation.
# 10. Building Applications on Top of This Codebase
Intended extension points:
- Add a new target by extending
codegen-core::Targetand adding a backend. - Add a new semantic check in
semantics. - Add a new runtime service by adding a runtime assembly unit and exposing it through
TargetSpec::Feature. - Add a new loader capability by extending
LoaderPlatformor the loader data model. - Add a new orchestrated workflow in
tyu.
What to use instead of modifying internals:
- Use
TargetSpecinstead of ad hocif target == ...checks. - Use
CodegenBackendinstead of emitting assembly from the driver. - Use
LoaderPlatforminstead of hardcodingmmap/mprotect. - Use
BuildCacheandtyu::graph::resolve_graph()rather than reinventing build discovery.
#
How-to 1: Add a new tyu subcommand
Goal:
- Add a command such as
tyu inspect.
Files to modify:
crates/tyu/src/args.rscrates/tyu/src/main.rs- New module under
crates/tyu/src/
Steps:
- Add a new variant to
args::Command. - Extend
parse()with a new branch. - Add a new command module and call it from
main.rs. - Decide whether the command needs project manifest resolution or profile resolution.
- Add tests in
crates/tyu/tests/.
Example:
// args.rs
pub enum Command {
// ...
Inspect(InspectArgs),
}Tests to add:
- CLI parse test.
- Failure mode test for missing required flags.
- Integration test if the command shells out.
Common mistakes:
- Forgetting to update
print_usage(). - Returning
Stringerrors in new code whenTyuErroris already available.
# How-to 2: Add a new target backend
Goal:
- Support a new architecture or platform.
Files to modify:
crates/codegen-core/src/target.rs- New backend crate under
crates/ crates/langc/src/driver.rscrates/tyu/src/build.rs- Runtime assembly under
runtime/<triple>/
Steps:
- Add a new
Targetvariant andTargetSpec. - Add assembler/linker/QEMU metadata and capabilities.
- Implement
CodegenBackendfor the ISA. - Teach
langcto select the new backend. - Add runtime assembly and linker scripts.
- Add loader/runner support if it is a new execution model.
Tests to add:
- Backend unit tests.
- Golden assembly/object tests.
- End-to-end
tyu run/tyu testcoverage.
Common mistakes:
- Forgetting to update
Target::ALL. - Forgetting to extend
tyutarget-specific tool requirements. - Diverging the ABI hash by changing target contract fields without updating goldens.
# How-to 3: Add a new language feature or builtin word
Goal:
- Add a new word, type atom, or syntax form.
Files to modify:
crates/frontend/src/parse/decl.rscrates/semantics/src/typecheck/builtins.rscrates/semantics/src/typecheck/irgen/*crates/ir/src/lib.rsand/orcrates/ir/src/contract.rs- Tests in
crates/frontend/tests/andcrates/semantics/tests/
Steps:
- Add syntax support in the parser.
- Extend the semantic environment or builtin table.
- Lower the construct to IR.
- Add backend support if the IR op is new.
- Add corpus coverage or golden tests.
Tests to add:
- Parse success/failure tests.
- Semantics acceptance/rejection tests.
- Backend output tests if codegen changes.
Common mistakes:
- Adding a parser form without a corresponding semantic rule.
- Updating the parser but forgetting the tests that lock in error codes.
# How-to 4: Add a new external integration
Goal:
- Integrate a new loader platform, runner, or debugging backend.
Files to modify:
crates/loader-core/src/platform.rscrates/tyu/src/runner.rscrates/tyu/src/debug_escalate.rs- Possibly
crates/rsp-client
Steps:
- Define the abstraction boundary first.
- Implement the concrete client or platform.
- Return stable error codes or structured errors.
- Add a test harness that exercises both happy and failure paths.
# 11. API Usage Examples
#
Minimal langc
langc --emit=ast src/Main.mod# Authenticated / secure deployment example
tyu deploy \
--target=x86_64-unknown-none \
--encrypt=fleet \
--key-encrypt=file:keys/fleet.kek \
--key-sign=file:keys/signing.key \
--sign \
src/Main.mod# Error-handling example
if ! tyu run --runner=qemu --timeout=15 src/Main.mod; then
echo "run failed; inspect stderr diagnostics"
fi# Advanced example
langc --emit=obj --target=armv7m-unknown-none \
--sysroot=sysroot \
--out-dir=target/tyu/armv7m-unknown-none \
-I src \
src/Main.mod# Connecting to another service
- The closest thing to a service connection in this repo is the
LoaderPlatformimplementation inhostedor the RSP client used bydebug_escalate. - For example, a new debugger backend would implement a TCP client analogous to
rsp-client::RspClientand then use it from a new escalation flow.
# Small feature example
- To add a new runtime unit, add a
runtime/<triple>/<unit>.asmfile, extendFeature::runtime_unit(), and lettyu buildinclude it when the feature is enabled.
# 12. Extension and Customization Guide
Extension mechanisms:
- Rust traits:
CodegenBackend,LoaderPlatform, andTypecheckObserver. - Target registry:
Target,TargetSpec,Feature, andPlatformCapability. - Runtime units: target-specific
.asmfiles underruntime/. - Build manifest:
tyu.tomlprofiles, toolchain overrides, and target aliases. - Test corpus: add fixtures under
crates/tooling-tests/tests/corpusorcrates/execution-tests/fixtures.
Safe extension checklist:
- Preserve stable numeric error codes.
- Update tests before changing parser or ABI behavior.
- Keep
TargetSpecauthoritative; do not duplicate target constants in multiple crates. - Decide whether a new feature changes semantics, runtime linkage, or both.
- Add loader/platform behavior only through
LoaderPlatformor the loader container format, not via ad hoc host-side special cases. - Validate new external tool dependencies in
tyu toolchain check.
What should stay internal:
irgenhelper internals.loader-corerelocation helpers.- Parser recovery details.
- Test-only debug scaffolding.
How extensions are discovered and loaded:
- Build-time: by
tyugraph resolution and runtime-unit inclusion. - Compile-time: by Rust
moddeclarations and explicit crate dependencies. - Runtime: by
LoaderPlatformand the chosen runner.
How extensions can break the system:
- Invalidating ABI hash assumptions.
- Changing loader trust semantics without updating docs/tests.
- Introducing new IR ops without backend support.
- Adding runtime units without target metadata.
# 13. Important Design Principles
The codebase appears to follow these principles:
- Explicit contracts over implicit convention. Examples:
TargetSpec,StackBound,LoaderPlatform,CodegenBackend. - Small fixed-capacity data structures in core code to keep
no_stdfriendliness and bound memory use. - Compatibility-by-construction. ABI hash, modinfo, and loader error codes are all intentionally stable.
- Layered lowering pipeline. Each phase owns a single responsibility.
- Host tooling separated from core runtime semantics. The core crates avoid host-only assumptions.
Tradeoffs:
- The system favors predictability and explicitness over maximal flexibility.
- Fixed capacities make implementation simpler but impose hard ceilings on some structures.
tyuuses shell-out orchestration rather than an in-process linker/assembler pipeline.- The loader’s trust model is explicit but somewhat conservative and platform-specific.
Complexity intentionally hidden:
- ABI hash computation.
- Container validation and signature/encryption layout.
- QEMU debug escalation.
- Build graph resolution and cache invalidation.
High-coupling areas:
- Target metadata and runtime units.
- ABI hash, modinfo, and container layout.
- Typechecker, IR, and backend op support.
Low-coupling areas:
- CLI wrappers around helper crates.
- Corpus tests around explicit output records.
Repeated patterns:
Result<T, E>with stable error codes.FixedVecplus explicit capacity checks.- Trait-driven backends/platforms.
no_stdin core crates andstdonly where required.
Risky areas:
- Version bumps in
modinfo/ ABI hash / runtime ABI. - Loader trust-tier behavior.
- Any new IR operation that must be classified everywhere.
# 14. Error Handling, Validation, and Edge Cases
Validation happens in several places:
- Parsing errors in
frontend. - Type/signature validation in
semantics. - Container structural checks in
lmod::validate::Container::parse. - Platform and trust checks in
loader-core. - CLI argument validation in
tyuandlangc.
Error types and patterns:
- Error enums with stable numeric codes are preferred.
diag::error_simple(code, msg)is used for user-facing diagnostics.thiserrorpowersTyuErrorformatting.
How errors are returned:
langcandtyugenerally return exit code2for user-facing failures in compiler-like paths.tyu runuses specific exit codes for hang/no-completion/failure-marker/mismatch.- Loader errors map to the
52xxband.
Retry/recovery:
- Build cache misses are normal and recover by recompiling.
- Missing tools can be skipped outside CI in some tests.
debug_escalateretries execution under gdbstub after missing in-guest diagnostics.
Explicit edge cases:
- Container bounds and overlap checks.
- Hash collisions in the global symbol map.
- Tool availability differences between local and CI runs.
- Test fixtures that are allowed to fail only in prescribed ways.
Under-tested or missing:
- The repository’s own docs note limited RISC-V end-to-end coverage.
- Fuzzing is limited to two cargo-fuzz targets (
fuzz/fuzz_targets/modinfo_decode.rs,parse_container.rs); parser and codegen surfaces are not fuzzed. - There is no visible HTTP/API layer, so network-edge validation is not a concern.
# 15. Authentication, Authorization, and Security
Authentication and authorization are not present in the usual web-app sense. The security model is loader- and key-centric.
Security mechanisms:
- Trusted container signatures and encryption envelopes.
- Trust levels in the loader platform abstraction;
verify_sigandunwrap_cekare requiredLoaderPlatformmethods, so platforms must implement signature verification and content-key unwrapping (on-device decryption) explicitly — there is no fail-open default. - Zeroized key material in
tyu::keys::KeyMaterial. - Key source parsing that rejects raw command-line hex keys and prefers
file:,env:, orfd:references. - A guarded OTP-commit path:
--commit-otpis refused unlessTYU_ALLOW_OTP=1andTYU_OTP_READBACK=verifiedare set, and is always refused underCI.
Where checks are enforced:
loader-core::load_moduleenforces trust-tier and signature/encryption rules.lmod::validate::Container::parseenforces structural safety.tyu::deployenforces key presence for fleet/device encryption and signing flows.
Secrets handling:
KeyMaterialstores keys in a zeroizing buffer.KeyRefsupports safe sources and rejects bare hex on the command line.
Main assumptions:
- Tier 0 trusts the platform by default.
- Tier 1 and 2 require stronger verification and/or re-derivation.
- The signed region and encrypted envelope layout are part of the compatibility contract.
Security-sensitive areas:
- Trust-tier defaults in
LoaderPlatform. - Encryption/signature trailer handling.
- Loader relocation and symbol resolution.
- QEMU gdbstub escalation, because it can expose execution state and symbols.
Obvious risks:
- A platform implementing
verify_sigorunwrap_cekincorrectly (e.g. always returning success) would weaken the trust model; there is no default left in place, but implementations are trusted. - Version mismatches between container format, modinfo, and ABI hash can silently reject old artifacts.
# 16. Testing Strategy
Test frameworks and styles:
- Standard Rust unit tests.
- Integration tests under crate-specific
tests/directories. - Corpus-driven end-to-end tests in
crates/tooling-tests. - Execution tests in
crates/execution-tests.
Where tests live:
crates/frontend/tests/crates/semantics/tests/crates/ir/tests/crates/codegen-*/tests/crates/loader-core/src/*unit testscrates/tooling-tests/tests/crates/execution-tests/tests/crates/lmod-encrypt/tests/
Patterns:
- Parser tests assert exact error variants and spans.
- Semantics tests assert IR shape, stack effects, and rejection codes.
- Corpus tests compare observed results to expected failure modes and diagnostic claims.
ci/guards.shensures crates with#[test]actually execute tests.ci-lint.shrejects some common test anti-patterns.
How to run tests locally:
cargo test --workspace --release
bash ci-lint.sh
bash ci/guards.shHow to add tests for a new feature:
- Add unit tests near the code you changed.
- Add a corpus entry if the behavior is end-to-end.
- Add a golden artifact if the output is stable and intended to remain stable.
- Add a regression test for every loader/codegen error code you touch.
Well-tested areas:
- Parser error handling.
- Core loader error codes.
- ABI hash stability.
- Diagnostic corpus behavior.
Weaker areas:
- RISC-V end-to-end coverage.
- Exhaustive effect/context-cell oracle coverage.
# 17. Local Development Setup
Required tools:
- Nightly Rust toolchain as pinned by
rust-toolchain.toml(includesrust-srcandriscv32im-unknown-none-elf). fasmldqemu-system-x86_64qemu-system-armqemu-system-riscv32- Optional:
gcc-arm-none-eabi,gcc-riscv64-unknown-elf python3for guard scripts
Install dependencies according to your platform package manager, then run:
cargo build --release -p langc -p tyu -p lmod-pack -p lmod-encrypt -p lmod-sign
cargo test --workspace --release
bash ci-lint.sh
bash ci/guards.shCommon setup problems:
- Missing assembler/linker/QEMU binaries.
- Wrong target triple or missing sysroot path.
TYU_BIN_DIRnot pointing at built host binaries for integration tests.
Useful commands:
tyu toolchain check <target>tyu build ...tyu run ...tyu test ...
# 18. Build, Release, and Deployment
Build system:
- Cargo workspace plus shell-based orchestration.
Artifacts:
- Compiler binaries:
langc,tyu,lmod-pack,lmod-sign,lmod-encrypt. - Object files in target output directories.
- ELF images for runtime execution.
.lmoddeployment bundles.
CI/CD:
ci-lint.shci/guards.sh- Workspace
cargo test/cargo buildcommands referenced in docs.
Versioning:
CODEGEN_REVinvalidates build cache.ABI_HASH_VERandRUNTIME_ABI_VERSIONprotect the loader boundary.FORMAT_VERprotects.lmodcontainer compatibility.
Deployment path:
- Build module graph and runtime.
- Pack object to
.lmod. - Optionally encrypt.
- Optionally sign.
- Run or distribute the final bundle.
Rollback assumptions:
- The repo does not show formal deployment rollback tooling.
- The loader rollback is transactional during load failure, not a full deployment rollback system.
# 19. Observability and Operations
Logging:
- Mostly stderr text and explicit diagnostics.
tyuprints manifest usage, feature resolution, and outcome summaries.langcemits diagnostics throughdiag-core.
Metrics/traces:
- No explicit metrics system is evident in the codebase.
- No tracing backend is visible.
Health checks:
- Toolchain checks via
tyu toolchain check. - Corpus tests and guard scripts act as operational canaries.
Debugging production issues:
- For compile issues, use
langc --emit=iror--emit=asm. - For load issues, inspect
LoadErrorandContainer::parse. - For runtime failures, use
tyu runplus gdbstub escalation.
Likely operational failure modes:
- Tool missing from PATH.
- QEMU or assembler mismatch.
- ABI/version mismatch.
- Trust-tier or signature mismatch.
# 20. Performance and Scalability
Likely bottlenecks:
- Repeated module compilation for large graphs.
- External assembler/linker invocations.
- QEMU execution and debug escalation.
- O(n) symbol lookup in the loader, although the symbol counts are expected to stay small.
Caching:
tyu::cache::BuildCacheavoids recompiling unchanged modules.- Build fingerprints include compiler revision, compiler mtime, transitive dependency hashes, and ABI hash.
Batching/pagination/concurrency:
- Build graph resolution is topological.
- Test suites run over filtered fixtures and all supported targets.
tyudoes not appear to use a worker pool; orchestration is sequential.
Scale assumptions:
- Small embedded-style symbol counts.
- Fixed capacities for many compiler/runtime structures.
- External tool invocations dominate cost, not in-memory algorithmic complexity.
What would need to change to scale further:
- Parallelize module compilation.
- Replace fixed capacities with dynamically sized structures where needed.
- Improve cache invalidation granularity and artifact reuse.
# 21. Common Developer Tasks
This section covers the template tasks that apply to this repository. (Tasks like “add a new endpoint”, “database migration”, “background job”, or “UI component” do not apply: there is no HTTP, database, queue, or UI surface here.)
# Add a new config value
Goal:
- Introduce a new
tyu.tomlsetting.
Files:
crates/tyu/src/project.rscrates/tyu/src/main.rscrates/tyu/src/args.rs
Steps:
- Add a field to the manifest struct.
- Parse it from TOML with
serde. - Thread it through the relevant args or build stage.
- Add tests for default and explicit values.
# Add a new database migration
There is no database layer or migration system in the repository.
# Add a new service/client
Goal:
- Add a client for a new external tool, debugger, or platform.
Files:
crates/tyu/src/runner.rscrates/loader-core/src/platform.rscrates/rsp-client/src/lib.rs
Steps:
- Decide which abstraction boundary it belongs to.
- Add a trait or wrapper if the tool is reusable.
- Implement the process/network interaction.
- Add integration tests and failure-mode checks.
# Add a new background job
There is no queue/worker system. Add it to tyu orchestration or to a new external process invocation.
# Add a new event/message type
If the message is an execution-output record, extend harness-core.
If the message is a loader diagnostic, extend diag-core.
# Add a new UI component or page
Not applicable. This repository has no web UI surface.
# Add a new CLI command
Use the tyu subcommand pattern described above.
# Add a new test
Pick the narrowest layer that captures the behavior:
- parser test for syntax
- semantics test for type/effect behavior
- loader test for container/load behavior
- corpus test for end-to-end regressions
# Debug a failing request
For compiler failures:
- Run
langc --emit=ir. - Compare the AST/IR with a passing fixture.
- Check
semanticserror codes and spans.
For loader failures:
- Inspect the
.lmodwithContainer::parse. - Check signature/encryption flags.
- Compare the computed ABI hash against the target spec.
# Debug a failed external integration
- Run
tyu toolchain check <target>. - Confirm the tool exists and is executable.
- Reproduce the invocation with the exact command from the build/test code.
# Run only part of the system locally
Examples:
cargo test -p frontend
cargo test -p semantics
cargo test -p loader-core
tyu test --filter=corpus --manifest=fixtures/manifest.toml# 22. Glossary
| Term | Definition | Where it appears | Why it matters |
|---|---|---|---|
| Module | A compilation unit, usually .mod |
frontend, langc, tyu |
The primary source artifact. |
| Word | A named stack transformer | frontend, semantics, ir |
Core language abstraction. |
| Signature | Stack input/output list | semantics, ir |
Drives typechecking and IR generation. |
| Effect | What a word does to runtime state | ir::contract, semantics |
Controls safety and scheduling. |
| Capability | A required grant | ir::contract, semantics |
Enforces context restrictions. |
| Context | Ambient checking environment | semantics::typecheck::context |
Tracks nested grants/forbids. |
| Region | Allocation discipline | semantics, codegen-* |
Replaces GC. |
| StackBound | Net and peak stack usage | ir::contract, loader-core |
Enforced at compile/load time. |
abi_hash |
Compatibility checksum | lmod, loader-core |
Prevents loading mismatched modules. |
.lmod |
Packaged module container | lmod, loader-core |
Deployable artifact. |
| Loader | Authenticates and maps modules | loader-core |
Runtime boundary. |
| Trust tier | Loader policy level | loader-core::platform |
Determines signature enforcement. |
| FeatureSet | Build feature bitset | codegen-core, tyu |
Selects runtime units and semantics. |
| TargetSpec | Per-target metadata | codegen-core::target |
Single source of truth for target behavior. |
TYU_BIN_DIR |
Workspace-binary override | tyu tests |
Keeps integration tests deterministic. |
| RSP | GDB remote serial protocol | rsp-client |
Used for escalation debugging. |
# 23. Known Limitations and Risks
Confirmed limitations:
- Some tests are ignored; the docs note 15 ignored tests at the time of writing.
- RISC-V end-to-end coverage is thinner than x86_64 and ARM.
- Fuzzing covers only
modinfo_decodeandparse_container; the parser and codegen paths have no fuzz targets. - The effect/context matrix is a normative artifact, but not backed by a fully synthesized per-cell oracle.
lang-assembleis not fully implemented for the GAS backends in the current code path.
Risks:
- ABI/version bumps can invalidate existing build artifacts and deployed modules.
- Trust-tier defaults can be misunderstood if a platform implementation leaves the default verification behavior in place.
- A lot of behavior depends on external tools, so local environment drift is a real operational risk.
Coupling and hidden dependencies:
- Runtime assembly file names and
Feature::runtime_unit()must match. TargetSpecfields must remain consistent with loader/ABI expectations.- The build cache key assumes the compiler binary mtime and
CODEGEN_REVare enough to model compiler identity.
What should be refactored first:
- Continue reducing duplicated target/tool lookup logic.
- Consider a clearer strategy for scaling beyond fixed-capacity compiler structures.
# 24. Onboarding Path for New Developers
Read first:
README.mddocs/GLOSSARY.mdSETUP.mddocs/TROUBLESHOOTING.mdcrates/codegen-core/src/target.rscrates/tyu/src/main.rscrates/langc/src/lib.rscrates/lmod/src/header.rscrates/loader-core/src/load.rs
Recommended local commands:
bash ci-lint.sh
bash ci/guards.sh
cargo test --workspace --release
tyu toolchain check x86_64-unknown-linux-gnuStarter task:
- Add a small parser or semantics test that exercises one current language construct and one failure case.
Concepts to understand before changing code:
- Target triples vs feature profiles.
- Module graph resolution.
- ABI hash and format versioning.
- The difference between inspection outputs and production outputs.
Mistakes to avoid:
- Editing runtime assumptions without updating loader/ABI tests.
- Adding a backend op without classifying it in every target.
- Assuming
tyuis a generic package manager; it is a project driver for this language and repository only.
# 25. Appendix
# Full command reference
cargo build --release -p langc -p tyu -p lmod-pack -p lmod-encrypt -p lmod-signcargo test --workspace --releasebash ci-lint.shbash ci/guards.shtyu buildtyu runtyu testtyu deploytyu platform list|info|lint|newtyu toolchain check <target>langc --emit=ast|ir|tc|asm|obj ...lmod-pack <input.o> <output.lmod>lmod-sign <input.lmod> <output.lmod> --key=<hex-key>lmod-encrypt <in.lmod> <out.lmod> --mode=fleet|device ...cargo fuzz run parse_container(fromfuzz/)
# Important file references
crates/tyu/src/main.rscrates/tyu/src/args.rscrates/tyu/src/build.rscrates/langc/src/lib.rscrates/semantics/src/typecheck/mod.rscrates/ir/src/lib.rscrates/codegen-core/src/target.rscrates/lmod/src/header.rscrates/lmod/src/modinfo.rscrates/loader-core/src/load.rscrates/hosted/src/loader.rscrates/harness-core/src/lib.rs
# Relevant diagrams
- Architecture flow in section 2.
- Loader/test sequence flow in section 5.
- Entity relationship diagram in section 8.
# Existing docs in the repo
README.mddocs/DOCS.mdSETUP.mddocs/TROUBLESHOOTING.mddocs/GLOSSARY.mddocs/hil/rp2350.md(hardware-in-the-loop replay viaTYU_RP2350_TRANSCRIPT/TYU_RP2350_EXPECT_DIAG)
Note: devdocs/ (design specs, technical manual, developer guide) is intentionally git-ignored and non-authoritative; see docs/DOCS.md.
# Unanswered questions
- The exact intent of the root
Arith.asmfile. - Whether
lang-assembleis meant to remain a thin wrapper or evolve into a first-class build step.
# Areas that need better documentation
- Exact target runtime symbol contracts.
- The full module-format-to-loader state machine.
- The relationship between the effect/context matrix and the corpus tests.
- The intended lifecycle of ignored tests and phase markers.