File size: 2,721 Bytes
a2ae9c3
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
"""
Task definitions for the Code Review environment.
3 tasks with progressive difficulty: easy → medium → hard
Each task covers a distinct bug category: syntax, logic, performance.
"""

TASKS = [
    {
        "id": 1,
        "difficulty": "easy",
        "language": "javascript",
        "category": "syntax",
        "title": "Missing Closing Parenthesis",
        "description": (
            "This function has a syntax error in its parameter list. "
            "It will throw a SyntaxError and cannot be parsed by any JS engine."
        ),
        "code": (
            "function add(a, b {\n"
            "  return a + b;\n"
            "}"
        ),
        # Agent must mention at least one of these in its identify response
        "identify_keywords": [
            "parenthesis", "paren", "syntax", "missing", "closing", "parameter", "("
        ],
        # Exact expected fix — normalized during grading
        "fixed_code": (
            "function add(a, b) {\n"
            "  return a + b;\n"
            "}"
        ),
    },
    {
        "id": 2,
        "difficulty": "medium",
        "language": "javascript",
        "category": "logic",
        "title": "Wrong Even/Odd Condition",
        "description": (
            "This function claims to check if a number is even, but the condition "
            "is inverted — it returns true for odd numbers instead."
        ),
        "code": (
            "function isEven(n) {\n"
            "  return n % 2 === 1;\n"
            "}"
        ),
        "identify_keywords": [
            "logic", "wrong", "condition", "odd", "even",
            "remainder", "modulo", "===", "inverted", "incorrect"
        ],
        "fixed_code": (
            "function isEven(n) {\n"
            "  return n % 2 === 0;\n"
            "}"
        ),
    },
    {
        "id": 3,
        "difficulty": "hard",
        "language": "javascript",
        "category": "performance",
        "title": "Inefficient Array Iteration",
        "description": (
            "This loop re-evaluates arr.length on every iteration and uses verbose "
            "index-based access. A modern functional approach is cleaner and avoids "
            "repeated property lookups."
        ),
        "code": (
            "for (let i = 0; i < arr.length; i++) {\n"
            "  console.log(arr[i]);\n"
            "}"
        ),
        "identify_keywords": [
            "performance", "optimize", "foreach", "for...of", "functional",
            "length", "iteration", "inefficient", "modern", "repeated", "lookup"
        ],
        "fixed_code": (
            "arr.forEach(item => {\n"
            "  console.log(item);\n"
            "});"
        ),
    },
]