Repository navigation
test(mcp): run the MCP client workflow tests offline in CI - #4350
Conversation
Nine test files no CI lane runs had been failing silently against APIs and contracts that changed underneath them. This brings them back to green against current main so the next change can put them in a lane. - test_sdk.py: assert the SDK surface that exists today (process_query via Agent.chat, the tool registry instead of the never-public execute_tool, openai_server's module-level app, Agent.STATE_* class constants, current RAGSDK/AudioClient/KokoroTTS methods, LLMClient as an ABC); drop the xfail DatabaseMixin block (it ships as gaia.database.mixin) and the placeholder docs-exist check. - test_multi_caller_equivalence.py: send the X-Gaia-UI header on mutating calls and read /api/connectors' "connectors" shape. - test_memory_integration.py: fresh installs are schema v4. - test_memory_api_integration.py: consolidation is 503 until a chat session registers a consolidator, and runs it once one has. - test_documents_router.py: two fixtures indexed for real and needed Lemonade. - test_tui_control_e2e.py: give the pty a size and a TERM like a terminal. - test_ui_email_scope_consent.py: the agent now declares microsoft_work too; drop three tests of the in-process /v1/email mount the UI no longer has. - test_lemonade_embedded_lifecycle.py: llamacpp:cpu has no macOS build. - test_email_mcp_stdio_parity.py: docstring said no Lemonade; triage uses it. - test_vlm_integration.py: deleted. A script that returned booleans instead of asserting, so it could not fail, and it called a removed constructor arg. Refs amd#4205
…blocking 43 test files ran in no CI lane, so they looked green on every PR whether they worked or not, and nothing stopped the count from growing. Now every test file is either run by a lane or listed with the reason CI can't run it, and lint fails the moment a new file is neither. - test_unit.yml gains an offline-integration job for the 23 files that need no Lemonade, live account or AMD hardware (with Go for the TUI e2e and the [mcp] extra for the SDK and MCP-server tests). - test_email_agent_unit.yml runs test_ui_email_scope_consent.py. - util/test_lane_allowlist.yml lists the 18 that need a live Lemonade Server, a real Gmail account, a self-hosted model runner, npm-fetched MCP servers, or are hand-run scripts, each with its reason. - util/lint.py runs check_test_lane_coverage.py as a blocking check (--test-lanes, and part of --all); lint.yml re-runs when the allowlist changes. Fixes amd#4205
The Agent UI wrote Document Library uploads and chat attachments to the real ~/.gaia even when GAIA_HOME pointed elsewhere, so the document and file router tests left files in the developer's GAIA home on every run. - The documents dir, the uploads dir and the static uploads mount now resolve GAIA_HOME at call time; the agent's writable scope follows the same dir. - A relocated documents dir is added as a document root so reindexing a dropped file still works when GAIA_HOME is outside the home directory. - A GAIA_HOME that is the home directory or above it is refused: the server deletes files in <GAIA_HOME>/documents as its own, and there that is the user's real Documents folder. - The router tests run under a fake home with GAIA_HOME set elsewhere, and fail if anything appears under <home>/.gaia. Fixes amd#4347
The only tests that drive GAIA's MCP client against a real server were broken and ran in no lane: one still asserted the removed `gaia mcp add` flow, the other fetched unpinned npm servers and broke on a tool rename. Both now spawn a local stdio server built on the official MCP SDK, so nothing is downloaded and there is no version to pin. The workflow file follows today's path end to end: `gaia connectors configure` writes a `$keyring` reference, an agent loads it, the secret reaches the server's environment, and `gaia connectors disconnect` removes it. The manager file covers connect, tool schemas, calls, tool errors, a server that cannot start, and reload following the config file. They move from the lane allowlist into the offline-integration job. Fixes amd#4346
The file-search tests walked the real home directory, so on a developer machine one test ran past two minutes, and the results depended on what that user owned. Most assertions were hedged with "if found" because the fixture lived under ~/.gaia, which the search skips as hidden. The search tests now point HOME/USERPROFILE at a temp dir and write their files into its Documents folder, so each one asserts the exact result. The file runs in about 4 seconds with the real HOME set. Refs amd#4205
# Conflicts: # tests/test_vlm_integration.py
…free box Both files this PR repairs still failed in the offline lane, so the "534 passed" claim held only on the author's machine. The memory test built its URL by interpolating a local-timezone stamp. At a negative UTC offset the "-" is URL-safe and it passes; on a UTC runner the "+00:00" decodes to a space, fromisoformat rejects it, and the endpoint correctly 422s. Passing the stamp through the client's params lets it percent-encode, and a second pinned +00:00 case means the test now catches this from any timezone rather than only from UTC. The TUI test set TERM to get color, but termenv treats any environment with CI set as "not a TTY" before it looks at TERM or the pty, so lipgloss dropped to the Ascii profile and rendered no escapes at all for format=ansi to return. CLICOLOR_FORCE is the documented override, and NO_COLOR outranks it, so both it and CLICOLOR are cleared. Also resolves the merge with main: amd#4290 removed only one of this file's three fallback_model uses, and VLMClient no longer takes that argument, so the deletion stands.
…ew live-Lemonade suite tests/test_ui_email_scope_consent.py was added to the email lane's pytest command but not to its paths filters, so a PR editing only that file still ran it nowhere -- while the new checker counted it as covered, because the checker asks whether a lane names a file, not whether any trigger reaches that lane. Listed in both the push and pull_request blocks, next to the other individually-named tests/test_email_* entry. Merging main brought tests/integration/test_lemonade_predownload_checks.py, which the gate correctly flagged as run by no lane. It takes require_lemonade, so it is allowlisted rather than wired offline.
uploads_dir() runs inside create_app(), which is not a request context, so the new guard's HTTPException surfaced as a raw "fastapi.exceptions.HTTPException: 500: ..." out of `gaia chat --ui`. The user sees a stack trace for a mistake they could have fixed in one step. It now raises UnsafeGaiaHomeError, and both launch paths -- `gaia chat --ui` and `python -m gaia.ui.server` -- print the message and exit 64 (EX_USAGE, the code gaia uninstall already uses for the same misconfiguration). The structural test itself moves to gaia.config as unsafe_gaia_home_reason(), which uninstall_command now calls instead of keeping a second copy. Its messages, tiers and exit codes are unchanged; it keeps its own identity/marker check on top. The UI copy had also dropped the filesystem-root case, which it now inherits for free. UnsafeGaiaHomeError moves to gaia.config alongside it and stays importable from uninstall_command, where it was defined and is still imported from.
|
No problem found in this PR — its two red tests were inherited from #4343, not caused here, and both are now fixed. Merged the updated stack in, so this should go green on its own merits. All 9 of the repaired MCP tests already passed in this PR's own lane run. The only failures were the memory and TUI tests from the bottom of the stack: one that only passed in a negative-UTC timezone, one that could never pass in CI at all. Details on #4343. One number in the description needs a nudge: the allowlisted count is now 17, not 16. #4344 picked up a new live-Lemonade file from main, so this PR still removes exactly its own two entries — the base it subtracts from just moved. 🔍 Technical detailsMerged 19 (#4344, including Local run is not evidence here, and I want to be explicit about why. 7 of the 9 tests fail on my box with My global env has So the fixture server is correct and the lane is the real check — where all 9 passed. Worth knowing that a contributor below the floor gets a misleading "Server closed connection" rather than the ImportError, since the child's stderr is not surfaced. Unrelated red: |
|
Verdict: Approve The rewrite is clean. Replacing the npx/uvx downloads with a local fixture server that speaks real JSON-RPC over stdio is the right approach — no version pins to rot, no network required, and the client is still exercised against an independently-implemented server. The Two minor observations (not merge blockers): 🟢 🟢 The 🔍 Technical detailsError match: pymupdf pin: |
…nc-4348 # Conflicts: # tests/integration/test_files_router.py
# Conflicts: # tests/integration/test_memory_integration.py
…2-4344 # Conflicts: # docs/reference/dev.mdx # util/lint.py
# Conflicts: # .github/workflows/test_unit.yml # util/test_lane_allowlist.yml
…4353) About 300 unit tests never ran in CI. Their files skip as a whole when a hub wheel (`gaia_agent_chat`, `gaia_agent`, `gaia_agent_email`) or an optional extra is missing. The unit lane lacks them, but it still names the files, so the lane check counted them as covered. With this PR, each file runs in a lane that installs what it needs, and a lane fails when a file skips as a whole without an allowlist entry saying which lane runs it. Stacked on #4344. Merge #4343 and #4344 first. - **The new guard runs inside each lane**, right after install. It collects the job's own pytest commands in that lane's environment, so it sees what the lane actually runs. It reports the skipping file by name. This matters because a file that imports a skipping helper is otherwise blamed on the helper's line: `test_chat_inline_web_ssrf.py` was hidden that way. - **Two moved files needed repairs to pass together.** `test_chat_fix_contracts.py` picked up file tools leaked from earlier tests. `test_chat_system_prompt_budget.py` evicted the chat agent module at collection, so other files' patches stopped hitting it. - **Two files stay allowlisted with no lane, for an owner to decide.** `test_profilespec_characterization.py` has 11 golden rows that drifted, and its docstring says golden updates need sign-off. `test_tool_loader_token_budget.py` has 4 token and tool-count pins that are stale, and even re-pinned, one ratio is over budget. Overlaps: #4350 is also stacked on #4344 and edits the offline-integration list and the allowlist, so expect a small conflict there. #4038, #3721, #3669, #3812 and #3072 touch other parts of `test_unit.yml` and `test_gaia_agent.yml`. ## Test plan - [x] Before: `python util/check_module_skips.py --workflow test_unit.yml --job unit-tests` with no `module_skips` entries reports 80 files skipping wholesale and exits 1 - [x] After: the guard exits 0 for all 7 guarded jobs, each run in a clean py3.12 venv built from that job's install step - [x] `python util/check_test_lane_coverage.py` and `python util/lint.py --test-lanes` pass (31 module-skip entries verified) - [x] New tests: `pytest tests/unit/test_check_module_skips.py tests/unit/test_check_test_lane_coverage.py` passes 64. They include a real `--collect-only` over a temp repo - [x] Chat-lane files in the chat env: 421 passed. Before the two test repairs, 2 failed when run together - [x] Flagship-lane files in the gaia env: 59 passed. `test_mcp2_server.py` plus the MCP transcript tests in the MCP env: 27 passed - [x] Email unit lane's full command plus `test_synthetic_mbox.py`: 4980 passed - [x] The 4 newly unskipped files in the unit job (docx, pptx, reportlab, slack): 60 passed. Full `tests/unit/` in that env: 14509 passed, 23 failed. The failures are in 3 files (uninstall, CLI smoke, Lemonade ASR) that also fail when run alone. They come from this Mac's setup: `GAIA_HOME` isolated and `gaia` not on PATH. This PR changes no code those files exercise - [x] `actionlint` is clean on the 6 edited workflows. `black`, `isort`, and `pylint --errors-only` are clean on the changed Python - [ ] Watch the MCP lane's Windows leg run `test_mcp2_server.py` and the guard. They were only run on macOS locally Fixes #4206 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Ovtcharov <[email protected]> Co-authored-by: Claude Opus 5 <[email protected]> Co-authored-by: f <f@f> Co-authored-by: probe <probe@local>
The only tests that run GAIA's MCP client against a real server were broken and ran in no CI lane. One still checked the
gaia mcp addflow removed in #977. The other downloaded unpinned npm servers and broke when one renamed a tool. Both now start a small local server built on the official MCP SDK, so they download nothing and have no version to pin. They move from the allowlist into the offline-integration job.Stacked on #4344. Merge that first. This PR removes the two allowlist entries #4344 adds, which drops its allowlisted count from 18 to 16.
gaia connectors configurestores the secret in the keyring and writes a reference to it. An agent loads the server, the secret reaches the server's environment, andgaia connectors disconnectremoves the server again.Test plan
sequentialthinkingtool)pytest tests/mcp/test_mcp_cli_to_agent_workflow.py tests/mcp/test_mcp_sdk_integration.pypasses 9 of 9 in about 3 s, offline, withGAIA_HOME/GAIA_DAEMON_HOMEisolated, in a clean py3.12 venv with-e ".[api,mcp]"$keyringenv resolution in the MCP client fails 2 of the new teststests/integration/test_files_router.pyis left out because its file-search tests hang on this Mac. That is unrelated to this PR.tests/unit/mcp+tests/unit/connectorspass: 1117 passedpython util/check_test_lane_coverage.pyexits 0 (850 files, 16 allowlisted). black, isort, andpylinterrors-only are clean on the changed filesOffline Integration Testsjob go green on LinuxFixes #4346