File size: 2,102 Bytes
bc5030f
 
 
 
 
 
e7eb0fa
bc5030f
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: ACRE
version: "1.0.0"
description: >
  Autonomous Code Refactoring Environment - an RL environment where an
  agent improves Python code quality using AST-level transformations.
author: "Nikhil Pratap Singh, Pranav Mangal, Ananya Gupta"
entrypoint: "server.app:app"
tags:
  - openenv

tasks:
  - id: rename_variables
    name: "Rename Variables (Easy)"
    description: "Rename generic variable names (x, tmp) to descriptive ones"
    difficulty: easy
    reward_range: [0.0, 1.0]
    max_steps: 5

  - id: remove_dead_code
    name: "Remove Dead Code (Medium)"
    description: "Remove unreachable statements, if-False blocks, and unused assignments"
    difficulty: medium
    reward_range: [0.0, 1.0]
    max_steps: 5

  - id: full_refactor
    name: "Full Refactor (Hard)"
    description: "Apply all transformations - rename, dead code removal, loop simplification, condition optimization, and function inlining"
    difficulty: hard
    reward_range: [0.0, 1.0]
    max_steps: 5

observation_space:
  type: Box
  shape: [4]
  dtype: float32
  low: [0.0, 0.0, 0.0, 0.0]
  high: [inf, inf, inf, 1.0]
  fields:
    - code_length
    - complexity_score
    - runtime_s
    - error_flag

action_space:
  type: Discrete
  n: 5
  actions:
    0: rename_variable
    1: remove_dead_code
    2: simplify_loop
    3: optimize_condition
    4: inline_function

api:
  health: "GET /"
  reset: "POST /reset"
  step: "POST /step"
  state: "GET /state"
  tasks: "GET /tasks"
  grade: "POST /tasks/{task_id}/grade"

reward:
  raw_range: [-32, 20]
  normalized_range: [0.0, 1.0]
  formula: "(raw + 32) / 52"
  components:
    success: { max: 10, min: -10 }
    complexity: { max: 5, min: -5 }
    performance: { max: 5, min: -2 }
    error: { max: 0, min: -15 }
    no_change: { max: 0, min: -2 }

validation:
  python_api:
    reset: "ObservationModel"
    step: "(ObservationModel, RewardModel, done, info)"
    state: "StateResponse"
  http_api:
    health: "GET /"
    reset: "POST /reset"
    step: "POST /step"
    state: "GET /state"
    tasks: "GET /tasks"
    grade: "POST /tasks/{task_id}/grade"