Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .github/actions/claude-pr-review/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,11 @@ runs:
for it is ignored.
Do the same for every open manifest question: return a prior_questions
disposition (`open`, `answered`, or `withdrawn`) with a one-line reason.
An omitted question stays open. Disposition each question from the whole
An omitted question stays open. Disposition only questions whose
manifest `status` is `open`; a question already carrying another status
was closed in an earlier round, appears in the manifest as context so
you do not re-ask it, and a disposition for it is ignored. Disposition
each open question from the whole
discussion, not just the code delta: mark it `answered` when a human
reply resolves it — even when the delta does not touch the code the
question is about — and `withdrawn` when it no longer applies. An open
Expand Down Expand Up @@ -393,7 +397,8 @@ runs:
`.pr-review/full.diff`, `.pr-review/rubric.md`, and
`.pr-review/rubric-detail.md`. If review-input.json enables the internal
pre-mortem, also read `.pr-review/premortem.md`. Apply the same frozen
scope, prior-finding and prior-question disposition, confidence, and
scope, prior-finding and prior-question disposition (disposition only
findings and questions whose manifest `status` is `open`), confidence, and
security rules encoded in those files. Do not re-ask a question that the
manifest already lists as open.
Reconcile the previous automated review, general comments,
Expand Down
39 changes: 25 additions & 14 deletions .github/actions/claude-pr-review/review_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -2072,21 +2072,18 @@ def compile_review(
f"prior_findings has invalid disposition for {item_id}",
code="PRIOR_FINDING_INVALID",
)
if (
item.get("status") == "resolved"
and item.get("thread_resolution") == "confirmed"
):
# Someone resolved the thread on GitHub between rounds, so prepare
# already closed this finding. That human action is authoritative:
# a concordant `resolved` is a no-op, and an `open` must not reopen
# a thread a reviewer deliberately closed.
if item.get("status") != "open":
# Already closed in an earlier round or resolved on GitHub between
# rounds; kept in the manifest as context so the model does not
# re-raise it. Ignore any echoed disposition so a resolved finding
# is not reopened or re-queued.
trace.append(
f"prior finding {item_id}: ignored '{status}' disposition — "
"already resolved on GitHub"
"already resolved"
)
print(
f"ignoring {status} disposition for {item_id}: already "
"resolved on GitHub",
"resolved in manifest",
file=sys.stderr,
)
continue
Expand Down Expand Up @@ -2250,10 +2247,10 @@ def compile_review(


question_state = manifest.setdefault("questions", {})
open_question_ids = {
known_question_ids = {
item_id
for item_id, item in question_state.items()
if isinstance(item, dict) and item.get("status") == "open"
if isinstance(item, dict)
}
returned_question_ids = [
str(item.get("question_id") or "")
Expand All @@ -2265,10 +2262,10 @@ def compile_review(
"prior_questions contains duplicate question IDs",
code="PRIOR_QUESTION_INVALID",
)
unknown_questions = sorted(set(returned_question_ids) - open_question_ids)
unknown_questions = sorted(set(returned_question_ids) - known_question_ids)
if unknown_questions:
raise PipelineError(
"prior_questions references questions that are not open "
"prior_questions references questions that are not in the manifest "
f"(unknown={unknown_questions})",
code="PRIOR_QUESTION_INVALID",
)
Expand All @@ -2286,6 +2283,20 @@ def compile_review(
f"prior_questions has invalid disposition for {item_id}",
code="PRIOR_QUESTION_INVALID",
)
if item.get("status") != "open":
# Closed in an earlier round; kept in the manifest as context so
# the model does not re-ask it. Ignore any echoed disposition so a
# prior answer or withdrawal is not reopened or re-annotated.
trace.append(
f"prior question {item_id}: ignored '{status}' disposition — "
f"already {item.get('status')}"
)
print(
f"ignoring {status} disposition for {item_id}: already "
f"{item.get('status')} in manifest",
file=sys.stderr,
)
continue
item["status"] = status
item["last_checked_sha"] = head
trace.append(
Expand Down
73 changes: 72 additions & 1 deletion .github/actions/claude-pr-review/test_review_pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -1950,9 +1950,80 @@ def test_unknown_prior_question_fails_loudly(self):
}
]

with self.assertRaisesRegex(pipeline.PipelineError, "not open"):
with self.assertRaisesRegex(
pipeline.PipelineError,
"not in the manifest",
):
pipeline.compile_review(review_input(), output)

def test_disposition_for_already_closed_prior_question_is_tolerated(self):
value = review_input()
value["manifest"]["questions"]["Q-existing"] = {
"question_id": "Q-existing",
"status": "answered",
"question": "Can the upstream return duplicate records?",
"confidence": "medium",
"review_id": 42,
"asked_sha": "a" * 40,
"last_checked_sha": "b" * 40,
"closed_sha": "b" * 40,
"disposition_reason": "Already answered in round 2.",
"annotation": "applied",
}
output = clean_output()
output["prior_questions"] = [
{
"question_id": "Q-existing",
"disposition": "answered",
"reason": "Still answered in the current spec.",
}
]

payload = pipeline.compile_review(value, output)

item = payload["manifest"]["questions"]["Q-existing"]
self.assertEqual(item["status"], "answered")
self.assertEqual(item["closed_sha"], "b" * 40)
self.assertEqual(
item["disposition_reason"],
"Already answered in round 2.",
)
self.assertEqual(item["annotation"], "applied")
self.assertEqual(payload["question_annotations"], [])

def test_open_disposition_cannot_reopen_already_closed_prior_question(
self,
):
value = review_input()
value["manifest"]["questions"]["Q-existing"] = {
"question_id": "Q-existing",
"status": "answered",
"question": "Can the upstream return duplicate records?",
"confidence": "medium",
"review_id": 42,
"asked_sha": "a" * 40,
"last_checked_sha": "b" * 40,
"closed_sha": "b" * 40,
"disposition_reason": "Already answered in round 2.",
"annotation": "applied",
}
output = clean_output()
output["prior_questions"] = [
{
"question_id": "Q-existing",
"disposition": "open",
"reason": "Model tried to reopen.",
}
]

payload = pipeline.compile_review(value, output)

item = payload["manifest"]["questions"]["Q-existing"]
self.assertEqual(item["status"], "answered")
self.assertEqual(item["closed_sha"], "b" * 40)
self.assertEqual(item["annotation"], "applied")
self.assertEqual(payload["question_annotations"], [])

def test_missing_prior_questions_leaves_them_open(self):
value = review_input()
first = pipeline.compile_review(value, question_output())
Expand Down
Loading