4.1 routing quality + 4.4 persona prompt
- VoiceConfig: add QueryMinScore (default 0.55) + Persona config fields - voice.go: remove queryMinScore const, wire from cfg.Voice.QueryMinScore as reactiveHandler field - llmphraser.go: add Persona to Config, prepend to system prompts in chat and query paths (systemPrompt/querySystemPrompt methods) - main.go: pass personaFromCfg into both phraser config blocks - Makefile: add download-embedder target (Xenova/paraphrase-multilingual- MiniLM-L12-v2, ~90MB ONNX) - AGENTS.md: document embedder model download + libonnxruntime setup - server.go: fix pre-existing wg.Add vs wg.Wait data race using accept mutex. make test green, zero races across all 29 packages.
This commit is contained in:
+16
-3
@@ -281,9 +281,10 @@ type Server struct {
|
||||
api atomic.Value // stores CoreAPI
|
||||
path string
|
||||
|
||||
ln net.Listener
|
||||
wg sync.WaitGroup
|
||||
done chan struct{}
|
||||
ln net.Listener
|
||||
wg sync.WaitGroup
|
||||
done chan struct{}
|
||||
accept sync.Mutex // guards wg.Add vs Close's wg.Wait sequence
|
||||
|
||||
// Check — optional authorization hook. dispatch runs it BEFORE method
|
||||
// dispatch, with the raw params, so the auth layer can make verdicts
|
||||
@@ -385,7 +386,12 @@ func (s *Server) Serve() error {
|
||||
return fmt.Errorf("ipc: accept: %w", err)
|
||||
}
|
||||
}
|
||||
// wg.Add under accept mutex so Close's wg.Wait (also under accept) sees
|
||||
// a consistent counter — a connection accepted just before Close closes
|
||||
// the listener must be tracked before Wait starts.
|
||||
s.accept.Lock()
|
||||
s.wg.Add(1)
|
||||
s.accept.Unlock()
|
||||
go func(c net.Conn) {
|
||||
defer s.wg.Done()
|
||||
defer c.Close()
|
||||
@@ -747,7 +753,14 @@ func (s *Server) Close() error {
|
||||
close(s.done)
|
||||
}
|
||||
err := s.ln.Close()
|
||||
// Under accept lock: after the listener closes, no new Accept can complete,
|
||||
// so no new wg.Add will be called. The Wait is safe to observe the wg
|
||||
// counter because any in-flight Accept that already got a conn either
|
||||
// already called wg.Add (before releasing the lock) or will see the closed
|
||||
// listener error and not call wg.Add at all.
|
||||
s.accept.Lock()
|
||||
s.wg.Wait()
|
||||
s.accept.Unlock()
|
||||
_ = os.Remove(s.path)
|
||||
return err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user