Review syntax after model without typo whitelist
myfileagent-python-ci/pipeline/head This commit looks good
Final project review (live) / review (push) Successful in 53s

This commit is contained in:
Codex Agent
2026-11-28 22:26:14 +00:00
parent 1d20412bd6
commit 0bffbdf4bd
19 changed files with 222 additions and 261 deletions
+10 -6
View File
@@ -97,14 +97,18 @@ def review(input_path, source_commit, out_dir, propose=backend):
candidate = response.get("candidate")
if type(candidate) is not str:
raise ValueError("backend candidate must be text")
expected = {"print(\"hello\"": "print(\"hello\")",
"print(\"hello\"\n": "print(\"hello\")\n"}
if source not in expected or candidate != expected[source]:
metadata.update(status="rejected", summary="Proposal exceeds the permitted closing-parenthesis repair")
try:
parsed = ast.parse(candidate)
except SyntaxError:
parsed = None
safe_program = ast.parse('print("hello")')
if (parsed is None or
ast.dump(parsed, include_attributes=False) != ast.dump(safe_program, include_attributes=False)
or candidate.endswith("\n") != source.endswith("\n")):
metadata.update(status="rejected", summary="Proposal changes the demo behavior or adds code")
code = 2
else:
ast.parse(candidate)
metadata.update(status="corrected", summary="Added the missing closing parenthesis",
metadata.update(status="corrected", summary="Model proposed runnable hello program",
diff="".join(difflib.unified_diff(source.splitlines(keepends=True),
candidate.splitlines(keepends=True), fromfile="original.py", tofile="reviewed.py")))
code = 0