Repository navigation
fix(uninstall): make --purge remove installer binaries, PATH edits and daemon state - #4320
kovtcharov wants to merge 3 commits into
Conversation
…d daemon state After `gaia uninstall --purge`, gaia-tui and gaia-agent stayed on PATH, every shell rc file kept the installer's PATH block (or the Windows user PATH kept its entries), and ~/.gaia/host kept the daemon's client token and custody store. - Purge now covers ~/.gaia/bin, ~/.gaia/traces and the daemon's host dir. A running daemon is stopped first so it cannot rewrite instance.json; if it won't stop, nothing is deleted. - The custody database goes with host/ on purpose: a full product purge removes all user data. It still survives an agent uninstall. - The "# Added by GAIA installer" block is removed from .zshrc, .bashrc, .bash_profile and .profile, in both the current and the pre-0.23 venv-only shape. The rest of each file stays byte-identical, symlinked rc files are edited in place, and hand-edited exports are left alone with a note. - On Windows, the installer's entries are removed from HKCU\Environment\Path with the value kind kept and other entries (including %VARS%) unexpanded. - A GAIA_HOME or GAIA_DAEMON_HOME outside ~/.gaia leaves the installer edits and daemon state alone rather than widening the deletion roots. Fixes amd#4225, fixes amd#3290
|
Verdict: Approve with suggestions — the logic is careful and unusually well tested for a destructive command, but two things should close before merge: the maintainer decision the author flagged, and the two unchecked test-plan boxes.
What needs a decision: the purge now deletes the daemon's custody database, which holds agent memory, sessions and audit history. The author raised this deliberately and the docs warn about it, but it reverses a stated design intent that audit rows persist, so it needs an explicit yes from a maintainer rather than a silent merge. What's worth changing: if one shell startup file can't be read, the command currently refuses to delete anything at all — the user's actual request (remove my data) is blocked by a side task (tidy up PATH). Failing loudly is right; failing totally is not, especially since the same PR already handles the write-side failure the gentler way. Report the unreadable file, skip it, purge the rest, and still exit non-zero. Before merge: the Windows user-PATH rewrite and the real shell-file removal are the two highest-risk paths in this change and neither has run outside a hand-written stand-in for the Windows registry. Those are exactly the two unchecked boxes in the test plan — worth finishing rather than trusting the fake. Real-world evidenceNo automated evidence bundle was produced for this run, so the verdict rests on static review plus the tests in the diff. The PR's own test plan asserts the dry-run lists the new paths and changes nothing, but the output isn't shown; the two on-machine items (POSIX rc removal after 🔍 Technical detailsIssues🟡 A single unreadable rc file (or registry read) aborts the whole purge (
🟡 The Windows PATH rewrite is only ever exercised against
Nits🟢 The With a custom 🟢 The Windows data-loss comment now documents the wrong call ( The new 🟢
Strengths
|
--purge read every shell rc file at plan time and raised on the first one it could not open, so the command exited before deleting anything. A root-owned or mode-000 ~/.profile therefore kept ~/.gaia/chat, documents and venv on disk -- none of which that file has anything to do with. The user asked to remove their data; tidying up PATH is a side task and must not veto it. The write side already had this right: _edit_rc_file reports the failure, returns False, and execute_plan downgrades the exit code. The read side now matches -- the unreadable file is recorded on the plan, printed as [error], and the run still exits EXIT_FS_ERROR. Same loudness, nothing stranded. UninstallPlanError had no remaining raise site afterwards, so the class, its handler and its docstring clause are gone rather than left as dead plumbing.
|
Fixed the "one unreadable file blocks the whole purge" finding and resynced with main. I am not merging this: after reading the custody-database question closely, I think it genuinely needs a maintainer's yes, and I've set out below exactly what I could and couldn't verify so that decision is a short one. The decision I'm leaving to you
The case for it is strong and I want to say so plainly: What stops me signing it off is the clause right next to it: "audit rows must persist — §0.19". I searched the tree and could not find §0.19 — no spec section, no governance document, nothing that defines what that requirement actually covers. So I can't confirm whether it's scoped to agent uninstall (in which case this PR is fine) or is a broader retention rule that a full purge is also meant to honour. That's not a code-quality judgement I can make from the code; it needs whoever wrote §0.19. Combined with the fact that the deletion is irreversible and lands in a product that ships a governance layer, guessing costs more than asking. Concretely, what would close this: confirm that §0.19's audit-retention requirement is scoped to agent uninstall and does not bind 🔍 Technical detailsWhat I fixed🟡 A single unreadable rc file (or registry read) aborted the whole purge. Both now return their messages instead of raising.
Two tests in What I could not verify — and it's the thing you flagged🟡 The Windows PATH rewrite still has only Worth knowing while you plan that: on Windows, the POSIX rc tests cannot pass at all, so the Windows CI leg gives no signal on them either. Merge and testsMerged
I checked the failures against the branch tip before my change and introduced none — the set is identical. They're all Windows-only artifacts: the POSIX shebang-resolution tests,
Nits from the review, not addressedLeft alone deliberately to keep the diff on the blocking issue: the |
|
Landed on The custody-database question you escalated is answered, and it went your way. §0.19 does exist — it is Safe to close this one. 🔍 What changed on the way in
Still unverified, and left unchecked rather than ticked: the Windows |
…emon state (amd#4413) `gaia uninstall --purge` used to leave the machine half-uninstalled: `gaia-tui` and `gaia-agent` stayed on PATH, the installer's `export PATH` block stayed in every shell rc file, and `~/.gaia/host` kept the daemon's client token and custody store. The purge now stops the daemon first, then deletes `~/.gaia/bin`, `~/.gaia/traces` and the daemon state, and removes exactly the installer's rc block (or its Windows PATH entries) while leaving every other line byte-identical. A shell rc file it cannot read is reported and skipped rather than aborting the whole purge, so tidying up PATH can no longer strand the user data the command was asked to delete. This replaces amd#4320 — same work, rebuilt on current `main` with the maintainer's open question answered and the three review nits folded in. Please close amd#4320 in favour of this. **The custody-database question is answered: §0.19 does not bind `gaia uninstall --purge`.** The clause Kalin could not locate is in `docs/plans/agent-ui-agent-capabilities-plan.md`, §0.19 "Audit trail — a host-custody sink, not agent-private" (lines 606-616). Its subject is agent-*private* storage, and the uninstall it names is the *agent* uninstall — §0.20 "Uninstall — data lifecycle" opens "§0.5 uninstall stops the sidecar + removes the binary". §0.19 argues the audit sink must move to host custody so an agent uninstall cannot erase it; it says nothing about the whole-product purge, which already deletes chat history and documents. Verbatim: > and email's action log is agent-*private* (§0.9) so the dashboard can't read > it and uninstall deletes it. **Every consequential action** ... must be appended to a **host-owned audit > log** via `POST /host/v1/audit` <details> <summary>🔍 Technical details</summary> **Nits folded in** (all three the author listed as deferred): - The "daemon state is outside the GAIA home" note named `GAIA_DAEMON_HOME` unconditionally. Two other paths reach that branch with it unset — a custom `GAIA_HOME`, and a symlinked `~/.gaia/host` with neither variable exported. It now names a variable only when one is set. A new test pins all three readings and fails on the old wording. - The `gaia.log` file-handler comment had a later `_stop_daemon` call inserted between it and the call it describes; moved back. - `~/.gaia/traces/` added to the install guide's "Where things live" table. **Lint:** `black` failed on `main`'s CI for this branch's predecessor — `rc.write_text("export PATH=\"...\"")` at `tests/unit/installer/test_uninstall_command.py` wants single outer quotes. Fixed; `black` and `isort` are clean here. **Ancestry** — every commit from amd#4320 is an ancestor of this branch, brought in by merge so authorship is preserved: ``` $ for c in d4c253c 3cb3000 9c5ba1e; do git merge-base --is-ancestor $c HEAD && echo "$c ANCESTOR"; done d4c253c ANCESTOR 3cb3000 ANCESTOR 9c5ba1e ANCESTOR ``` </details> ## Test plan - [x] `pytest tests/unit/installer/` → **205 passed, 6 skipped** - [x] `.venv/bin/python util/lint.py --black --isort` → both PASS - [x] Real purge against a populated, fully isolated `HOME` — removes `bin`, `traces`, `host` (custody.db + WAL + shm + token), edits `.bashrc`/`.profile` byte-exactly, leaves unrelated files unchanged by md5 (transcript below) - [x] 5 adversarial containment cases — symlinked `traces/`, symlinked `host/`, `GAIA_HOME` escaping via `../../`, `GAIA_HOME=$HOME`, `GAIA_DAEMON_HOME` outside. The out-of-`HOME` tree is byte-identical afterwards (transcript below) - [x] `tests/unit/` full suite: 32 failed / 17721 passed on this branch vs 31 failed / 17705 passed on a clean checkout of `main` at 143c697. The single extra is `test_chat_completion_stream::test_client_disconnect_cancels_the_agent`, which is order-dependent — it fails on plain `main` too when that file is run alone, and an unrelated PR (amd#4414) hits it in CI on the same `main` - [ ] **On Windows after `install.ps1`: the user PATH loses only `~\.gaia\venv\Scripts` and `~\.gaia\bin`.** Not verified — needs a throwaway Windows machine. The registry path has only `_FakeWinreg` behind it; nobody has run it against real `winreg`. Fixes amd#4225, fixes amd#3290 --------- Co-authored-by: Kalin Ovtcharov <[email protected]> Co-authored-by: Kalin Ovtcharov <[email protected]>
Before this change,
gaia uninstall --purgeleftgaia-tuiandgaia-agenton PATH. The installer's PATH block also stayed in every shell rc file (or its entries stayed on the Windows user PATH), and~/.gaia/hostkept the daemon's client token and custody store. Now the purge stops the daemon, then deletes~/.gaia/bin,~/.gaia/tracesand the daemon state. It also removes exactly the installer's rc block or PATH entries and leaves every other line and entry as it was.One decision a reviewer should confirm: the custody database (agent memory, sessions, audit history) is now deleted with
host/. It still survives an agent uninstall, which is the case its docstring was written for. A full product purge already deletes chat history, so keeping this store seemed inconsistent. The CLI reference warns about it, and the reasoning is in the docstring.🔍 Technical details
export PATH="$PATH:…"line whose entries are all~/.gaia/venv/bin/~/.gaia/bin. That covers the current shape and the pre-0.23 venv-only shape across.zshrc,.bashrc,.bash_profileand.profile. It also drops the blank line the installer wrote before the marker. Hand-edited exports are kept and reported. Symlinked rc files are edited through the link.HKCU\Environment\Paththroughwinreg, which does not expand values. The value kind is kept and the change is broadcast withWM_SETTINGCHANGE.installer/nsis/gaia-path.ps1isn't in the wheel, so it can't be called at runtime. This applies the same rules as that script.GAIA_HOMEother than~/.gaiaskips the rc/PATH cleanup, because those edits still point at~/.gaia. AGAIA_DAEMON_HOMEoutside the GAIA home is skipped with a note, so the containment roots are not widened.GAIA_HOME/GAIA_DAEMON_HOME. Before, 18 existing tests failed whenever those were exported, and the isolation rule for test runs requires exporting them.TestPurgeRemoval::test_refuses_to_purge_a_live_embedded_instancealso fails on unmodifiedmainlocally. This change doesn't touch it.Test plan
main(13 of 14; theGAIA_HOMEguard test passes on both) and pass here:pytest tests/unit/installer/test_uninstall_command.py -q, run withGAIA_HOME/GAIA_DAEMON_HOMEset to temp dirspytest tests/unit/installer/ tests/unit/test_lemonade_macos_uninstall.py tests/unit/test_amd_gaia_urls.py tests/unit/test_daemon.py tests/unit/test_daemon_client.py -q: all pass except the embedded-instance test above, which also fails onmaingaia uninstall --purge --dry-runlists~/.gaia/bin,~/.gaia/tracesand~/.gaia/hostand changes nothinginstall.sh:gaia uninstall --purge --yesremoves the rc block, and a new shell no longer findsgaia-tuiinstall.ps1: the user PATH loses only~\.gaia\venv\Scriptsand~\.gaia\binFixes #4225, fixes #3290