Dolphin-Syndrom commited on
Commit
708fe21
·
1 Parent(s): e708130

model taxonomy

Browse files
Files changed (1) hide show
  1. models.py +84 -10
models.py CHANGED
@@ -5,23 +5,97 @@
5
  # LICENSE file in the root directory of this source tree.
6
 
7
  """
8
- Data models for the Code Review Env Environment.
9
 
10
- The code_review_env environment is a simple test environment that echoes back messages.
11
  """
12
 
13
- from openenv.core.env_server.types import Action, Observation
 
 
14
  from pydantic import Field
15
 
16
 
17
- class CodeReviewAction(Action):
18
- """Action for the Code Review Env environment - just a message to echo."""
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19
 
20
- message: str = Field(..., description="Message to echo back")
 
21
 
 
 
 
 
 
 
 
 
22
 
23
- class CodeReviewObservation(Observation):
24
- """Observation from the Code Review Env environment - the echoed message."""
25
 
26
- echoed_message: str = Field(default="", description="The echoed message")
27
- message_length: int = Field(default=0, description="Length of the echoed message")
 
 
 
5
  # LICENSE file in the root directory of this source tree.
6
 
7
  """
8
+ Typed models for the Code Review environment.
9
 
10
+ These models define the contract between the agent/client and server.
11
  """
12
 
13
+ from typing import Literal
14
+
15
+ from openenv.core.env_server.types import Action, Observation, State
16
  from pydantic import Field
17
 
18
 
19
+ ISSUE_TAXONOMY = [
20
+ "null_pointer",
21
+ "missing_return",
22
+ "type_error",
23
+ "index_out_of_bounds",
24
+ "sql_injection",
25
+ "hardcoded_secret",
26
+ "missing_input_validation",
27
+ "race_condition",
28
+ "timing_attack",
29
+ "improper_error_handling",
30
+ "integer_overflow",
31
+ "path_traversal",
32
+ ]
33
+
34
+
35
+ class ReviewAction(Action):
36
+ """Action submitted by the agent after reviewing a code snippet."""
37
+
38
+ review_comment: str = Field(
39
+ ...,
40
+ description="Human-readable review explaining identified issues and suggested fixes.",
41
+ )
42
+ issues_found: list[str] = Field(
43
+ default_factory=list,
44
+ description="List of issue tags found by the agent, chosen from ISSUE_TAXONOMY.",
45
+ )
46
+ severity: Literal["low", "medium", "high", "critical"] = Field(
47
+ default="medium",
48
+ description="Overall severity level assessed by the agent for this review.",
49
+ )
50
+
51
+
52
+ class ReviewObservation(Observation):
53
+ """Observation returned by the environment before/after a review step."""
54
+
55
+ task_id: str = Field(
56
+ default="task_easy",
57
+ description="Current task identifier such as task_easy, task_medium, or task_hard.",
58
+ )
59
+ file_name: str = Field(
60
+ default="",
61
+ description="File name associated with the code snippet under review.",
62
+ )
63
+ task_description: str = Field(
64
+ default="",
65
+ description="Instructions describing what the agent should review and return.",
66
+ )
67
+ code_snippet: str = Field(
68
+ default="",
69
+ description="Python code snippet containing planted issues for review.",
70
+ )
71
+ feedback: str = Field(
72
+ default="",
73
+ description="Grading feedback for the most recent action or startup guidance after reset.",
74
+ )
75
+ step_number: int = Field(
76
+ default=0,
77
+ description="Current step number within the episode (starts at 0 right after reset).",
78
+ )
79
+ available_issue_tags: list[str] = Field(
80
+ default_factory=lambda: ISSUE_TAXONOMY.copy(),
81
+ description="Allowed issue tags that the agent can use in issues_found.",
82
+ )
83
+
84
 
85
+ class ReviewState(State):
86
+ """Episode-level internal state for the environment."""
87
 
88
+ current_task_id: str = Field(
89
+ default="task_easy",
90
+ description="Task currently loaded in the episode.",
91
+ )
92
+ max_steps: int = Field(
93
+ default=3,
94
+ description="Maximum number of review attempts allowed in one episode.",
95
+ )
96
 
 
 
97
 
98
+ # Backward-compatible aliases while migrating scaffolded files.
99
+ CodeReviewAction = ReviewAction
100
+ CodeReviewObservation = ReviewObservation
101
+ CodeReviewState = ReviewState