Skip to content

Latest commit

 

History

History
184 lines (121 loc) · 12.8 KB

testing.md

File metadata and controls

184 lines (121 loc) · 12.8 KB

Testing

Production gate

Run the same offline gate used by pull requests:

npm ci
npm run verify:production

The command runs TypeScript validation, lint, the format check, the source hygiene check, the frontend boundary check, builds the distributable CLI, and executes the core, extensions, and ui test groups. Any failed test or timeout returns a non-zero exit code. npm run verify:release runs this gate, then the platform group, then the package and installation checks; see Releasing.

npm test runs only the three test groups, without typecheck, lint, or build. It selects the same tests as the gate; npm test -- --list prints them.

Lint and formatting

Biome lints and formats src/, scripts/, and the root configuration files. step/, the golden fixtures, and package-lock.json are excluded. The configuration is biome.jsonc; every rule switched off there has a comment giving the reason.

npm run lint           # fails on errors and warnings
npm run format         # rewrite files in place
npm run format:check   # report files that differ from the formatter output

Lint and the format check are part of verify:production. Run npm run format before committing.

Frontend boundaries

The terminal UI, the entry points, the RPC server, and the ACP agent use the session SDK (src/sdk/) and never load the modules that hold conversation state or run turns: the QueryEngine and agentic loop, session storage and file history, the state/ stores, plan files, thinking settings, the teammate mailbox, permission checks, and the Bash tool. npm run check:frontend-boundaries enforces this; type-only imports are allowed. The list and the reason for each entry live in scripts/check-frontend-boundaries.ts.

RPC schema

docs/rpc-protocol.schema.json is generated from src/rpc/protocol.ts. After changing the protocol, run npm run rpc:schema; npm run test:rpc fails while the checked-in file is stale.

ACP conformance

npm run test:acp covers the ACP mapping offline. Before a release that changes src/acp/, also run the ACP Test Compatibility Kit against the built agent with the fixture provider, for example:

uv run acp-tck --agent-cwd /tmp/acp-wd --agent-env HOME=/tmp/acp-home \
  --agent-env EASY_AGENT_PROTOCOL=anthropic --agent-env EASY_AGENT_MODEL=fixture \
  --agent-env EASY_AGENT_BASE_URL=<fixture url> --agent-env EASY_AGENT_API_KEY=fixture \
  -- node dist/eagent.js --acp

The verdict must be CONFORMANT.

The formatter collapses repeated spaces in JSX text. Write text that needs them, such as indentation inside a <Text>, as a string expression: <Text>{" ↳ "}{label}</Text>.

.git-blame-ignore-revs lists the bulk formatting commit. GitHub skips it in blame views; run git config blame.ignoreRevsFile .git-blame-ignore-revs once to do the same locally.

Each offline test process receives a temporary HOME, USERPROFILE, XDG directories, and Windows application-data directories. Provider credentials, API endpoints, MCP settings, editor overrides, and EASY_AGENT_* feature settings inherited from the developer environment are removed. Tests must create their own configuration and fixtures under the assigned temporary directories.

Coverage inventory

Area Included checks Execution
Core flow CLI and Headless protocols, the session SDK contract (events, interaction requests, plan follow-ups, deny rules and trust under the SDK, multi-session isolation, /resume handles, transcripts that restore the model's context), headless sessions (nothing written to disk, settings MCP servers connected), the RPC protocol (initialize and version negotiation, JSON-RPC errors, permission and question round trips, interrupt, busy and queued sends, saved-session management, resume, trust and deny rules under RPC, process exit, the example client, messages validated against the published schema), ACP (driven by the official ACP TypeScript client: initialization and terminal login, session new/load/resume/list/close/delete, streamed replies, tool calls with diffs, permission requests, cancellation, plan approval, form elicitation, modes, slash commands, images, editor MCP servers, deny rules and trust, the registry entry; every agent message validated against the ACP JSON Schema), QueryEngine commands, provider stream adapters, tools, ToolSearch, MCP content and recovery, Skills, tasks, and agents core
Permissions Allow/deny behavior, structured Bash read-only analysis, realpath and symbolic-link boundaries, Auto Mode configuration, Plan Mode paths, and sandbox policy core
Storage and configuration Configuration precedence and source shapes, workspace trust, credential inheritance, headless routing, session JSONL and restore shape, file history, and retention core, extensions
Extensions Worktrees, agent teams, hooks, commands, web and multimodal tools, plugins, and resilience extensions
UI Ink rendering, input, transcript, permission prompts, progress, status line, and plugin management ui
Release Package metadata, README contract, bundle hygiene, source map, third-party notices, tarball contents and credential scan, isolated installation, installed Headless and interactive startup, installer behavior, and old Node failure path verify:release, test:stage36
Platform Host sandbox and Bash sandbox integration platform
External Real provider streaming, ToolSearch, Auto Mode classifier requests, and plugin compatibility against a supplied package live, verify:plugin

The checked-in characterization fixtures are:

  • cli-headless-characterization.golden.txt for CLI flags, stdin merging, and text, JSON, and stream JSON output.
  • queryengine-characterization.golden.txt for local commands and orchestration events.
  • interactive-session-characterization.golden.txt for interactive turns: provider requests, permission and question prompts, interrupt, plan approval, background wake-ups, the session transcript, and resume.
  • providerstream-characterization.golden.txt for provider request translation and stream events.
  • config-session-characterization.golden.txt for configuration precedence, session JSONL, and restored session data.
  • request-content-characterization.golden.txt for what the default configuration sends to the model: every system prompt block, tool definitions in order, cache markers, request parameters, beta headers, and messages, across an empty workspace, project memory, Plan Mode, project skills and sub-agents, an MCP server with and without ToolSearch, the turn after compaction, and the openai-chat and gemini protocols. Each scenario runs in its own process; system text and tool definitions are listed once in a content section at the end. Temp paths, the project memory key, the date, the operating system line, and the Windows-only PowerShell tool are normalized.
  • permission-decisions-characterization.golden.txt for checkPermission: every registered tool plus a read-only and a writing MCP tool, in default, plan, and auto mode, with no rule, an allow rule, or a deny rule; targeted Bash, WebFetch, and session rules; Auto Mode classifier verdicts from the fixture, repeated blocks, and the failure circuit breaker; and project rules with and without workspace trust. Sandbox auto-allow depends on the host, so those cases are asserted against the detected sandbox capability instead.

Both use the scripted Anthropic fixture (src/scripts/fixtures/anthropicFixture.ts), which records the whole request body and also answers non-streaming requests such as compaction summaries and classifier calls.

Execution groups

Group Command Default gate
core npm run verify:production:core Yes
extensions npm run verify:production:extensions Yes
ui npm run verify:production:ui Yes
platform npm run verify:production:platform macOS and Linux CI
live npm run verify:production:live No

List every test selected by a group without running it:

node --import tsx scripts/verify-production.ts --group core --list

Multiple --group options may be combined. Tests in the default gate run sequentially with independent user directories so failures are reproducible and shared process state cannot leak between test files.

Run the Bash read-only security regression suite directly while changing command parsing or permission behavior:

npm run test:bash-readonly

Run the workspace path boundary suite after changing file tools, allowed roots, file history, or path handling:

npm run test:path-boundary

Run the persistence suite after changing settings, runtime state, tasks, teams, sessions, or atomic file writes:

npm run test:persistence

Run the subprocess suite after changing Bash, PowerShell, hooks, the status line, or process cleanup:

npm run test:controlled-process

Run the Hooks suite after changing Hook settings, shell selection, or event handling:

npm run test:stage22
npm run test:hooks-hardening

Run the configuration trust suite after changing settings precedence, environment loading, providers, MCP, plugins, sandbox settings, or headless startup:

npm run test:config-trust

Source hygiene

npm run check:source-hygiene scans production code under src/ for roadmap stage numbers, development-plan references, pointers to a reference implementation, and tutorial or simplification wording. Comments should describe current behavior, constraints, and reasons.

src/scripts/ is excluded because it holds test and smoke scripts that are not bundled, and their stage-numbered names are kept for command compatibility. step/, article/, and historical development documents are outside the scanned tree.

A legitimate match, such as the Explanatory output style's teaching wording, goes into ALLOWED_MATCHES in scripts/check-source-hygiene.ts with a reason. An allowance that no longer matches any line fails the check, so the list cannot go stale.

Configuration inventory

npm run check:config-inventory parses production code under src/ (without src/scripts/) and fails when it reads something the inventory does not list:

  • an environment variable missing from ENVIRONMENT_VARIABLES in src/config/catalog.ts, read as process.env.NAME, process.env["NAME"], or env.NAME;
  • an environment variable read by a computed name outside the files in DYNAMIC_ENV_READS;
  • a process.argv check outside the CLI parser (src/entrypoint/) missing from ARGV_CHECKS;
  • a settings key missing from SETTING_CATALOG, read through the settings helpers or a source's raw object.

It also fails when an entry no longer matches the code: a listed variable nobody reads, a SettingsSchema key without a catalog entry or the reverse, or a behavior constant whose declaration changed. docs/configuration-inventory.md is generated from the same data; run npm run config:inventory after changing it. A self-test runs first, so the check cannot pass because the detector stopped finding reads.

The bundle is not minified, so comments from application modules ship in dist/eagent.js. The release gate runs node --import tsx scripts/check-source-hygiene.ts --bundle dist/eagent.js, which applies the same rules and allowances to every src/ module in the bundle and fails if a module from an excluded directory was bundled or no module markers were found.

Platform and external checks

Platform tests exercise the actual host sandbox and therefore run separately from the portable offline gate:

npm run verify:production:platform

Linux host tests require bubblewrap, socat, rg, and permission to create unprivileged user, PID, and network namespaces. The suite verifies real read/write restrictions, allowed and denied network destinations, fail-closed configuration errors, output, and exit-code preservation.

Live tests require valid provider credentials and may consume API quota. They run only when requested explicitly:

npm run verify:production:live

Plugin compatibility verification also requires an explicit package path or repository URL and remains outside the default gate:

npm run verify:plugin -- /path/to/plugin

Adding coverage

Add deterministic tests to the appropriate group in scripts/verify-production.ts. A test included in the offline gate must not read the real user profile, load the repository .env, call a public endpoint, require an interactive terminal, or mutate host state. Put host-dependent checks in platform and credentialed network checks in live.

Agent Teams lifecycle

Run npm run test:team-lifecycle to check concurrent team writes, shared task ownership, control messages and crash recovery. This test is included in npm run verify:production.