antony647 commited on
Commit
e287d32
·
verified ·
1 Parent(s): f8b35ca

Upload models.py

Browse files
Files changed (1) hide show
  1. server/models.py +54 -0
server/models.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from pydantic import BaseModel, Field
2
+ from typing import Dict, Any
3
+
4
+
5
+ class Observation(BaseModel):
6
+ cpu_usage_percent: float = Field(
7
+ ...,
8
+ description="Current CPU load of the IoT gateway (0.0 to 100.0).",
9
+ )
10
+ packet_rate_pps: float = Field(
11
+ ...,
12
+ description="Incoming packets per second observed at the network interface.",
13
+ )
14
+ active_connections: int = Field(
15
+ ...,
16
+ description="Number of concurrent TCP connections to the device.",
17
+ )
18
+ bandwidth_mbps: float = Field(
19
+ ...,
20
+ description="Current bandwidth consumption in megabits per second.",
21
+ )
22
+ memory_usage_percent: float = Field(
23
+ ...,
24
+ description="Device memory utilization (0.0 to 100.0).",
25
+ )
26
+ system_health: float = Field(
27
+ ...,
28
+ description="Cumulative system integrity score (0.0 to 100.0). "
29
+ "Degrades under sustained unmitigated attacks.",
30
+ )
31
+
32
+
33
+ class Action(BaseModel):
34
+ decision: str = Field(
35
+ ...,
36
+ description="The mitigation action to apply. "
37
+ "Must be one of: 'monitor', 'rate_limit', or 'block'.",
38
+ )
39
+
40
+
41
+ class StepResponse(BaseModel):
42
+ observation: Observation
43
+ reward: float = Field(
44
+ ...,
45
+ description="Reward score for the agent's action (strictly 0.0 to 1.0).",
46
+ )
47
+ done: bool = Field(
48
+ ...,
49
+ description="Whether the episode has terminated.",
50
+ )
51
+ info: Dict[str, Any] = Field(
52
+ default_factory=dict,
53
+ description="Diagnostic metadata: attack phase, severity, health, etc.",
54
+ )