Testing & Verification
Hya’s test suite is fast when you run the right layer. Locally, verify only the components your change touches (plus direct dependents when you change a public API). GitHub Actions CI (.github/workflows/ci.yml) runs checks on demand based on changed paths (gated by a single required ci-gate check)—do not burn 15 minutes running cargo test --workspace or all terminal specs locally unless making a workspace-wide change.
1. Which tests own what?
| Tier | Where it lives | What it tests |
|---|---|---|
| Track I (In-process Rust) | Each crate’s src/ unit tests + single tests/it/main.rs integration binary |
Deep engine logic, Projection replay, SQLite locks, provider decoders, permission math, boundary guards (xtask), and /v2 HTTP ↔ gRPC parity (hya-server). |
| Track P (Process E2E) | crates/hya-e2e (tests/it/pNN_*.rs + matrix.toml) |
Real hya binary + scripted local FakeLlm: end-to-end tools, skills, MCP, .hyabundle fixtures, offline migration, headless exec, and encrypted Relay tunnels. |
| TUI In-Memory UI | packages/hya-tui/test/ (testRender + FakeBackend) |
Layout presets, keybindings, overlays, Vim/composer, streaming cards, subagent panes, and management views (/key, /project, /diff, etc.) in milliseconds. |
TUI Real-PTY Seam (tui-exp) |
packages/hya-tui-web/e2e/*.spec.ts on Bun PTY + @xterm/headless |
Real OS PTY, OSC 52/9/0 terminal sequences, bare hya launcher, daemon auto-start/restart, gRPC, Relay bridge, and confined Bun VM extensions. |
2. Running Rust component tests (Track I)
Find direct workspace dependents of a crate you changed:
cargo tree --workspace -i <crate> --depth 1 -e normal,dev --prefix noneThen run fmt, clippy, and tests for the touched crate(s):
cargo fmt --all --checkcargo clippy -p hya-engine -p hya-server --all-targets -- -D warningscargo test -p hya-engine --test it turn_loop:: # fast iteration on one modulecargo test -p hya-engine -p hya-server # full crate tests before finishingIntegration test binary rule: Each crate keeps one
tests/it/main.rsbinary with submodules (tests/it/<area>.rs) so Cargo links one test binary per crate instead of dozens. Keep PR tests event-driven—never addsleeps over 1 second (heavy OS fault/soak tests carry#[ignore = "nightly OS fault/soak"]for.github/workflows/nightly.yml).
Core tests use local bundle fixtures
Use the standard tool registry, an in-test tool, or a local native/JS fixture (crates/hya-backend/tests/fixtures/cli-driver-example, crates/hya-e2e/tests/fixtures/mini-agents) to exercise the host. Official bundle behavior is tested in the official bundle repository.
3. Running process E2E tests (crates/hya-e2e)
Build the host, migration binary, and native mini-agents fixture in one Cargo invocation to share the lockstep ABI. Track P drives the real host with FakeLlm:
cargo build --locked -p hya-backend -p hya-migration -p hya-mini-agents-example --bins --libcargo test -p hya-e2e --test it p06_bundle_lifecycle_and_runtime:: -- --test-threads=4cargo test -p hya-e2e --test it p38_relay:: -- --test-threads=4The mini-agents case installs the local fixture and selects only its package. The core layout and offline migration cases live in p44_v2_bare_bundles_and_migration.rs.
If you add or rename a scenario in crates/hya-e2e or matrix.toml, validate the registry:
cargo run -p xtask -- matrix-checkHonest oracle rule: In Track P, never assert solely that FakeLlm received N requests or that tool-call arguments contained a string. Assert real outcomes: files written on disk, session tree depth (GET /v2/sessions), or tool results appearing in the follow-up FakeLlm request.
4. Running Frontend, TUI & Adapter tests (Bun)
Run checks only in the package(s) you edited:
# TUI unit + @opentui/solid testRender UI suites (default tier for UI changes)cd packages/hya-tui && bun run typecheck && bun test
# TUI SDK & QuickJS VM testscd packages/hya-tui-sdk && bun run typecheck && bun test
# Core Code Mode unit testscargo test -p hya-code-mode
# Bun / Claude plugin adapterscd crates/hya-plugin-bun/adapter && bun run typecheck && bun testcd crates/hya-plugin-claude/adapter && bun run typecheck && bun test
# WebUI host unit tests + targeted real-PTY seam spec (build hya and xtask first)cargo build --locked -p hya-backend -p xtask --bins(cd packages/hya-tui && bun run build)cd packages/hya-tui-webbun run typecheck && bun test ./testHYA_BIN="$PWD/../../target/debug/hya" bun run test:tui-exp:parity -- e2e/hya-tui-launch-daemon.spec.tsLive TUI preview in a browser (no tmux scraping)
Never use tmux or script to check TUI output. Serve the TUI in the WebUI host and open the URL in a browser (or inspect test-results/<test>/final-screen.png from an optional Playwright check):
HYA_BIN=target/debug/hya bun packages/hya-tui-web/src/main.ts --port 7681 -- \ bun packages/hya-tui/src/main.ts --dir "$PWD"5. On-demand GitHub Actions CI (ci-gate)
.github/workflows/ci.yml starts with a lightweight changes job (.github/scripts/ci_changes.py) that classifies modified files into scopes and skips unaffected jobs, followed by a single required ci-gate job (main branch ruleset):
| Change area | Jobs run |
|---|---|
public/** & docs/** (GitHub Pages landing page + non-generated Starlight docs) |
docs (.github/scripts/check_web.py fast-fail on public/ JS/CSS/anchors + Astro tests, typecheck, assembled dist-pages build & link check) |
Pure Bun/TUI frontend (packages/** excluding manifests/generated contract) |
frontend, build-bin, tui (skips Rust lint, test, e2e) |
Pure Rust internals (crates/**, etc.) |
lint, test, build-bin, e2e, tui (keeps real backend ↔ TUI integration) |
Cross-boundary contracts & adapters (proto/hya/v2/**, hya-api, hya-proto, hya-runtime-abi, hya-server, hya-backend, hya-plugin*, versions.toml, packages/*/package.json, frontend-version.ts, operations.json) |
Full Rust + Frontend + tui (plus docs when proto/hya/v2/** or docs/protocol/* changes) |
Repo meta-docs (README.md, AGENTS.md, .agents/**) |
changes → ci-gate only |
The official bundle repository owns official bundle implementation checks. This workspace uses local packages and fake providers to verify host contracts. See the Open Static Registry Protocol v1 for release verification.
Manual runs via workflow_dispatch accept a scope input (all, auto, rust, frontend, docs, defaulting to all).
When rust=true, build-bin compiles hya, hya-migration, xtask, the two native fixture cdylibs (hya-cli-driver-example, hya-mini-agents-example), and the workspace test archive (ci-nextest-archive), runs offline ABI SDK packaging and pinned source-build checks, and runs xtask check-abi alongside xtask gen-api drift verification and xtask matrix-check. For an intentional ABI change, bump the ABI version and run cargo run -p xtask -- update-abi-lock to refresh abi-contract.lock before rechecking. Downstream test, e2e, and tui jobs reuse those prebuilt artifacts. Frontend-only runs build the core binaries and fixtures needed for the PTY gate.