Test fixture
Code transformation while preserving behavior and intent.
The model receives the prompt (and optional system message). The run uses scorer rubric_json_metrics with the JSON configuration below. Pass/fail and partial credit are determined entirely by that scorer against the model output; no human grading.
Return JSON only with keys refactor, rationale, tests. Refactor a function with four levels of nested if/else blocks by applying early returns (guard clauses) for each validation failure at the top of the function. The success path must remain at the outermost level with no indentation change to its logic.
{
"metrics": {
"visible": {
"checks": [
{
"contains": [
"early return"
]
},
{
"contains": [
"guard clause"
]
},
{
"contains": [
"flat structure"
]
}
]
},
"hidden": {
"checks": [
{
"contains": [
"all validations preserved"
]
},
{
"contains": [
"same error messages"
]
},
{
"contains": [
"success path unchanged"
]
}
]
},
"intent": {
"checks": [
{
"contains": [
"reduce nesting"
]
},
{
"contains": [
"readability"
]
},
{
"contains": [
"control flow clarity"
]
}
]
}
}
}temperature
0
max_tokens
460
timeout (s)
120
type
scored
file
refactor-early-return-nesting.json