fix(install): preserve user fleet data on re-seed + refresh active units (#631)
CRITICAL data-loss in the routine update path. `mosaic update` auto-runs install.sh keep-mode sync (#610); the rsync --delete honored PRESERVE_PATHS but fleet/ was not listed, so the sync WIPED ~/.config/mosaic/fleet/roster.yaml (and fleet/run, fleet/agents). Any user running `mosaic update` lost their fleet. PRIMARY (data-loss): - install.sh PRESERVE_PATHS += fleet/*.yaml, fleet/agents, fleet/run. The framework still SEEDS fleet/examples + fleet/roles + fleet/roster.schema.json (synced); the operator's roster, custom rosters, per-agent env, and heartbeat run dir are preserved. - Made the cp (no-rsync) fallback GLOB-AWARE so fleet/*.yaml is preserved there too; fixed the restore to re-glob per pattern (restores only the user file, not the freshly-synced fleet/ dir). - file-adapter.ts (TS installer): mirrored the preserve list for dual-installer parity. (syncDirectory is copy-only — never --delete — so it never had the bug; this is parity + belt-and-suspenders.) SECONDARY (stale active units): - refreshActiveFleetUnits(): the re-seed updates ~/.config/mosaic/systemd/user but systemd runs ~/.config/systemd/user, so shipped unit fixes (#627) did not take effect after update. `mosaic update` now copies the fresh mosaic-*.service → the active dir + daemon-reload (best-effort, only when a fleet is installed). Verified: bash F6 fixture (roster/custom-yaml/agents/run survive + examples refreshed + schema seeded), 20/20 migration matrix; TS file-adapter keep-mode test; 2 refreshActiveFleetUnits unit tests. tsc/eslint/prettier/sanitize clean. Refs #631 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EsgTQzV5YUGk1JtCLP4B83
This commit is contained in:
@@ -82,3 +82,7 @@ Active workstream is **W1 — Federation v1**. Workers should:
|
||||
## north-star doctrine consolidation — doc PR — feat/north-star-doctrine
|
||||
|
||||
- Status: applied Mos's consolidated merge-map to docs/fleet/north-star.md (budget governance + control plane/central register + 200k cap + delegation + unified-identity Fleet + role-based naming + tmux security + drift re-captures). Doctrine only; #622/#623/#625/#628 out-of-scope. Conflict checklist green. Detail: scratchpads/north-star-doctrine.md.
|
||||
|
||||
## #631 — re-seed preserves user fleet data (CRITICAL) — fix/631-reseed-preserves-fleet-data
|
||||
|
||||
- Status: implemented + tested. PRIMARY: install.sh PRESERVE_PATHS += fleet/\*.yaml + fleet/agents + fleet/run (glob-aware cp-fallback); TS parity. SECONDARY: refreshActiveFleetUnits propagates unit fixes to ~/.config/systemd/user on mosaic update. bash F6 + TS + unit tests green. Detail: scratchpads/631-reseed-preserves-fleet.md.
|
||||
|
||||
32
docs/scratchpads/631-reseed-preserves-fleet.md
Normal file
32
docs/scratchpads/631-reseed-preserves-fleet.md
Normal file
@@ -0,0 +1,32 @@
|
||||
# #631 — re-seed must preserve user fleet data (CRITICAL data-loss)
|
||||
|
||||
- **Issue:** #631 · **Branch:** `fix/631-reseed-preserves-fleet-data`
|
||||
|
||||
## Root cause
|
||||
|
||||
`mosaic update` auto-runs `install.sh` keep-mode sync (#610). install.sh's rsync `--delete` (keep mode)
|
||||
honored PRESERVE_PATHS, but `fleet/` wasn't listed → the sync WIPED `~/.config/mosaic/fleet/roster.yaml`
|
||||
(+ run/, agents/). Any user running `mosaic update` lost their roster. (overwrite mode wipes by design;
|
||||
the live loss was keep mode.)
|
||||
|
||||
## Fix (PRIMARY)
|
||||
|
||||
- install.sh PRESERVE_PATHS += `fleet/*.yaml`, `fleet/agents`, `fleet/run` — the framework still SEEDS
|
||||
fleet/examples + fleet/roles + fleet/roster.schema.json (synced), but user files survive.
|
||||
- Made the cp-fallback (no-rsync) GLOB-AWARE so `fleet/*.yaml` preserves every user roster there too;
|
||||
fixed the restore to re-glob per-pattern (so only the user file is restored, not the whole fleet/ dir).
|
||||
- file-adapter.ts (TS installer): mirrored the preserve list for parity. (TS syncDirectory is copy-only,
|
||||
never --delete, so it never had the bug — belt-and-suspenders + parity.)
|
||||
|
||||
## Fix (SECONDARY)
|
||||
|
||||
- `refreshActiveFleetUnits()` (update-checker.ts): the re-seed updates ~/.config/mosaic/systemd/user but
|
||||
systemd runs ~/.config/systemd/user, so unit fixes (#627) didn't take effect. After the re-seed,
|
||||
`mosaic update` now copies the fresh mosaic-\*.service → the active dir + daemon-reload (best-effort,
|
||||
only when a fleet is already installed). Wired into the cli.ts update flow.
|
||||
|
||||
## Verification
|
||||
|
||||
- bash F6 fixture (6 checks: roster/custom-yaml/agents/run survive + examples refreshed + schema seeded);
|
||||
20/20 migration matrix green. TS file-adapter test (roster/run/agents survive keep sync). 2 unit tests
|
||||
for refreshActiveFleetUnits. tsc/eslint/prettier/sanitize clean.
|
||||
Reference in New Issue
Block a user