• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

valksor / go-assern / 21232054917

22 Jan 2026 01:08AM UTC coverage: 52.533% (+4.6%) from 47.928%
21232054917

push

github

k0d3r1s
Add tool aliases, CLI disambiguation, and performance optimizations
Adds tool aliasing system, CLI colon notation, and caching for better performance:
- cmd: Add Execute() with colon notation support (e.g., list:servers)
- cmd: Integrate go-toolkit disambiguate for interactive command selection
- tools: Add alias management (SetAliases, AddAlias, RemoveAlias, ResolveAlias)
- tools: Improve ParsePrefixedName() to return errors instead of empty strings
- registry: Add double-checked locking cache to generic registry
- registry: Invalidate cache on mutations for consistency
- resources: Add proper error handling for ParsePrefixedURI()
- prompts: Add proper error handling for ParsePrefixedPromptName()
- instance: Add buffer pool (256KB) for proxy I/O operations
- instance: Replace time-based session IDs with atomic counter
- transport: Make ParseLogLevel() case-insensitive
- aggregator: Add benchmark_test.go with 8 benchmark functions
- aggregator: Add registry_test.go with 16 registry cache tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

101 of 153 new or added lines in 8 files covered. (66.01%)

475 existing lines in 8 files now uncovered.

1649 of 3139 relevant lines covered (52.53%)

127.59 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

27.4
/internal/instance/proxy.go
1
package instance
2

3
import (
4
        "context"
5
        "io"
6
        "log/slog"
7
        "net"
8
        "os"
9
        "sync"
10
)
11

12
const (
13
        // proxyBufferSize is the buffer size for io.CopyBuffer operations.
14
        // 256KB is optimized for MCP message sizes which can be large.
15
        proxyBufferSize = 256 * 1024
16
)
17

18
// bufferPool provides reusable buffers for proxy I/O operations.
19
var bufferPool = sync.Pool{
NEW
20
        New: func() any {
×
NEW
21
                buf := make([]byte, proxyBufferSize)
×
NEW
22

×
NEW
23
                return &buf
×
NEW
24
        },
×
25
}
26

27
// Proxy connects to an existing assern instance and bridges stdio to it.
28
type Proxy struct {
29
        socketPath string
30
        logger     *slog.Logger
31
        conn       net.Conn
32
}
33

34
// NewProxy creates a new proxy to an existing instance.
35
func NewProxy(socketPath string, logger *slog.Logger) *Proxy {
11✔
36
        return &Proxy{
11✔
37
                socketPath: socketPath,
11✔
38
                logger:     logger,
11✔
39
        }
11✔
40
}
11✔
41

42
// Connect establishes connection to the primary instance.
43
func (p *Proxy) Connect(ctx context.Context) error {
9✔
44
        var dialer net.Dialer
9✔
45
        conn, err := dialer.DialContext(ctx, "unix", p.socketPath)
9✔
46
        if err != nil {
11✔
47
                return err
2✔
48
        }
2✔
49

50
        p.conn = conn
7✔
51

7✔
52
        return nil
7✔
53
}
54

55
// Close closes the connection to the primary instance.
56
func (p *Proxy) Close() error {
8✔
57
        if p.conn != nil {
15✔
58
                return p.conn.Close()
7✔
59
        }
7✔
60

61
        return nil
1✔
62
}
63

64
// ServeStdio bridges stdin/stdout to the socket connection.
65
// This makes the proxy transparent to the calling LLM.
66
func (p *Proxy) ServeStdio(ctx context.Context) error {
×
67
        if p.conn == nil {
×
68
                if err := p.Connect(ctx); err != nil {
×
69
                        return err
×
70
                }
×
71
        }
72

73
        p.logger.Info("proxy connected - forwarding stdio to primary instance")
×
74

×
75
        var wg sync.WaitGroup
×
76
        errCh := make(chan error, 2)
×
77

×
78
        // stdin -> socket
×
79
        wg.Add(1)
×
80
        go func() {
×
81
                defer wg.Done()
×
NEW
82
                bufPtr, ok := bufferPool.Get().(*[]byte)
×
NEW
83
                if !ok {
×
NEW
84
                        errCh <- io.ErrShortBuffer
×
NEW
85

×
NEW
86
                        return
×
NEW
87
                }
×
NEW
88
                defer bufferPool.Put(bufPtr)
×
NEW
89
                _, err := io.CopyBuffer(p.conn, os.Stdin, *bufPtr)
×
90
                if err != nil && ctx.Err() == nil {
×
91
                        errCh <- err
×
92
                }
×
93
        }()
94

95
        // socket -> stdout
96
        wg.Add(1)
×
97
        go func() {
×
98
                defer wg.Done()
×
NEW
99
                bufPtr, ok := bufferPool.Get().(*[]byte)
×
NEW
100
                if !ok {
×
NEW
101
                        errCh <- io.ErrShortBuffer
×
NEW
102

×
NEW
103
                        return
×
NEW
104
                }
×
NEW
105
                defer bufferPool.Put(bufPtr)
×
NEW
106
                _, err := io.CopyBuffer(os.Stdout, p.conn, *bufPtr)
×
107
                if err != nil && ctx.Err() == nil {
×
108
                        errCh <- err
×
109
                }
×
110
        }()
111

112
        // Wait for context cancellation or connection close
113
        select {
×
114
        case <-ctx.Done():
×
115
                _ = p.conn.Close()
×
116
        case err := <-errCh:
×
117
                p.logger.Debug("proxy connection closed", "error", err)
×
118
                _ = p.conn.Close()
×
119
        }
120

121
        wg.Wait()
×
122

×
123
        return nil
×
124
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc