feat(pool): add start_index so manual and auto pools can coexist

Production had two disjoint tmux pools named alike but for different
purposes:
  ccl-0..ccl-9           — manual/interactive sessions (operator)
  ccl-auto-11..ccl-auto-20 — autonomous dispatcher pool

Until now the daemon's loops iterated prefix + 0..Max, so with the
deployed config ("prefix: ccl-auto", min=2, max=10) the dispatcher
looked for sessions "ccl-auto0..ccl-auto9" that never existed, while
the real auto pool ccl-auto-11..20 was invisible. Net effect: no task
was ever dispatched, and killAllPoolSessions fabricated phantom
"ccl-auto0/1" sessions on each swap.

- AutonomousConfig gains StartIndex (yaml start_index, default 0).
  Behaviour is unchanged when StartIndex is 0.
- Monitor, switcher (kill + recreate), dispatcher (findFreeSession),
  and lifecycle (EnsureAll + reconcile) all iterate
  [StartIndex, StartIndex+Max) so the daemon only touches its own
  range and leaves ccl-0..ccl-9 alone.
- Production config updated to prefix: "ccl-auto-", start_index: 11,
  min: 10, max: 10 — covering the 10 real ccl-auto-11..20 sessions.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Ubuntu 2026-04-15 20:39:57 +00:00
parent 8fdb1937fc
commit eb6b74c547
6 changed files with 73 additions and 14 deletions

View file

@ -1,4 +1,46 @@
# Version actuelle : 0.3.0
# Version actuelle : 0.3.1
## [0.3.1] - 2026-04-15
**Type:** Patch — `start_index` pour faire coexister pool manuel et pool auto
### Corrigé
- **Bug prod non détecté depuis longtemps** : le pool autonome daemon ignorait
le pool réel et vice-versa. Conséquence : **aucune tâche automatique n'était
dispatchée** (ex. `installer-d2-cli` dans secuaas-hosting/inbox depuis 18:39).
- Cause : le config avait `prefix: "ccl-auto"` (sans tiret), donc les loops
généraient `ccl-auto0..9` alors que `setup-tmux.sh` crée `ccl-auto-11..20`.
Le daemon créait en plus 2 sessions fantômes `ccl-auto0/1` au swap.
### Ajouté
- `config.AutonomousConfig.StartIndex` (YAML `start_index`, défaut 0).
Les loops du daemon (monitor, dispatcher, switcher kill/recreate, lifecycle
ensure/reconcile) itèrent désormais `start..start+Max-1` au lieu de `0..Max-1`.
- Permet au pool autonome `ccl-auto-11..20` de coexister avec le pool manuel
`ccl-0..9` (réservé opérateur). Le daemon ne touche que ce qu'il gère.
### Modifié
- `/etc/claude-failover/config.yaml` :
```yaml
autonomous:
prefix: "ccl-auto-" # + tiret
start_index: 11 # NEW
min: 10
max: 10
```
### Tests effectués
- ✅ `go test ./...` full suite
- ✅ Sessions `ccl-auto0/1` fantômes kill manuellement, pool `ccl-auto-11..20`
intact, pool manuel `ccl-0..9` intact
- ✅ Daemon redémarré, `config loaded: ... pool min=10 max=10`
### Fichiers modifiés
- `internal/config/config.go` — champ `StartIndex`
- `internal/quota/monitor.go` — loop avec StartIndex
- `internal/switcher/account_switcher.go` — kill + recreate avec StartIndex
- `internal/dispatcher/dispatcher.go` — findFreeSession avec StartIndex
- `internal/lifecycle/manager.go` — ensure + reconcile avec StartIndex
- `/etc/claude-failover/config.yaml` — prefix fixé + start_index
## [0.3.0] - 2026-04-15
**Type:** Minor — Auto-resume des sessions dédiées après un swap légitime