Skip to content

armgit / ECC

Public Imported from GitHub
0

The agent harness performance optimization system. Skills, instincts, memory, security, and research-first development for Claude Code, Codex, Opencode, Cursor and beyond.

fix: complete Discord delivery receipts reliably (#2738)

Affaan Mustafa649def769bd8
diff --git a/scripts/discord/announcement-core.mjs b/scripts/discord/announcement-core.mjs
index d3c9e3914..891f432ab 100644
--- a/scripts/discord/announcement-core.mjs
+++ b/scripts/discord/announcement-core.mjs
@@ -72,11 +72,12 @@ export function discussionReceiptMarker(key) {
}
export function findDiscussionReceipt(comments, marker) {
- return comments.find(comment => (
- comment?.author?.login === 'github-actions[bot]'
+ const trusted = comments.filter(comment => (
+ ['github-actions', 'github-actions[bot]'].includes(comment?.author?.login)
&& typeof comment.body === 'string'
&& comment.body.includes(marker)
- )) || null;
+ ));
+ return trusted.find(comment => discussionReceiptStatus(comment) === 'complete') || trusted[0] || null;
}
export function discussionReceiptStatus(comment) {
diff --git a/scripts/discord/release-announce.mjs b/scripts/discord/release-announce.mjs
index f03f4b583..6ac1e2f51 100644
--- a/scripts/discord/release-announce.mjs
+++ b/scripts/discord/release-announce.mjs
@@ -127,13 +127,6 @@ async function addReceiptComment(discussionId, body) {
return data.addDiscussionComment.comment.id;
}
-async function updateReceiptComment(commentId, body) {
- await githubGraphql(
- `mutation($id:ID!,$body:String!){updateDiscussionComment(input:{commentId:$id,body:$body}){comment{id}}}`,
- { id: commentId, body },
- );
-}
-
async function deleteReceiptComment(commentId) {
await githubGraphql(
`mutation($id:ID!){deleteDiscussionComment(input:{id:$id}){clientMutationId}}`,
@@ -179,7 +172,10 @@ async function deliver(discussion) {
throw new Error(`Discord webhook request failed (${response.status})`);
}
const message = await response.json();
- await updateReceiptComment(claimId, `${marker}\n\nDiscord delivery: complete (message ${message.id}).`);
+ await addReceiptComment(discussion.id, `${marker}\n\nDiscord delivery: complete (message ${message.id}).`);
+ await deleteReceiptComment(claimId).catch(() => {
+ console.warn('announcement delivered; pending receipt cleanup requires attention');
+ });
console.log('announcement delivered by channel webhook');
return;
}
diff --git a/tests/scripts/release-announce.test.js b/tests/scripts/release-announce.test.js
index 4e2a6fcc2..a111dfeff 100644
--- a/tests/scripts/release-announce.test.js
+++ b/tests/scripts/release-announce.test.js
@@ -52,7 +52,8 @@ const receiptMarker = discussionReceiptMarker('affaan-m/ECC:discussion:D_kw123')
assert.match(receiptMarker, /^<!-- ecc-discord-receipt:[a-f0-9]{32} -->$/);
assert.equal(findDiscussionReceipt([
{ id: 'forged', body: `Discord delivery: complete\n${receiptMarker}`, author: { login: 'attacker' } },
- { id: 'comment-1', body: `Discord delivery: complete\n${receiptMarker}`, author: { login: 'github-actions[bot]' } },
+ { id: 'pending', body: `Discord delivery: pending.\n${receiptMarker}`, author: { login: 'github-actions' } },
+ { id: 'comment-1', body: `Discord delivery: complete\n${receiptMarker}`, author: { login: 'github-actions' } },
], receiptMarker).id, 'comment-1');
assert.equal(findDiscussionReceipt([{ id: 'comment-2', body: 'unrelated' }], receiptMarker), null);
assert.equal(discussionReceiptStatus({ body: `Discord delivery: pending.\n${receiptMarker}` }), 'pending');