xonecas.io
60255
Zn

Zoea-Nova / commit 20887c8

refactor: remove 5 zoea_* tools from MCP interface

Remove zoea_list_myses, zoea_send_message, zoea_broadcast,
zoea_search_broadcasts, and zoea_claim_account from the MCP tool
registry. Myses can no longer manage other myses or broadcast to the
swarm - these capabilities are now TUI-only.

Remaining zoea tools: zoea_search_messages, zoea_search_reasoning

Changes:
- Remove 5 tool registrations from internal/mcp/tools.go (384→165 lines)
- Remove MysisInfo, BroadcastResult, AccountInfo types
- Remove 3 methods from Orchestrator interface
- Remove SearchBroadcasts from store
- Remove zoea_swarm_status from snapshot tool detection
- Update all adapter implementations
- Remove related tests
- Update documentation to reflect 2 remaining tools

xonecas2026-02-09 20887c8ad8774995e4d9be9d3644f2d86193b9eb parent 0c31724

16 files changed

This diff is too big to show in full. The first 1000 lines are below, and every file is listed with its counts.

cmd/zoea/main.go+1−64
@@ -285,19 +285,6 @@ type commanderAdapter struct {
285285 commander *core.Commander
286286 }
287287
288-func (a *commanderAdapter) ListMyses() []mcp.MysisInfo {
289- myses := a.commander.ListMyses()
290- result := make([]mcp.MysisInfo, len(myses))
291- for i, mysis := range myses {
292- result[i] = mcp.MysisInfo{
293- ID: mysis.ID(),
294- Name: mysis.Name(),
295- LastError: mysis.LastError(),
296- }
297- }
298- return result
299-}
300-
301288 func (a *commanderAdapter) MysisCount() int {
302289 return a.commander.MysisCount()
303290 }
@@ -359,34 +346,6 @@ func (a *commanderAdapter) SearchReasoning(mysisID, query string, limit int) ([]
359346 return results, nil
360347 }
361348
362-func (a *commanderAdapter) SearchBroadcasts(query string, limit int) ([]mcp.BroadcastResult, error) {
363- broadcasts, err := a.commander.Store().SearchBroadcasts(query, limit)
364- if err != nil {
365- return nil, err
366- }
367-
368- results := make([]mcp.BroadcastResult, len(broadcasts))
369- for i, b := range broadcasts {
370- results[i] = mcp.BroadcastResult{
371- Content: b.Content,
372- CreatedAt: b.CreatedAt.Format("2006-01-02 15:04:05"),
373- }
374- }
375- return results, nil
376-}
377-
378-func (a *commanderAdapter) ClaimAccount() (mcp.AccountInfo, error) {
379- acc, err := a.commander.Store().ClaimAccount()
380- if err != nil {
381- return mcp.AccountInfo{}, err
382- }
383-
384- return mcp.AccountInfo{
385- Username: acc.Username,
386- Password: acc.Password,
387- }, nil
388-}
389-
390349 // runMCPTest tests the MCP connection and tool calling.
391350 func runMCPTest(configPath string) {
392351 fmt.Println("=== MCP Tool Test ===")
@@ -454,17 +413,7 @@ func runMCPTest(configPath string) {
454413 fmt.Printf("\nTotal: %d tools (%d local, %d upstream)\n", len(tools), localCount, upstreamCount)
455414 }
456415
457- // Test calling a local tool
458- fmt.Println("\n--- Testing Local Tool Call ---")
459- fmt.Println("Calling: zoea_swarm_status")
460- result, err := mcpProxy.CallTool(ctx, mcp.CallerContext{}, "zoea_swarm_status", nil)
461- if err != nil {
462- fmt.Printf("ERROR: %v\n", err)
463- } else if result.IsError {
464- fmt.Printf("TOOL ERROR: %s\n", result.Content[0].Text)
465- } else {
466- fmt.Printf("OK: %s\n", result.Content[0].Text)
467- }
416+ // Test calling a local tool - removed zoea_swarm_status as it has been deleted
468417
469418 // Test calling an upstream tool if available
470419 if mcpProxy.HasUpstream() {
@@ -502,10 +451,6 @@ func runMCPTest(configPath string) {
502451 // mockOrchestrator is a simple orchestrator for testing.
503452 type mockOrchestrator struct{}
504453
505-func (m *mockOrchestrator) ListMyses() []mcp.MysisInfo {
506- return []mcp.MysisInfo{}
507-}
508-
509454 func (m *mockOrchestrator) MysisCount() int {
510455 return 0
511456 }
@@ -542,11 +487,3 @@ func (m *mockOrchestrator) SearchMessages(mysisID, query string, limit int) ([]m
542487 func (m *mockOrchestrator) SearchReasoning(mysisID, query string, limit int) ([]mcp.ReasoningResult, error) {
543488 return []mcp.ReasoningResult{}, nil
544489 }
545-
546-func (m *mockOrchestrator) SearchBroadcasts(query string, limit int) ([]mcp.BroadcastResult, error) {
547- return []mcp.BroadcastResult{}, nil
548-}
549-
550-func (m *mockOrchestrator) ClaimAccount() (mcp.AccountInfo, error) {
551- return mcp.AccountInfo{}, fmt.Errorf("not available in test mode")
552-}
documentation/architecture/CONTEXT_COMPRESSION.md+0−16
@@ -220,19 +220,6 @@ Search a Mysis's past messages by text content.
220220
221221 Returns matching messages with role, source, content, and timestamp.
222222
223-### zoea_search_broadcasts
224-
225-Search past swarm broadcasts by text content.
226-
227-```json
228-{
229- "query": "enemy spotted",
230- "limit": 20
231-}
232-```
233-
234-Returns matching broadcasts with content and timestamp.
235-
236223 ### zoea_search_reasoning
237224
238225 Search a Mysis's past reasoning content by text.
@@ -299,9 +286,6 @@ func (s *Store) GetRecentMemories(mysisID string, limit int) ([]*Memory, error)
299286
300287 // SearchMemories searches memories by content text (case-sensitive).
301288 func (s *Store) SearchMemories(mysisID, query string, limit int) ([]*Memory, error)
302-
303-// SearchBroadcasts searches broadcast messages by content text (case-sensitive).
304-func (s *Store) SearchBroadcasts(query string, limit int) ([]*BroadcastMessage, error)
305289 ```
306290
307291 ## Tradeoffs
documentation/architecture/MESSAGE_FORMAT_GUARANTEES.md+6−5
@@ -52,14 +52,15 @@ When no real user message exists in the database, `getContextMemories()` adds a
5252 ### Real User Messages (Reset Counter)
5353
5454 1. **Commander Broadcast** - User types `b` in TUI and sends message to all myses
55-2. **Mysis Broadcast** - One mysis uses `zoea_broadcast` tool to message swarm
56-3. **Direct Message** - User types `m` in TUI and targets specific mysis
55+2. **Direct Message** - User types `m` in TUI and targets specific mysis
5756
5857 All real user messages:
5958 - Are stored in database with `role=user` and `source=broadcast|direct`
6059 - Reset encouragement counter to 0
6160 - Start idle myses automatically (broadcasts) or via API call (direct)
6261
62+**Note:** Myses cannot broadcast to each other. Only the Commander (via TUI) can send broadcast messages to the swarm.
63+
6364 ### Synthetic Messages (Increment Counter)
6465
6566 **Source:** `getContextMemories()` line 1461-1478
@@ -254,7 +255,7 @@ Context is limited to the most recent 20 messages (`MaxContextMessages = 20`). W
254255 When `findLastUserPromptIndex` returns -1 (no user message in sliding window), `getContextMemories` performs a secondary check:
255256
256257 1. Query database for most recent broadcast: `GetMostRecentBroadcast(mysisID)`
257-2. If broadcast exists (even outside window OR from another mysis), include it in context
258+2. If broadcast exists (even outside window), include it in context
258259 3. Reset encouragement counter to 0
259260 4. Mysis continues running with mission directive
260261
@@ -262,8 +263,8 @@ When `findLastUserPromptIndex` returns -1 (no user message in sliding window), `
262263
263264 **Global Fallback:** `GetMostRecentBroadcast` has two-tier lookup:
264265 1. First, search for broadcasts sent to this specific mysis
265-2. If none found, search for most recent broadcast in entire system (global swarm mission)
266-3. This ensures new myses created after a broadcast inherit the current mission
266+2. If none found, search for most recent Commander broadcast in entire system (global swarm mission)
267+3. This ensures new myses created after a Commander broadcast inherit the current mission
267268
268269 **Benefits:**
269270 - Ensures autonomous operation: myses stay running as long as broadcasts exist
documentation/architecture/MYSIS_ACCOUNT_MANAGEMENT.md+4−4
@@ -22,7 +22,7 @@ Myses need game accounts to play SpaceMolt. We maintain a pool of accounts to co
2222 | Calls `register(username, empire)` | Pool is empty | Proxy passes to game server, stores new account | `session_id` (actually registered) |
2323 | Calls `login(username, password)` | Any | Proxy passes to game server, marks account in_use | `session_id` or error |
2424 | Calls `logout()` | Any | Proxy passes to game server, releases account | Success |
25-| Lists tools | Any | `zoea_claim_account` filtered out | Only game tools visible |
25+| Lists tools | Any | N/A - `zoea_claim_account` removed entirely | Only game tools visible |
2626
2727 ---
2828
@@ -33,7 +33,7 @@ Myses need game accounts to play SpaceMolt. We maintain a pool of accounts to co
3333 3. **Login passthrough:** Login calls always go to game server (no interception)
3434 4. **Account locking:** Successful login (real or substituted) marks account as in_use
3535 5. **Account release:** Logout releases account back to pool
36-6. **Tool filtering:** `zoea_claim_account` hidden from tool list
36+6. **Internal claiming:** Account claiming is handled internally by proxy shadowing `login`/`register` - no `zoea_claim_account` tool exists
3737
3838 ---
3939
@@ -60,7 +60,7 @@ Mysis: login() → Game: session_id → Proxy: mark_in_use → Mysis: PLAYING
6060 | Pool empty, mysis calls register | Mysis gets session_id, pool has 1 account (the new one) |
6161 | Mysis calls login with pool credentials | Mysis gets session_id, account marked in_use |
6262 | Mysis calls logout | Account released, pool gains 1 available account |
63-| Mysis lists tools | `zoea_claim_account` not in list |
63+| Mysis lists tools | Only game tools visible (no `zoea_claim_account` - tool removed) |
6464
6565 ---
6666
@@ -77,4 +77,4 @@ Mysis: login() → Game: session_id → Proxy: mark_in_use → Mysis: PLAYING
7777 - Token budget management
7878 - Structural JSON compaction
7979 - Tool call merging
80-- Review of other `zoea_*` tools
80+- Review of other `zoea_*` tools (note: `zoea_claim_account` was removed entirely)
documentation/architecture/VERSION_ONE_DESIGN.md+3−3
@@ -128,7 +128,7 @@ This document serves as the **single source of truth** for what Zoea Nova v0.5.0
128128 | Feature | Documented | Implemented | Tested | Match? | Notes |
129129 | ------------------------ | -------------------- | ---------------------------- | --------- | ------------- | ---------------------------------- |
130130 | **Proxy architecture** | ✅ Documented | ✅ `proxy.go` | ✅ Tested | ✅ YES | - |
131-| **Local tools** | ⚠️ Partial | ✅ 7 tools | ✅ Tested | ⚠️ INCOMPLETE | Not all listed in docs |
131+| **Local tools** | ⚠️ Partial | ✅ 2 tools | ✅ Tested | ⚠️ INCOMPLETE | Not all listed in docs |
132132 | **Upstream tools** | ✅ Dynamic discovery | ✅ `ListTools()` | ✅ Tested | ✅ YES | - |
133133 | **Offline mode** | ✅ Documented | ✅ `stub.go` | ✅ Tested | ✅ YES | - |
134134 | **Stub tools** | ⚠️ 4 tools listed | ✅ 5 tools | ✅ Tested | ⚠️ MISSING | `get_notifications` not documented |
@@ -145,7 +145,7 @@ This document serves as the **single source of truth** for what Zoea Nova v0.5.0
145145 - **Fix:** Add `get_notifications` to `OFFLINE_MODE.md`
146146
147147 2. **Local Tools Not Listed**
148- - **Implemented:** 7 `zoea_*` tools (list_myses, send_message, broadcast, search_messages, etc.)
148+ - **Implemented:** 2 `zoea_*` tools (search_messages, search_reasoning)
149149 - **Documentation:** Not listed in offline mode docs
150150 - **Fix:** Add section listing all local tools
151151
@@ -224,7 +224,7 @@ This document serves as the **single source of truth** for what Zoea Nova v0.5.0
224224 - **Fix:** Create `BROADCAST_ARCHITECTURE.md` explaining storage model
225225
226226 3. **Search Methods Undocumented**
227- - **Implementation:** `SearchMemories`, `SearchReasoning`, `SearchBroadcasts`
227+ - **Implementation:** `SearchMemories`, `SearchReasoning`
228228 - **Fix:** Document in store API reference
229229
230230 4. **Two-Phase Account Claiming Undocumented**
documentation/current/KNOWN_ISSUES.md+2−2
@@ -81,9 +81,9 @@ Active todo list of known issues, bugs, and planned improvements for Zoea Nova.
8181
8282 - [x] **Track broadcast sender and suppress self-response** (2026-02-05) - Added sender_id to memories (schema v8), excluded sender from broadcast recipients, and updated focus view labels to distinguish swarm broadcasts from self broadcasts.
8383
84-- [x] **Tool payload bloat removal** (2026-02-04) - Removed `provider` and `state` fields from MysisInfo struct and `zoea_list_myses` tool payload. Added `GetStateCounts()` method to Commander for `zoea_swarm_status`. Saves ~22 tokens per mysis, ~352 tokens for full swarm (16 myses).
84+- [x] **Tool payload bloat removal** (2026-02-04) - Removed `provider` and `state` fields from MysisInfo struct and `zoea_list_myses` tool payload. Added `GetStateCounts()` method to Commander for `zoea_swarm_status`. Saves ~22 tokens per mysis, ~352 tokens for full swarm (16 myses). **Note:** Both `zoea_list_myses` and `zoea_swarm_status` tools were later removed entirely.
8585
86-- [x] **Context snapshot compaction** (2026-02-04) - Implemented snapshot compaction in `getContextMemories()` to keep only most recent result for each snapshot tool (get_ship, get_system, get_poi, get_nearby, get_cargo, zoea_swarm_status, zoea_list_myses). Added search tool reminders to SystemPrompt and ContinuePrompt. See `documentation/architecture/CONTEXT_COMPRESSION.md` for details.
86+- [x] **Context snapshot compaction** (2026-02-04) - Implemented snapshot compaction in `getContextMemories()` to keep only most recent result for each snapshot tool (get_ship, get_system, get_poi, get_nearby, get_cargo). Added search tool reminders to SystemPrompt and ContinuePrompt. See `documentation/architecture/CONTEXT_COMPRESSION.md` for details.
8787
8888 - [x] **Database reset with account backup** (2026-02-05) - Added `make db-reset-accounts` target to safely wipe database while preserving account credentials via export/import cycle.
8989
documentation/current/TODO.md+0−2
@@ -32,8 +32,6 @@ Recommendations
3232
3333 - network activity indicator revision
3434
35-- remove zoea_list_mysis()
36-
3735 - Investigate no content from AI messages in coversation log. only happens ocasionally.
3836
3937 ```
internal/core/mysis.go+1−6
@@ -1502,12 +1502,7 @@ func (m *Mysis) isSnapshotTool(toolName string) bool {
15021502 if strings.HasPrefix(toolName, "get_") {
15031503 return true
15041504 }
1505- switch toolName {
1506- case "zoea_swarm_status", "zoea_list_myses":
1507- return true
1508- default:
1509- return false
1510- }
1505+ return false
15111506 }
15121507
15131508 // run is the mysis main processing loop.
internal/core/mysis_helpers_test.go+0−3
@@ -86,8 +86,6 @@ func TestIsSnapshotTool(t *testing.T) {
8686 {"get_prefix", "get_status", true},
8787 {"get_system", "get_system", true},
8888 {"get_anything", "get_foo", true},
89- {"zoea_swarm_status", "zoea_swarm_status", true},
90- {"zoea_list_myses", "zoea_list_myses", true},
9189 {"action_tool", "move_to", false},
9290 {"mine_action", "mine_resources", false},
9391 {"empty", "", false},
@@ -112,7 +110,6 @@ func TestExtractToolNameFromResult(t *testing.T) {
112110 toolCallNames := map[string]string{
113111 "call_123": "get_status",
114112 "call_456": "mine_resources",
115- "call_789": "zoea_swarm_status",
116113 }
117114
118115 tests := []struct {
internal/core/mysis_test.go+19−19
@@ -436,7 +436,7 @@ func TestContinuePromptContainsSearchReminder(t *testing.T) {
436436 // TestContinuePromptAddsDriftReminder removed - buildContinuePrompt() method removed.
437437 // Drift reminders are now part of the system prompt, not dynamically generated.
438438
439-func TestZoeaListMysesCompaction(t *testing.T) {
439+func TestSnapshotCompaction(t *testing.T) {
440440 s, bus, cleanup := setupMysisTest(t)
441441 defer cleanup()
442442
@@ -447,12 +447,12 @@ func TestZoeaListMysesCompaction(t *testing.T) {
447447 // Add system prompt
448448 s.AddMemory(stored.ID, store.MemoryRoleSystem, store.MemorySourceSystem, "System prompt", "", "")
449449
450- // Add multiple zoea_list_myses tool results (should be compacted to keep only the latest)
450+ // Add multiple get_status tool results (should be compacted to keep only the latest)
451451 for i := 0; i < 5; i++ {
452- s.AddMemory(stored.ID, store.MemoryRoleUser, store.MemorySourceDirect, "list myses", "", "")
453- s.AddMemory(stored.ID, store.MemoryRoleAssistant, store.MemorySourceLLM, constants.ToolCallStoragePrefix+"call_1:zoea_list_myses:{}", "", "")
452+ s.AddMemory(stored.ID, store.MemoryRoleUser, store.MemorySourceDirect, "check status", "", "")
453+ s.AddMemory(stored.ID, store.MemoryRoleAssistant, store.MemorySourceLLM, constants.ToolCallStoragePrefix+"call_1:get_status:{}", "", "")
454454 s.AddMemory(stored.ID, store.MemoryRoleTool, store.MemorySourceTool,
455- fmt.Sprintf(`call_1:[{"id":"mysis-%d","name":"test-%d"}]`, i, i), "", "")
455+ fmt.Sprintf(`call_1:{"status":"active","iteration":%d}`, i), "", "")
456456 }
457457
458458 // Get context memories
@@ -462,25 +462,25 @@ func TestZoeaListMysesCompaction(t *testing.T) {
462462 }
463463
464464 // With turn-aware composition + snapshot compression:
465- // - Historical context: latest tool loop from turns 0-3 (mysis-3)
466- // - Current turn: all of turn 4 (user + assistant + tool for mysis-4)
467- // - Compression: zoea_list_myses is a snapshot tool, so only the LATEST is kept (mysis-4)
468- // So we expect 1 tool result: mysis-4 (most recent)
469- listResults := 0
470- hasMysis4 := false
465+ // - Historical context: latest tool loop from turns 0-3 (iteration 3)
466+ // - Current turn: all of turn 4 (user + assistant + tool for iteration 4)
467+ // - Compression: get_status is a snapshot tool, so only the LATEST is kept (iteration 4)
468+ // So we expect 1 tool result: iteration 4 (most recent)
469+ statusResults := 0
470+ hasIteration4 := false
471471 for _, m := range memories {
472- if m.Role == store.MemoryRoleTool && strings.Contains(m.Content, `"id":"mysis-`) {
473- listResults++
474- if strings.Contains(m.Content, `"id":"mysis-4"`) {
475- hasMysis4 = true
472+ if m.Role == store.MemoryRoleTool && strings.Contains(m.Content, `"iteration":`) {
473+ statusResults++
474+ if strings.Contains(m.Content, `"iteration":4`) {
475+ hasIteration4 = true
476476 }
477477 }
478478 }
479- if listResults != 1 {
480- t.Errorf("expected 1 zoea_list_myses result after compression, got %d", listResults)
479+ if statusResults != 1 {
480+ t.Errorf("expected 1 get_status result after compression, got %d", statusResults)
481481 }
482- if !hasMysis4 {
483- t.Error("expected mysis-4 result (latest snapshot after compression)")
482+ if !hasIteration4 {
483+ t.Error("expected iteration 4 result (latest snapshot after compression)")
484484 }
485485 }
486486
internal/integration/broadcast_sender_test.go+26−131
@@ -1,127 +1,18 @@
11 package integration
22
33 import (
4- "context"
5- "encoding/json"
64 "path/filepath"
75 "testing"
86 "time"
97
108 "github.com/xonecas/zoea-nova/internal/config"
119 "github.com/xonecas/zoea-nova/internal/core"
12- "github.com/xonecas/zoea-nova/internal/mcp"
1310 "github.com/xonecas/zoea-nova/internal/provider"
1411 "github.com/xonecas/zoea-nova/internal/store"
1512 "golang.org/x/time/rate"
1613 )
1714
18-type orchestratorAdapter struct {
19- commander *core.Commander
20-}
21-
22-func (a *orchestratorAdapter) ListMyses() []mcp.MysisInfo {
23- myses := a.commander.ListMyses()
24- result := make([]mcp.MysisInfo, len(myses))
25- for i, mysis := range myses {
26- result[i] = mcp.MysisInfo{
27- ID: mysis.ID(),
28- Name: mysis.Name(),
29- LastError: mysis.LastError(),
30- }
31- }
32- return result
33-}
34-
35-func (a *orchestratorAdapter) MysisCount() int {
36- return a.commander.MysisCount()
37-}
38-
39-func (a *orchestratorAdapter) MaxMyses() int {
40- return a.commander.MaxMyses()
41-}
42-
43-func (a *orchestratorAdapter) GetStateCounts() map[string]int {
44- return a.commander.GetStateCounts()
45-}
46-
47-func (a *orchestratorAdapter) SendMessageAsync(mysisID, message string) error {
48- return a.commander.SendMessageAsync(mysisID, message)
49-}
50-
51-func (a *orchestratorAdapter) BroadcastAsync(message string) error {
52- return a.commander.BroadcastAsync(message)
53-}
54-
55-func (a *orchestratorAdapter) BroadcastFrom(senderID, message string) error {
56- return a.commander.BroadcastFrom(senderID, message)
57-}
58-
59-func (a *orchestratorAdapter) SearchMessages(mysisID, query string, limit int) ([]mcp.SearchResult, error) {
60- memories, err := a.commander.Store().SearchMemories(mysisID, query, limit)
61- if err != nil {
62- return nil, err
63- }
64-
65- results := make([]mcp.SearchResult, len(memories))
66- for i, m := range memories {
67- results[i] = mcp.SearchResult{
68- Role: string(m.Role),
69- Source: string(m.Source),
70- Content: m.Content,
71- CreatedAt: m.CreatedAt.Format("2006-01-02 15:04:05"),
72- }
73- }
74- return results, nil
75-}
76-
77-func (a *orchestratorAdapter) SearchReasoning(mysisID, query string, limit int) ([]mcp.ReasoningResult, error) {
78- memories, err := a.commander.Store().SearchReasoning(mysisID, query, limit)
79- if err != nil {
80- return nil, err
81- }
82-
83- results := make([]mcp.ReasoningResult, len(memories))
84- for i, m := range memories {
85- results[i] = mcp.ReasoningResult{
86- Role: string(m.Role),
87- Source: string(m.Source),
88- Content: m.Content,
89- Reasoning: m.Reasoning,
90- CreatedAt: m.CreatedAt.Format("2006-01-02 15:04:05"),
91- }
92- }
93- return results, nil
94-}
95-
96-func (a *orchestratorAdapter) SearchBroadcasts(query string, limit int) ([]mcp.BroadcastResult, error) {
97- broadcasts, err := a.commander.Store().SearchBroadcasts(query, limit)
98- if err != nil {
99- return nil, err
100- }
101-
102- results := make([]mcp.BroadcastResult, len(broadcasts))
103- for i, b := range broadcasts {
104- results[i] = mcp.BroadcastResult{
105- Content: b.Content,
106- CreatedAt: b.CreatedAt.Format("2006-01-02 15:04:05"),
107- }
108- }
109- return results, nil
110-}
111-
112-func (a *orchestratorAdapter) ClaimAccount() (mcp.AccountInfo, error) {
113- acc, err := a.commander.Store().ClaimAccount()
114- if err != nil {
115- return mcp.AccountInfo{}, err
116- }
117-
118- return mcp.AccountInfo{
119- Username: acc.Username,
120- Password: acc.Password,
121- }, nil
122-}
123-
124-func setupIntegrationCommander(t *testing.T) (*core.Commander, *store.Store, *mcp.Proxy, func()) {
15+func setupIntegrationCommander(t *testing.T) (*core.Commander, *store.Store, func()) {
12516 t.Helper()
12617
12718 tmpDir := t.TempDir()
@@ -147,20 +38,17 @@ func setupIntegrationCommander(t *testing.T) (*core.Commander, *store.Store, *mc
14738 }
14839
14940 cmd := core.NewCommander(s, reg, bus, cfg)
150- proxy := mcp.NewProxy(nil)
151- mcp.RegisterOrchestratorTools(proxy, &orchestratorAdapter{commander: cmd})
152- cmd.SetMCP(proxy)
15341
15442 cleanup := func() {
15543 bus.Close()
15644 s.Close()
15745 }
15846
159- return cmd, s, proxy, cleanup
47+ return cmd, s, cleanup
16048 }
16149
16250 func TestBroadcastSenderTracking(t *testing.T) {
163- cmd, s, proxy, cleanup := setupIntegrationCommander(t)
51+ cmd, s, cleanup := setupIntegrationCommander(t)
16452 defer cleanup()
16553
16654 sender, _ := cmd.CreateMysis("sender", "mock")
@@ -182,15 +70,10 @@ func TestBroadcastSenderTracking(t *testing.T) {
18270 t.Fatal("myses failed to start within timeout")
18371 }
18472
185- ctx := context.Background()
186- caller := mcp.CallerContext{MysisID: sender.ID(), MysisName: sender.Name()}
187- args := json.RawMessage(`{"message": "integration test broadcast"}`)
188- result, err := proxy.CallTool(ctx, caller, "zoea_broadcast", args)
73+ // Send broadcast from sender using BroadcastFrom
74+ err := cmd.BroadcastFrom(sender.ID(), "integration test broadcast")
18975 if err != nil {
190- t.Fatalf("CallTool() error: %v", err)
191- }
192- if result.IsError {
193- t.Fatalf("tool returned error: %v", result.Content[0].Text)
76+ t.Fatalf("BroadcastFrom() error: %v", err)
19477 }
19578
19679 time.Sleep(200 * time.Millisecond)
@@ -222,14 +105,26 @@ func TestBroadcastSenderTracking(t *testing.T) {
222105 }
223106 }
224107
225- broadcasts, err := s.SearchBroadcasts("integration test", 10)
226- if err != nil {
227- t.Fatalf("SearchBroadcasts() error: %v", err)
228- }
229- if len(broadcasts) == 0 {
230- t.Fatal("broadcast not found in search")
108+ // Verify sender_id was tracked correctly by checking receiver memories
109+ foundWithSender := false
110+ for _, receiver := range []*core.Mysis{receiver1, receiver2} {
111+ mems, err := s.GetRecentMemories(receiver.ID(), 50)
112+ if err != nil {
113+ t.Fatalf("GetRecentMemories() error: %v", err)
114+ }
115+ for _, m := range mems {
116+ if m.Source == store.MemorySourceBroadcast && m.Content == "integration test broadcast" {
117+ if m.SenderID == sender.ID() {
118+ foundWithSender = true
119+ break
120+ }
121+ }
122+ }
123+ if foundWithSender {
124+ break
125+ }
231126 }
232- if broadcasts[0].SenderID != sender.ID() {
233- t.Errorf("broadcast sender_id: got %q, want %q", broadcasts[0].SenderID, sender.ID())
127+ if !foundWithSender {
128+ t.Error("broadcast sender_id not correctly tracked in receiver memories")
234129 }
235130 }
internal/mcp/mcp_test.go+21−83
@@ -4,7 +4,6 @@ import (
44 "context"
55 "encoding/json"
66 "errors"
7- "fmt"
87 "net/http"
98 "net/http/httptest"
109 "testing"
@@ -175,16 +174,10 @@ func TestClientWithMockServer(t *testing.T) {
175174 }
176175
177176 // mockOrchestrator is a test implementation of the Orchestrator interface.
178-type mockOrchestrator struct {
179- myses []MysisInfo
180-}
181-
182-func (m *mockOrchestrator) ListMyses() []MysisInfo {
183- return m.myses
184-}
177+type mockOrchestrator struct{}
185178
186179 func (m *mockOrchestrator) MysisCount() int {
187- return len(m.myses)
180+ return 2
188181 }
189182
190183 func (m *mockOrchestrator) MaxMyses() int {
@@ -192,27 +185,17 @@ func (m *mockOrchestrator) MaxMyses() int {
192185 }
193186
194187 func (m *mockOrchestrator) GetStateCounts() map[string]int {
195- counts := map[string]int{
196- "running": 0,
188+ return map[string]int{
189+ "running": 2,
197190 "idle": 0,
198191 "stopped": 0,
199192 "errored": 0,
200193 }
201- for _, mysis := range m.myses {
202- if mysis.LastError != nil {
203- counts["errored"]++
204- } else {
205- counts["running"]++
206- }
207- }
208- return counts
209194 }
210195
211196 func (m *mockOrchestrator) SendMessageAsync(mysisID, message string) error {
212- for _, mysis := range m.myses {
213- if mysis.ID == mysisID {
214- return nil
215- }
197+ if mysisID == "mysis-1" || mysisID == "mysis-2" {
198+ return nil
216199 }
217200 return errors.New("mysis not found")
218201 }
@@ -233,21 +216,9 @@ func (m *mockOrchestrator) SearchReasoning(mysisID, query string, limit int) ([]
233216 return []ReasoningResult{}, nil
234217 }
235218
236-func (m *mockOrchestrator) SearchBroadcasts(query string, limit int) ([]BroadcastResult, error) {
237- return []BroadcastResult{}, nil
238-}
239-
240-func (m *mockOrchestrator) ClaimAccount() (AccountInfo, error) {
241- return AccountInfo{}, fmt.Errorf("not available in test mode")
242-}
243-
244219 func TestOrchestratorTools(t *testing.T) {
245220 // Create mock orchestrator
246- orchestrator := &mockOrchestrator{
247- myses: []MysisInfo{
248- {ID: "mysis-1", Name: "test-mysis"},
249- },
250- }
221+ orchestrator := &mockOrchestrator{}
251222
252223 // Create proxy and register tools
253224 proxy := NewProxy(nil)
@@ -255,10 +226,11 @@ func TestOrchestratorTools(t *testing.T) {
255226
256227 ctx := context.Background()
257228
258- // Test zoea_list_myses
259- result, err := proxy.CallTool(ctx, CallerContext{}, "zoea_list_myses", nil)
229+ // Test zoea_search_messages
230+ args := json.RawMessage(`{"mysis_id": "mysis-1", "query": "test"}`)
231+ result, err := proxy.CallTool(ctx, CallerContext{}, "zoea_search_messages", args)
260232 if err != nil {
261- t.Fatalf("CallTool(zoea_list_myses) error: %v", err)
233+ t.Fatalf("CallTool(zoea_search_messages) error: %v", err)
262234 }
263235 if result.IsError {
264236 t.Errorf("unexpected error: %s", result.Content[0].Text)
@@ -266,14 +238,9 @@ func TestOrchestratorTools(t *testing.T) {
266238
267239 }
268240
269-func TestZoeaListMysesPayloadMinimal(t *testing.T) {
270- // Create mock orchestrator with test myses
271- orchestrator := &mockOrchestrator{
272- myses: []MysisInfo{
273- {ID: "mysis-1", Name: "test-mysis-1"},
274- {ID: "mysis-2", Name: "test-mysis-2"},
275- },
276- }
241+func TestZoeaSearchMessagesPayload(t *testing.T) {
242+ // Create mock orchestrator
243+ orchestrator := &mockOrchestrator{}
277244
278245 // Create proxy and register tools
279246 proxy := NewProxy(nil)
@@ -281,47 +248,18 @@ func TestZoeaListMysesPayloadMinimal(t *testing.T) {
281248
282249 ctx := context.Background()
283250
284- // Call zoea_list_myses
285- result, err := proxy.CallTool(ctx, CallerContext{}, "zoea_list_myses", nil)
251+ // Call zoea_search_messages
252+ args := json.RawMessage(`{"mysis_id": "mysis-1", "query": "test"}`)
253+ result, err := proxy.CallTool(ctx, CallerContext{}, "zoea_search_messages", args)
286254 if err != nil {
287- t.Fatalf("CallTool(zoea_list_myses) error: %v", err)
255+ t.Fatalf("CallTool(zoea_search_messages) error: %v", err)
288256 }
289257 if result.IsError {
290258 t.Fatalf("unexpected error: %s", result.Content[0].Text)
291259 }
292260
293- // Parse JSON result
294- var myses []map[string]interface{}
295- if err := json.Unmarshal([]byte(result.Content[0].Text), &myses); err != nil {
296- t.Fatalf("failed to parse JSON: %v", err)
297- }
298-
299- // Verify we have 2 myses
300- if len(myses) != 2 {
301- t.Fatalf("expected 2 myses, got %d", len(myses))
302- }
303-
304- // Verify each mysis has only id and name fields
305- for i, mysis := range myses {
306- // Check required fields are present
307- if _, ok := mysis["id"]; !ok {
308- t.Errorf("mysis %d missing 'id' field", i)
309- }
310- if _, ok := mysis["name"]; !ok {
311- t.Errorf("mysis %d missing 'name' field", i)
312- }
313-
314- // Check bloat fields are NOT present
315- if _, ok := mysis["provider"]; ok {
316- t.Errorf("mysis %d should not have 'provider' field (bloat)", i)
317- }
318- if _, ok := mysis["state"]; ok {
319- t.Errorf("mysis %d should not have 'state' field (bloat)", i)
320- }
321-
322- // Verify only 2 fields total
323- if len(mysis) != 2 {
324- t.Errorf("mysis %d has %d fields, expected exactly 2 (id, name)", i, len(mysis))
325- }
261+ // Verify we get a response (empty results are expected with empty mock)
262+ if len(result.Content) == 0 {
263+ t.Fatal("expected content in result")
326264 }
327265 }
internal/mcp/proxy.go+0−4
@@ -94,10 +94,6 @@ func (p *Proxy) ListTools(ctx context.Context) ([]Tool, error) {
9494 // Start with local tools
9595 tools := make([]Tool, 0, len(p.localTools))
9696 for _, t := range p.localTools {
97- // Filter out zoea_claim_account - not exposed to myses
98- if t.Name == "zoea_claim_account" {
99- continue
100- }
10197 tools = append(tools, t)
10298 }
10399
internal/mcp/tools.go+0−219
@@ -6,13 +6,6 @@ import (
66 "fmt"
77 )
88
9-// MysisInfo represents mysis information returned by the orchestrator.
10-type MysisInfo struct {
11- ID string
12- Name string
13- LastError error
14-}
15-
169 // SearchResult represents a search result from memory.
1710 type SearchResult struct {
1811 Role string
@@ -29,22 +22,9 @@ type ReasoningResult struct {
2922 CreatedAt string
3023 }
3124
32-// BroadcastResult represents a broadcast search result.
33-type BroadcastResult struct {
34- Content string
35- CreatedAt string
36-}
37-
38-// AccountInfo represents account credential information.
39-type AccountInfo struct {
40- Username string
41- Password string
42-}
43-
4425 // Orchestrator defines the interface for swarm orchestration.
4526 // This interface breaks the import cycle between mcp and core packages.
4627 type Orchestrator interface {
47- ListMyses() []MysisInfo
4828 MysisCount() int
4929 MaxMyses() int
5030 GetStateCounts() map[string]int
@@ -53,112 +33,10 @@ type Orchestrator interface {
5333 BroadcastFrom(senderID, message string) error
5434 SearchMessages(mysisID, query string, limit int) ([]SearchResult, error)
5535 SearchReasoning(mysisID, query string, limit int) ([]ReasoningResult, error)
56- SearchBroadcasts(query string, limit int) ([]BroadcastResult, error)
57- ClaimAccount() (AccountInfo, error)
5836 }
5937
6038 // RegisterOrchestratorTools registers the internal orchestration tools with the proxy.
6139 func RegisterOrchestratorTools(proxy *Proxy, orchestrator Orchestrator) {
62- // List myses tool
63- proxy.RegisterTool(
64- Tool{
65- Name: "zoea_list_myses",
66- Description: "List all myses in the swarm with their current status",
67- InputSchema: json.RawMessage(`{"type": "object", "properties": {}}`),
68- },
69- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
70- myses := orchestrator.ListMyses()
71- var result []map[string]interface{}
72- for _, m := range myses {
73- result = append(result, map[string]interface{}{
74- "id": m.ID,
75- "name": m.Name,
76- })
77- }
78-
79- data, _ := json.MarshalIndent(result, "", " ")
80- return &ToolResult{
81- Content: []ContentBlock{{Type: "text", Text: string(data)}},
82- }, nil
83- },
84- )
85-
86- // Send message to mysis tool
87- proxy.RegisterTool(
88- Tool{
89- Name: "zoea_send_message",
90- Description: "Send a message to a specific mysis",
91- InputSchema: json.RawMessage(`{
92- "type": "object",
93- "properties": {
94- "mysis_id": {"type": "string", "description": "The ID of the mysis"},
95- "message": {"type": "string", "description": "The message to send"}
96- },
97- "required": ["mysis_id", "message"]
98- }`),
99- },
100- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
101- var params struct {
102- MysisID string `json:"mysis_id"`
103- Message string `json:"message"`
104- }
105- if err := json.Unmarshal(args, &params); err != nil {
106- return &ToolResult{
107- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
108- IsError: true,
109- }, nil
110- }
111-
112- if err := orchestrator.SendMessageAsync(params.MysisID, params.Message); err != nil {
113- return &ToolResult{
114- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to send message: %v", err)}},
115- IsError: true,
116- }, nil
117- }
118-
119- return &ToolResult{
120- Content: []ContentBlock{{Type: "text", Text: "message queued for delivery"}},
121- }, nil
122- },
123- )
124-
125- // Broadcast message tool
126- proxy.RegisterToolWithContext(
127- Tool{
128- Name: "zoea_broadcast",
129- Description: "Send a message to all running myses (you will not receive your own broadcast)",
130- InputSchema: json.RawMessage(`{
131- "type": "object",
132- "properties": {
133- "message": {"type": "string", "description": "The message to broadcast"}
134- },
135- "required": ["message"]
136- }`),
137- },
138- func(ctx context.Context, caller CallerContext, args json.RawMessage) (*ToolResult, error) {
139- var params struct {
140- Message string `json:"message"`
141- }
142- if err := json.Unmarshal(args, &params); err != nil {
143- return &ToolResult{
144- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
145- IsError: true,
146- }, nil
147- }
148-
149- if err := orchestrator.BroadcastFrom(caller.MysisID, params.Message); err != nil {
150- return &ToolResult{
151- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("broadcast failed: %v", err)}},
152- IsError: true,
153- }, nil
154- }
155-
156- return &ToolResult{
157- Content: []ContentBlock{{Type: "text", Text: "broadcast sent to all running myses (excluding you)"}},
158- }, nil
159- },
160- )
161-
16240 // Search messages tool
16341 proxy.RegisterTool(
16442 Tool{
@@ -283,101 +161,4 @@ func RegisterOrchestratorTools(proxy *Proxy, orchestrator Orchestrator) {
283161 }, nil
284162 },
285163 )
286-
287- // Search broadcasts tool
288- proxy.RegisterTool(
289- Tool{
290- Name: "zoea_search_broadcasts",
291- Description: "Search past swarm broadcasts by text content",
292- InputSchema: json.RawMessage(`{
293- "type": "object",
294- "properties": {
295- "query": {"type": "string", "description": "Text to search for in broadcast content"},
296- "limit": {"type": "integer", "description": "Maximum results to return (default 20, max 100)"}
297- },
298- "required": ["query"]
299- }`),
300- },
301- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
302- var params struct {
303- Query string `json:"query"`
304- Limit int `json:"limit"`
305- }
306- if err := json.Unmarshal(args, &params); err != nil {
307- return &ToolResult{
308- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("invalid arguments: %v", err)}},
309- IsError: true,
310- }, nil
311- }
312-
313- if params.Query == "" {
314- return &ToolResult{
315- Content: []ContentBlock{{Type: "text", Text: "query cannot be empty"}},
316- IsError: true,
317- }, nil
318- }
319-
320- limit := params.Limit
321- if limit <= 0 {
322- limit = 20
323- } else if limit > 100 {
324- limit = 100
325- }
326-
327- results, err := orchestrator.SearchBroadcasts(params.Query, limit)
328- if err != nil {
329- return &ToolResult{
330- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("search failed: %v", err)}},
331- IsError: true,
332- }, nil
333- }
334-
335- if len(results) == 0 {
336- return &ToolResult{
337- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("no broadcasts found matching '%s'", params.Query)}},
338- }, nil
339- }
340-
341- data, _ := json.MarshalIndent(results, "", " ")
342- return &ToolResult{
343- Content: []ContentBlock{{Type: "text", Text: string(data)}},
344- }, nil
345- },
346- )
347-
348- // Claim account tool
349- proxy.RegisterTool(
350- Tool{
351- Name: "zoea_claim_account",
352- Description: "Get existing credentials from swarm pool. Returns username and password to use with the game's login tool. No arguments needed.",
353- InputSchema: json.RawMessage(`{"type": "object", "properties": {}}`),
354- },
355- func(ctx context.Context, args json.RawMessage) (*ToolResult, error) {
356- account, err := orchestrator.ClaimAccount()
357- if err != nil {
358- // Check if no accounts available
359- if err.Error() == "no accounts available" {
360- data, _ := json.Marshal(map[string]string{
361- "status": "no_accounts",
362- "action_required": "register",
363- })
364- return &ToolResult{
365- Content: []ContentBlock{{Type: "text", Text: string(data)}},
366- }, nil
367- }
368- return &ToolResult{
369- Content: []ContentBlock{{Type: "text", Text: fmt.Sprintf("failed to claim account: %v", err)}},
370- IsError: true,
371- }, nil
372- }
373-
374- data, _ := json.Marshal(map[string]string{
375- "username": account.Username,
376- "password": account.Password,
377- })
378- return &ToolResult{
379- Content: []ContentBlock{{Type: "text", Text: string(data)}},
380- }, nil
381- },
382- )
383164 }
internal/store/memories.go+0−48
@@ -351,51 +351,3 @@ func (s *Store) SearchReasoning(mysisID, query string, limit int) ([]*Memory, er
351351
352352 return memories, rows.Err()
353353 }
354-
355-// SearchBroadcasts searches unique broadcast messages by content text.
356-// Returns broadcasts where content contains the query string (case-sensitive).
357-func (s *Store) SearchBroadcasts(query string, limit int) ([]*BroadcastMessage, error) {
358- rows, err := s.db.Query(`
359- SELECT sender_id, content, MAX(created_at) as created_at
360- FROM memories
361- WHERE source = 'broadcast' AND content LIKE '%' || ? || '%'
362- GROUP BY content, sender_id
363- ORDER BY created_at DESC
364- LIMIT ?
365- `, query, limit)
366- if err != nil {
367- return nil, fmt.Errorf("search broadcasts: %w", err)
Cut short: this commit's diff is over 1000 lines.
internal/store/memories_test.go+0−32
Cut short: this commit's diff is over 1000 lines.