feat(symlinks): add shared-state symlink manager (A1)

Adds internal/symlinks package that encodes in code the convention
previously maintained by hand on the VM: every Claude account home
must expose `session-env`, `file-history` and `projects` as symlinks
to a single shared target, so account failover does not create
divergent state (duplicate JSONL transcripts, broken undo history).

- EnsureForAccount(home, required) creates missing links and target
  directories, refuses to auto-correct a divergent link (risks data
  loss), and errors when a regular file sits where the link belongs.
- ValidateAll(homes, required) aggregates errors across both accounts
  so the operator sees every problem at once rather than fixing one
  per restart cycle.
- RequiredShared exposes the production defaults so lifecycle and
  switcher (A2/A3) can depend on it directly.

9/9 unit tests green.

Part of Phase 1 Chantier A — Failover robuste.
This commit is contained in:
Ubuntu 2026-04-16 18:55:32 +00:00
parent 4cbdcf143a
commit 91091d7abf
4 changed files with 414 additions and 4 deletions

View file

@ -1,13 +1,26 @@
# Travaux en Cours - claude-failover
## Dernière mise à jour
2026-04-15 19:30:00
2026-04-16 19:00:00
## Version Actuelle
0.3.0
0.3.5 (en cours de progression vers 0.4.0)
## Demande Actuelle
Aucune — v0.2.3 shippée, service stable.
**Phase 1 / Chantier A — Failover robuste** (spec dans `ccl-platform/phases/phase1/A-failover.md`).
Rendre le failover compte1 ↔ compte2 déterministe en intégrant dans le code les fixes manuels
(symlinks partagés), en ajoutant un registre UUID fiable, et en durcissant tmux send-keys.
Branche : `feat/phase1-A-failover-robust`.
## Sous-tâches Chantier A
- [x] A1 — `internal/symlinks/shared.go` (+ tests) — v0.3.5
- [ ] A2 — `lifecycle/manager.go` : `ValidateAll` au startup
- [ ] A3 — `switcher/account_switcher.go` : `EnsureForAccount` post-flip
- [ ] A4 — `internal/registry/uuid_registry.go` (+ tests)
- [ ] A5 — `internal/tmux/send.go` avec retry exponentiel (+ tests)
- [ ] A6 — Capture UUID 200 → 500 lignes
- [ ] A7 — `scripts/test-failover.sh` dans ccl-platform + scripts associés
## Étapes Complétées
- [x] v0.2.1 — Cooldown post-swap + log forensique (trigger_session, pattern, snippet)