Add scout constellation mode for APK venue persona packs.
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
Cluster 3+ scout_report hits on the same SSID within 10 minutes; server infers airport/campus/retail venue class and pushes persona spread_policy. Emberwake weather-map merges active scout biomes. Includes agent, server API, and Vitest coverage.
This commit is contained in:
@@ -163,6 +163,98 @@ func TestSchedulerStuckHostTriggersL4Elevation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
type mockSurgicalTrace struct {
|
||||
trace SurgicalTraceContext
|
||||
ok bool
|
||||
}
|
||||
|
||||
func (m *mockSurgicalTrace) TraceForAgent(string) (SurgicalTraceContext, bool) {
|
||||
return m.trace, m.ok
|
||||
}
|
||||
|
||||
type mockStrainStore struct {
|
||||
mu sync.Mutex
|
||||
rows []string
|
||||
}
|
||||
|
||||
func (m *mockStrainStore) InsertStrainMemory(agentID, sessionID, failedTier, strain, fixType, fixArgs, outcome string) error {
|
||||
m.mu.Lock()
|
||||
m.rows = append(m.rows, agentID+":"+fixType+":"+outcome)
|
||||
m.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
type mockSeer struct {
|
||||
mu sync.Mutex
|
||||
events []string
|
||||
}
|
||||
|
||||
func (m *mockSeer) EmitSeerEvent(eventType, agentID string, payload map[string]interface{}) error {
|
||||
m.mu.Lock()
|
||||
m.events = append(m.events, eventType+":"+agentID)
|
||||
m.mu.Unlock()
|
||||
return nil
|
||||
}
|
||||
|
||||
func TestSchedulerSurgicalReplayDispatchesOneCommand(t *testing.T) {
|
||||
old := DecideFunc
|
||||
defer func() { DecideFunc = old }()
|
||||
DecideFunc = func(_ context.Context, _, _, _, _ string) (string, error) {
|
||||
return `Rationale: skip broken docker tier.
|
||||
{"commands":[{"type":"skip_tier","args":{"tier":"docker"}}]}`, nil
|
||||
}
|
||||
|
||||
exec := &mockExec{}
|
||||
store := &mockStore{}
|
||||
strain := &mockStrainStore{}
|
||||
seer := &mockSeer{}
|
||||
sched := NewScheduler(
|
||||
&mockCfg{cfg: Config{Enabled: true, Endpoint: "http://test/v1", IntervalSec: 1}},
|
||||
&mockSnap{
|
||||
ids: []string{"surg-1"},
|
||||
snap: AgentSnapshot{
|
||||
AgentID: "surg-1", Name: "host",
|
||||
LOTLAttempts: []TierAttempt{
|
||||
{Tier: "vuln_recon", OK: true},
|
||||
{Tier: "docker", OK: false, Error: "daemon down"},
|
||||
},
|
||||
},
|
||||
},
|
||||
exec,
|
||||
store,
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
sched.SetSurgicalDeps(SurgicalDeps{
|
||||
Trace: &mockSurgicalTrace{
|
||||
trace: SurgicalTraceContext{SessionID: "trace-99", HopIndex: 0, HopCount: 2},
|
||||
ok: true,
|
||||
},
|
||||
Strain: strain,
|
||||
Seer: seer,
|
||||
})
|
||||
sched.lastRun["surg-1"] = time.Now().Add(-2 * time.Minute)
|
||||
sched.Tick()
|
||||
|
||||
exec.mu.Lock()
|
||||
n := len(exec.calls)
|
||||
call := exec.calls
|
||||
exec.mu.Unlock()
|
||||
if n != 1 || call[0].Type != CmdReorderTiers {
|
||||
t.Fatalf("expected single reorder_tiers dispatch, got %+v", call)
|
||||
}
|
||||
strain.mu.Lock()
|
||||
defer strain.mu.Unlock()
|
||||
if len(strain.rows) != 1 {
|
||||
t.Fatalf("strain memory: %v", strain.rows)
|
||||
}
|
||||
seer.mu.Lock()
|
||||
defer seer.mu.Unlock()
|
||||
if len(seer.events) != 1 || seer.events[0] != "surgical_replay:surg-1" {
|
||||
t.Fatalf("seer events: %v", seer.events)
|
||||
}
|
||||
}
|
||||
|
||||
func TestSchedulerCourtRetryElevatesL4(t *testing.T) {
|
||||
old := DecideFunc
|
||||
defer func() { DecideFunc = old }()
|
||||
|
||||
Reference in New Issue
Block a user