code wiki / (root) / nx_audit_dashboard_test.nx

nx_audit_dashboard_test.nx source

↩ module page · 59 lines · 2372 B

1// nx_audit_dashboard_test.nx -- smoke for nx_audit_dashboard. 2 3import "nx_syscalls.nx" 4import "nx_audit_dashboard.nx" 5 6func main() -> i64 { 7 let s: *NxAuditDashboardSnapshot = nx_audit_dashboard_snapshot_new() 8 if s.captured_us != 0 { return 1 } 9 10 // Idle snapshot: no attention needed 11 if nx_audit_dashboard_attention_needed(s) != 0 { return 2 } 12 if nx_audit_dashboard_alert_score_q10(s) != 0 { return 3 } 13 14 // Populate moderate activity 15 nx_audit_dashboard_set_capture_ts(s, 1000) 16 nx_audit_dashboard_set_hunt(s, 3, 5) 17 nx_audit_dashboard_set_gather(s, 7, 1500) 18 nx_audit_dashboard_set_xeno(s, 2) 19 if s.hunt_active_count != 3 { return 4 } 20 if s.hunt_kill_count != 5 { return 5 } 21 if s.gather_field_count != 7 { return 6 } 22 if s.gather_total_yield_ms != 1500 { return 7 } 23 if s.xeno_evidence_count != 2 { return 8 } 24 25 // No alerts yet -> still no attention needed 26 if nx_audit_dashboard_attention_needed(s) != 0 { return 9 } 27 28 // Add a book alert -> attention now needed 29 nx_audit_dashboard_set_book_alerts(s, 1) 30 if nx_audit_dashboard_attention_needed(s) != 1 { return 10 } 31 let score1: nx_int = nx_audit_dashboard_alert_score_q10(s) 32 if score1 < 256 { return 11 } // book alert contributes 256 33 34 // Add a scam flag + treaty breach + twin-key pending 35 nx_audit_dashboard_set_scam(s, 1) 36 nx_audit_dashboard_set_treaty_breaches(s, 1) 37 nx_audit_dashboard_set_twin_key_pending(s, 1) 38 let score2: nx_int = nx_audit_dashboard_alert_score_q10(s) 39 if score2 < score1 { return 12 } // strictly higher 40 41 // Colony compromised -> high score 42 nx_audit_dashboard_set_colony(s, 3) // NX_COL_COMPROMISED 43 let score3: nx_int = nx_audit_dashboard_alert_score_q10(s) 44 if score3 < 700 { return 13 } 45 if score3 > 1024 { return 14 } // capped 46 47 // Host pressure also raises score 48 nx_audit_dashboard_set_pressure(s, 950, 950) 49 if nx_audit_dashboard_attention_needed(s) != 1 { return 15 } 50 51 // Fresh snapshot: idle baseline returns 52 let s2: *NxAuditDashboardSnapshot = nx_audit_dashboard_snapshot_new() 53 nx_audit_dashboard_set_colony(s2, 0) // HEALTHY 54 nx_audit_dashboard_set_pressure(s2, 400, 400) 55 if nx_audit_dashboard_attention_needed(s2) != 0 { return 16 } 56 if nx_audit_dashboard_alert_score_q10(s2) != 0 { return 17 } 57 58 return 0 59}