Skip to content

fix(setup): plan against the server setup will use; plain error when Lemonade isn't answering - #5542

Merged
kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:kalin/setup-plan-real-server
Oct 23, 2026
Merged

kovtcharov-amd merged 6 commits into
amd:mainfrom
kovtcharov:kalin/setup-plan-real-server

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

First-run setup said the models were "already downloaded" whenever another Lemonade happened to run on the default port, and choosing "Use GAIA's own" changed nothing on screen before downloading both anyway. A Lemonade that wasn't answering showed a raw HTTPConnectionPool exception. Now the plan reflects the server setup will really use, the download step shows progress and size, and an unreachable server gets a plain message with a working way out. The unit suite also stops writing into the developer's real ~/.gaia.

Setup plan against the server it will use
GAIA's own server chosen: the plan shows the real downloads
Setup finished

Test plan

  • Full pytest tests/unit: 27235 passed; the 27 failures also fail on clean main except test_windows_system32_is_blocked, which passes alone and in three parallel reruns (order-dependent)
  • npx vitest run in src/gaia/apps/webui: 1532 passed
  • Live, fresh profile with a user Lemonade on the default port: the plan offers "Use mine" / "Use GAIA's own", and choosing GAIA's own re-plans to show what it will download
  • Unit: an unreachable server gives the plain "isn't answering" message, the start hint and "Use GAIA's own instead"; with LEMONADE_BASE_URL set it says to unset it
  • tests/unit/test_gaia_home_isolation.py fails if a unit test resolves GAIA's home to the real ~/.gaia
🔍 Technical details
  • The plan asks the user's server only when they chose it, GAIA's own only while it runs, and otherwise reads sizes from the registry.
  • The start hint comes from describe_start_hint(); when LEMONADE_BASE_URL picks the server it says to unset it, since it outranks any saved choice.
  • Test isolation: GAIA's home falls back to a per-session tmp dir (not GAIA_HOME suite-wide, which would outrank tests' own Path.home patches); GAIA_LOG_FILE moves the log; goals.db and the RAG HMAC key now follow gaia_home().

A fresh setup said the chat and embedding models were "already downloaded"
whenever another Lemonade ran on the default port, because the plan asked
that server, not GAIA's own; choosing "Use GAIA's own" then changed nothing
on screen and the run downloaded both. The plan now asks the user's server
only when they chose it, GAIA's own only while it runs, and otherwise reads
sizes from the registry, so re-planning after the choice shows the truth.

- A failed or stopped run no longer hides "Choose where GAIA runs", so a
  Lemonade already running is still offered on the next launch.
- The download step shows its percentage and size, e.g. "45% · 1.20 GB of
  2.50 GB".
First-run setup against an unreachable Lemonade showed the raw
HTTPConnectionPool exception and offered only "Try again" or the same
failing command for a terminal. It now says "Your Lemonade Server at
127.0.0.1:9 isn't answering.", says how to start it (from
describe_start_hint, never a hard-coded command), and offers "Use GAIA's
own instead", which re-runs setup with --gaia-lemonade. When
LEMONADE_BASE_URL picks the server it says to unset it instead, since the
variable outranks any saved choice. The raw error stays under Details.

- The Chat model step is no longer checked off when setup never picked a
  model.
- A retry after a failed switch keeps switching, and a failure of GAIA's
  own server is reported as itself, not as the user's server being down.
Running the unit suite wrote edit backups, the file audit log, goals.db,
the RAG HMAC key, scratch databases and log lines into the developer's own
~/.gaia. Tests now resolve GAIA's home to a per-session tmp dir unless they
set GAIA_HOME, GAIA_CONFIG_DIR or a home of their own, and the log goes to
the session's tmp dir through a new GAIA_LOG_FILE override.

- GAIA_HOME is not set suite-wide: it outranks the Path.home patches and
  GAIA_CONFIG_DIR that many tests rely on. Only the ~/.gaia fallback moves.
- goals.db and the RAG HMAC key now follow gaia_home(), so GAIA_HOME moves
  them too; the hard-coded-path allowlist drops both.
- The refusal-exit-code test forwards GAIA_LOG_FILE to its hand-built child
  environment.
@github-actions github-actions Bot added documentation Documentation changes rag RAG system changes tests Test changes performance Performance-critical changes agents labels Oct 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

First-run setup now plans its downloads against the server it will actually use. Before, another Lemonade on the default port could make setup say "already downloaded". When the user's own server isn't answering, setup now shows a plain message with a way to start it and a one-click switch to GAIA's own. Unit tests also stop writing into the developer's real ~/.gaia. The logic is sound and well tested. Nothing blocks the merge; there are two small hardening suggestions below.

Real-world evidence

N/A: no evidence bundle was produced for this run. The PR description embeds three Agent UI screenshots: the plan against the chosen server, the plan after switching to GAIA's own, and setup finished. These cover the main flow. The new "server isn't answering" screen has unit and Vitest coverage only. Beyond those screenshots, this verdict rests on static review.

🔍 Technical details

Issues found

🟢 A crash in the failure probe would leave setup stuck on "running" (src/gaia/ui/setup_runner.py, the watcher's server_problem() call)
server_problem() runs on the watcher thread before the state lock. choice.probe never raises, and LemonadeChoiceError/GaiaConfigError are caught. But resolve_lemonade() / describe_start_hint() inside _start_hint aren't guarded. If either raises (for example an OSError while scanning install paths), the thread dies and the UI polls a running state forever. Consider catching OSError around _start_hint and logging it, so the run still ends failed with the raw error line.

🟢 A wildcard bind address gets the "remote computer" hint (src/gaia/ui/setup_runner.py:734)
LEMONADE_BASE_URL=http://0.0.0.0:13305 would produce "Start it on the computer at 0.0.0.0". That address is a local bind, so the local start hint fits better.

_LOOPBACK_HOSTS = ("localhost", "127.0.0.1", "::1", "0.0.0.0")

Strengths

  • The plan no longer asks the default port when GAIA's own server isn't running (url: None plus the _NoServer stand-in). This removes the false "already downloaded" at its source, and test_gaias_own_not_running_never_asks_the_default_port pins it.
  • The start hint goes through describe_start_hint(), and LEMONADE_BASE_URL is handled correctly. The switch is refused (409) and the UI shows what to unset instead of a button that would do nothing. A test also asserts lemonade-server serve never appears.
  • Test isolation only moves the ~/.gaia fallback, so GAIA_HOME and Path.home patches still win. The new test_gaia_home_isolation.py guards it, and two hardcoded Path.home() / ".gaia" uses were removed from the allowlist along the way.

…he start hint fails

A Lemonade bound to 0.0.0.0 or :: is on this PC, so it gets the local start hint instead of 'start it on the computer at 0.0.0.0'. If working out the start hint raises an OSError, setup still reports that the user's server isn't answering and logs why the hint is missing.
@kovtcharov

Copy link
Copy Markdown
Contributor Author

Both suggestions are in, and CI is green. A Lemonade bound to 0.0.0.0 or :: now gets this PC's start hint. If the start hint can't be worked out, setup still says the user's server isn't answering. The three red checks before came from a Launchpad outage and from timing-sensitive tests. None of them involved this change.

  • Probe crash: the bot was partly right. It said the run would stay "running", but _watch already catches the error and fails the run. What it lost was the plain "isn't answering" message. An OSError while building the start hint is now logged and leaves only the hint empty.
🔍 Technical details
  • _LOCAL_HOSTS adds 0.0.0.0 and ::. server_problem wraps _start_hint in except OSError and logs a warning. New tests: test_a_wildcard_bind_address_is_this_pc (both addresses) and test_a_start_hint_that_cannot_be_worked_out_still_names_the_problem.
  • Earlier failures:
    • Linux Full Integration: ppa.launchpadcontent.net returned 503 for the lemonade-team PPA, so apt couldn't see lemonade-server.
    • macOS: test_file_lock::test_the_next_waiter_takes_the_lock_within_milliseconds. It fails the same way on at least five other branches this week.
    • Linux: four test_stdio_hung_server process-reaping tests on a single xdist worker. They pass locally (225/225), and this PR touches nothing in the MCP client.
  • All of these passed on the rerun this push triggered.
  • Local: the setup runner, setup plan and home-isolation tests give 105 passed. tests/unit -k "shell or permission or confirm or setup or empty_answer" gives 2497 passed, with 3 shell tests that fail on this Windows box on main as well. Black and isort are clean.

@kovtcharov-amd
kovtcharov-amd added this pull request to the merge queue Oct 23, 2026
Merged via the queue into amd:main with commit 200b092 Oct 23, 2026
54 of 57 checks passed
@kovtcharov-amd
kovtcharov-amd deleted the kalin/setup-plan-real-server branch October 23, 2026 11:49
kovtcharov pushed a commit to kovtcharov/gaia that referenced this pull request Oct 23, 2026
Brings in amd#5542, amd#5598 and amd#5633 alongside the installer that downloads no
model and the setup screen that names and downloads the model that fits.

Kept from this branch: the installer never runs `gaia init`, so main.cjs no
longer asks the install-time Lemonade question and backend-installer keeps
no init record; the setup screen starts the server first (`server_only`),
pins the planned model (`--chat-model`), reads `--progress-json` progress,
and shows the memory and disk warnings.

Kept from main: the plan asks the server setup will use and an unanswering
Lemonade gets plain words with "Use GAIA's own instead" (amd#5542), now passed
through every run shape as a fourth `gaia_lemonade` flag; the greyed AMD
gateway, its re-check button and the disabled start button (amd#5633); and the
new-chat "setup didn't finish" notice (amd#5598).

That notice read the installer's failed-init record, which no longer exists.
Its source is now the setup screen's own last failed run, kept in
~/.gaia/chat/setup-error and cleared by a run that succeeds, so a run whose
models download but fail to load still warns before the first message. The
installer test for recording init's failure and the source test for the
removed Lemonade dialog are dropped with the code they covered. API types are
regenerated from the merged models.
kovtcharov-amd added a commit to tylerbea/gaia that referenced this pull request Oct 30, 2026
…reach (amd#5653)

Of the last 150 bug fixes, 147 shipped a regression test, yet CI caught
only about 7 of those bugs before users or RC testing did. Each test
guards the one call site that broke, and the next site with the same
flaw ships untested. Meanwhile every PR ran all ~27k unit tests on three
operating systems, even for a docs edit, and most main-branch runs were
cancelled before they finished. This PR guards the recurring bug shapes
everywhere, fixes a real bug the new tests found, and makes a PR run
only the tests it can affect.

- **Guards for the shapes behind most recent fixes.** A ratchet counts
subprocess and HTTP calls with no timeout, kill-by-image-name, and
`except Exception` bodies that only pass or return a placeholder.
Existing sites are grandfathered, new ones fail CI, and fixing one
lowers the count.
- **Folder grants were lost when several GAIA processes saved at once.**
A four-process test lost 96–98 of 100: the read-modify-write had no
lock, and a torn read "rebuilt" the file from empty. It is now locked
and atomic. Six runtime calls that could hang forever now time out, with
actionable errors.
- **PRs run only the reachable tests.** `util/select_tests.py` combines
a nightly per-test coverage map with static rules for what coverage
can't see. Windows and macOS run the OS-touching subset of that. The
median PR runs about a quarter of the suite. On ~1,150 recent commits,
it selected every bug fix's own regression test from the fix's source
changes alone.
- **Full coverage moves to main and nightly.** Every push to main runs
the full suite on Linux and now finishes instead of being cancelled. The
nightly run covers all three operating systems and rebuilds the map. The
frozen flagship binary also builds on packaging PRs and weekly, not only
at an RC.
- **Duplicates trimmed.** The email unit lane no longer re-runs ~90
files `test_unit.yml` already covers, and the warning-only C++
benchmarks run on main instead of every PR.

Also unbreaks main's TUI build: amd#5464 documented the desktop app's
`gaia` shim in backticks, and the TUI doc check only exempted it before
a space, so every PR's TUI checks went red. The shim is the Python
CLI's, so the exemption now accepts any punctuation after it.

Trade-offs to know: a Windows- or macOS-only bug outside the OS-touching
subset surfaces at the nightly run, not on the PR, and PRs no longer
upload partial coverage to Codecov. To run the full suite on a branch,
dispatch `test_unit.yml` on it.

## Test plan
- [x] `pytest tests/unit/test_select_tests.py
tests/unit/test_process_safety_ratchet.py
tests/unit/test_allowed_paths_concurrency.py`: 26 + 33 + 1 passed; the
concurrency test fails on the old code (96–98 of 100 grants lost)
- [x] Full `tests/unit` locally: 27,501 passed; 26 failures that fail
identically on main in this environment (PATH-installed `gaia`, real
wheel installs)
- [x] `python util/lint.py --all` passes, including the lane-coverage,
path-coverage, trigger and ancestor-skip checks
- [x] Selector replayed over ~1,150 recent commits with a map built from
a real `--cov-context=test` run
- [ ] After merge: the first nightly run saves `unit-test-map-*`, and
the next PR's "Select unit tests" summary reports a map-based selection

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

- Static rules: module-level imports (transitive); every import and
module-naming string in tests and tooling (transitive); filename strings
and directory scans (one hop); nested `conftest.py`; top-level fixtures
by requested name, through fixture chains; autouse isolation fixtures
(one hop); CLIs run with `python -m`, whose lazy imports coverage can't
see. A package `__init__` reaches everything below it when it changes,
but the walk never continues through one.
- Full-run triggers: any `conftest.py`, packaging or pytest config, the
selector or `test_unit.yml`, and any deleted or renamed file (`git diff
--no-renames`). So does a selection over 70% of the suite.
- With no map (a cache miss), function-level imports are followed too
and the job summary says so; a map over 3 days old raises a warning.
- A push diffs against the last commit a successful main run tested, so
merges whose runs were dropped while pending still reach Windows and
macOS. The event name is in the concurrency group, so a push can't drop
the nightly.
- Known blind spot, documented in `docs/reference/dev.mdx`: code behind
a cache or shared fixture is credited in coverage only to the first test
that ran it.
- Open PRs touching the same files (amd#5453, amd#5417, amd#5511, amd#5600, amd#5475,
amd#5542, amd#5558) test-merge cleanly against this branch; none gains a
conflict from it.
</details>

---------

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

Labels

agents documentation Documentation changes performance Performance-critical changes rag RAG system changes tests Test changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants