fix: dedup guard fails open when pre-run marker missing
ci / lint (push) Skipped

This commit is contained in:
2026-07-08 09:35:17 +02:00
parent 1e72b9bcba
commit 3022d90402
+7 -1
View File
@@ -200,7 +200,12 @@ if [ "$MODE" != "pr" ]; then
# during the run (any comment by $NAME newer than the pre-run newest id from fetch-thread.sh), # during the run (any comment by $NAME newer than the pre-run newest id from fetch-thread.sh),
# its self-post IS the reply — skip the duplicate framework comment. Markers (CLOSE_ISSUE, # its self-post IS the reply — skip the duplicate framework comment. Markers (CLOSE_ISSUE,
# DELEGATE, MERGE_PR, subtasks) were already processed above and are unaffected. # DELEGATE, MERGE_PR, subtasks) were already processed above and are unaffected.
pre_cid=$(cat /tmp/thread_max_cid 2>/dev/null || echo 0) # FAIL OPEN: if the pre-run marker is missing (fetch-thread hiccup), pre_cid=0 would make the
# agent's comments from PREVIOUS runs count as self-posts and wrongly suppress the reply.
# Without the marker, skip the guard and post normally.
pre_cid=$(cat /tmp/thread_max_cid 2>/dev/null || echo "")
selfposts=0
if [ -n "$pre_cid" ]; then
: > /tmp/all_comments.json : > /tmp/all_comments.json
for pg in $(seq 1 10); do for pg in $(seq 1 10); do
cpg=$(curl -sS "${hdr[@]}" "$API/issues/$NUM/comments?limit=50&page=$pg" 2>/dev/null) || cpg='[]' cpg=$(curl -sS "${hdr[@]}" "$API/issues/$NUM/comments?limit=50&page=$pg" 2>/dev/null) || cpg='[]'
@@ -209,6 +214,7 @@ if [ "$MODE" != "pr" ]; then
[ "${cn:-0}" -lt 50 ] && break [ "${cn:-0}" -lt 50 ] && break
done done
selfposts=$(jq -rs --arg n "$NAME" --argjson c "${pre_cid:-0}" '[ (add // [])[] | select(.user.login==$n) | select(.id > $c) ] | length' /tmp/all_comments.json 2>/dev/null || echo 0) selfposts=$(jq -rs --arg n "$NAME" --argjson c "${pre_cid:-0}" '[ (add // [])[] | select(.user.login==$n) | select(.id > $c) ] | length' /tmp/all_comments.json 2>/dev/null || echo 0)
fi
if [ "${selfposts:-0}" -gt 0 ]; then if [ "${selfposts:-0}" -gt 0 ]; then
echo "agent @$NAME already posted ${selfposts} comment(s) on #$NUM during this run — skipping duplicate framework reply" echo "agent @$NAME already posted ${selfposts} comment(s) on #$NUM during this run — skipping duplicate framework reply"
else else