File size: 1,674 Bytes
9763ffa
 
 
 
 
 
 
 
 
 
090dc69
9763ffa
090dc69
9763ffa
 
 
 
 
7bc8744
9763ffa
 
 
 
 
 
e96c0d4
9763ffa
 
090dc69
 
 
 
 
 
 
 
 
 
 
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
# Copyright (c) Meta Platforms, Inc. and affiliates.
# All rights reserved.
#
# This source code is licensed under the BSD-style license found in the
# LICENSE file in the root directory of this source tree.

"""
Data models for the Rust Coder Environment.
"""

from typing import Any, Dict, List
from openenv.core.env_server.types import Action, Observation
from pydantic import BaseModel, Field


class RustCoderAction(Action):
    """Action for the Rust Coder environment - contains the Rust code to evaluate."""

    code: str = Field(default="", description="Rust source code to compile and run")


class RustCoderObservation(Observation):
    """Observation space for the Rust Coder environment."""

    problem_description: str = Field(default="", description="The text description of the current coding task, including requirements.")
    header_section: str = Field(default="", description="LeetCode-style header/scaffold (imports + signatures/types) for deterministic evaluation.")
    compilation_success: bool = Field(default=False, description="Binary flag indicating if the last submission compiled.")
    compilation_output: str = Field(default="", description="Raw stdout/stderr from the rustc compiler.")
    test_results: List[Dict] = Field(default_factory=list, description="A list of results from automated test assertions.")
    reward_breakdown: Dict = Field(default_factory=dict, description="Detailed components of the 0.0-1.0 reward.")


class TaskInfo(BaseModel):
    """Metadata for a single task exposed via GET /tasks."""

    task_id: str
    difficulty: str
    description: str
    action_schema: Dict[str, Any] = Field(default_factory=dict)