Skip to content

test: cover every starting state against a recording model server - #7331

Merged
kovtcharov-amd merged 9 commits into
amd:mainfrom
kovtcharov:kalin/ci-starting-state-matrix
Nov 12, 2026
Merged

kovtcharov-amd merged 9 commits into
amd:mainfrom
kovtcharov:kalin/ci-starting-state-matrix

Conversation

@kovtcharov

@kovtcharov kovtcharov commented Nov 12, 2026 •

Copy link
Copy Markdown
Contributor

In rc18 a cloud-only user had a 5 GB local model downloaded and loaded without being asked: by the start-up warm-up, by Memory > Run Inference, and by a scheduled run. Each bug fired only from one starting state, and every existing test started from a PC that was already set up, with the client mocked. This adds a matrix that crosses five starting states with three entry points, runs each against the installer journeys' stand-in Lemonade over real HTTP, and asserts what actually reached that server.

A new starting state or entry point is one row; every combination is then covered, and a combination with no rule is an error.

start-up warm-up Memory > Run Inference scheduled run
cloud model as default_model ✅ ✅ ✅
cloud model picked in the app ✅ ✅ (#7270) ❌ new: #7329
cloud model as Custom model ID ✅ (#7271) ✅ ❌ new: #7329
empty cache ✅ ✅ (#7270) not asserted
local model on disk (control) ✅ ✅ ✅

The two ❌ cells are strict expected failures naming the issue, so the fix has to delete its line. Three more cells failed when this PR opened (#7217, #7218); their fixes, #7270 and #7271, merged since, the strict markers tripped as designed, and those lines are gone.

New bug it found: #7184 made gaia schedule run honour default_model, but a cloud model picked in the desktop app is saved elsewhere, so a scheduled run for that user still loads (and downloads) local Gemma. Filed as #7329.

Test plan

  • python -m pytest tests/unit/test_starting_state_matrix.py -q reports 14 passed, 2 xfailed
  • Delete a line from KNOWN_BUGS and the failure prints the requests the server saw, ending in POST /api/v1/load Gemma-4-E4B-it-GGUF
  • Runs in the unit job; the warm-up column needs the flagship package, so it skips there and runs in test_gaia_agent.yml, which now names this file
🔍 Technical details
  • tests/fixtures/fake_lemonade.py starts installer/headless/fake_model_server.py (the server the setup and installer journeys already use) and reads its request log into pulls, loads, chats and downloads. No second fake server. A load or chat asked of a model that is not downloaded counts as a download, because real Lemonade fetches it by itself.
  • The matrix pins installed memory to 128 GB, because the warm-up is skipped on a small PC and a CI runner would hide the bug, and stubs the PC scan so profile inference never reads the machine it runs on.
  • Not covered here: what the setup and model screens say from these states (F1, F6, F43). Those are assertions on API payloads, not on server requests.

In rc18 a cloud-only user had a 5 GB local model downloaded and loaded behind
their back by the start-up warm-up, by Memory > Run Inference and by a
scheduled run. Each bug fired only from one starting state, and every test had
been written from a PC that was already set up.

tests/fixtures/fake_lemonade.py is a model server that answers like Lemonade
over real HTTP and writes down every request. The matrix crosses five starting
states with three entry points and asserts what reached the server: no local
chat model touched on a cloud setup, nothing downloaded unasked, and the local
default used where that is right.

Three cells fail on the open fixes for amd#7217 and amd#7218. Two fail on a bug the
matrix found: a scheduled run ignores a cloud model picked in the app (amd#7329).
All five are strict expected failures.
@github-actions github-actions Bot added the tests Test changes label Nov 12, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This adds a fake Lemonade server that records every request, plus a test matrix that runs three entry points (start-up warm-up, Memory › Run Inference, scheduled run) from five starting states. It catches models being downloaded or loaded when the user never asked. It changes tests only, and I reproduced the claimed result: 10 passed, 5 xfailed.

One thing worth fixing before merge: the five expected-failure cells count any exception as the expected failure. A broken import or a renamed function would still show as "known bug, still failing", so the cell would stop testing the bug without anyone noticing. Limiting them to assertion failures closes that gap.

Merge order: #7270 and #7271 must land after this PR or edit its known-bugs list. Otherwise their fixed cells pass unexpectedly and turn the unit job red.

Real-world evidence

N/A: tests-only PR. No user-facing surface changed, so the verdict rests on static review plus a local run of the new file:

$ python -m pytest tests/unit/test_starting_state_matrix.py -q
....xxx.x.x....                                                          [100%]
10 passed, 5 xfailed in 8.23s
🔍 Technical details

🟢 Strict xfail also absorbs crashes, not just the bug (tests/unit/test_starting_state_matrix.py:543)

Before I installed the flagship hub package, from gaia_agent import server raised ModuleNotFoundError. The 4 non-xfail warm-up cells failed loudly, but cloud_custom_model_id-start_up_warm_up was reported as XFAIL - amd/gaia#7217 because the import error satisfied the xfail. A future rename of _model_to_warm, stream_inference or runner.fire would hide the same way in any KNOWN_BUGS cell. Pin it to the assertion:

                marks.append(
                    pytest.mark.xfail(
                        reason=KNOWN_BUGS[key], strict=True, raises=AssertionError
                    )
                )

🟢 Server thread leaks if saving the custom model fails (tests/unit/test_starting_state_matrix.py:568-573)

The server is appended to started only after _save_custom_model runs, so a failed PUT /api/settings assertion skips teardown for that server. Register it as soon as it starts:

        server = FakeLemonade(models=state.models())
        server.__enter__()
        started.append(server)
        monkeypatch.setenv("LEMONADE_BASE_URL", server.base_url)
        if state.custom_model:
            _save_custom_model(state.custom_model, tmp_path)
        return server

Notes (no action needed)

  • I checked that cloud_custom_model_id really runs against the fix in fix(ui): warm the model the user set as Custom model ID #7271: that PR mirrors custom_model into last_model in config.json, which this fixture redirects via GAIA_CONFIG_FILE. Saving to a tmp UI DB does not bypass the fix.
  • Sibling paths and doc drift: no production code or docs changed, so nothing to search. The missed-bug-class "Cold start and non-default setups" is exactly what this PR covers.

Strengths

  • Assertions run against requests that reached a real HTTP socket, not mocked client calls. That is the "mocks prove we called it, not that the call is valid" gap in CLAUDE.md.
  • _cells() raises when a state × entry pair has no rule, and test_every_known_bug_names_a_real_cell catches stale KNOWN_BUGS keys. Adding a row can't silently skip coverage.
  • Pinning ram_total_gb to 128 GB stops a small CI runner from skipping the warm-up path and passing vacuously.

The unit job does not install the flagship package, so the start-up warm-up
cells failed there with ModuleNotFoundError. They now skip when the package
is absent, and test_gaia_agent.yml, the lane that installs it, runs the
matrix so the column is still enforced.
installer/headless/fake_model_server.py already answers like Lemonade and
logs every request, so the fixture now starts that server and reads its log
instead of carrying a second one. It plays a PC whose only downloaded models
are the ones a state names, and refuses a model that is not downloaded, so a
request for one is counted as the download it would be on a user's PC.
The matrix's fixture starts installer/headless/fake_model_server.py, so a
change to that file has to run the lane that runs the matrix.
@github-actions github-actions Bot added the devops DevOps/infrastructure changes label Nov 12, 2026
kovtcharov and others added 4 commits November 11, 2026 23:57
Both fixes are on main now, so the memory-inference and warm-up cells pass
and their expected-failure lines go, as the strict marker requires. The two
scheduled-run cells (amd#7329) are the ones left.
…bug cells

The fake server logs a stderr line per request into a pipe nobody read, so it
stalled once the pipe filled: after 77 requests on Windows, ~700 on Linux. It
now logs to a file in its own folder, and a test drives 200 KB of log through
it.

A known-bug cell now only passes as expected on an assertion failure, so a
broken import or a renamed entry point fails loudly instead of reading as the
bug. The scheduled run's refused load is the request the cell judges, so that
refusal no longer ends the run before the assertion. The server is registered
for teardown as soon as it starts.
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Nov 12, 2026
# Conflicts:
#	.github/workflows/test_gaia_agent.yml
@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Nov 12, 2026
Merged via the queue into amd:main with commit 0377c0e Nov 12, 2026
24 of 27 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/ci-starting-state-matrix branch November 12, 2026 11:44
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
Every unit test indexes three files and stores five memories, and rc18
fell over at 300 of each: a folder index reloaded the embedder once per
file, so 300 small files took 15 minutes, and a memory search over a few
hundred rows ended the turn on a JSON error. This adds a scale run that
does both at a real user's size on every release tag, with no model: the
installer journeys' fake model server answers, and the test asserts
counts of what GAIA asked it for.

What it asserts:

| At scale | Assertion | Today |
|---|---|---|
| large folder index | every file indexed, exactly one library row each
| ✅ |
| large folder index | the embedder is loaded at most twice, within a
time budget | ✅ (fixed by amd#7310 while this was in review; it caught
amd#7288, a reload per file, before that) |
| search over 500 memories | the result can be sent as JSON | ✅ (fixed
by amd#7308 while this was in review; the test caught it before that) |
| 500 memories | the memory API reaches every one, page by page | ✅ |

**Size:** 300 files, the size rc18 failed at. With amd#7310 in, they index
in about 25 s against the fake server, well inside the 240 s budget;
before it, 300 ran past 45 minutes on a hosted runner (that slowness was
the bug).

**Not built here, and why:** the 60-turn chat with the context meter
compared to what the model is sent (F59) needs a real flagship turn loop
behind the relay, and the memory page showing only 200 of 500 (F63) and
duplicate rows from a re-add during indexing (F65) are a frontend bug
and a race. Each has its own focused test in its fix PR (amd#7309, amd#7312,
amd#7311); a scale version belongs with the Electron journey proposed in
amd#7343.

Stacked on amd#7331 (it uses that PR's `tests/fixtures/fake_lemonade.py`);
the commits before "test: run GAIA at a real user's size ..." are that
PR.

## Test plan

- [ ] The new **Scale Run** workflow on this PR passes (4 passed)
- [ ] Locally: `GAIA_SCALE_FILES=8 python -m pytest
tests/integration/test_scale_run.py -q` passes
- [ ] Runs on every `v*` tag (each RC and final) and on PRs that touch
the test, its fixture or the workflow

<details>
<summary>🔍 Technical details</summary>

- The folder is indexed once per run through `POST
/api/documents/index-folder` with the real RAG code; the embedder's load
and unload requests are read from the fake server's log.
- The time budget (240 s) sits in the same expected-failure test as the
load count, since the reloads are what make it slow.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
kovtcharov-amd added a commit to kovtcharov/gaia that referenced this pull request Nov 12, 2026
…d#7342)

rc18 shipped four CLI bugs that one table could have caught: `gaia
download --list` exited 0 with the model server down and listed every
model as "not downloaded", `gaia prompt` printed its answer twice, and
`gaia talk --index` and `gaia api start` sent requests to the default
server instead of the one `--base-url` named. This adds that table. It
reads every command from the CLI's own parser and runs each one for
real, so a command or a `--base-url` flag added tomorrow is covered with
no edit.

What every command is held to:

- **No traceback**, for all commands the parser registers, run with the
model server down.
- For every command that takes `--base-url`, plus a short list of flag
variants the walk cannot reach (`download --list`, `prompt`, `llm`,
`-p`):
- with `--base-url X`, **every request goes to X** and none to the
server the environment names;
  - the model's **answer is printed once**;
- with the server down, a command that uses it **exits non-zero and says
why**.

**What its first run found** (155 cases, under three minutes in the new
workflow):

| Command | What happens | Issue |
|---|---|---|
| `gaia api start`, model server down | prints the error, exits 0 |
**new: amd#7344** |
| `gaia chat --base-url X`, `gaia -p ... --base-url X` | embedder,
health and hardware calls still go to the default server | **new:
amd#7345** |
| `schedule show / remove / pause / resume / run <unknown>` | traceback
| amd#7333 |
| `connectors connect <unknown>` | traceback | amd#7334 |
| `mcp engineering`, `mcp code-index` | refusal shown as a traceback |
amd#7335 |
| `gateway auth` with no terminal | traceback | amd#7336 |

All twelve are strict expected failures naming the issue, so each fix
has to delete its line.

Stacked on amd#7331 (it uses that PR's `tests/fixtures/fake_lemonade.py`);
the commits before "test(cli): ..." are that PR.

## Test plan

- [ ] The new **CLI Contract** workflow on this PR passes
- [ ] `python -m pytest tests/integration/test_cli_contract.py -k
"download or prompt" -q` passes locally
- [ ] Delete a `KNOWN_BUGS` line and the workflow fails with that
command's own output in the message

<details>
<summary>🔍 Technical details</summary>

- Each command runs as `python -m gaia.cli ...` in a throwaway home with
stdin closed and a 25 s limit; one still running then (a server, a
prompt) is ended with its children. A daemon a command starts in that
home is stopped after the run.
- Nine command groups are never started (`kill`, `uninstall`, `init`,
`daemon`, `lemonade embedded`, `eval`, `test`, `telegram`, `slack`),
each with the reason in `NEVER_STARTED`; a test fails if that table
names a command that no longer exists.
- `gaia gateway install` is outside the `--base-url` rule: its flag is
the gateway's address, not the model server's.
- It has its own workflow instead of joining the unit job: about 150
subprocess runs, on Linux only, and only when `src/gaia` changes.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

devops DevOps/infrastructure changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants