refactor: Remove in-memory swarms map, make Manager stateless

The swarm Manager was maintaining an in-memory map of swarms that was
never persisted and duplicated state from beads. This caused stale state
after restarts and confusion about source of truth.

Changes:
- Remove swarms map from Manager (now stateless)
- Add LoadSwarm() that queries beads for swarm state
- Refactor all methods to use LoadSwarm() instead of in-memory lookup
- Discover workers from assigned tasks in beads
- Remove obsolete unit tests that tested in-memory behavior
- Keep type/state tests that do not need beads

The E2E test (gt-kc7yj.4) now covers the beads integration.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Steve Yegge
2025-12-29 17:12:18 -08:00
parent 5fa1772cb0
commit f7393b6cdb
6 changed files with 147 additions and 460 deletions

View File

@@ -658,14 +658,9 @@ func runSwarmLand(cmd *cobra.Command, args []string) error {
// Use swarm manager for the actual landing (git operations)
mgr := swarm.NewManager(foundRig)
sw, err := mgr.Create(swarmID, nil, "main")
sw, err := mgr.LoadSwarm(swarmID)
if err != nil {
return fmt.Errorf("loading swarm for landing: %w", err)
}
// Execute landing to main
if err := mgr.LandToMain(swarmID); err != nil {
return fmt.Errorf("landing swarm: %w", err)
return fmt.Errorf("loading swarm from beads: %w", err)
}
// Execute full landing protocol