mirror of
https://github.com/NoFxAiOS/nofx.git
synced 2026-07-14 00:07:01 +08:00
fix(agent): address critical issues from PR #1485 review
1. Prevent double-close panic on Stop() by using sync.Once in Scheduler, Brain, and Sentinel; remove duplicate Stop() call in main.go 2. Add trade quantity (100k) and leverage (125x) sanity caps to prevent LLM hallucinations or input errors from reaching the exchange 3. Mask secrets in onboarding setup state — only store "****" markers in SystemConfig instead of plaintext API keys/secrets Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ type Brain struct {
|
||||
logger *slog.Logger
|
||||
http *http.Client
|
||||
stopCh chan struct{}
|
||||
stopOnce sync.Once
|
||||
recentSignals sync.Map // debounce
|
||||
}
|
||||
|
||||
@@ -29,7 +30,7 @@ func NewBrain(agent *Agent, logger *slog.Logger) *Brain {
|
||||
}
|
||||
}
|
||||
|
||||
func (b *Brain) Stop() { close(b.stopCh) }
|
||||
func (b *Brain) Stop() { b.stopOnce.Do(func() { close(b.stopCh) }) }
|
||||
|
||||
// cleanStaleSignals removes debounce entries older than 30 minutes.
|
||||
func (b *Brain) cleanStaleSignals() {
|
||||
|
||||
Reference in New Issue
Block a user