Skip to content

Latest commit

 

History

History
490 lines (373 loc) · 28.6 KB

development.en.md

File metadata and controls

490 lines (373 loc) · 28.6 KB

English · 中文

Local Development and Testing Guide

Follow the steps in this document to run both regular tests and the full integration test suite (IT). For strategy and service registration details, see refactoring/integration.md and refactoring/test-infra.md; for the three pre-submit gates, see AGENTS.md.

mega2 is the second-generation, agent-oriented Mega engine; its core capabilities are the Monorepo and Agent Traces archiving. This document focuses on building from source and the test environment; for how the product components fit together, see Architecture, and for the Traces protocol contract, see Traces protocol reference.

Monorepo product rules (main is the only public branch, Git clients may not operate on tags, initialization and directory layout, trunk invariants) live in the central User Guide. For trunk / storage-only deployment, see deployment.md and deploy-trunk.en.md.

Recommended: use the script instead of pasting commands

The repo root provides a single entry point, scripts/dev-test.sh, so steps are not missed when copying and pasting (especially git-cli / .env.test / UID). Shared logic lives in scripts/lib/mega2-it.sh.

./scripts/dev-test.sh --help

# Stack
./scripts/dev-test.sh up-data          # data plane only
./scripts/dev-test.sh up-full          # data plane + git-cli (recommended)
./scripts/dev-test.sh up-scorpio       # data plane + mega2 + scorpiofs (ScorpioFS integration)
./scripts/dev-test.sh health
./scripts/dev-test.sh down

# Tests
./scripts/dev-test.sh unit             # lib unit tests without compose
./scripts/dev-test.sh basic            # data plane + cargo test --all (no git-cli)
./scripts/dev-test.sh full             # full IT (recommended path)
./scripts/dev-test.sh vault            # integration_vault
./scripts/dev-test.sh git-cli          # integration_git_cli
./scripts/dev-test.sh scorpio-smoke    # ScorpioFS stack-level smoke (run up-scorpio first)
./scripts/dev-test.sh gates            # fmt + clippy + full IT

The backward-compatible manual steps are in the sections below; prefer the script for new workflows.

Concepts (read these four first)

  1. Compose = data plane: docker/docker-compose.test.yml provides the mega2 dependencies such as Postgres / Redis / RustFS; Mailpit only captures website auth/product email in IT, and does not replace the processes under test that each test case starts.
  2. Black-box isolation: tests/integration_*.rs uses CARGO_BIN_EXE_mega2 to start a separate service http per test case (own port, temp directory, isolated DB).
  3. --profile app ≠ isolated IT: the long-running compose mega2 (:19180) is only for stack-level smoke / manual probes; it does not replace per-case black-box isolation.
  4. Fixed project name: every start/stop command must include -p mega2-it (it cannot coexist with a project named after the default directory).

Prerequisites

Item Notes
OS Full IT / git-cli is accepted on Linux and macOS Docker Desktop (bridge + host.docker.internal); Windows is not accepted
Tools Docker Compose v2, Rust stable, nightly (only for the rustfmt gate)
Repository layout Object storage code lives in src/orbit_api/ + src/orbit/; website session integration tests use the optional Compose web profile
Configuration Generate a local env from the example (not committed): cp .env.test.example .env.test (dev-test.sh creates it automatically)

Public test credentials (IT stack only, already written in compose / example):

  • Postgres: user/database mega2, password mega2_test_password
  • RustFS: rustfs / rustfs_secret, buckets mega2 (mega2 IT) and the compatibility name monoui (website integration tests, FS-ME-01)

Quick start: regular / basic tests

Unit tests without external dependencies can run directly (no compose needed):

./scripts/dev-test.sh unit
# or filter by substring
./scripts/dev-test.sh unit <substring> -- --nocapture
# manual equivalent: cargo test -p mega2 --lib

For in-crate integration tests and most black-box cases that need DB / Redis, start the default data plane first, then load the env:

./scripts/dev-test.sh basic
# manual equivalent:
# docker compose -p mega2-it -f docker/docker-compose.test.yml up -d --wait
# cp -n .env.test.example .env.test && source .env.test
# cargo test --all

Health self-check:

./scripts/dev-test.sh health

Full integration test stack (recommended path)

Run from the repo root. Goal: data plane + RustFS bucket initialization + git-cli, then run the full test suite.

./scripts/dev-test.sh full

Manual equivalent:

# 1) Shared git work root (must mkdir first, so Docker does not create it as root and cause EACCES)
dir="${MEGA2_IT_GIT_WORKDIR:-/tmp/mega2-git}"
mkdir -p "$dir" && chmod 1777 "$dir"
export MEGA2_IT_GIT_UID="$(id -u)" MEGA2_IT_GIT_GID="$(id -g)"

# 2) Data plane + rustfs-init creates buckets + git-cli (mailpit only for website IT capture)
#    Use a single --profile git up, so git-cli is not left out and integration_git_cli does not hard-fail.
docker compose -p mega2-it -f docker/docker-compose.test.yml \
  --profile git up -d --wait

# 3) Load connection strings and run everything (black-box + module integration)
cp -n .env.test.example .env.test
# RustFS / S3-compatible smoke only needs RustFS running (included in the previous step); no .env.test change needed (the test sets its own S3 env)
source .env.test
cargo test --all

For the data plane only, without running integration_git_cli, you can omit --profile git:

./scripts/dev-test.sh up-data
# or: docker compose -p mega2-it -f docker/docker-compose.test.yml up -d --wait

Clean up when done (including profile services and named volumes):

./scripts/dev-test.sh down
# equivalent:
# docker compose -p mega2-it -f docker/docker-compose.test.yml \
#   --profile git --profile app --profile web --profile smoke --profile scorpio down -v

Compose profiles

Profile Services When to enable
(default) postgres, redis, rustfs, rustfs-init Everyday mega2 IT data plane; rustfs-init idempotently creates the mega2 + monoui buckets, then stays up for --wait
(default, optional consumer) mailpit Website auth/product email capture; not a mega2 test gate
git git-cli (bridge + host.docker.internal) Running integration_git_cli / the full cargo test --all gate
app Long-running mega2 → 127.0.0.1:19180 Stack-level HTTP smoke / integration debugging; not isolated black-box
scorpio scorpiofs → 127.0.0.1:12725 (FUSE daemon, depends_on: mega2) ScorpioFS ↔ mega2 stack-level integration; must start together with --profile app, see "ScorpioFS integration" below

Stack-level HTTP probe example (build the image first, see test-infra.md):

docker compose -p mega2-it -f docker/docker-compose.test.yml \
  --profile app up -d --wait mega2
curl -sf http://127.0.0.1:19180/api/openapi.json >/dev/null
# optional: export MEGA2_IT_HTTP_URL=http://127.0.0.1:19180
# cargo test -p mega2 --test integration_vault integration_compose_mega2_http_smoke

ScorpioFS integration

ScorpioFS is a FUSE daemon that mounts monorepo paths as a local file system; its read-only paths go through mega2's /api/v1/tree*, /api/v1/file/tree, and /api/v1/file/blob/{oid}. docker/docker-compose.test.yml provides a long-running scorpiofs service under the scorpio profile (see the registration entry in refactoring/test-infra.md). It builds scorpiofs:local from the sibling checkout ../scorpiofs and depends_on the long-running mega2 (profile app), so both profiles must be started together.

Prerequisites: ../scorpiofs is checked out; the host runs rootful Docker and has /dev/fuse (the container needs --device /dev/fuse + CAP_SYS_ADMIN, plus CAP_DAC_READ_SEARCH so that the passthrough layer's open_by_handle_at uses the real path instead of falling back; rootless Docker is not supported).

./scripts/dev-test.sh up-scorpio          # first run builds scorpiofs:local (several minutes)
./scripts/dev-test.sh up-scorpio --build  # force a rebuild after ../scorpiofs changes
./scripts/dev-test.sh scorpio-smoke       # stack-level smoke, see below
ls /tmp/mega2-scorpiofs/mount             # browse the monorepo directly on the host
./scripts/dev-test.sh down                # down -v together with the scorpio profile

Manual equivalent:

dir="${MEGA2_IT_SCORPIO_WORKDIR:-/tmp/mega2-scorpiofs}"
mkdir -p "$dir/mount" "$dir/antares"      # created by the test UID; mount must be empty
docker compose -p mega2-it -f docker/docker-compose.test.yml \
  --profile app --profile scorpio up -d --wait
bash scripts/scorpiofs_smoke.sh

The mount is visible on the host. scorpiofs bind-mounts the host's ${MEGA2_IT_SCORPIO_WORKDIR:-/tmp/mega2-scorpiofs}/mount and …/antares with rshared into the container at /mnt/scorpiofs/mount / /mnt/scorpiofs/antares (overriding the image's default paths via SCORPIO_WORKSPACE / SCORPIO_ANTARES_MOUNT_ROOT), so FUSE mounts made inside the container propagate back to the host: <workdir>/mount is the read-only monorepo root, and Antares task mounts appear under <workdir>/antares/<mount_id>. ScorpioFS mounts with allow_other, so non-root users on the host can read it directly (files show root as owner). This requires the host path to sit on a mount with shared propagation (the default on systemd hosts) and dockerd to share the host's mount namespace; on macOS Docker Desktop, propagation stops at the VM and the host sees nothing.

scripts/scorpiofs_smoke.sh uses host curl (127.0.0.1:12725), host findmnt, and docker compose … exec -T scorpiofs to cover: GET /health; the dicfuse read-only root lists the initialized tree (project, third-party) and project/.gitkeep has placeholder content; host-mount: the host <workdir>/mount is a fuse mount readable by the current UID; the legacy POST /api/fs/mount → GET /api/fs/mpoint → POST /api/fs/unmount; Antares POST /antares/mounts → /ready → the mount directory is listed both in the container and on the host → DELETE → the mount point directory is reclaimed both in the container and on the host (needs a ScorpioFS image that includes the remove_mount_dirs fix; rebuild with up-scorpio --build). When the service is not running it prints SKIP (set SCORPIOFS_IT=1 to fail instead); to run a single case, use MEGA2_SMOKE_CASE=<name>.

Integration notes:

  • The host sees the same FUSE mount; container path /mnt/scorpiofs/mount ⇄ host <workdir>/mount. You can also look from inside the container: docker compose -p mega2-it -f docker/docker-compose.test.yml --profile app --profile scorpio exec -T scorpiofs ls -la /mnt/scorpiofs/mount.
  • down/stop unmounts gracefully via SIGTERM (stop_grace_period: 45s), and the host mount goes away with it; if the container is SIGKILLed, the host keeps a stale mount reporting Transport endpoint is not connected, and up-scorpio refuses to start and suggests sudo umount -l <path>. Do not leave a shell sitting in the mount directory before running down (EBUSY slows the unmount).
  • Do not delete only the mega2-data volume while keeping the database: the compose mega2 blobs (local object storage) and the vault key live in the volume, while the metadata lives in the postgres public schema; deleting them separately yields core key file is missing and 0-byte files. To reset, run down -v on the whole stack.
  • When debugging the API contract, raise the log level to debug: MEGA2_IT_SCORPIO_LOG_LEVEL=scorpio=debug ./scripts/dev-test.sh up-scorpio, then docker compose -p mega2-it -f docker/docker-compose.test.yml --profile app --profile scorpio logs -f scorpiofs.
  • The ScorpioFS HTTP API has no authentication and its port binds only to 127.0.0.1; do not change it to 0.0.0.0.
  • The Antares CL layer (/api/v1/cl/{link}/files-list) is only provided by the review policy; the IT stack mega2 uses review by default, while the trunk stacks (macos-orbstack-mega2-compose.yml / linux-mega2-compose.yml / docker/docker-compose-storage-only.yml) do not include it.

Focused commands

./scripts/dev-test.sh vault
./scripts/dev-test.sh git-cli
# manual equivalent:
# source .env.test
# cargo test -p mega2 --test integration_vault -- --nocapture --test-threads=1
# cargo test -p mega2 --test integration_git_cli -- --nocapture --test-threads=1

The three pre-submit gates (same as AGENTS.md):

./scripts/dev-test.sh gates
# manual equivalent:
# cargo +nightly fmt --all --check
# cargo clippy --all-targets --all-features -- -D warnings
# source .env.test && cargo test --all   # requires up-full; gates runs up-full itself

Ports and credentials at a glance

Service Host binding Purpose
postgres 127.0.0.1:15432 → 5432 MEGA_DATABASE__DB_URL
redis 127.0.0.1:16379 → 6379 MEGA_REDIS__URL
mailpit SMTP 127.0.0.1:11025 → 1025 Website IT SMTP capture (not mega2)
mailpit UI/API 127.0.0.1:18025 → 8025 Viewing website IT captures (not mega2)
rustfs S3 API 127.0.0.1:19000 → 9000 MEGA_OBJECT_STORAGE__S3__ENDPOINT_URL
rustfs console 127.0.0.1:19001 → 9001 Manual inspection
mega2 (app) 127.0.0.1:19180 → 8000 MEGA2_IT_HTTP_URL
scorpiofs (scorpio) 127.0.0.1:12725 → 2725 MEGA2_IT_SCORPIO_URL (ScorpioFS HTTP API, no authentication)
git-cli No port mapping Reaches high host ports from the bridge network via host.docker.internal

The network name is fixed as mega2-test-network: a stack started with -p mega2-it and one started without -p contend for it, so down -v the old stack before starting a new one.

Environment variables: resource connections vs harness

Resource connections (.env.test / .env.test.example, read by processes after export):

  • MEGA_DATABASE__DB_TYPE / MEGA_DATABASE__DB_URL
  • MEGA_REDIS__URL
  • MAILPIT_API_URL / MAILPIT_SMTP_HOST / MAILPIT_SMTP_PORT: only for website auth/product email IT capture; mega2 does not read them
  • MEGA_NOTIFICATION__WEBSITE_MAIL_BASE_URL / MEGA_NOTIFICATION__WEBSITE_MAIL_BEARER: placeholders for the website product email API client in isolated IT; not SMTP configuration
  • Optional S3: MEGA_OBJECT_STORAGE__STORAGE_TYPE=s3compatible and MEGA_OBJECT_STORAGE__S3__* (must match rustfs / rustfs_secret in compose)

Harness / compose orchestration (MEGA2_IT_*, controls the runner rather than business config field names):

Variable Purpose
MEGA2_IT_GIT_WORKDIR Shared host root for git-cli (default /tmp/mega2-git); after changing it, --force-recreate git-cli is required
MEGA2_IT_GIT_UID / GID User inside the container; required when local id -u ≠ 1000 (the script exports the current user by default)
MEGA2_IT_HTTP_URL Points to the long-running compose app service
MEGA2_IT_SCORPIO_URL Points to the long-running ScorpioFS API of compose scorpio (default http://127.0.0.1:12725, used by scorpiofs_smoke.sh)
MEGA2_IT_SCORPIO_WORKDIR Root of the host-visible FUSE mounts (default /tmp/mega2-scorpiofs; mount/ and antares/ are bound into the container with rshared); after changing it, --force-recreate scorpiofs is required
MEGA2_IT_SCORPIO_LOG_LEVEL SCORPIO_LOG_LEVEL for the scorpiofs container (default info; set scorpio=debug when debugging integration)
MEGA2_IT_ALLOW_HOST_GIT=1 Use host git only for local experiments; not the acceptance path
MEGA2_IT_SKIP_GIT_CLI=1 Explicitly skip git-cli cases (not the default gate)
MEGA2_IT_PROJECT Compose project name (default mega2-it; the script can override it)

Do not put compose service names (such as postgres) into host-side URLs: host processes always connect to 127.0.0.1:<high port>; only inside containers (profile app) are service DNS names used.

Troubleshooting and reset

Stack not ready / connected to the wrong database

docker compose -p mega2-it -f docker/docker-compose.test.yml ps
docker compose -p mega2-it -f docker/docker-compose.test.yml logs postgres redis mailpit rustfs
psql 'postgres://mega2:[email protected]:15432/mega2' \
  -c "select current_database(), count(*) from seaql_migrations"

After source .env.test, confirm that the URLs point to 15432 / 16379 and that the production defaults in config/config.toml are not being used by mistake.

git-cli runner unavailable

  • Did you run ./scripts/dev-test.sh up-full (or --profile git up -d --wait)?
  • Was the work root created with mkdir + chmod 1777? Do UID/GID match the host?
  • Host git cannot replace acceptance; set MEGA2_IT_ALLOW_HOST_GIT=1 only for debugging.

git work directory EACCES / mount divergence

./scripts/dev-test.sh up-full
# If it still fails, force-recreate git-cli:
dir="${MEGA2_IT_GIT_WORKDIR:-/tmp/mega2-git}"
mkdir -p "$dir" && chmod 1777 "$dir"
export MEGA2_IT_GIT_UID="$(id -u)" MEGA2_IT_GIT_GID="$(id -g)"
docker compose -p mega2-it -f docker/docker-compose.test.yml \
  --profile git up -d --force-recreate --wait git-cli

Test schema buildup (mega2_test_*)

In-crate unit tests use crate::jupiter::tests::test_db_connection / test_db_config to create one mega2_test_<pid>_<n> schema per test case in the mega2 database. The schema is dropped with DROP SCHEMA ... CASCADE together with the test's connection (or the TestSchemaGuard returned by test_db_config), including on panic paths; a schema still held when the test thread ends (for example by the vault connection pool) is released at that point; schemas left by runs that predate this guard keep accumulating, showing up as could not resize shared memory segment ... No space left on device and Postgres failing to restart. Check the count first, then clean up with the script (destructive; by default it only reports, and it skips schemas of test processes that are still running):

docker compose -p mega2-it -f docker/docker-compose.test.yml exec -T postgres \
  psql -U mega2 -d mega2 -Atc "select count(*) from pg_namespace where nspname like 'mega2\_test\_%'"
./scripts/drop_test_schemas.sh                   # report only
./scripts/drop_test_schemas.sh --apply --vacuum  # actually drop and reclaim the system catalogs

Website email does not reach Mailpit

curl -fsS http://127.0.0.1:18025/api/v1/messages

Check the test email provider / SMTP configuration of website-next; mega2 has no SMTP configuration and does not treat Mailpit availability as a startup or test gate. Note that the IT stack injects EMAIL_PROVIDER=test by default (an in-process, in-memory provider that does not send SMTP), so when WE-06 passes, Mailpit is expected to be empty; to make email actually land in Mailpit, change website-next's EMAIL_PROVIDER to smtp and set SMTP_HOST=mailpit / SMTP_PORT=1025. The website application source for this optional test stack lives in a separate sibling checkout (apps/web).

Workspace Code stack IT (WEBSITE_IT=1)

The website-next service in docker/docker-compose.test.yml injects MEGA_CODE_DATA_BACKEND=mega2 and the in-container MEGA2_PUBLIC_BASE_URL=http://mega2:8000, so the website application's /api/mega Code read path is forwarded to mega2 through the BFF. Run the related check in the website application repository:

WEBSITE_IT=1 pnpm test:api -- tests/api/mega/workspace-code-stack.test.ts

It needs the --profile app --profile web stack to be ready; without WEBSITE_IT=1, the test is skipped automatically.

Workspace object storage IT (FS-02, website-next)

website-next also injects the RustFS S3 environment (reserved bucket name monoui):

Variable Compose value
STORAGE_PROVIDER s3
S3_BUCKET monoui
S3_ENDPOINT http://rustfs:9000
S3_PUBLIC_URL http://127.0.0.1:19000/monoui
S3_FORCE_PATH_STYLE true
S3_ACCESS_KEY_ID / S3_ACCESS_KEY_SECRET rustfs / rustfs_secret

website-next depends on rustfs-init: service_healthy (both buckets mega2 + monoui created). If you also have the website application's sibling checkout, see its docs/implementation/workspace-storage-backend.md for design details.

Clean reset

./scripts/dev-test.sh down
# Refresh the local env (merge by hand if you want to keep custom comments)
cp .env.test.example .env.test

For zero leftovers, check that volumes and networks are empty by compose project label (see test-infra.md).

Debugging summary: test failures caused by the local environment

The two kinds of failure below have nothing to do with the code; they come from local tool versions or a network proxy. They look like code regressions, which makes it easy to go down the wrong path. Use the self-check commands in this section to confirm whether it is an environment problem before looking at the code.

git-lfs version differs from the pinned version

Symptom: the 4 cases of integration_git_lfs (integration_git_lfs_storage_events_basic_upload, integration_git_lfs_storage_events_presigned_gap, integration_git_lfs_trunk_push_auth_none_round_trip, integration_git_lfs_trunk_push_auth_token_round_trip) fail with the assertion:

host git-lfs used by trunk LFS IT must be the pinned version
  left: "git-lfs/3.8.0"
 right: "git-lfs/3.7.1"

Cause: the tests require git-lfs in two places to exactly equal the pinned version: the host's git lfs version (assert_host_git_lfs_pinned in tests/integration_git_lfs.rs, with ~/.local/bin first in PATH), and the version inside the compose git-cli runner container (assert_pinned_git_lfs). After Homebrew auto-upgrades the host git-lfs, it no longer matches the version pinned in the repo.

Fix: since v0.40.13 (2026-09-26) the pinned version is 3.8.0. When the host git-lfs is upgraded again, raise the pinned version everywhere instead of downgrading the host:

  1. Update every pinned location together: the two assertions in tests/integration_git_lfs.rs; GIT_LFS_VERSION and the amd64 / arm64 sha256 values in Dockerfile.git-cli and Dockerfile.git-smoke; the image tags and healthchecks in both compose files; the registration entry in test-infra.md. Note that the healthcheck is written as the regex 3[.]8[.]0, so a literal search for 3.8.0 misses it. Take the sha256 from the GitHub release asset digest (the output already strips the sha256: prefix):
version=3.8.0
gh api "repos/git-lfs/git-lfs/releases/tags/v${version}" \
  --jq '.assets[] | select(.name | test("^git-lfs-linux-(amd64|arm64)-")) | "\(.name) \(.digest | ltrimstr("sha256:"))"'
  1. Rebuild the runner image and replace only the git-cli container (the build downloads the git-lfs release archive and verifies it with the sha256 above). As in "git work directory EACCES / mount divergence" above, prepare the work directory and export UID / GID first:
dir="${MEGA2_IT_GIT_WORKDIR:-/tmp/mega2-git}"
mkdir -p "$dir" && chmod 1777 "$dir"
export MEGA2_IT_GIT_UID="$(id -u)" MEGA2_IT_GIT_GID="$(id -g)"
docker compose -p mega2-it -f docker/docker-compose.test.yml --profile git build git-cli
docker compose -p mega2-it -f docker/docker-compose.test.yml --profile git up -d --wait --no-deps git-cli
# If you also run the linked stack-level smoke, rebuild git-smoke the same way (it depends on mega2 from profile app):
docker compose -p mega2-it -f docker/docker-compose.test.yml --profile app --profile smoke build git-smoke

Self-check:

PATH="$HOME/.local/bin:$PATH" git lfs version           # host (same PATH order as the tests)
docker exec mega2-it-git-cli-1 git lfs version          # compose runner

Both version numbers must equal the pinned version; if either one differs, integration_git_lfs fails.

System proxy (Clash Verge) makes the S3 smoke return 502

Symptom: integration_object_storage_s3_compatible_smoke fails, while direct connections to RustFS work:

Generic S3 error: Error performing PUT http://127.0.0.1:19000/mega2/... after 10 retries ...
Server returned non-2xx status code: 502 Bad Gateway

integration_git_lfs_storage_events_presigned_gap, which also points object storage at 127.0.0.1:19000, can fail for the same reason (when the pinned version does not match, it fails first at the version assertion, which hides this problem).

Cause (two layers combined):

  1. mega2 does not read the system proxy's exception list. The tests start the mega2 child process with env_clear(), so NO_PROXY is not passed in; on macOS, mega2's HTTP stack (reqwest → hyper-util) reads only the system proxy's HTTP / HTTPS addresses, not "Bypass proxy settings for these Hosts & Domains" (ExceptionsList). So even if 127.0.0.1 is listed as an exception in System Settings, requests to the local RustFS still go to the proxy (for example Clash Verge's 127.0.0.1:7897).
  2. The proxy does not route loopback addresses directly. The proxy forwards 127.0.0.1 to a remote node, which cannot reach the local machine, so it returns 502. In Clash Verge 2.x, prepend-rules written in "Extend Config" (formerly Merge) do not take effect: since v1.7.x, prepend / append rules moved to "Edit Rules" in the subscription's right-click menu.

Fix: in Clash Verge, right-click the subscription → "Edit Rules" → "Add Prepend Rule", and choose DIRECT as the proxy policy for each:

Rule type Rule content
IP-CIDR 127.0.0.0/8 (required; RustFS is at 127.0.0.1:19000)
DOMAIN localhost
IP-CIDR6 ::1/128
IP-CIDR 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12

You can also use an "Extend Script" to insert these rules at the front of config.rules, or temporarily turn off the system proxy while running tests.

Self-check:

scutil --proxy | grep -E 'HTTP(S)?(Enable|Proxy|Port)'   # whether the system proxy is on, and its port
# RustFS must be ready, otherwise the smoke below just skips; this step returns immediately when it is already running, and fails when it is not ready
docker compose -p mega2-it -f docker/docker-compose.test.yml up -d --wait rustfs rustfs-init
# Hit the RustFS health check through the system proxy: 200 means the proxy routes loopback directly, 502 means it does not
port="$(scutil --proxy | awk '/HTTPPort/{print $3}')"
env -u NO_PROXY -u no_proxy curl -sS -x "http://127.0.0.1:${port}" -o /dev/null -w '%{http_code}\n' http://127.0.0.1:19000/health
# Rerun the S3 smoke on its own
source .env.test && cargo test -p mega2 --test integration_vault integration_object_storage_s3_compatible_smoke -- --nocapture

When the test cannot reach 127.0.0.1:19000, it prints ... requires RustFS ... skipping and returns, and the result still shows as passed; a pass only means the S3 path actually ran when that line is absent from the output.

Debugging trap: curl -x <proxy> still honors the NO_PROXY environment variable. When the current shell's NO_PROXY contains 127.0.0.1, curl actually connects directly, leading to the wrong conclusion that "the proxy works"; when verifying the proxy, always strip it with env -u NO_PROXY -u no_proxy.

Other known local noise

  • On macOS, cargo build --tests may print the linker note warning: linker stderr: ld: __eh_frame section too large .... It is platform linker output, not a code problem; cargo counts it as 1 warning (linker_messages). Per the user's decision (2026-09-26), it is treated as platform noise, does not count against the 0-warning gate for cargo build --tests, and needs no action.
  • These environment problems are registered in plan-20260923.md as DEP-FU-05 (local baseline environment failures).

Related documents