docs/tests.md

Tests

Run commands from the repository root. The justfile owns recurring commands; the documentation index routes to code and contract owners. Choose coverage before running it.

Commands

CommandCoverage
just test-go-package PACKAGE *ARGSOne Go package or package pattern, with optional Go test flags
just test-go *ARGSDefault Go coverage: non-AgentHub root packages and the nested module, with Go's normal result cache
just test-go-freshSame non-AgentHub Go coverage with -count=1 for deliberate fresh execution
just test-go-agenthub *ARGSAgentHub-owned Go packages only
just test-go-all *ARGSComplete root and nested Go coverage, including AgentHub
just test-ruby-sourceRuby source tests using an existing bundled interpreter
just test-distIsolated Linux distribution archive and installer fixtures
just test-agenthub-fixturesIndependent AgentHub literal checks
just test-agenthub-e2eShipped Hub process tests using isolated fixtures
just test-quickNon-AgentHub Go, Ruby source tests, Python quick cases
just test-full-offlineRoot/nested Go, Ruby source tests, AgentHub literals, all provider-free Python cases
just testFull aggregate, including AgentHub literals and ordinary configured-model Python cases
just test-llmProvider-dependent Python cases, with live OpenAI separately opt-in

*ARGS means optional arguments, not a literal argument. Go recipes do not build shipped binaries. Aggregate and LLM recipes build first. The Ruby source recipe requires the bundled interpreter to have been built.

Use test-go or test-quick for unrelated development. AgentHub-owned Go packages are internal/agenthub/..., cmd/ez-agent-hub/..., internal/hubfeature/... and pkg/ezhubapi/.... They remain in place and run through test-go-agenthub; shared CLI, frontend and TUI regressions stay in the default set. Run the Hub scope when changing those packages or shared code whose behavior affects Hub TLS, transport, storage or lifecycle. A focused test-go-package selection is still appropriate while editing.

test-go-all, test-full-offline and test explicitly include AgentHub. Do not use those full-repository checks for unrelated work unless that coverage is requested. test-full-offline includes the Go, Ruby and Python quick coverage; do not precede it with another Go aggregate or follow it with an E2E suite it already contains. Ordinary just test also includes configured-model tests; test-llm selects only Python llm cases, not Go/Ruby unit tests. Live OpenAI remains separately opt-in.

Arguments to test, test-quick, test-full-offline and test-llm go to Python, not Go. A leading suite, path or node selector runs only that Python scope after building. A leading option such as -k retains the aggregate language stages. Friendly aliases live in tests/run_tests.py.

sh
1just test-full-offline protocol
2just test-full-offline tests/suites/test_builtin.py::TestBuiltinSubprocess::test_hello_and_announce_on_startup
3just test-llm plugin-queries::test_leaf_stats_and_history_after_one_prompt --model=ollama/YOUR_MODEL

Offline recipes pass --no-llm and cannot execute provider-dependent cases. Run online or LLM-dependent tests only when the user explicitly requests them. just vet includes native vet and maintained AgentHub/frontend cross-platform compile and vet checks. Cross-compilation does not establish runtime coverage.

The nested cd ez-agent-ruby && just test remains available for source-lock and toolchain-cache shell checks as well as Go packages. Repository aggregates invoke nested Go unit tests directly. A new Ruby runtime tree may run ez-agent-ruby/runtime/profile-test.sh during its build; the quick recipe adds neither another profile nor a forced cold rebuild.

Focused checks

During implementation, test the changed behavior and relevant callers. Select named regressions or the owning package rather than running every aggregate. For example, dispatcher changes can use these alternative selections:

sh
1just test-go-package ./internal/agenthub/peer -run '^TestTypedDispatchDuplicateAndAbandonedInboxes$'
2just test-go-package ./internal/agenthub/peer -race -run '^TestTypedDispatch'

Use focused race coverage for changed concurrent ownership, cancellation or shutdown. Broader race and maximum-capacity runs need an assigned owner and a specific uncovered risk. Do not self-assign them as completion gates. When Go tests build helper processes separately, parent -race alone does not instrument those helpers. Follow the fixture's instrumentation support.

For Python-only feedback with current binaries already in build/, avoid an unnecessary aggregate rebuild:

sh
1python3 tests/run_tests.py protocol --no-llm

Keep durable regressions for supported behavior. Test verification, persistence, security and lifecycle guarantees at meaningful boundaries; do not mock the behavior under assertion. Controlled fakes can supply dependencies, clocks, transport results and failures while the real wrapper or API logic runs. Test our policy and ownership rules rather than repeating the TLS library's own coverage. Keep focused real-TLS tests for role wiring, certificate-disclosure ordering and authenticated shutdown; shared connection machinery should not require a separate full integration matrix for every caller. Remove one-off probes after investigation. Keep tests and their data with code, not under docs/. Review skill prose as documentation, not as wording to freeze in tests.

In multi-agent work, assign one owner for each validation scope. Implementers report focused commands, results and untested scope. Reviewers reuse those results and check missing coverage rather than repeating the same tests. At merge review, the integration owner runs the authoritative just build and one selected offline aggregate after assembly and review. Standalone contributors own that integration step; finishing an editing task needs focused checks, not a separate aggregate. If integration finds a regression, fix it with spot tests before the integration owner reruns the necessary validation.

Documentation-only edits need relevant content/link checks. Rebuild when validating embedded resources.

Cache and timing

Keep recurring commands and flags consistent so Go can reuse passing results. Do not add -count=1 or repetition counts by default. Use fresh execution deliberately for reproduction, timing or flake investigation, either on a focused selection or through just test-go-fresh for an assigned Go aggregate.

For deliberate fresh AgentHub or complete Go measurements, use just test-go-agenthub -count=1 or just test-go-all -count=1. These commands disable test-result caching, not Go's build cache.

Reuse a result only when its tested source, helpers and relevant environment are unchanged. Failed packages, changed test binaries and different selections need new results. A cached pass is useful regression evidence, not fresh timing or flake evidence. Report the command, source revision, relevant environment, result and any coverage excluded from the selection.

Routine repeat validation should fit within ten minutes, including necessary build and focused race work. This is a budget, not a claim that current commands already meet it. An all-cached pass or renaming a slow run does not demonstrate that budget. Reduce duplicate setup and obsolete coverage while preserving distinct TLS/security, persistence and lifecycle assertions.

The Go recipes use EZ_AGENT_GO_TEST_TIMEOUT, defaulting to 30m per package. That is a failure bound, not a whole-command runtime guarantee or an extension of production deadlines. Aggregate arguments cannot set Go flags; use the environment variable for their Go package timeout. Focused Go recipes accept an explicit -timeout override.

AgentHub fixtures

Executable fixtures and literals live under internal/agenthub/testdata. Run just test-agenthub-fixtures for their independent checks. These fixtures use public deterministic test material, not user credentials.

CorpusOwner and scope
trustIdentity, signed records, pairing, invitations, TLS exporters, storage, gateway, configuration and application literals
privatePrivate administration vectors, configuration and accounting checks
circuitBootstrap, DATA/ACK, fixed-session and recovery literals
carrierEndpoint envelopes and restricted pairing carrier literals
routingRouting bytes, path selection and rejection cases
relayRelay setup, attachment and control literals

The local-control corpus is pkg/ezhubapi/testdata/control.json, consumed by pkg/ezhubapi/literal_test.go. Its contract owners are the typed library and local control.

Literal checks establish bytes and codec behavior, not production service lifecycle or security acceptance. Package *_test.go files own runtime regressions alongside the AgentHub packages. AgentHub testkit owns reusable package fixtures; process suites own shipped-process integration. The contract inventory routes to behavior owners.

Isolation

Prefer the standard fixtures. tests/conftest.py owns isolated daemon startup, readiness, model injection and shutdown. tests/client.py owns the socket JSONL test client. Package fixtures use test-owned state and join their runtime owners at cleanup. The controlled global OnStart test checks listener availability with a real Unix connection from its helper. Hub deployment tests separately require application API readiness, one shipped Hub child, Hub control readiness, and application socket creation before control socket creation. OnStart is asynchronous: those observations need not precede fixture yield and do not prove that application Accept ran before the child started.

The AgentHub service parallelServiceFixture helper limits concurrent fixtures to four, including cleanup. Use it for independent fixtures, before allocating resources and at only one test nesting level; nested acquisition can deadlock. A table parent that only launches independent gated subtests can call t.Parallel() without taking another fixture slot. Otherwise, Go waits for that whole table before starting the next one, leaving fixture slots unused.

Opt-in directory and mux ownership fixtures advance a separate peer scheduling clock to recorded retry deadlines after attempt cleanup. Real TCP/TLS, directory exchange and transport deadlines remain in use; peer tests retain backoff-boundary coverage. Entry-retry pacing checks distinguish the settled NoRoute refresh from the admission deadline and wait for route publication to be consumed before comparing them; the absolute attempt timing and stale-token assertions remain enforced. Circuit recovery clock jumps likewise wait for the scheduler's absolute timer arm before advancing virtual time. Dropped-LIVE coverage requires matched PING/PONG progress without extending the original grace deadline, including eligibility one nanosecond before expiry and timeout at equality. The routing refresh/expiry fixture completes the incoming initial commit before releasing outgoing SyncEnd. This prevents an initial table notification from rearming the writer across a virtual clock jump. It still checks refresh at 20 seconds, stale replay at 59 seconds, presence at 78 seconds, and expiry at 79 seconds.

Pairing shutdown and handoff fixtures hold semantic time fixed during setup while retaining real TLS and runtime deadlines. Security-clock boundary tests own final-append refusal; lifecycle tests must reach their accepted state before cancelling it or deliberately advancing to their tested decision deadline. Accepted Add Hub outcome tests use the same semantic setup fence before testing alias-sidecar failure or expired carrier handoff. The handoff test also verifies the exact stored request and Context commit revision after carrier retirement. Pairing uncertainty fixtures likewise hold semantic setup time fixed and require the intended committed-WAL count, exactly one injected failure, and the matching Add Hub outcome before asserting freeze, shutdown and strict reopen behavior. Routed Prepared-path fixtures also prove that the injected Context refusal fired and the target accepted the exact request before cancellation or restart; a local Prepared checkpoint alone does not establish either precondition. The routed physical-loss fixture makes one Add Hub call and proves an exact unapproved Accepted checkpoint with one live held owner before closing transit. It then joins that owner and requires the durable row to remain unchanged. The forged-prefix quota fixture holds joining and target semantic setup time for one healthy Add Hub call. It requires exact unapproved Accepted evidence while both hostile channels remain live and all three connection reservations coexist. It restores semantic callbacks only after joining the healthy owner, both hostile channels and pairing capacity. TLS, runtime and handshake deadlines remain live. Outbound-only target fixtures use one Add Hub call and one semantic setup second through Context and Completion. They restore semantic callbacks after pairing owners join, preserving exact routed Q, ceremony, deadline and retention while runtime/TLS clocks stay live and no-inbound assertions remain unchanged. Post-restart and fresh-ceremony checks retain live clocks and recover the same durable request to Accepted instead of replaying Add Hub or assuming one check must persist Context. The idle/restart regression observes zero TCP accepts across both scheduler-sized windows. It then drops one explicitly requested recovery connection and verifies that the caller releases its owner and capacity without changing the stored checkpoint or approval. Subsequent exact-request checks belong to the caller, not a daemon scheduler, and must reach the expected durable phase. The day-eight active scenario also forces one failed carrier during setup and reviews both exact checkpoints before one caller-owned activation check. Only that activation commit pins semantic time; the fixture restores the live callback before the retention jump, and runtime/TLS clocks stay live throughout. A boundary regression advances wall time at append and checks that the restored clocks see it. Durable active access and preserved approvals are required before advancing to retention; the final retention-boundary and no-dial assertions remain strict. Retained-Completion success cases use production control handlers on a test-owned socket with a commit instant sampled after the approval cutoff and before retention. They do not override service, runtime or TLS clocks. A separate API-boundary regression holds the API clock through preparation, then advances it at the WAL cut for refusal or leaves it fixed for success. It requires exactly one preparation, carrier and WAL-cut entry with the original evidence. Service time advances at both validation and the WAL cut, and semantic, runtime and TLS clocks must observe both advances. The fixture starts at second 59 and reserves a security horizon covering both advances before opening the carrier, so the final TLS check does not depend on a background maintenance tick. The socket late-cancellation Completion case also fixes only the API commit instant. Before cancellation, it requires the exact request to be Active with installed access while holding its recovery owner at retirement. Reaching that gate alone does not prove Completion committed. The completed-check writer-lock test uses the same API-only clock control and requires a newer committed revision before taking the writer lock and cancelling. Its result must still report the original observed revision when cancellation prevents the final revision read. Blocked-carrier cancellation and abrupt EOF still use the service's normal control socket and live clocks.

Direct service lifecycle setup drives typed CheckPairing while joining approval delivery is pending, as an open pairing view does. Local approval is not proof of remote delivery. The shutdown regression refuses one target approval append and requires status-first recovery of the stored signature, without replaying the local approval command. Lost-approval restart coverage requires Accepted state and a held owner before target shutdown, then one durable local Approval and joined carrier before live clock restoration. It observes exact-Q status followed by the original stored signature on real recovery frames after restart, without replaying approval. Directory-topology pairing uses one semantic commit second while keeping TLS and runtime clocks live. Bilateral repair waits for initial carrier retirement, then drives exact-request Completion checks until both sides are Active before waiting for normal peer links. Only Completion setup pins joining semantic time, and it restores the callback afterward. The repair checks preserve Q, consent, deadline and retention across activation. Peer-removal setup re-reviews the exact genesis, head, generation and pairing request before a fresh decision. Only a direct typed conflict with no result permits another attempt, not raw, wrapped or uncertain errors. The three-peer lifecycle fixture exercises this policy through its asynchronous control-call barrier, with one injected refusal before real removal and late-result release on cancellation. Blocked diagnostic-consumer tests inspect and join each removal attempt before waiting for the closure event it causes; a refused removal must not be reported as a missing diagnostic. The sink remains blocked through successful removal, link retirement and shutdown. Lost-approved-result authorization recovery waits for the approval's signed access-revision update to converge before a fresh list/select operation. The fixture also requires the pre-approval admission snapshot to fail recheck; a live route does not make a stale authorization snapshot usable.

Routine circuit-admission regressions use small component fixtures. They exercise configured policy, budget reservation, invocation-worker joins and relay settlement together, without repeating Hub onboarding, TLS or application roundtrips. Startup/configuration tests check that saved policy reaches those owners. Focused TLS/security and application-drain tests retain their distinct assertions. The Python-owned shipped-process journeys cover executable wiring and user-visible behavior; do not repeat that journey for every ownership case or add another end-to-end matrix for each configuration setting.

Shipped registration, invitation and approval setup can receive a definite conflict when preparation crosses a security second. The fixtures make a bounded new decision only after re-reading unchanged revision, authority and inventory; transport uncertainty, success output and other errors still fail. Composed journeys separately allow an explicitly unsent stale review to be observed afresh under the same authority. The typed process fixture applies the same rule to registration, deletion and admission-invitation creation: a direct API conflict with no result and the same revision permits a new decision only after a full unchanged status review. Each decision uses a fresh request; the intentional stale-revision rejection remains outside this helper. TUI model-command setup waits for rendered completions, not just an outgoing model-inventory request. JOIN cards are read in full and validated with the shipped parser, including its hyphenated words.

Typed peer-dispatch rejection tests join the exact link's drain signal before inspecting required-channel retirement. A remote OPEN_ERROR can arrive before the local link owner publishes draining. The unknown-setup case still requires rejection without draining.

The authenticated application maximum retains its full population behind EZ_AGENT_MAXIMUM_CAPACITY=1. It is an explicit capacity check, not a routine control journey repeated in the package suite.

The 2,048-circuit and 1 GiB retained-ciphertext fixtures are explicit stress profiles, not shipped defaults or fixed product maxima. Keep their meaningful transport, persistence, lifecycle and security scope rather than scaling their populations to the 524,288 logical admission default. Configurable counter tests cover global and trusted-key policy, independent adapter admission and raised positive-int64 settings. Allocation tests cover demand-grown queues, RX body and adapter charges, release and joined reuse. Registry tests cover prepaid metadata, ordered pagination and churn without maximum-sized scratch arrays. These are admitted-accounting assertions, not RSS or OOM-safety tests.

Unused-carrier tests advance the fixture's circuit clock to the TLS deadline recorded on the real carrier, rather than sleeping through the handshake bound. They still join every owner and assert released capacity. Separate handshake expiry and production-deadline cases retain real wall-clock coverage.

start_daemon waits up to 10 seconds for hello_ack with ready: true, retrying early maintenance replies and connection failures rather than treating socket acceptance as readiness. restart_daemon waits for the new listener to accept connections. Both create test-specific runtime/state directories and stop their isolated daemon cleanly.

Standalone subprocess tests use read_frame in tests/conftest.py. It reads stdout descriptors directly and retains unread frames and partial lines across calls, with a monotonic timeout. Do not mix it with buffered reads on the same stdout pipe. test_subprocess_frames.py covers batching, partial lines, and EOF.

Ruby source tests use test_helper.rb to replace XDG_CONFIG_HOME, XDG_STATE_HOME, and XDG_RUNTIME_DIR with private temporary directories before loading the API. This applies to the source runner and direct runs of individual test files. Children inherit those isolated paths unless supplied their own fixture paths. Intentional API failures write tombstones only into test state, not the caller's live audit directory. The helper drains the shared incident recorder and removes its temporary tree on exit or failure. The provider-free workflow service-exit test gates its Ruby history observer on the held provider stream starting. Admission is then durably sent, so history hydration cannot race the ready-to-sent transition. Observer failures terminate the seed process and preserve its output in the Python failure report.

Before any manual client/service launch or ad hoc daemon test, isolate all three of XDG_CONFIG_HOME, XDG_STATE_HOME and XDG_RUNTIME_DIR. Subagents inherit the running orchestrator's environment. Use built binaries under build/, not $AGENTCLI, for test launches and shutdown. Stop only the exact test daemon with the built client under the same isolated XDG environment. Never stop the live orchestrator or use broad pkill/killall. Use kill only for a specific unresponsive test daemon.

Never inspect, read, copy, hash, print or probe auth files. Config helpers may copy config.yaml and record an external auth path, but only the service's protected auth loader accesses credentials. Test config directories use mode 0700, including under a group-writable umask. Offline fixtures use synthetic, provider-free configuration without reading user auth.

Computer-use checks

Requested manual and agent-driven tmux cases are in Computer-use checks. Select the affected interaction; they are not an automatic coding or merge gate.

Rendered regressions live in pkg/tui; native ownership and handoff regressions live in internal/frontend. The AgentHub process suite provides scripted shipped-process coverage. just test-agenthub-e2e selects it explicitly; do not repeat it if the selected offline aggregate already ran it. Its optional tmux captures require explicit opt-in and an owned test session.

Live OpenAI

The live suite tests the public OpenAI Responses runtime. Ordinary just test-llm skips live_openai cases. Selecting openai-live through the friendly runner adds --live-openai; direct pytest use must supply that option. Run only with explicit user approval.

Repeat --live-openai-subscription-ref and --live-openai-api-ref for configured provider/model refs. Each ref is an independent case, so a missing subscription model does not gate paid API cases. The labels describe the intended auth route; configure that route in config.yaml. There are no dialect selectors or fixed model rosters.

sh
1just test-llm openai-live --live-openai-config-home="$HOME/.config" \
2 --live-openai-subscription-ref=openai/gpt-6-luna \
3 --live-openai-api-ref=paid/gpt-6-luna

These aliases and model names are examples, not required entries. Explicit refs replace the provider fallback for their route. Without subscription refs, --live-openai-subscription-provider defaults to openai and expands that alias to openai/gpt-6-luna; an empty value disables it. The optional --live-openai-api-provider uses the same model fallback. Either provider option also accepts a full ref unchanged.

For paid API only, disable the subscription fallback and repeat API refs:

sh
1python3 -m pytest -q tests/suites/test_openai_live_acceptance.py --live-openai \
2 --live-openai-config-home="$HOME/.config" \
3 --live-openai-subscription-provider= \
4 --live-openai-api-ref=paid/gpt-6-luna \
5 --live-openai-api-ref=paid/YOUR_OTHER_MODEL

Repeatable --live-openai-http-ref selects refs already configured with responses.websocket: false. The suite does not change transport settings. For HTTP only, disable the subscription fallback and select the configured ref:

sh
1just test-llm openai-live --live-openai-config-home="$HOME/.config" \
2 --live-openai-subscription-provider= \
3 --live-openai-http-ref=http-optout/gpt-6-luna

Each case checks local model configuration before provider I/O, then exercises a no-tool prompt, a buffer read of a harmless prepared /tmp file, and a follow-up. The buffer prompt specifies operator="read" and the exact file:/tmp/... name. A successful durable result is required, not an exact number of retries or calls. WebSocket cases require full initial context, incremental continuation on the same socket, and full context after daemon restart. Configured HTTP optouts require HTTP before and after restart. Checks use secret-free transport telemetry.

--live-openai-config-home selects the source XDG config home, not its ez-agent subdirectory. Without it, the fixture uses inherited XDG_CONFIG_HOME, falling back to ~/.config. It copies only that home's ez-agent/config.yaml into a private test config home and isolates config, state and runtime XDG paths. Config directories have mode 0700. An explicit absolute auth_file stays external; otherwise the default is the source home's ez-agent/auth.yaml. Relative auth paths and %USER_CONFIG_DIR% are anchored to the source config directory. The test rig never reads or copies auth. Only the service's protected auth loader accesses it. The standard daemon fixture owns shutdown and teardown; ordinary offline fixtures are unchanged.

Offline subscription regressions

pkg/service/config/chatgpt_lifecycle_test.go owns stateful local HTTP coverage of login, signed OIDC, protected save/reload, refresh generations across restart, and Responses inference. The Linux suite tests/suites/test_chatgpt_offline_application.py uses test-only overlays and standard isolated daemons to exercise configurator handoff, normal prompts, rotations, and shutdown during consumed renewal. Narrow OAuth pairing, redaction, permissions, cross-process exclusion, and authorization watcher tests remain separate. Use fixture-supported GOFLAGS=-race when instrumenting separately compiled helpers; parent go test -race alone does not instrument them. Synthetic routing and expiry acceleration never ship or change production TLS or scheduling. These tests do not establish live OpenAI renewal success.

Background bash regressions

tests/suites/test_background.py is full-offline coverage for generic ownership RPCs, correlated conflicts, client state/configuration eligibility, abort/delete kill routing, sticky late-completion rejection, provider loss, and the builtin's initial-result/completion/buffer/removal contract. Package tests in pkg/service/background_test.go, pkg/ezagentapi/background_test.go, and cmd/ez-agent-builtin/internal/builtin/runcommand/background_test.go cover unloaded registration, eviction/deletion races, detached cancellation, live and empty captures, timeout while registration waits, completion admission ordering, terminal status, rejected steers, and shutdown joining. Buffer and compaction regressions exercise read-only task metadata and registry reminders.

Integration uses a deterministic local HTTP model to hold a foreground command beyond the completion RPC budget beside a fast background command, with and without parallel scheduling. Service tests hold success/idle terminalization and cover cancellation, preservation of the claimed model outcome, and registration/ removal versus abort snapshots. Held terminal triggers and a controlled tip change must still produce exactly one stored completion and model delivery before ownership removal. Manual compaction preserves live tasks, registry reminders, buffers, and the original completion destination. The CLI background suite also checks bundled Ruby Workflow waiting and follow-up. If its first model request misses the admission deadline, it captures startup markers and output even from a live child, plus pre-cleanup process status, the executable path where available, and the daemon-log path. If the child is still the public Go launcher on Linux, failure-only capture records process and lock state and requests a stack dump from the pidfd-pinned child before bounded cleanup. Lock holders are inspected, never signalled. Capture drains both output pipes and preserves partial output and the original failure if diagnostics fail. It does not extend the admission deadline, retry the request, or trace successful runs.

Shared-connection tests hold one leaf gate while another admits its tool result, completion, and removal; timeout/disconnect must not create late ghost ownership. Gate tests cancel queued acquisition and real SQLite pool waits. Bash tests distinguish missing-leaf statistics from explicit RPC failure.