File size: 2,105 Bytes
b29893e
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
56
57
58
59
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.

"""
Data models for the PostMortem incident-triage environment.

An agent plays an on-call SRE responding to a live incident. It queries fake
telemetry (logs / metrics / traces), scopes blast radius, hypothesises a root
cause, applies a mitigation, and writes a status-page update. The reward is a
5-stage process-reward ladder in [0, 1].
"""

from typing import Any, Dict, List

from openenv.core.env_server.types import Action, Observation
from pydantic import Field


class PostmortemAction(Action):
    """
    Single action envelope. `tool` selects an investigation / response verb,
    `args` is a tool-specific dict.

    Supported tools:
      - "ack"              args: {}
      - "query_logs"       args: {"service": str}
      - "query_metrics"    args: {"service": str}
      - "query_traces"     args: {"trace_id": str}
      - "scope"            args: {"services": list[str]}
      - "hypothesize"      args: {"root_cause": str}
      - "mitigate"         args: {"action": str}
      - "write_status"     args: {"text": str}
    """

    tool: str = Field(..., description="Investigation/response verb")
    args: Dict[str, Any] = Field(default_factory=dict, description="Tool args")


class PostmortemObservation(Observation):
    """Observation returned after each step."""

    task_id: str = Field(default="", description="Current scenario id")
    task_description: str = Field(default="", description="Incident brief")
    available_services: List[str] = Field(default_factory=list)
    available_trace_ids: List[str] = Field(default_factory=list)
    tool_result: str = Field(default="", description="Result from the last tool call")
    subgoals: Dict[str, bool] = Field(
        default_factory=lambda: {
            "acked": False,
            "scoped": False,
            "hypothesized": False,
            "mitigated": False,
            "written": False,
        }
    )
    reward_so_far: float = Field(default=0.0)
    steps_remaining: int = Field(default=0)
    last_error: str = Field(default="")