Skip to content

Commit a18d822

Browse files
Pigbibicodex
andcommitted
fix: retain remediation state across retries
Co-Authored-By: Codex <noreply@openai.com>
1 parent a1198ec commit a18d822

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

scripts/run_codex_pr_review.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -287,6 +287,11 @@ def fetch_pr_diff(token: str, repo: str, pr_number: int) -> str:
287287

288288
def fetch_compare_diff(token: str, repo: str, base_sha: str, head_sha: str) -> str:
289289
"""Fetch only the remediation delta between two trusted reviewed heads."""
290+
comparison = github_request(
291+
token, "GET", f"/repos/{repo}/compare/{base_sha}...{head_sha}"
292+
)
293+
if not isinstance(comparison, dict) or comparison.get("status") != "ahead":
294+
raise ReviewError("remediation head is not a strict descendant of the trusted reviewed head")
290295
compare_url = (
291296
f"{API_BASE}/repos/{repo}/compare/"
292297
f"{urllib.parse.quote(base_sha, safe='')}...{urllib.parse.quote(head_sha, safe='')}"
@@ -2185,7 +2190,7 @@ def main() -> int:
21852190
current_head_sha=current_head_sha,
21862191
reviewed_head_sha=current_head_sha,
21872192
finding_history_marker=build_finding_history_marker(
2188-
finding_history, [], current_head_sha
2193+
finding_history, [], ""
21892194
),
21902195
)
21912196

@@ -2301,7 +2306,7 @@ def main() -> int:
23012306
reviewed_head_sha=previous_head_sha,
23022307
new_head=True,
23032308
finding_history_marker=build_finding_history_marker(
2304-
finding_history, [], current_head_sha
2309+
finding_history, [], ""
23052310
),
23062311
)
23072312
print(

0 commit comments

Comments
 (0)