diff --git a/graph/fixes/fix-cleanup-of-duplicate-labels-and-prs-from-issue-poller-in-91e8d0.md b/graph/fixes/fix-cleanup-of-duplicate-labels-and-prs-from-issue-poller-in-91e8d0.md new file mode 100644 index 00000000000..b57b4f9da41 --- /dev/null +++ b/graph/fixes/fix-cleanup-of-duplicate-labels-and-prs-from-issue-poller-in-91e8d0.md @@ -0,0 +1,47 @@ +--- +id: 91e8d0c6-74c0-472f-b123-d30123bfd009 +type: fix +title: "Fix: Cleanup of duplicate labels and PRs from issue-poller infinite loop in paper-dynasty-database" +tags: [paper-dynasty-database, gitea, cleanup, automation, duplicate-labels, claude-scheduled] +importance: 0.5 +confidence: 0.8 +created: "2026-03-03T21:25:33.268899+00:00" +updated: "2026-03-03T21:25:33.268899+00:00" +--- + +# Cleanup: Duplicate Labels and PRs from Issue-Poller Loop + +## Project +paper-dynasty-database on git.manticorum.com + +## What Was Cleaned Up + +### Duplicate PRs +Closed PRs #36, #37, #39 (created by the infinite loop). Left open: +- PR #35 — real fix for issue #25 +- PR #38 — fix for issue #24 + +### Duplicate Repo Labels +Deleted 8 duplicate labels: +- 4 extra `ai-working` labels (IDs 49, 41, 56, 58) +- 4 extra `ai-reviewing` labels (IDs 51, 59, 57, 50) + +These were created because Haiku kept calling `create_repo_label` instead of checking for existing labels first. + +## Root Cause of Duplicates +The Haiku-based label creation did not search existing labels before creating. Each poll cycle created new label entries. + +## Prevention +The `ensure_label()` helper function in the rewritten poller searches existing labels first and only creates if missing: + +```bash +ensure_label() { + local name="$1" + local color="$2" + # Search existing labels, create only if not found + existing=$(gitea_get "/repos/$OWNER/$REPO/labels" | jq -r ".[] | select(.name==\"$name\") | .id") + if [ -z "$existing" ]; then + gitea_post "/repos/$OWNER/$REPO/labels" "{\"name\":\"$name\",\"color\":\"$color\"}" + fi +} +```