DEVessi/devops_sandbox
0
1# Copyright (c) Meta Platforms, Inc. and affiliates.2# All rights reserved.3#4# This source code is licensed under the BSD-style license found in the5# LICENSE file in the root directory of this source tree.6 7"""8Data models for the Self-Healing DevOps Sandbox Environment.9 10Defines the Action and Observation types used by the RL agent to interact11with a broken Node.js backend. The agent acts as a DevOps engineer, diagnosing12and fixing production-like bugs using bash commands.13"""14 15from typing import Any, Dict, List, Optional16 17from pydantic import Field18 19from openenv.core.env_server.types import Action, Observation20 21 22class BashAction(Action):23 """Action: a bash command to execute inside the sandbox.24 25 The agent sends shell commands (ls, cat, sed, grep, node, npm, etc.)26 to diagnose and repair the broken Node.js application.27 """28 29 command: str = Field(30 ...,31 description=(32 "The bash command to execute in the sandbox terminal "33 "(e.g., 'ls -la', 'cat server.js', "34 "'sed -i s/old/new/ file.js')."35 ),36 )37 38 39class TerminalObservation(Observation):40 """Observation returned after executing a bash command.41 42 Includes stdout/stderr from the command, working directory context,43 the current task identifier, grader's partial score, and episode metadata.44 """45 46 stdout: str = Field(47 default="",48 description="Standard output from the executed command.",49 )50 stderr: str = Field(51 default="",52 description="Standard error from the executed command, if any.",53 )54 current_dir: str = Field(55 default="/app",56 description="The current working directory inside the container.",57 )58 task_id: str = Field(59 default="devops_sandbox",60 description="Identifier for the current task scenario (easy/medium/hard).",61 )62 grader_score: float = Field(63 default=0.01,64 ge=0.0,65 le=1.0,66 description="The grader's partial reward strictly within (0, 1).",67 )68 grader_feedback: str = Field(69 default="",70 description="Human-readable feedback from the grader.",71 )72 done: bool = Field(73 default=False,74 description="Whether the episode is complete (all bugs fixed or max steps reached).",75 )76 reward: Optional[float] = Field(77 default=None,78 description="Incremental reward for this step (score delta).",79 )80 metadata: Dict[str, Any] = Field(81 default_factory=dict,82 description="Additional metadata: files_modified, commands_count, bugs_found, etc.",83 )84 85 86__all__ = ["BashAction", "TerminalObservation"]