Codex changes
Co-authored-by: Codex
This commit is contained in:
parent
a82db56ab6
commit
aa0e651130
5 changed files with 431 additions and 243 deletions
17
services/compute/src/alert-scoring.ts
Normal file
17
services/compute/src/alert-scoring.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
import type { ClassifierHitEvent, FlowPacket } from "@islandflow/types";
|
||||
|
||||
export const scoreAlert = (
|
||||
packet: FlowPacket,
|
||||
hits: ClassifierHitEvent[]
|
||||
): { score: number; severity: string } => {
|
||||
const premium =
|
||||
typeof packet.features.total_premium === "number" ? packet.features.total_premium : 0;
|
||||
const premiumScore = Math.min(70, Math.round(premium / 1000));
|
||||
const maxConfidence = hits.reduce((max, hit) => Math.max(max, hit.confidence), 0);
|
||||
const confidenceScore = Math.round(maxConfidence * 20);
|
||||
const hitScore = Math.min(20, hits.length * 5);
|
||||
const score = Math.max(0, Math.min(100, premiumScore + confidenceScore + hitScore));
|
||||
const severity = score >= 80 ? "high" : score >= 45 ? "medium" : "low";
|
||||
return { score, severity };
|
||||
};
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue