Skip to content

perf(test): build zone_server's integration tests as one binary - #117

Merged
abnegate merged 3 commits into
mainfrom
perf/one-integration-test-binary
Oct 6, 2026
Merged

abnegate merged 3 commits into
mainfrom
perf/one-integration-test-binary

Conversation

@abnegate

@abnegate abnegate commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Why

Cargo built each of the 100 files in runner/zone_server/tests/ as its own test executable, and every one statically linked all of zone_server plus ONNX Runtime. That was most of the build dir, and every edit to zone_server relinked all of them — multiplied across the ~15 agent worktrees sharing one build dir.

What

  • autotests = false plus one [[test]] name = "integration" at tests/integration/main.rs, declaring each former file as a module. Shared helpers moved to tests/integration/common/, reached as crate::common.
  • Module names drop the redundant _tests suffix: api_tests.rs → integration/api.rs. Test IDs become integration api::<name> in nextest; filters like -E 'test(/^api::/)' select one former file.
  • tests/integration/layout.rs fails if a .rs file lands in tests/ (it would never compile with autotests off) or a file in tests/integration/ is not declared in main.rs. Branches still adding test files at the old paths fail loudly instead of silently not running.
  • Updated every reference to an individual test binary: tests/CONTEXT.md, the "Run with" headers, src and installer comments, the coverage workflow comment, docs/SYSTEM-PROMPT-RESEARCH.md. CI commands (--workspace --all-targets) need no change.
  • fix(chat): boxes Routing::Chat's Route. Rust Lint is red on main with large_enum_variant; this is byte-identical to the fix in fix(tools): sanitize tool output with abnegate-secret #110–fix(mail): deliver account mail over STARTTLS through abnegate-notify #114, so it merges cleanly whichever lands first.

Shared process state

nextest still runs each test in its own process, so CI's test job is unaffected. Plain cargo test and cargo llvm-cov (Rust Coverage) now run all modules in one process instead of one per file. The only test-side process mutations are chat_agent (ZONE_CHAT_AGENT_CWD, set once through a LazyLock) and chat_handover (prepends stand-in claude/codex to PATH, also once). Both are safe to share.

One real cross-module dependency surfaced: IMAGE_GENERATIONS in ws/chat.rs admits one media generation per process. chat_lifecycle and chat_ws_media_contract each serialized on a private mutex, so in one process chat_ws's media tests held the lane while chat_ws_contract::queued_media_stops_when_its_chat_lease_is_fenced expected it free — it failed 4/4 single-process runs. Those tests now share common::MEDIA; 3/3 single-process runs pass.

Measurements

Isolated build dir (CARGO_BUILD_BUILD_DIR/CARGO_TARGET_DIR in scratch), cargo build --workspace --exclude zone_desktop --all-targets, debug = "line-tables-only", dependency debuginfo off, Homebrew rustc 1.98.1, M-series Mac. Edit-rebuild appends a line to zone_server/src/lib.rs, three runs.

before (main a376d11) after
debug/deps 19 GiB 4.4 GiB
whole build dir after 3 edits 28 GiB 8.8 GiB
test/bin executables in deps 137, 14.78 GiB 38, 1.51 GiB
zone_server integration executables 101, 13.54 GiB 1, 241 MB
clean build 121 s 107 s
edit-rebuild 31 / 32 / 33 s 9 / 8 / 8 s

Tests

Local, against disposable pgvector Postgres 17 + Valkey 8.1 with migrations applied:

  • cargo nextest run --workspace --exclude zone_desktop --all-targets --no-default-features --features zone_context/test-utils: 6389 passed, 61 skipped (1262 in zone_server::integration).
  • After the media-lock commit, cargo nextest run -p zone_server --test integration: 1261 passed, 6 skipped.
  • cargo test -p zone_server --test integration (one process, as llvm-cov runs it): 1261 passed, 6 ignored, three runs.
  • cargo clippy --workspace --exclude zone_desktop --all-targets --all-features -- -D warnings and cargo fmt --all --check clean.

🤖 Generated with Claude Code

abnegate and others added 3 commits October 7, 2026 00:35
large_enum_variant fails Rust Lint on main: Routing::Chat carries an 856-byte
ChatRow plus Route. Matches the identical change in the open migrate/* PRs so
whichever lands first merges cleanly with the rest.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Cargo built each of the 100 files in zone_server/tests as its own executable,
and each statically linked all of zone_server plus ONNX Runtime. On a clean
build that was 14.8 GiB of 19 GiB in debug/deps, and every edit to zone_server
relinked all of them.

The files now live under tests/integration/ as modules of a single
`integration` target (autotests = false), with the shared helpers at
crate::common. Module names drop the redundant _tests suffix, so a test is
addressed as `integration api::name` instead of `api_tests name`.

With autotests off, a file dropped in tests/ or left out of main.rs would
silently never compile; layout.rs fails in either case, which also catches
branches that add test files at the old paths.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
IMAGE_GENERATIONS admits one media generation per process. chat_lifecycle and
chat_ws_media_contract each serialized on their own mutex, which held while
every file was its own binary. In the merged binary under plain cargo test or
cargo llvm-cov, chat_ws's media tests hold the lane while
chat_ws_contract::queued_media_stops_when_its_chat_lease_is_fenced expects it
free, and the test failed 4 of 4 single-process runs. One common::MEDIA lock
taken by every test that drives a generation makes it pass.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Oct 6, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Too many files!

This PR contains 113 files, which is 13 over the limit of 100.

To get a review, reduce the PR to 100 files or fewer by splitting it into smaller PRs or changing its base branch.

Upgrade to a paid plan to raise the limit.

This review couldn't start because sufficient usage credits or metered capacity aren't available. Add credits or update usage-based reviews in the billing tab, then retry.

Check out review usage here.

⚙️ Run configuration
  • Configuration used: Repository: abnegate/zone/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d61f09e-2486-4da6-9952-9a2551accc70
📥 Commits

Reviewing files that changed from the base of the PR and between a376d11 and 37fed1d.

📒 Files selected for processing (113)
  • .github/workflows/rust-coverage.yml
  • docs/SYSTEM-PROMPT-RESEARCH.md
  • runner/zone_installer/src/migration/runner.rs
  • runner/zone_server/Cargo.toml
  • runner/zone_server/src/workers/gathering.rs
  • runner/zone_server/src/workers/task.rs
  • runner/zone_server/src/ws/chat.rs
  • runner/zone_server/tests/CONTEXT.md
  • runner/zone_server/tests/integration/agent_host_login.rs
  • runner/zone_server/tests/integration/agent_login.rs
  • runner/zone_server/tests/integration/agent_session_resume.rs
  • runner/zone_server/tests/integration/ai_settings.rs
  • runner/zone_server/tests/integration/ai_settings_routing.rs
  • runner/zone_server/tests/integration/ai_theme_authorization.rs
  • runner/zone_server/tests/integration/analytics_window.rs
  • runner/zone_server/tests/integration/api.rs
  • runner/zone_server/tests/integration/artifacts.rs
  • runner/zone_server/tests/integration/audit.rs
  • runner/zone_server/tests/integration/auth_console_contract.rs
  • runner/zone_server/tests/integration/auth_session_revocation.rs
  • runner/zone_server/tests/integration/authz_ai_settings_role.rs
  • runner/zone_server/tests/integration/authz_context_gather.rs
  • runner/zone_server/tests/integration/authz_cross_tenant_coverage.rs
  • runner/zone_server/tests/integration/authz_invitation_scope.rs
  • runner/zone_server/tests/integration/authz_project_enumeration.rs
  • runner/zone_server/tests/integration/authz_workspace_deletion.rs
  • runner/zone_server/tests/integration/background_job.rs
  • runner/zone_server/tests/integration/boundary_paths.rs
  • runner/zone_server/tests/integration/boundary_ssrf.rs
  • runner/zone_server/tests/integration/boundary_uploads.rs
  • runner/zone_server/tests/integration/cache.rs
  • runner/zone_server/tests/integration/chat_agent.rs
  • runner/zone_server/tests/integration/chat_agent_tools.rs
  • runner/zone_server/tests/integration/chat_attached_sources.rs
  • runner/zone_server/tests/integration/chat_context.rs
  • runner/zone_server/tests/integration/chat_context_store.rs
  • runner/zone_server/tests/integration/chat_context_tokens.rs
  • runner/zone_server/tests/integration/chat_generation_contract.rs
  • runner/zone_server/tests/integration/chat_handover.rs
  • runner/zone_server/tests/integration/chat_lifecycle.rs
  • runner/zone_server/tests/integration/chat_offline.rs
  • runner/zone_server/tests/integration/chat_project.rs
  • runner/zone_server/tests/integration/chat_replay.rs
  • runner/zone_server/tests/integration/chat_sandbox.rs
  • runner/zone_server/tests/integration/chat_search.rs
  • runner/zone_server/tests/integration/chat_sessions.rs
  • runner/zone_server/tests/integration/chat_sources.rs
  • runner/zone_server/tests/integration/chat_title.rs
  • runner/zone_server/tests/integration/chat_vision_history.rs
  • runner/zone_server/tests/integration/chat_ws.rs
  • runner/zone_server/tests/integration/chat_ws_contract.rs
  • runner/zone_server/tests/integration/chat_ws_media_contract.rs
  • runner/zone_server/tests/integration/common/context.rs
  • runner/zone_server/tests/integration/common/mod.rs
  • runner/zone_server/tests/integration/common/transcript.rs
  • runner/zone_server/tests/integration/console_contract.rs
  • runner/zone_server/tests/integration/context.rs
  • runner/zone_server/tests/integration/cross_tenant_authorization.rs
  • runner/zone_server/tests/integration/deferred_tool.rs
  • runner/zone_server/tests/integration/email_verification.rs
  • runner/zone_server/tests/integration/gathering_worker.rs
  • runner/zone_server/tests/integration/indexing.rs
  • runner/zone_server/tests/integration/invitations.rs
  • runner/zone_server/tests/integration/invitations_routes.rs
  • runner/zone_server/tests/integration/knowledge.rs
  • runner/zone_server/tests/integration/knowledge_recovery.rs
  • runner/zone_server/tests/integration/knowledge_url.rs
  • runner/zone_server/tests/integration/layout.rs
  • runner/zone_server/tests/integration/learning_thresholds.rs
  • runner/zone_server/tests/integration/lora_flows.rs
  • runner/zone_server/tests/integration/main.rs
  • runner/zone_server/tests/integration/mcp_agent.rs
  • runner/zone_server/tests/integration/mcp_task_tools.rs
  • runner/zone_server/tests/integration/memory.rs
  • runner/zone_server/tests/integration/memory_isolation.rs
  • runner/zone_server/tests/integration/memory_store.rs
  • runner/zone_server/tests/integration/message_embedding.rs
  • runner/zone_server/tests/integration/migration_atomicity.rs
  • runner/zone_server/tests/integration/model_namespaces.rs
  • runner/zone_server/tests/integration/models.rs
  • runner/zone_server/tests/integration/organization_console_contract.rs
  • runner/zone_server/tests/integration/organization_members.rs
  • runner/zone_server/tests/integration/password_reset.rs
  • runner/zone_server/tests/integration/plans.rs
  • runner/zone_server/tests/integration/pr_reception_status.rs
  • runner/zone_server/tests/integration/prompt_assembly.rs
  • runner/zone_server/tests/integration/pull_ws.rs
  • runner/zone_server/tests/integration/reminder_turn.rs
  • runner/zone_server/tests/integration/role_demotion.rs
  • runner/zone_server/tests/integration/role_demotion_race.rs
  • runner/zone_server/tests/integration/sessions.rs
  • runner/zone_server/tests/integration/skills_store.rs
  • runner/zone_server/tests/integration/subscriptions.rs
  • runner/zone_server/tests/integration/sync.rs
  • runner/zone_server/tests/integration/task_authorization.rs
  • runner/zone_server/tests/integration/task_creation.rs
  • runner/zone_server/tests/integration/task_execution.rs
  • runner/zone_server/tests/integration/task_lifecycle.rs
  • runner/zone_server/tests/integration/task_migration.rs
  • runner/zone_server/tests/integration/task_pr_fields.rs
  • runner/zone_server/tests/integration/task_review_verdict.rs
  • runner/zone_server/tests/integration/task_run_ws_authorization.rs
  • runner/zone_server/tests/integration/task_scope.rs
  • runner/zone_server/tests/integration/tenant_admin_permissions.rs
  • runner/zone_server/tests/integration/tenant_isolation.rs
  • runner/zone_server/tests/integration/test_config.rs
  • runner/zone_server/tests/integration/usage.rs
  • runner/zone_server/tests/integration/wait_for.rs
  • runner/zone_server/tests/integration/workspace_creation_atomicity.rs
  • runner/zone_server/tests/integration/workspace_owner_backfill.rs
  • runner/zone_server/tests/integration/workspace_owner_floor.rs
  • runner/zone_server/tests/integration/ws.rs
  • runner/zone_server/tests/integration/ws_context.rs

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@abnegate
abnegate merged commit 545bc33 into main Oct 6, 2026
16 checks passed
@abnegate
abnegate deleted the perf/one-integration-test-binary branch October 6, 2026 22:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant