Skip to content

fix(storage): factory-reset must not uninstall the CLI or erase the local Convex DB - #87

Merged
Bhasvanth-Dev9380 merged 1 commit into
mainfrom
fix/factory-reset-preserve-runtime
Jul 19, 2026
Merged

fix(storage): factory-reset must not uninstall the CLI or erase the local Convex DB#87
Bhasvanth-Dev9380 merged 1 commit into
mainfrom
fix/factory-reset-preserve-runtime

Conversation

@Bhasvanth-Dev9380

Copy link
Copy Markdown
Contributor

Problem

wipeLocalBrigadeState() did a blunt rm -rf ~/.brigade. But two things live under that dir that must not be destroyed by a state reset:

  • The running install. The no-Node bundled install puts Brigade's own Node runtime and the brigade binary under ~/.brigade/runtime (Unix installer), so "Clear it" / "Start fresh" / store reset --purge-local deleted the interpreter that was runningbrigade/node/npm become command not found in every new shell.
  • The local Convex DB. A global install keeps the self-hosted backend's database at ~/.brigade/convex/data. The same wipe was silent, irreversible data loss — and on Windows an EPERM crash mid-wipe while the backend held its sqlite open.

Fix

  • wipeLocalBrigadeState now clears state contents while preserving, name-agnostically, whatever top-level entry holds the running node (process.execPath) or the installed package — so it holds whether the installer named the dir runtime (Unix) or node (Windows), and is a no-op when the runtime lives outside the state dir. Plus the local convex/ store.
  • store reset --purge-local routed through the same primitive (it had its own raw rm -rf).
  • onboard stops a running gateway before the wizard wipes — honoring the factory-reset "gateway must be stopped first" contract (a live daemon's open handles otherwise EPERM-abort the wizard on Windows).

Tests

  • factory-reset.test.ts: replaced the old "removes the entire dir" assertion (which pinned the bug); added runtime-preservation, convex-preservation, and name-agnostic detection tests — including the Windows node-named layout. 12/12 storage tests pass.
  • Typecheck + build clean.

…ocal Convex DB

wipeLocalBrigadeState() did a blunt `rm -rf ~/.brigade`. But a no-Node install
puts Brigade's own Node runtime + the `brigade` binary UNDER ~/.brigade (the Unix
installer -> ~/.brigade/runtime), so "Clear it" / "Start fresh" / `store reset
--purge-local` deleted the running interpreter, leaving `brigade`/`node`/`npm`
"command not found" in every new shell. A global install also keeps the local
Convex database at ~/.brigade/convex/data, so the same wipe was silent,
irreversible data loss -- and on Windows an EPERM crash mid-wipe while the
backend holds its sqlite open.

Clear state CONTENTS while preserving, name-agnostically, whatever entry holds
the running node (process.execPath) or the installed package -- so the guard
holds whether the installer named the dir `runtime` (Unix) or `node` (Windows) --
plus the local `convex/` store. Route `store reset --purge-local` through the
same primitive. Stop a running gateway before the onboard wizard wipes, honoring
the factory-reset "gateway must be stopped first" contract (a live daemon's open
handles otherwise EPERM-abort the wizard on Windows).
@Bhasvanth-Dev9380
Bhasvanth-Dev9380 merged commit 3268e35 into main Jul 19, 2026
10 checks passed
@Bhasvanth-Dev9380
Bhasvanth-Dev9380 deleted the fix/factory-reset-preserve-runtime branch July 19, 2026 21:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant