From ddaf3a00972aab163f98c7c24edcc4c4693ea70c Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Sat, 10 Oct 2026 23:00:30 -0500 Subject: [PATCH 1/3] fix(dev-lead): disposition a fixed bot issue comment and keep its sha valid across a guard rebase (#2261) On PR #2205 a fix-bot-comment pass fixed a CodeAnt finding posted as a PR issue comment and answered it like a review thread. The maintainer-comment gate reads only a comment-disposition reply, so the comment was never dispositioned, and the claim in that reply cited a commit the push guard had rebased away. - Prompt: fix-bot-comment now says, for every reviewer bot, that a finding fixed from an issue comment gets exactly one comment-disposition `fixed sha=` reply, and that the addressed-marker and the claim are for review threads only. - resolve_dispositioned_comments: a `fixed` sha that is not on the pushed head but maps through _PUSH_GUARD_REWRITES is judged by its rebased successor with the same rdc_fixed_verdict, and our reply is edited in place to cite it. An unmapped sha, a successor that is not on the head or fails the content rule, or a reply that cannot be edited stays open. - retract_unlanded_claims: also sweeps this pass's claim replies posted as PR issue comments. One is re-pointed when its commit was rebased and landed, and retracted otherwise. A comment-disposition marker in the same reply is kept. Not changed: the #2004 content rule. A fix that only adds lines, for a finding that names a token, still does not verify (the #2205 fix itself). Co-Authored-By: Claude Opus 5.5 --- .../maintainer-comment-gate.md | 4 + prompts/dev-lead/fix-bot-comment.md | 24 ++ scripts/dev-lead-fix-reviews.sh | 98 ++++- scripts/lib/claim-landing.sh | 8 +- scripts/lib/comment-disposition-verify.sh | 31 ++ tests/dev-lead/unit/test_claim_sweep.bats | 380 ++++++++++++++++++ .../unit/test_comment_disposition_verify.bats | 76 ++++ tests/dev-lead/unit/test_fix_reviews.bats | 84 ++++ 8 files changed, 694 insertions(+), 11 deletions(-) diff --git a/docs/pr-review-agent/maintainer-comment-gate.md b/docs/pr-review-agent/maintainer-comment-gate.md index 2d5052a75..1eeda778a 100644 --- a/docs/pr-review-agent/maintainer-comment-gate.md +++ b/docs/pr-review-agent/maintainer-comment-gate.md @@ -116,6 +116,10 @@ minimized with classifier `RESOLVED`. In practice: `::warning::… fixed-unverified:`. The harness then re-answers with the branch commit whose diff removes the token, when one exists. Otherwise the next pass re-answers the disposition, which is not settled. + When the push guard rebased the cited commit during the pass, that sha never + reaches the branch. The harness then judges the commit's rebased successor by + the same rules and, when it verifies, edits the reply so its marker cites the + successor (#2261). - **A maintainer clears it without dev-lead (#1910/#1918).** When dev-lead is suppressed, rate-limited, cancelled, or never dispatched, a maintainer can run [`scripts/maintainer-resolve-comment.sh`](../../scripts/maintainer-resolve-comment.sh) diff --git a/prompts/dev-lead/fix-bot-comment.md b/prompts/dev-lead/fix-bot-comment.md index 40f1e68e6..3f7a49d2a 100644 --- a/prompts/dev-lead/fix-bot-comment.md +++ b/prompts/dev-lead/fix-bot-comment.md @@ -55,6 +55,7 @@ Analyze the bot's findings and address each actionable issue: 2. Locate the referenced files and line numbers using Read/Grep/Glob tools 3. Apply targeted fixes using Edit/Write tools 4. **Reply to each fixed thread with the specific change** — the harness resolves the addressed bot threads afterward (see below); do not resolve them yourself +5. **Disposition the bot's issue comment when the finding came from one** — a review thread and a PR issue comment are answered differently; see [Fixing a finding posted as a PR issue comment](#fixing-a-finding-posted-as-a-pr-issue-comment-2261) ### Replying to threads from this bot @@ -109,6 +110,27 @@ The claim payload is schema `v1` — one comment per reply, with a full 40-char **Do not resolve the thread yourself.** You must not call the `resolveReviewThread` (or `unresolveReviewThread`) GraphQL mutation under any circumstance — resolution is done **only** by the harness (`dev-lead-fix-reviews.sh`), whose deterministic guards are the authoritative merge gate. The harness resolves every bot thread you addressed with an our-account addressed-marker reply, plus any thread from this bot marked `isOutdated: true`. Your reply and its marker are your only lever on resolution. +### Fixing a finding posted as a PR issue comment (#2261) + +Every registered reviewer bot (`scripts/lib/reviewer-sources.tsv`), not only CodeRabbit, can post a finding as a PR **issue comment** instead of a review thread: CodeAnt's `## CodeAnt Nitpicks`, a Qodo or CodeRabbit summary, a SonarCloud quality-gate comment. The comment that triggered this pass is one, and `${COMMENT_NODE_ID}` is its node id. An issue comment has **no** review thread, so nothing in *Replying to threads from this bot* applies to it. + +**The addressed-marker and the claim are for review threads only. They do not disposition an issue comment.** The maintainer-comment gate clears an issue comment only on a verified `dev-lead:comment-disposition` reply. A "Fixed in …" PR comment that ends with `` and a claim leaves the bot's comment undispositioned, the retries run out, and the PR can never be approved (PR #2205). Never put the addressed-marker or a claim in a PR comment. + +When you fix a finding from an issue comment, **commit the fix locally first**, then post **exactly one** reply on the PR. Name the file(s) you changed and how the change addresses the finding, and end the reply with **exactly one** marker: `disposition=fixed` with the full 40-char sha of that commit. + +```bash +# First run the target and already-dispositioned check under "Non-actionable bot +# notices" below: it guards every disposition, not only `informational`. +node_id='${COMMENT_NODE_ID}' +[ -n "$node_id" ] || { echo "no triggering comment node id — not dispositioning" >&2; exit 1; } +sha=$(git rev-parse HEAD) # read AFTER committing the fix +gh pr comment "${PR_NUMBER}" --repo "${REPO}" --body "Fixed in scripts/foo.sh: replaced the unpinned curl|bash install with a SHA-verified binary download. + +" +``` + +One comment gets one reply and one marker, however many findings it lists. Say how each finding was handled, and use `fixed` if you changed code for any of them. If you changed no code, end the same single reply with `answered`, `invalid` or `out-of-scope ref=#` and the reason. `informational` is only for a notice that carries no finding (see below). The harness verifies the sha against the pushed head and minimizes the bot's comment RESOLVED; do not call `minimizeComment` yourself. *Cite the commit that fixed it* below is the rule the sha must pass, and `scripts/lib/comment-disposition-verify.sh` is the normative parser. If the same bot also opened review threads, answer those in their threads with the addressed-marker and claim, and still post the one disposition reply for the comment. + ## Deferring a valid finding that is out of scope (#2045) When a thread from this bot is a real finding that does not belong in this PR, do not leave a bare skip note: that thread can never be resolved and blocks merge. Defer it to the repo's **single** `dev-lead: deferred review findings` tracking issue (never one issue per finding): @@ -230,6 +252,7 @@ Some bot comments are pure **operational notices**, not code findings: a rate-li - Do not suppress bot rules without a documented reason - Do not modify the bot's configuration files - For every thread you fix, post a reply naming the specific change, ending with the addressed-marker — never reply-less +- For a finding you fix from a PR issue comment, post exactly one reply on the PR ending with exactly one `` marker. The addressed-marker and the claim are for review threads only: they never disposition an issue comment, so never put them in a PR comment (#2261) - **Never resolve a thread yourself**: do not call the `resolveReviewThread` (or `unresolveReviewThread`) mutation. Resolution is the harness's job — it resolves the addressed and outdated threads from `${ACTOR}`; your only lever is the addressed-marker on your reply - Stay within the scope of the pull request's changed files where possible - Commit your fixes locally so your claims can cite them, but **never push**. The CI workflow pushes after you finish, verifies the push landed, and retracts any claim that did not land (#2013) @@ -242,6 +265,7 @@ After applying fixes, output a summary: Bot: ${ACTOR} Issues addressed: N - : [replied + addressed-marker] +- : [issue comment: disposition=fixed sha=] - : outdated — replied (harness resolves) Files changed: Skipped (informational): diff --git a/scripts/dev-lead-fix-reviews.sh b/scripts/dev-lead-fix-reviews.sh index a03c7c006..b0afa4bc6 100755 --- a/scripts/dev-lead-fix-reviews.sh +++ b/scripts/dev-lead-fix-reviews.sh @@ -1345,6 +1345,45 @@ rdc_find_fixing_commit() { return 1 } +# rdc_repoint_rebased_fixed +# The #2032 treatment for a `fixed` disposition (#2261). The model cites the +# commit it made BEFORE the push. When the push guard rebased that commit onto a +# concurrent one (#1607), the cited sha never reaches the branch (PR #2205), and +# rdc_find_fixing_commit cannot find a fix whose diff removes no token. So map +# the cited sha through _PUSH_GUARD_REWRITES and judge its rebased successor. +# Returns 0, with the successor in RDC_REPOINTED_SHA, only when ALL of these hold: +# - is not-on-head (any other failure is not a rebase); +# - _PUSH_GUARD_REWRITES maps to a successor (cl_map_sha); +# - the successor passes the whole rdc_fixed_verdict: on the pushed head, not +# on the base branch, its diff content, its date; +# - OUR reply was edited in place so its marker cites the successor, +# leaving no disposition on the PR that names a commit GitHub never saw. +# Anything else returns 1 and the caller's unverified path runs (fail closed). +rdc_repoint_rebased_fixed() { + local cid="$1" sha="$2" reason="$3" reply_id="$4" reply_body="$5" body="$6" created="$7" + local rebased rebased_reason new_body + RDC_REPOINTED_SHA="" + [ "$reason" = "not-on-head" ] || return 1 + rebased=$(cl_map_sha "$sha" "${_PUSH_GUARD_REWRITES:-}") || return 1 + if ! rebased_reason=$(rdc_fixed_verdict "$rebased" "$body" "$created"); then + echo "::warning::comment ${cid}: the push guard rebased the cited ${sha} to ${rebased}, which did not verify either (fixed-unverified:${rebased_reason}) (#2261)" + return 1 + fi + if ! new_body=$(cdv_rewrite_disposition_sha "$reply_body" "$cid" "$sha" "$rebased") || [ -z "$new_body" ]; then + echo "::warning::comment ${cid}: the push guard rebased the cited ${sha} to ${rebased}, but disposition reply ${reply_id} could not be rewritten to cite it; it stays open (#2261)" + return 1 + fi + if ! gh api graphql \ + -f query='mutation($id:ID!,$body:String!){updateIssueComment(input:{id:$id,body:$body}){issueComment{id}}}' \ + -f id="$reply_id" -f body="$new_body" >/dev/null 2>&1; then + echo "::warning::comment ${cid}: the push guard rebased the cited ${sha} to ${rebased}, but disposition reply ${reply_id} could not be updated to cite it; it stays open (#2261)" + return 1 + fi + RDC_REPOINTED_SHA="$rebased" + echo "::notice::comment ${cid}: \`fixed\` disposition cited ${sha}, which the push guard rebased onto a concurrent commit; it landed as ${rebased} (${rebased_reason}) — disposition reply ${reply_id} now cites the rebased commit (#2261)" + return 0 +} + # resolve_deferred_bot_threads: resolves bot-originated review threads whose finding # dev-lead judged valid but OUT OF SCOPE and deferred to a tracking issue (#2045) — # the review-thread sibling of the issue-comment `out-of-scope` disposition (#1813). @@ -1984,6 +2023,11 @@ resolve_dispositioned_comments() { if fixed_reason=$(rdc_fixed_verdict "$sha" "$orig_body" "$orig_created"); then verified="true" echo "::notice::comment ${cid}: \`fixed\` disposition verified against ${sha} (${fixed_reason}) (#2004)" + elif rdc_repoint_rebased_fixed "$cid" "$sha" "$fixed_reason" "$chosen_reply_id" "$reply_body" "$orig_body" "$orig_created"; then + # #2261: the cited commit was rebased by the push guard and its successor + # verified; our reply now cites the successor. + sha="$RDC_REPOINTED_SHA" + verified="true" else # AC2: loud and distinguishable from "dev-lead has not run yet". echo "::warning::comment ${cid}: \`fixed\` disposition citing ${sha} did not verify (fixed-unverified:${fixed_reason}); the cited commit's diff must remove what the finding names (#2004)" @@ -3288,6 +3332,8 @@ stamp_pass_replies() { # posted since PASS_START_ISO, verify its commit is one this pass produced AND is # on the REMOTE head (acv_claim_in_pass); otherwise rewrite it with # cl_retract_body, which strips both markers so it can never resolve a thread. +# Both surfaces are swept (#2261): review-thread replies, and the PR issue +# comments the model posts when it answers a bot's issue comment the same way. # # The reference head is the remote head. When there is no upstream (rc 1) on an # `ok` outcome, the local HEAD is what was pushed; in every other case — including @@ -3328,10 +3374,41 @@ retract_unlanded_claims() { echo "::warning::retract_unlanded_claims: could not parse the review comments on PR #${PR_NUMBER} — this pass's claim replies were NOT verified (#2013)" return 1 } - local rebased remapped=0 - while IFS=$'\t' read -r id sha; do + + # #2261: the model can also post its addressed/claim reply as a PR ISSUE comment + # (PR #2205: "Fixed in …" answering a bot's issue comment). That reply is not in + # the review-comment listing above, so its claim was never checked and kept + # citing a commit that was never pushed. Sweep the same selection (our account, + # since the pass start, carrying the marker or a claim) over the issue comments. + # An unreadable listing is reported as a failure: those replies were NOT + # verified. The thread replies above are still swept. + local issue_raw="" issue_comments="" issue_rows="" + if ! issue_raw=$(gh api --paginate "repos/${REPO}/issues/${PR_NUMBER}/comments?per_page=100" 2>/dev/null) \ + || ! issue_comments=$(jq -s 'add // []' <<<"$issue_raw" 2>/dev/null) \ + || ! issue_rows=$(cl_select_pass_claims "$issue_comments" "$bot_user" "$PASS_START_ISO"); then + echo "::warning::retract_unlanded_claims: could not list the issue comments on PR #${PR_NUMBER} — claim replies this pass posted as PR comments were NOT verified (#2261)" + issue_comments="" + issue_rows="" + failed=1 + fi + # One row per reply: `\t\t`. is the REST collection + # the reply lives in (pulls = review-thread reply, issues = PR issue comment), + # which is also the path segment its PATCH uses. + rows=$( + [ -z "$rows" ] || awk '{ print "pulls\t" $0 }' <<<"$rows" + [ -z "$issue_rows" ] || awk '{ print "issues\t" $0 }' <<<"$issue_rows" + ) + + local rebased remapped=0 surface listing what + while IFS=$'\t' read -r surface id sha; do [ -z "$id" ] && continue - body=$(printf '%s' "$comments" | jq -r --arg id "$id" 'first(.[] | select((.id | tostring) == $id)) | .body // ""' 2>/dev/null || echo "") + listing="$comments" + what="claim reply" + if [ "$surface" = "issues" ]; then + listing="$issue_comments" + what="PR-comment claim reply" + fi + body=$(printf '%s' "$listing" | jq -r --arg id "$id" 'first(.[] | select((.id | tostring) == $id)) | .body // ""' 2>/dev/null || echo "") if [ -z "$sha" ]; then reason="unverifiable" else @@ -3357,21 +3434,24 @@ retract_unlanded_claims() { new_body=$(cl_rewrite_claim_sha "$body" "$rebased") || new_body="" if acv_claim_in_pass "$base" "$on_ref" "$in_base" >/dev/null \ && [ -n "$new_body" ]; then - if gh api -X PATCH "repos/${REPO}/pulls/comments/${id}" -f body="$new_body" >/dev/null 2>&1; then + if gh api -X PATCH "repos/${REPO}/${surface}/comments/${id}" -f body="$new_body" >/dev/null 2>&1; then remapped=$((remapped + 1)) - echo "::notice::claim reply ${id} on PR #${PR_NUMBER}: ${sha} was rebased onto a foreign commit and landed as ${rebased} — claim updated, not retracted (#2032)" + echo "::notice::${what} ${id} on PR #${PR_NUMBER}: ${sha} was rebased onto a foreign commit and landed as ${rebased} — claim updated, not retracted (#2032)" continue fi - echo "::warning::could not update claim reply ${id} on PR #${PR_NUMBER} to the rebased commit ${rebased} — retracting it instead (#2032)" + echo "::warning::could not update ${what} ${id} on PR #${PR_NUMBER} to the rebased commit ${rebased} — retracting it instead (#2032)" fi fi fi + # cl_retract_body removes only the addressed-marker and the claim. A + # `dev-lead:comment-disposition` marker in the same reply is kept: the + # disposition resolver verifies that one on its own (#2261). new_body=$(cl_retract_body "$body" "$reason") - if gh api -X PATCH "repos/${REPO}/pulls/comments/${id}" -f body="$new_body" >/dev/null 2>&1; then + if gh api -X PATCH "repos/${REPO}/${surface}/comments/${id}" -f body="$new_body" >/dev/null 2>&1; then retracted=$((retracted + 1)) - echo "::warning::retracted claim reply ${id} on PR #${PR_NUMBER} (${reason}; cited ${sha:-}, remote head ${ref:-}) (#2013)" + echo "::warning::retracted ${what} ${id} on PR #${PR_NUMBER} (${reason}; cited ${sha:-}, remote head ${ref:-}) (#2013)" else - echo "::error::could not retract claim reply ${id} on PR #${PR_NUMBER} (${reason}) — a false 'Fixed' reply may remain (#2013)" + echo "::error::could not retract ${what} ${id} on PR #${PR_NUMBER} (${reason}) — a false 'Fixed' reply may remain (#2013)" failed=1 fi done <<< "$rows" diff --git a/scripts/lib/claim-landing.sh b/scripts/lib/claim-landing.sh index e2d792ea0..ccc302c1d 100644 --- a/scripts/lib/claim-landing.sh +++ b/scripts/lib/claim-landing.sh @@ -85,7 +85,8 @@ cl_push_landed_verdict() { # cl_select_pass_claims # is the REST `pulls/{pr}/comments` array ({id, user.login, body, -# created_at}). Emits one `\t` row per comment that (a) our account +# created_at}), or the `issues/{pr}/comments` array, which has the same fields +# (#2261). Emits one `\t` row per comment that (a) our account # authored (bot_user or its [bot]-suffixed / stripped form), (b) was created at or # after (the pass start), and (c) still carries the addressed-marker or # a claim comment. is the parsed claim SHA, or empty when the claim is @@ -262,10 +263,13 @@ cl_retract_body() { unaddressed_line="${_CL_UNADDRESSED_MARKER}"$'\n' fi + # The claim comment ends at its FIRST `-->` (as acv_parse_claim reads it), so a + # different marker later on the same line, such as a comment-disposition, is + # kept (#2261). local stripped stripped=$(jq -Rsr --arg marker "$_DEV_LEAD_ADDRESSED_MARKER" ' gsub($marker; "") - | gsub(""; "") + | gsub(""; "") | sub("\\s+$"; "") ' <<<"$body" 2>/dev/null) || stripped="" local quoted diff --git a/scripts/lib/comment-disposition-verify.sh b/scripts/lib/comment-disposition-verify.sh index 59ff38035..1e2a20c87 100755 --- a/scripts/lib/comment-disposition-verify.sh +++ b/scripts/lib/comment-disposition-verify.sh @@ -367,6 +367,37 @@ cdv_fixed_verdict() { return 0 } +# cdv_rewrite_disposition_sha +# with the `sha=` of its disposition marker changed from +# to ; every other byte is kept. Used when the push guard rebased the +# commit a `fixed` disposition cites, so the marker must name the commit that +# actually landed (#2261), as cl_rewrite_claim_sha does for a thread claim. +# Returns 1 (echoing nothing) unless the body carries exactly one marker, that +# marker is a `fixed` disposition for citing , both shas are full +# 40-hex, and the rewritten body parses back to the same disposition citing +# . Pure. +cdv_rewrite_disposition_sha() { + local body="${1:-}" cid="${2:-}" old="${3:-}" new="${4:-}" + [[ -n "$cid" ]] || return 1 + [[ "$old" =~ ^[0-9a-f]{40}$ && "$new" =~ ^[0-9a-f]{40}$ ]] || return 1 + + local parsed + parsed=$(cdv_parse_disposition "$body" 2>/dev/null) || return 1 + [[ "$(jq -r '[.id, .disposition, .sha] | join(" ")' <<<"$parsed" 2>/dev/null)" == "$cid fixed $old" ]] || return 1 + + local before rest attrs after rewritten + before="${body%%"$_CDV_MARKER_PREFIX"*}" + rest="${body#*"$_CDV_MARKER_PREFIX"}" + attrs="${rest%%"$_CDV_MARKER_SUFFIX"*}" + after="${rest#*"$_CDV_MARKER_SUFFIX"}" + rewritten="${before}${_CDV_MARKER_PREFIX}${attrs//sha=${old}/sha=${new}}${_CDV_MARKER_SUFFIX}${after}" + + # Re-parse: the result must be the same disposition, citing the new sha. + parsed=$(cdv_parse_disposition "$rewritten" 2>/dev/null) || return 1 + [[ "$(jq -r '[.id, .disposition, .sha] | join(" ")' <<<"$parsed" 2>/dev/null)" == "$cid fixed $new" ]] || return 1 + printf '%s' "$rewritten" +} + # cdv_select_disposition # Duplicate recovery / idempotency (#1992). The pre-#1992 resolver required # EXACTLY ONE authorized disposition per comment and failed closed on more, so diff --git a/tests/dev-lead/unit/test_claim_sweep.bats b/tests/dev-lead/unit/test_claim_sweep.bats index d5f6a29d6..c2771d58d 100644 --- a/tests/dev-lead/unit/test_claim_sweep.bats +++ b/tests/dev-lead/unit/test_claim_sweep.bats @@ -345,3 +345,383 @@ _landed_fix() { [ -f "$PATCHES/211" ] grep -q "reason=not-on-ref" "$PATCHES/211" } + +# --------------------------------------------------------------------------- +# #2261: a bot finding posted as a PR ISSUE comment +# --------------------------------------------------------------------------- +# PR #2205: a fix-bot-comment pass answered CodeAnt's issue comment with a new PR +# comment carrying the addressed-marker and a claim citing f8f0b54. The push guard +# then rebased that commit onto a concurrent one, so the fix landed as 3e5025bd and +# f8f0b54 never reached GitHub. The sweep listed only review-thread replies +# (`pulls//comments`), so the claim was neither re-pointed nor retracted, and a +# `fixed` disposition citing the pre-rebase sha could not have verified either. + +# _issue_gh_stub — setup()'s gh stub, plus the PR's ISSUE comments: served from +# $ISSUE_COMMENTS, and a PATCH to one recorded as $PATCHES/issue-. +# ISSUE_LIST_FAILS=1 makes the issue-comment listing fail. +_issue_gh_stub() { + ISSUE_COMMENTS="$BATS_TEST_TMPDIR/issue-comments.json" + echo '[]' > "$ISSUE_COMMENTS" + cat > "$STUB_BIN_DIR/gh" < "$PATCHES/\${kind}\${id}" + echo '{}' + ;; + *"issues/54/comments"*) + if [ -n "\${ISSUE_LIST_FAILS:-}" ]; then echo "gh: Bad Gateway (HTTP 502)" >&2; exit 1; fi + cat "$ISSUE_COMMENTS" + ;; + *"pulls/54/comments"*) cat "$COMMENTS" ;; + *) echo '{}' ;; +esac +GHEOF + chmod +x "$STUB_BIN_DIR/gh" +} + +# _issue_reply [login] — a PR issue comment (REST shape). +_issue_reply() { + jq -c -n --argjson id "$1" --arg at "$2" --arg body "$3" --arg login "${4:-donpetry-bot}" \ + '{id: $id, user: {login: $login}, created_at: $at, body: $body}' +} + +# _serve_issue ... — the PR's issue comments. +_serve_issue() { + printf '%s\n' "$@" | jq -s -c . > "$ISSUE_COMMENTS" +} + +@test "#2261 AC3: a claim reply posted as a PR issue comment whose commit never landed is retracted" { + _issue_gh_stub + local ghost="f8f0b543ee9d935538a65233d261bb1284d60276" + _serve_issue "$(_issue_reply 301 "2026-10-09T03:01:00Z" "$(_claim "$ghost")")" + + run retract_unlanded_claims fix-bot-comment ok + [ "$status" -eq 0 ] + [[ "$output" == *"retracted 1 claim reply(ies)"* ]] + # Patched through the ISSUE-comment endpoint, not the review-comment one. + [ -f "$PATCHES/issue-301" ] + [ ! -f "$PATCHES/301" ] + grep -q "Retracted" "$PATCHES/issue-301" + grep -q "" "$PATCHES/issue-301" + if grep -q "dev-lead:addressed" "$PATCHES/issue-301"; then false; fi + if grep -q "" "$PATCHES/issue-302" + # No claim on the PR cites a commit that is not on the branch. + if grep -q "$cited" "$PATCHES/issue-302"; then false; fi + run acv_parse_claim "$(cat "$PATCHES/issue-302")" + [ "$status" -eq 0 ] + [ "$(jq -r .sha <<<"$output")" = "$rebased" ] +} + +@test "#2261 AC3: only OUR issue comments from THIS pass are swept; a landed claim is left alone" { + _issue_gh_stub + local ghost="f8f0b543ee9d935538a65233d261bb1284d60276" + # A fix this pass committed and pushed: its claim is true. + echo fixed > f; git add f; git commit -q -m "fix(bot): address bot feedback" + git push -q origin main + local landed; landed=$(git rev-parse HEAD) + _serve_issue \ + "$(_issue_reply 311 "2026-10-09T03:01:00Z" "$(_claim "$ghost")")" \ + "$(_issue_reply 312 "2026-10-09T03:01:00Z" "$(_claim "$ghost")" "mallory")" \ + "$(_issue_reply 313 "2026-10-09T02:59:59Z" "$(_claim "$ghost")")" \ + "$(_issue_reply 314 "2026-10-09T03:02:00Z" "$(_claim "$landed")")" \ + "$(_issue_reply 315 "2026-10-09T03:02:00Z" "Looked into it; nothing to change.")" + + run retract_unlanded_claims fix-bot-comment ok + [ "$status" -eq 0 ] + # Ours, this pass, never landed: retracted. + [ -f "$PATCHES/issue-311" ] + # Another author's comment, ours from before the pass start, a claim that + # landed, and a comment with no marker or claim: all untouched. + [ ! -f "$PATCHES/issue-312" ] + [ ! -f "$PATCHES/issue-313" ] + [ ! -f "$PATCHES/issue-314" ] + [ ! -f "$PATCHES/issue-315" ] + [ "$(find "$PATCHES" -type f | wc -l | tr -d '[:space:]')" -eq 1 ] +} + +@test "#2261 AC3: the sweep never strips a comment-disposition marker from the reply it rewrites" { + _issue_gh_stub + source "$LIB_DIR/comment-disposition-verify.sh" + local ghost="f8f0b543ee9d935538a65233d261bb1284d60276" + local disp="" + # Two retracted replies (commit never landed; in 323 the disposition marker + # shares the claim's line) and a re-pointed one (rebased, landed). + echo fixed > f; git add f; git commit -q -m "fix(bot): address bot feedback" + local cited; cited=$(git rev-parse HEAD) + _serve_issue \ + "$(_issue_reply 321 "2026-10-09T03:01:00Z" "$(_claim "$ghost") +${disp}")" \ + "$(_issue_reply 322 "2026-10-09T03:01:00Z" "$(_claim "$cited") +${disp}")" \ + "$(_issue_reply 323 "2026-10-09T03:01:00Z" "$(_claim "$ghost") ${disp}")" + _foreign_push merged-main.txt "from main" + push_no_clobber + + run retract_unlanded_claims fix-bot-comment ok + [ "$status" -eq 0 ] + local id + for id in 321 322 323; do + [ -f "$PATCHES/issue-${id}" ] + run cdv_parse_disposition "$(cat "$PATCHES/issue-${id}")" + [ "$status" -eq 0 ] + [ "$(jq -r .id <<<"$output")" = "IC_FIND" ] + [ "$(jq -r .disposition <<<"$output")" = "fixed" ] + [ "$(jq -r .sha <<<"$output")" = "$ghost" ] + done + # The retracted ones lost the addressed-marker and the claim, and only those. + for id in 321 323; do + grep -q "" "$PATCHES/issue-${id}" + if grep -q "dev-lead:addressed" "$PATCHES/issue-${id}"; then false; fi + if grep -q ""), + isMinimized: false, minimizedReason: null, createdAt: "2026-10-09T03:01:00Z"} + ]' > "$NODES" +} + +# A finding that names no distinctive token: only a commit this pass produced can +# verify it, and no search of the branch can find the fix again (#2004). +_TOKENLESS_FINDING="Incomplete implementation: the empty-input case has no guard." + +# _additive_fix — this pass's commit: it only ADDS lines. Echoes its sha. +_additive_fix() { + printf '%s\n' "${1:-guard the empty-input case}" > guard.txt + git add guard.txt + git commit -q -m "fix(bot): address bot feedback" + git rev-parse HEAD +} + +@test "#2261 AC2: a fixed disposition citing a commit the push guard rebased verifies against the rebased commit, and its marker is re-pointed" { + _disposition_resolver + local cited; cited=$(_additive_fix) + _finding_and_fixed_reply "$_TOKENLESS_FINDING" "$cited" + # The auto-rebase bot pushes to the branch before dev-lead's push (#1607). + _foreign_push merged-main.txt "from main" + push_no_clobber + local rebased; rebased=$(git rev-parse HEAD) + [ "$rebased" != "$cited" ] + [ "$(git --git-dir="$REMOTE" rev-parse main)" = "$rebased" ] + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"it landed as ${rebased} (tokenless-this-pass)"* ]] + [[ "$output" != *"fixed-unverified"* ]] + # The bot's comment is cleared in this pass. + grep -Eq 'classifier:RESOLVED.*id=IC_FIND' "$MINLOG" + # OUR reply was edited in place, and nothing new was posted or hidden. + [ ! -s "$POSTLOG" ] + if grep -q 'classifier:OUTDATED' "$MINLOG"; then false; fi + [ -f "$EDITS/R1" ] + grep -q "Fixed in guard.txt: added the missing guard." "$EDITS/R1" + # Its one marker cites the commit that is on the branch, not the one that is not. + if grep -q "$cited" "$EDITS/R1"; then false; fi + run cdv_parse_disposition "$(cat "$EDITS/R1")" + [ "$status" -eq 0 ] + [ "$(jq -r .id <<<"$output")" = "IC_FIND" ] + [ "$(jq -r .disposition <<<"$output")" = "fixed" ] + [ "$(jq -r .sha <<<"$output")" = "$rebased" ] +} + +@test "#2261 AC2: a rebased fix that removes the finding's token is re-pointed in place, with no second reply" { + _disposition_resolver + # The README says `base`; the fix replaces that line, so its diff removes the token. + echo ready > README; git add README; git commit -q -m "fix(bot): address bot feedback" + local cited; cited=$(git rev-parse HEAD) + _finding_and_fixed_reply 'The README still says `base`, a placeholder.' "$cited" + _foreign_push merged-main.txt "from main" + push_no_clobber + local rebased; rebased=$(git rev-parse HEAD) + [ "$rebased" != "$cited" ] + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"it landed as ${rebased} (content-removes-token)"* ]] + grep -Eq 'classifier:RESOLVED.*id=IC_FIND' "$MINLOG" + [ ! -s "$POSTLOG" ] + grep -q "sha=${rebased} -->" "$EDITS/R1" +} + +@test "#2261 AC2: a cited commit that was never rebased or pushed stays unverified" { + _disposition_resolver + local cited; cited=$(_additive_fix) + _finding_and_fixed_reply "$_TOKENLESS_FINDING" "$cited" + # No push at all: the commit exists only locally, and nothing maps it. + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"citing ${cited} did not verify (fixed-unverified:not-on-head)"* ]] + [ ! -s "$MINLOG" ] + [ ! -s "$POSTLOG" ] + [ -z "$(ls -A "$EDITS")" ] +} + +@test "#2261 AC2: a rewrite that maps to a commit not on the pushed head stays unverified" { + _disposition_resolver + local cited; cited=$(_additive_fix) + _finding_and_fixed_reply "$_TOKENLESS_FINDING" "$cited" + # A map entry is not proof: its target must itself be on the remote head. + local unpushed; unpushed=$(_additive_fix "a second local-only commit") + _PUSH_GUARD_REWRITES="${cited}"$'\t'"${unpushed}" + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"rebased the cited ${cited} to ${unpushed}, which did not verify either (fixed-unverified:not-on-head)"* ]] + [ ! -s "$MINLOG" ] + [ ! -s "$POSTLOG" ] + [ -z "$(ls -A "$EDITS")" ] +} + +@test "#2261 AC2: the rebased commit must still pass the #2004 content rule (the PR #2205 shape stays open)" { + _disposition_resolver + # PR #2205's finding names a token (`escalate = no`), and its fix only added an + # assertion, removing nothing. #2004 rejects that with or without a rebase, and + # the rebase mapping must not become a way around it. + local cited; cited=$(_additive_fix "the bullet must not say escalate = yes") + _finding_and_fixed_reply 'This assertion never verifies the no-ADR branch says `escalate = no`, so changing that decision to yes can pass this regression guard.' "$cited" + _foreign_push merged-main.txt "from main" + push_no_clobber + local rebased; rebased=$(git rev-parse HEAD) + [ "$rebased" != "$cited" ] + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"rebased the cited ${cited} to ${rebased}, which did not verify either (fixed-unverified:content-no-token-removed)"* ]] + [ ! -s "$MINLOG" ] + [ -z "$(ls -A "$EDITS")" ] +} + +@test "#2261 AC2: when our reply cannot be updated, the comment stays open" { + _disposition_resolver + export EDIT_FAILS=1 + local cited; cited=$(_additive_fix) + _finding_and_fixed_reply "$_TOKENLESS_FINDING" "$cited" + _foreign_push merged-main.txt "from main" + push_no_clobber + local rebased; rebased=$(git rev-parse HEAD) + [ "$rebased" != "$cited" ] + + run resolve_dispositioned_comments fix-bot-comment + [ "$status" -eq 0 ] + [[ "$output" == *"disposition reply R1 could not be updated to cite it; it stays open"* ]] + # A marker citing a commit GitHub never saw must not clear the comment. + [ ! -s "$MINLOG" ] + [ -z "$(ls -A "$EDITS")" ] +} diff --git a/tests/dev-lead/unit/test_comment_disposition_verify.bats b/tests/dev-lead/unit/test_comment_disposition_verify.bats index 298d81a1b..9c3013cc0 100644 --- a/tests/dev-lead/unit/test_comment_disposition_verify.bats +++ b/tests/dev-lead/unit/test_comment_disposition_verify.bats @@ -598,3 +598,79 @@ Also `real_token`.' run bash -c "cd '$root' && source .dev-lead/scripts/lib/comment-disposition-verify.sh && cd pr-worktree && cdv_body_has_findings '**Actionable comments posted: 2**'" [ "$status" -eq 0 ] } + +# ── #2261: a `fixed` disposition whose commit the push guard rebased ─────────── +# The model cites the commit it made before the push. When the push guard rebases +# that commit onto a concurrent one, the cited sha never reaches the branch. The +# harness then edits OUR reply so its marker cites the commit that landed. +# cdv_rewrite_disposition_sha +# 0 + the body with only the marker's sha changed +# 1 + nothing, unless the body carries exactly one `fixed` marker for +# citing and is a full sha + +_OLD_SHA="f8f0b543ee9d935538a65233d261bb1284d60276" +_NEW_SHA="3e5025bd8f8bccecb3bd76544eadcc8de851a854" + +_rewrite() { + run bash -c "source '$LIB'; cdv_rewrite_disposition_sha \"\$1\" \"\$2\" \"\$3\" \"\$4\"" _ "$1" "$2" "$3" "$4" +} + +_fixed_body() { # $1=sha [$2=comment id] + printf 'Fixed in tests/foo.bats:154 (commit %s): added the missing assertion.\n\n' \ + "${1:0:7}" "${2:-IC_FIND}" "$1" +} + +@test "#2261: cdv_rewrite_disposition_sha re-points the marker and keeps every other byte" { + _rewrite "$(_fixed_body "$_OLD_SHA")" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 0 ] + # Only the marker changed: the prose, which names the short old sha, is kept. + [ "$output" = "$(printf 'Fixed in tests/foo.bats:154 (commit %s): added the missing assertion.\n\n' "${_OLD_SHA:0:7}" "$_NEW_SHA")" ] +} + +@test "#2261: the re-pointed body parses as one fixed disposition citing the new sha" { + _rewrite "$(_fixed_body "$_OLD_SHA")" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 0 ] + _parse "$output" + [ "$status" -eq 0 ] + [ "$(jq -r .id <<<"$output")" = "IC_FIND" ] + [ "$(jq -r .disposition <<<"$output")" = "fixed" ] + [ "$(jq -r .sha <<<"$output")" = "$_NEW_SHA" ] +} + +@test "#2261: a marker for another comment, or citing another sha, is not rewritten" { + _rewrite "$(_fixed_body "$_OLD_SHA" "IC_OTHER")" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 1 ] + [ -z "$output" ] + _rewrite "$(_fixed_body "$_NEW_SHA")" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 1 ] + [ -z "$output" ] +} + +@test "#2261: only a fixed disposition is rewritten" { + _rewrite "Not a defect. +" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 1 ] + [ -z "$output" ] +} + +@test "#2261: an abbreviated, malformed or empty new sha fails closed" { + _rewrite "$(_fixed_body "$_OLD_SHA")" "IC_FIND" "$_OLD_SHA" "${_NEW_SHA:0:7}" + [ "$status" -eq 1 ] + [ -z "$output" ] + _rewrite "$(_fixed_body "$_OLD_SHA")" "IC_FIND" "$_OLD_SHA" "${_NEW_SHA:0:39}Z" + [ "$status" -eq 1 ] + [ -z "$output" ] + _rewrite "$(_fixed_body "$_OLD_SHA")" "IC_FIND" "$_OLD_SHA" "" + [ "$status" -eq 1 ] + [ -z "$output" ] +} + +@test "#2261: a body with no marker, or more than one, is not rewritten" { + _rewrite "Fixed it, honest." "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 1 ] + [ -z "$output" ] + _rewrite "$(_fixed_body "$_OLD_SHA") +" "IC_FIND" "$_OLD_SHA" "$_NEW_SHA" + [ "$status" -eq 1 ] + [ -z "$output" ] +} diff --git a/tests/dev-lead/unit/test_fix_reviews.bats b/tests/dev-lead/unit/test_fix_reviews.bats index 9820f32b0..7dcd61454 100644 --- a/tests/dev-lead/unit/test_fix_reviews.bats +++ b/tests/dev-lead/unit/test_fix_reviews.bats @@ -7114,3 +7114,87 @@ _stale_nodes() { [[ "$out" != *'${STALE_DISPOSITIONS}'* ]] done } + +# ── #2261: a finding fixed in a bot ISSUE comment is dispositioned, not "addressed" ── +# PR #2205: fix-bot-comment fixed a CodeAnt finding posted as a PR issue comment and +# answered it like a review thread, with the addressed-marker and a claim. The +# maintainer-comment gate reads neither, so the comment was never dispositioned and +# the retries ran out. The prompt described a `fixed` disposition only for CodeRabbit +# summaries; it now describes one for every bot's issue comment. + +# _fbc_issue_comment_section — the prompt's "Fixing a finding posted as a PR issue +# comment" section, rendered as build_and_run renders it (envsubst over the +# variables the template declares) for the triggering comment IC_FIND. +_fbc_issue_comment_section() { + local p="$SCRIPT_DIR/prompts/dev-lead/fix-bot-comment.md" vars + vars=$(head -1 "$p" | sed 's///' \ + | tr ',' '\n' | awk '{gsub(/^ +| +$/, ""); if (length) printf "${%s}", $0}') + COMMENT_NODE_ID=IC_FIND PR_NUMBER=54 REPO=petry-projects/.github-private envsubst "$vars" < "$p" \ + | awk '/^### Fixing a finding posted as a PR issue comment \(#2261\)$/{f=1; next} f && /^##+ /{exit} f' +} + +@test "#2261 AC1: fix-bot-comment prompt — the addressed-marker and claim are for review threads only; an issue comment gets one fixed disposition" { + local p="$SCRIPT_DIR/prompts/dev-lead/fix-bot-comment.md" sec + # The Task steps name the issue-comment answer, not only the thread reply. + grep -qE '^5\. \*\*Disposition the bot.s issue comment when the finding came from one\*\*' "$p" + sec=$(_fbc_issue_comment_section) + [ -n "$sec" ] + [[ "$sec" == *'**The addressed-marker and the claim are for review threads only. They do not disposition an issue comment.**'* ]] + [[ "$sec" == *'Never put the addressed-marker or a claim in a PR comment.'* ]] + # Every registered reviewer bot, not only CodeRabbit. + [[ "$sec" == *'Every registered reviewer bot (`scripts/lib/reviewer-sources.tsv`), not only CodeRabbit'* ]] + # Exactly one reply, exactly one marker: fixed, with the commit's full sha. + [[ "$sec" == *'post **exactly one** reply on the PR'* ]] + [[ "$sec" == *'**exactly one** marker: `disposition=fixed` with the full 40-char sha of that commit'* ]] + [ "$(grep -c 'gh pr comment' <<<"$sec")" -eq 1 ] + [ "$(grep -c '' <<<"$sec")" -eq 1 ] # named once, as what NOT to post + # The Constraints list repeats the rule. + grep -qE '^- For a finding you fix from a PR issue comment, post exactly one reply .*.*review threads only.*#2261' "$p" +} + +@test "#2261 AC1: the prompt's issue-comment example, executed, posts one reply the disposition parser accepts as fixed for the triggering comment" { + local snip="$BATS_TEST_TMPDIR/fixed-snippet.sh" repo="$BATS_TEST_TMPDIR/fixrepo" + local posted="$BATS_TEST_TMPDIR/posted" fix_sha + _fbc_issue_comment_section | awk '/^```bash$/{f=1; next} f && /^```$/{exit} f' > "$snip" + [ -s "$snip" ] + + # The pass's local fix commit, which the reply must cite. + mkdir -p "$repo" "$posted" + git -C "$repo" init -q + echo fixed > "$repo/f" + git -C "$repo" add f + git -C "$repo" -c user.email=t@test -c user.name=T commit -q -m "fix(bot): address bot feedback" + fix_sha=$(git -C "$repo" rev-parse HEAD) + + # A gh that records each `gh pr comment` body as $posted/, and refuses any + # other call (a thread reply would be one). + cat > "$STUB_BIN_DIR/gh" < "$posted/\$((n + 1))" + ;; + *) echo "unexpected gh call: \$*" >&2; exit 1 ;; +esac +GHEOF + chmod +x "$STUB_BIN_DIR/gh" + + run bash -c "cd '$repo' && bash '$snip'" + [ "$status" -eq 0 ] + # Exactly one reply was posted. + [ "$(find "$posted" -type f | wc -l | tr -d '[:space:]')" -eq 1 ] + # It carries no thread marker… + if grep -q 'dev-lead:addressed' "$posted/1"; then false; fi + if grep -q 'dev-lead:claim' "$posted/1"; then false; fi + # …and the normative parser reads exactly one disposition: fixed, for the + # triggering comment, citing the pass's commit. + run bash -c "source '$SCRIPT_DIR/scripts/lib/comment-disposition-verify.sh'; cdv_parse_disposition \"\$(cat '$posted/1')\"" + [ "$status" -eq 0 ] + [ "$(jq -r .id <<<"$output")" = "IC_FIND" ] + [ "$(jq -r .disposition <<<"$output")" = "fixed" ] + [ "$(jq -r .sha <<<"$output")" = "$fix_sha" ] +} From a05647911c0f860c16aefefb4e915165d782e503 Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Sun, 11 Oct 2026 12:31:31 -0500 Subject: [PATCH 2/3] fix(dev-lead): remove a claim whose JSON spans lines when retracting it (#2261) cl_strip_claim_markers stopped at the first newline, while acv_parse_claim reads a claim through its first ` -->` across lines. A retracted reply with a multi-line claim kept the claim comment in its quoted original, so the next sweep selected and retracted it again. The pattern now runs to the first `-->` across lines and still keeps a later marker. Co-Authored-By: Claude Opus 5.5 --- scripts/lib/claim-landing.sh | 6 +++--- tests/dev-lead/unit/test_claim_sweep.bats | 21 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/scripts/lib/claim-landing.sh b/scripts/lib/claim-landing.sh index 419171047..54a33ebfb 100644 --- a/scripts/lib/claim-landing.sh +++ b/scripts/lib/claim-landing.sh @@ -327,12 +327,12 @@ cl_escape_dashes() { # without its addressed-marker and claim comment, and without trailing # whitespace. The claim comment ends at its FIRST `-->` (as acv_parse_claim reads # it), so a different marker later on the same line, such as a -# comment-disposition, is kept (#2261). Returns 1 when the body cannot be -# processed. Pure. +# comment-disposition, is kept, and a claim whose JSON spans lines is removed +# whole (#2261). Returns 1 when the body cannot be processed. Pure. cl_strip_claim_markers() { jq -Rsr --arg marker "$_DEV_LEAD_ADDRESSED_MARKER" ' gsub($marker; "") - | gsub(""; "") + | gsub(""; "") | sub("\\s+$"; "") ' <<<"${1:-}" 2>/dev/null } diff --git a/tests/dev-lead/unit/test_claim_sweep.bats b/tests/dev-lead/unit/test_claim_sweep.bats index 47078dc8a..4d401ee01 100644 --- a/tests/dev-lead/unit/test_claim_sweep.bats +++ b/tests/dev-lead/unit/test_claim_sweep.bats @@ -695,3 +695,24 @@ $(_pr_comment 483 "$PASS_AT" "x ` across lines; the retraction + # must remove the same span. + local body + body=$(printf 'Fixed in f.\n\n\n ' "$GHOST_2261") + run acv_parse_claim "$body" + [ "$status" -eq 0 ] + _serve "$(_reply 491 "2026-10-09T03:01:00Z" "$body")" + + run retract_unlanded_claims fix-reviews ok + [ -f "$PATCHES/491" ] + ! grep -q "" "$PATCHES/491" + # Idempotent: the next sweep finds nothing to select in the retracted reply. + run cl_select_pass_claims "$(jq -c -n --arg b "$(cat "$PATCHES/491")" \ + '[{id: 491, user: {login: "donpetry-bot"}, created_at: "2026-10-09T03:01:00Z", body: $b}]')" "donpetry-bot" "$PASS_AT" + [ "$status" -eq 0 ] + [ -z "$output" ] +} From 95fb9124bf76ca8d111f124eae10d48e902a033b Mon Sep 17 00:00:00 2001 From: Don Petry <36422719+don-petry@users.noreply.github.com> Date: Sun, 11 Oct 2026 13:12:24 -0500 Subject: [PATCH 3/3] fix(dev-lead): an issue-comment listing that is not a list no longer fails the claim sweep (#2261) cl_without_fixed_dispositions rejected a JSON payload that was not an array, so retract_unlanded_claims returned non-zero and a pushed pass was reported as failed. CI caught it in "resolve_deferred_bot_threads (#2045): after a pushed commit, the resolve-failed marker is keyed to the pushed head", whose gh stub answers the listing with an object. The helper now passes such a payload through, and the claim selector reads it as "no replies", as it and main's `fixed`-disposition sweep already do. A payload that is not JSON still fails. Co-Authored-By: Claude Opus 5.5 --- scripts/lib/claim-landing.sh | 10 ++++++---- tests/dev-lead/unit/test_claim_sweep.bats | 23 ++++++++++++++++++++--- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/scripts/lib/claim-landing.sh b/scripts/lib/claim-landing.sh index 54a33ebfb..af416e55c 100644 --- a/scripts/lib/claim-landing.sh +++ b/scripts/lib/claim-landing.sh @@ -583,14 +583,16 @@ cl_select_fixed_dispositions() { # that carry a `disposition=fixed` marker, by the same test # cl_select_fixed_dispositions selects them with. Those replies belong to the # `fixed`-disposition sweep, which also handles a claim they carry; the claim -# sweep reads the rest, so no reply is rewritten by both (#2261). Returns 1 on a -# payload that is not an array. Pure. +# sweep reads the rest, so no reply is rewritten by both (#2261). A payload +# that is JSON but not an array is echoed unchanged: the claim selector reads it +# as "no replies", as it does for the review-comment listing. Returns 1 only +# when the payload is not JSON. Pure. cl_without_fixed_dispositions() { - jq -ce ' + jq -c ' if type == "array" then map(select(((objects | .body // "") | test("") $(_pr_comment 483 "$PASS_AT" "x ")")") [ "$(jq -c '[.[].id]' <<<"$kept")" = "[481,483]" ] - run cl_without_fixed_dispositions '{"message":"Bad credentials"}' + # JSON that is not a list passes through for the claim selector to read as + # "no replies"; only a payload that is not JSON fails. + run cl_without_fixed_dispositions '{}' + [ "$status" -eq 0 ] + [ "$output" = "{}" ] + run cl_without_fixed_dispositions 'not json' [ "$status" -ne 0 ] - [ -z "$output" ] +} + +@test "#2261: an issue-comment listing that is JSON but not a list does not fail the sweep" { + # A full-script gh stub (and any proxy) may answer the listing with an object. + # main's `fixed`-disposition sweep reads that as "no replies"; the claim sweep + # must too, or a pushed pass is reported as failed. + printf '{}' > "$ISSUE_COMMENTS" + _serve "$(_reply 495 "2026-10-09T03:01:00Z" "$(_claim "$GHOST_2261")")" + + run retract_unlanded_claims fix-reviews ok + [ "$status" -eq 0 ] + [[ "$output" != *"NOT verified"* ]] + [ -f "$PATCHES/495" ] } @test "#2261: a claim whose JSON spans lines is removed whole, so the retracted reply is not selected again" {