From 9a22e407a4129c94f22db921773a2e3b58cb1102 Mon Sep 17 00:00:00 2001 From: Agent Date: Tue, 7 Apr 2026 21:45:07 +0000 Subject: [PATCH] fix: fix: triage agent creates root cause issues without backlog label (#386) --- docker/reproduce/entrypoint-reproduce.sh | 34 +++++++++++++++++++++++- formulas/triage.toml | 2 +- 2 files changed, 34 insertions(+), 2 deletions(-) diff --git a/docker/reproduce/entrypoint-reproduce.sh b/docker/reproduce/entrypoint-reproduce.sh index c36192a..f2068ee 100644 --- a/docker/reproduce/entrypoint-reproduce.sh +++ b/docker/reproduce/entrypoint-reproduce.sh @@ -323,7 +323,7 @@ For each root cause found: -d '{ "title": "fix: ", "body": "## Root cause\\n\\n\\n## Fix suggestion\\n\\n\\n## Context\\nDecomposed from #\${ISSUE_NUMBER} (cause N of M)\\n\\n## Dependencies\\n<#X if this depends on another cause being fixed first>", - "labels": ["backlog"] + "labels": [{"name": "backlog"}] }' 3. Note the newly created issue numbers. @@ -487,6 +487,38 @@ if [ $CLAUDE_EXIT -eq 124 ]; then log "WARNING: Claude session timed out after ${FORMULA_TIMEOUT_MINUTES}m" fi +# --------------------------------------------------------------------------- +# Triage post-processing: enforce backlog label on created issues +# --------------------------------------------------------------------------- +# The triage agent may create sub-issues for root causes. Ensure they have +# the backlog label so dev-agent picks them up. Parse Claude output for +# newly created issue numbers and add the backlog label. +if [ "$AGENT_TYPE" = "triage" ]; then + log "Triage post-processing: checking for created issues to label..." + + # Extract issue numbers from Claude output that were created during triage. + # Match unambiguous creation patterns: "Created issue #123", "Created #123", + # or "harb#123". Do NOT match bare #123 which would capture references in + # the triage summary (e.g., "Decomposed from #5", "cause 1 of 2", etc.). + CREATED_ISSUES=$(grep -oE '(Created|created) issue #[0-9]+|(Created|created) #[0-9]+|harb#[0-9]+' \ + "/tmp/reproduce-claude-output-${ISSUE_NUMBER}.txt" 2>/dev/null | \ + grep -oE '[0-9]+' | sort -u | head -10) + + if [ -n "$CREATED_ISSUES" ]; then + # Get backlog label ID + BACKLOG_ID=$(_label_id "backlog" "#fef2c0") + + if [ -z "$BACKLOG_ID" ]; then + log "WARNING: could not get backlog label ID — skipping label enforcement" + else + for issue_num in $CREATED_ISSUES; do + _add_label "$issue_num" "$BACKLOG_ID" + log "Added backlog label to created issue #${issue_num}" + done + fi + fi +fi + # --------------------------------------------------------------------------- # Read outcome # --------------------------------------------------------------------------- diff --git a/formulas/triage.toml b/formulas/triage.toml index eb3bc3a..63be3d9 100644 --- a/formulas/triage.toml +++ b/formulas/triage.toml @@ -183,7 +183,7 @@ For each root cause found: -d '{ "title": "fix: ", "body": "## Root cause\\n\\n\\n## Fix suggestion\\n\\n\\n## Context\\nDecomposed from #${ISSUE_NUMBER} (cause N of M)\\n\\n## Dependencies\\n<#X if this depends on another cause being fixed first>", - "labels": ["backlog"] + "labels": [{"name": "backlog"}] }' 3. Note the newly created issue numbers.