Development & Coding Standards
Welcome! This guide covers what you need installed to build Hya locally and the engineering rules that keep the codebase clean and reliable.
1. Prerequisites & first build
- Rust
1.100.1(pinned inrust-toolchain.tomlwithrustfmtandclippy; workspace MSRV is1.91, Rust edition2024, Cargo resolver3) - Bun
1.4.2+ (runspackages/hya-tui,packages/hya-tui-web,packages/hya-tui-sdk, and the Bun/Claude plugin adapters) - Git (plus standard C/OpenSSL build headers on Linux:
build-essential pkg-config libssl-dev)
Clone and build a working local hya binary + TUI in four commands:
git clone https://github.com/chrono-foundry/hya.gitcd hya
(cd packages/hya-tui && bun install --frozen-lockfile)(cd packages/hya-tui-web && bun install --frozen-lockfile)cargo build-core
# Launch your local debug build!./target/debug/hya2. Developing against installed bundles
cargo build-core builds the core host binary (target/debug/hya). Official first-party bundles live in chrono-foundry/hya-bundles and are installed from the static registry into your user registry (~/.local/share/hya/bundles/registry.sqlite3).
With a matching host ABI, install the official profile and select the subset you need:
cargo build-core./target/debug/hya abi info --json./target/debug/hya bundle install --profile default -y./target/debug/hya --bundles workflow,tui,provider-openaiCI runs cargo run -p xtask -- check-abi to check the Native ABI v2 contract against abi-contract.lock. For an intentional contract change, advance the ABI version and run cargo run -p xtask -- update-abi-lock, then commit the refreshed lockfile. See the release guide.
If your local branch changes the Native ABI v2 digest, generate a matching four-crate ABI SDK archive and build your native bundle against it in the bundle repository:
cargo run --locked -p xtask -- package-abi-sdk --out dist-sdkSee Developing, Installing & Publishing Bundles, Native Bundle Runtime ABI v2, and Open Static Registry Protocol v1.
- Core binary only (
--bare):Terminal window cargo build-core./target/debug/hya --bare --model hya/offline exec "hello" - Reuse prebuilt same-ABI libraries from another worktree or directory (
HYA_PREBUILT_BUNDLES_DIR):Terminal window # Fresh local Cargo outputs in `target/debug/` still take priority;# unbuilt bundles fall back to the `:`-separated directories below.# Every loaded library still passes `hya_native_abi_v2` digest checks.HYA_PREBUILT_BUNDLES_DIR=/path/to/prebuilt-bundles \./target/debug/hya --bundles full - Dev-only opt-in to skip missing native libraries (
HYA_DEV_SKIP_MISSING_BUNDLES=1): Default startup is strictly fail-closed when an enabled native bundle library is missing. In non-installed Cargo dev layouts (never honored when running from<prefix>/bin/hya), settingHYA_DEV_SKIP_MISSING_BUNDLES=1logs a warning and skips missing native bundles individually while still failing hard on ABI mismatches or registration errors:Terminal window HYA_DEV_SKIP_MISSING_BUNDLES=1 ./target/debug/hya --model hya/offline exec "hello" - Dev build profiles (
[profile.dev]vs--profile dev-full): The workspace[profile.dev]uses slim debuginfo (debug = "line-tables-only",split-debuginfo = "unpacked",debug = 0for third-party dependencies and build-overrides, withopt-level = 2forsha2,base64,sevenz-rust2, andlzma-rust2) for fast links and smalltarget/footprints while preserving full Rust backtraces. When you need full DWARF variable inspection ingdb/lldb, pass--profile dev-full:Terminal window cargo build --profile dev-full -p hya-backend --bin hya
Interface reference
| Surface | Contract |
|---|---|
Cargo alias cargo build-core |
cargo build -p hya-backend --bin hya (defined in .cargo/config.toml). |
Global flag --bundles <SPEC> |
Supported on runtime-composing hya commands whose FlagCaps allow bundle selection, and propagated to auto-started daemons. Install the official default profile, then select from installed bundles using names, presets (static/presets, tui, providers), and negation (-<name>). Use --bare for zero bundles. See the CLI reference for prerequisite closure and precedence. |
HYA_BUILTIN_BUNDLES |
Same <SPEC> grammar as --bundles. Precedence: --bare / --bundles > HYA_BUILTIN_BUNDLES > config.toml bundles.builtin. |
HYA_PREBUILT_BUNDLES_DIR |
:-separated directories searched after fresh local Cargo outputs (deps/, <exe-dir>/, build/<pkg>/*/out/) and before staged .hyabundle packages. Subject to lockstep abi_digest_v2() verification. |
HYA_DEV_SKIP_MISSING_BUNDLES |
1 or true (non-installed Cargo dev layouts only; ignored in <prefix>/bin/). Skips AbiError::DisabledOrMissing per engine native bundle with a WARN log. |
3. Core codebase rules
- No panics and complete doc comments in library crates (
unwrap_used,expect_used, andmissing_docsdenied): Workspace lints forbid.unwrap(),.expect(), and undocumented public items in library code. Return typed errors (StoreError,CoreError,ToolError,ProviderError,HostError) instead of crashing the daemon. Binaries and tests may allowunwrap_used/expect_usedlocally where appropriate. - Preserve single-source event sourcing: Never invent a second mutable read model in the server or TUI that can drift from
event_log. Append durable events inhya-storeand fold them throughhya_proto::Projection(and bundleProjectionReducers). - Respect ring and core/bundle boundaries: Core crates (
crates/) must stay free of bundle domain identifiers and outer-ring dependencies (enforced bycargo run -p xtask -- boundary-checkandcargo test -p xtaskviacrates/xtask/boundary.toml). Keephya-protofree of async runtimes, SQLite, or HTTP libraries, and keephya-updaterandhya-relayfree of runtime crates (hya-engine,hya-app,hya-server). - Reuse core planes &
HostRuntime: Route core permissions, user prompts, skills, and URI handles throughhya-tool’s core planes (PermissionPlane,InteractionPlane,SkillPlane,HandleRouter/UriSchemaPlane, andExtensionPlanes), and route all native bundle storage, session, turn, model, event, and API operations exclusively throughArc<dyn HostRuntime>(crates/hya-runtime-abi). Never linkhya-store,sqlx,hya-engine,hya-server,axum, ortonicinside a nativecdylibbundle. - One interactive frontend (
packages/hya-tui): Never add a second terminal UI or move UI rendering intohya-server. Both the terminal TUI and browser WebUI sharepackages/hya-tui,packages/hya-tui-webremains a generic PTY host, and core shortcuts must stay browser-safe (never bind a core action only toCtrl/Cmd+W,T,N,L,Tab, orCtrl+Tab, which browsers intercept).
4. Multi-step task plans
For multi-step work, run python3 scripts/new-plan.py from the repository root to scaffold the shared Plan Template into the next git-ignored .plan/pN/task_plan.md Kanban board, and consult .agents/spec/ before editing backend layers.
5. Shipping features with documentation
Every new or changed user- or developer-facing feature ships with updated documentation in the same atomic change, covering an introduction, usage (with a short worked example), and exact interface definitions:
- User-facing behavior & workflows: Update the matching short guide under
docs/guide/and exact flags/fields/keys indocs/reference/. - Bundle, Native ABI, Hook, TUI SDK, or
/v2API changes: Updatedocs/extend/ordocs/protocol/(runcargo run -p xtask -- gen-apiifproto/hya/v2/changed,gen-schemasif Config v3 schemas changed, orgen-pluginif plugin hook wire types changed). - Internal engine, storage, or crate boundary changes: Update
docs/architecture/(anddocs/architecture/codebase-map.mdif crate roles or rings changed).
Keep user guides short, plain-spoken, and focused on tasks; put exhaustive schemas and flag tables in docs/reference/, docs/extend/, or docs/protocol/.
6. Formatting & quick local check
Before opening a PR or committing, check formatting across the Rust workspace and run Clippy + tests only for the crates/packages you touched (see Testing & Verification):
cargo fmt --all --checkcargo clippy -p <changed-crate> --all-targets -- -D warningscargo test -p <changed-crate>cargo build-core