Remove Guard and make Desktop updates atomic / 移除 Guard 并实现桌面端原子更新
Summary
This PR removes Guard and product Safe Mode from the normal Reasonix Desktop lifecycle, fixes the Windows shutdown crash caused by native window queries during teardown, and replaces flat in-place updates with an atomic versioned install layout.
- Stop querying Wails window geometry during
beforeClose/shutdown; persist only validated frontend-reported last-known state. - Remove Guard crash-loop and Safe Mode product behavior.
REASONIX_SAFE_MODEno longer changes Desktop or CLI behavior. - Add a permanent thin launcher,
current.jsonversion pointer, isolated staging, version retention, and a one-shot legacy migrator. - Keep the compatibility filename
reasonix-guard(.exe)only inside old-client payloads; it now contains the one-shot migrator, not the former Guard product. - Make Windows and Linux v1.20+ updates publish a complete version and swap
current.jsonlast without legacy health probation. - Add in-memory LKG/default recovery for damaged user configuration and isolate project/plugin/provider configuration failures.
- Replace split Wails update operations with one
ApplyUpdateRequestflow and one frontend "Update and restart" action.
User-visible result
The default path is zero-configuration: install or update, restart once, and continue normally. Users are no longer asked to understand Safe Mode, Guard, crash counters, pending health checks, or manual marker cleanup.
| User path | Behavior |
|---|---|
| Fresh v1.20 install | Starts through the permanent launcher with a versioned layout; Guard is not installed. |
| Upgrade from v1.18.0, v1.19.0, or v1.19.1 | The old updater can consume the compatibility payload; the one-shot migrator commits the exact legacy transaction, creates the versioned layout, starts the launcher, and removes itself. |
| Existing user blocked by an older pending transaction | A normal signed recovery installer starts v1.20; after the UI becomes ready, Reasonix archives only a strictly older install-local transaction for diagnostics. |
| Later Windows/Linux updates | Download, verify, stage, atomically activate, and relaunch without creating a Guard health transaction. |
| Damaged user/project configuration | The original file is preserved; Reasonix uses LKG or defaults in memory and presents a non-blocking actionable warning. |
Backward compatibility audit
| Contract / data | Old-data behavior | Conclusion |
|---|---|---|
Flat install without current.json |
Launcher permits the legacy sibling only when the pointer is genuinely absent; compatibility migrator upgrades the complete release unit. | Compatible migration path. |
Present but invalid current.json |
Launcher and migrator fail closed instead of overwriting the pointer or running a stale flat executable. | Safe failure; preserves evidence. |
Legacy pending-update.json |
Exact matching transactions are finalized during migration. Recovery installs archive only strictly older transactions whose every target remains inside the detected install root. | No blind delete; foreign/equal/newer transactions are rejected. |
| Existing user/project TOML | No persisted schema change. A complete disposable decode must succeed before values merge into the active configuration. | Existing valid files are unchanged; partial mutation on invalid files is removed. |
UpdateProgress.phase |
Adds relaunching; frontend and browser bridge accept it. Older stored data is unaffected because progress events are ephemeral. |
Backward-safe Wails event extension. |
reasonix-guard(.exe) payload member |
Old helpers still find the expected filename, but the binary performs one migration only and is not persisted by normal installs. | Wire-compatible bridge to the Guard-free product. |
Atomicity and concurrency
ActivateVersionuses a bounded cross-process file lock.- Version members and stable root entries are staged and validated before publication.
- Existing same-version and root entries are backed up and restored if publication or pointer commit fails.
current.jsonis the final commit point.- A single update request owner covers download, verification, installation, and relaunch, closing the previous phase gap.
- Frontend request/channel/version correlation continues to reject stale progress completions.
No confirmed data race remains in the changed paths. Windows installer UI behavior and multi-process activation were validated deterministically where portable; real signed-installer timing remains a release gate below.
Verification
go test ./...cd desktop && go test ./...- Targeted
go test -racefor config, install layout, repair, CLI, launcher, migrator, and updater paths go vet ./...in both Go modulespnpm test:updater— 31 passedpnpm build— TypeScript, Vite production build, CSS checks, and bundle budgets passed- Cache guard and cache-impact checks passed
- Windows amd64 Desktop/update-helper test binaries cross-compiled successfully
- Linux amd64 launcher/migrator/update-helper binaries cross-compiled successfully
- Windows portable, NSIS, Linux desktop/deb, and macOS no-Guard packaging contracts passed
Integration note
PR #7192 overlaps this PR in configuration recovery, updater coordination, frontend bindings, and the former Guard path. A merge-tree check currently reports conflicts in desktop/frontend/src/App.tsx, desktop/frontend/src/lib/types.ts, desktop/main.go, desktop/updater_app.go, plus a modify/delete conflict for the removed Guard source.
Recommended order: finish #7192 first, then rebase this PR onto the resulting main-v2. Preserve #7192's independent session/configuration fixes, while resolving Guard/update conflicts in favor of this PR's versioned, Guard-free architecture.
Remaining release gates
- Real signed upgrade matrix from v1.18.0, v1.19.0, and v1.19.1 on Windows
- Windows multi-DPI repeated start/exit soak and Authenticode/NSIS end-to-end validation
- Linux deb Polkit cancellation/retry on a real package install
- macOS notarization, Dock, and bundle launch validation
- Preview observation and production migration telemetry gates
Cache review
Cache-impact: none - Safe Mode removal changes runtime recovery/config gating only; provider-visible prompt, tool schemas/order, provider request serialization, memory prefix, and compaction are unchanged.
Cache-guard: ./scripts/cache-guard.sh passed locally; ./scripts/check-cache-impact.sh passes with these explicit review fields.
System-prompt-review: Reviewed against the PR diff; no provider-visible system prompt bytes or assembly path are changed.