From 3022d9040220203a79a7f989a84ce79a176d0c15 Mon Sep 17 00:00:00 2001 From: ffaerber Date: Wed, 8 Jul 2026 09:35:17 +0200 Subject: [PATCH] fix: dedup guard fails open when pre-run marker missing --- .gitea/workflows/scripts/publish.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/.gitea/workflows/scripts/publish.sh b/.gitea/workflows/scripts/publish.sh index 8fa3fc2..2422a4f 100755 --- a/.gitea/workflows/scripts/publish.sh +++ b/.gitea/workflows/scripts/publish.sh @@ -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), # 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. - 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 for pg in $(seq 1 10); do 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 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) + fi if [ "${selfposts:-0}" -gt 0 ]; then echo "agent @$NAME already posted ${selfposts} comment(s) on #$NUM during this run — skipping duplicate framework reply" else