File size: 1,577 Bytes
e287d32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from pydantic import BaseModel, Field
from typing import Dict, Any


class Observation(BaseModel):
    cpu_usage_percent: float = Field(
        ...,
        description="Current CPU load of the IoT gateway (0.0 to 100.0).",
    )
    packet_rate_pps: float = Field(
        ...,
        description="Incoming packets per second observed at the network interface.",
    )
    active_connections: int = Field(
        ...,
        description="Number of concurrent TCP connections to the device.",
    )
    bandwidth_mbps: float = Field(
        ...,
        description="Current bandwidth consumption in megabits per second.",
    )
    memory_usage_percent: float = Field(
        ...,
        description="Device memory utilization (0.0 to 100.0).",
    )
    system_health: float = Field(
        ...,
        description="Cumulative system integrity score (0.0 to 100.0). "
        "Degrades under sustained unmitigated attacks.",
    )


class Action(BaseModel):
    decision: str = Field(
        ...,
        description="The mitigation action to apply. "
        "Must be one of: 'monitor', 'rate_limit', or 'block'.",
    )


class StepResponse(BaseModel):
    observation: Observation
    reward: float = Field(
        ...,
        description="Reward score for the agent's action (strictly 0.0 to 1.0).",
    )
    done: bool = Field(
        ...,
        description="Whether the episode has terminated.",
    )
    info: Dict[str, Any] = Field(
        default_factory=dict,
        description="Diagnostic metadata: attack phase, severity, health, etc.",
    )