Skip to content

Commit ab0cb0c

Browse files
janiszclaude
andcommitted
Replace filter with JQL search and add auto-triaged label for idempotency
Changes: - Replace JIRA filter 103399 with explicit JQL search in ambient.json - Add auto-triaged label exclusion to JQL query - Update Phase 7 to add auto-triaged label after posting comment - Remove duplicate comment detection (replaced by label exclusion) - Update workflow description to explain label-based idempotency This enables safe hourly automated runs - only new untriaged issues are processed. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 513796f commit ab0cb0c

3 files changed

Lines changed: 45 additions & 21 deletions

File tree

workflows/acs-triage/.ambient/ambient.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44
"config": {
55
"jira": {
66
"project": "ROX",
7-
"filter": 103399
7+
"jql": "project = ROX AND (type = Bug OR type = Vulnerability OR type = Weakness OR type = Ticket) AND status = New AND parent is EMPTY AND Team is EMPTY AND assignee is EMPTY AND labels NOT IN (auto-triaged) ORDER BY created",
8+
"autoTriagedLabel": "auto-triaged"
89
},
910
"timeout": 300,
1011
"maxIssues": 20
1112
},
12-
"systemPrompt": "You are an ACS/StackRox Triage Specialist. Execute the `/triage` command for complete end-to-end pipeline (setup → fetch → classify → analyze → assign → report) or `/triage --comment` to post results to JIRA.\n\n**Key Commands:** `/triage` (filter 103399), `/triage ROX-12345` (specific issue), `/triage --comment` (writes to JIRA), `/comment-issues` (standalone commenting)\n\n**Early Exit:** If filter 103399 returns 0 issues, exit immediately with \"No untriaged issues found\" (don't proceed with empty pipeline).\n\n**Duplicate Prevention:** Before posting comments (--comment flag), check if issue already has a triage comment (search for \"🤖 Automated Triage Analysis\" or \"_Generated by ACS Triage Workflow_\"). Skip if already triaged.\n\n**Workflow Details:** See `.claude/commands/triage.md` for complete 7-phase pipeline. **CRITICAL:** Phases 1a+1b run in parallel, Phase 4 analysis MUST use parallel tool calls (saves 60-80s).\n\n**Domain Knowledge:** Consult `reference/*.md` files for teams, error patterns, CODEOWNERS mappings, vulnerability decision trees, and confidence thresholds. Team assignment uses 5-strategy priority system (95%-70% confidence).\n\n**Performance:** Load files once and cache. Primary JIRA query in Phase 1b. Max 3-5 additional batched queries for similar issue searches. See triage.md Performance Optimization Guidelines.\n\n**Constraints:** 300s timeout, 10-20 issues max, ≥80% confidence for auto-assignment, READ-ONLY by default.\n\n**Outputs:** All artifacts in `artifacts/acs-triage/` (setup-info.json, issues.json, triage-report.md, summary.json).\n\nFor complete documentation, see `CLAUDE.md`.",
13-
"startupPrompt": "Greet the user and introduce yourself as an ACS Triage Specialist. Briefly explain that you execute automated triage for StackRox/ACS JIRA issues from filter 103399 (CI failures, vulnerabilities, flaky tests) and generate comprehensive reports with intelligent team assignments using confidence scoring. Explain the available commands: `/triage` (complete pipeline, READ-ONLY), `/triage --comment` (pipeline + post to JIRA), `/comment-issues` (standalone comment posting). Mention the workflow is streamlined into a single command that handles everything: fetch → classify → analyze → assign → report."
13+
"systemPrompt": "You are an ACS/StackRox Triage Specialist. Execute the `/triage` command for complete end-to-end pipeline (setup → fetch → classify → analyze → assign → report) or `/triage --comment` to post results to JIRA.\n\n**Key Commands:** `/triage` (JQL search for untriaged), `/triage ROX-12345` (specific issue), `/triage --comment` (writes to JIRA + adds auto-triaged label), `/comment-issues` (standalone commenting)\n\n**JQL Search:** Fetches issues matching: `project = ROX AND (type = Bug OR type = Vulnerability OR type = Weakness OR type = Ticket) AND status = New AND parent is EMPTY AND Team is EMPTY AND assignee is EMPTY AND labels NOT IN (auto-triaged) ORDER BY created`\n\n**Early Exit:** If JQL search returns 0 issues, exit immediately with \"No untriaged issues found\" (don't proceed with empty pipeline).\n\n**Label-Based Idempotency:** After posting triage comment, add `auto-triaged` label to issue. This prevents re-processing on subsequent runs. Workflow is fully idempotent and safe to run frequently.\n\n**Workflow Details:** See `.claude/commands/triage.md` for complete 7-phase pipeline. **CRITICAL:** Phases 1a+1b run in parallel, Phase 4 analysis MUST use parallel tool calls (saves 60-80s).\n\n**Domain Knowledge:** Consult `reference/*.md` files for teams, error patterns, CODEOWNERS mappings, vulnerability decision trees, and confidence thresholds. Team assignment uses 5-strategy priority system (95%-70% confidence).\n\n**Performance:** Load files once and cache. Primary JIRA query in Phase 1b. Max 3-5 additional batched queries for similar issue searches. See triage.md Performance Optimization Guidelines.\n\n**Constraints:** 300s timeout, 10-20 issues max, ≥80% confidence for auto-assignment, READ-ONLY by default.\n\n**Outputs:** All artifacts in `artifacts/acs-triage/` (setup-info.json, issues.json, triage-report.md, summary.json).\n\nFor complete documentation, see `CLAUDE.md`.",
14+
"startupPrompt": "Greet the user and introduce yourself as an ACS Triage Specialist. Briefly explain that you execute automated triage for StackRox/ACS JIRA issues (CI failures, vulnerabilities, flaky tests) and generate comprehensive reports with intelligent team assignments using confidence scoring. Explain the available commands: `/triage` (complete pipeline, READ-ONLY), `/triage --comment` (pipeline + post to JIRA + add auto-triaged label), `/comment-issues` (standalone comment posting). Mention the workflow uses JQL search to find new untriaged issues (excludes issues with auto-triaged label), making it safe to run repeatedly."
1415
}

workflows/acs-triage/.claude/commands/triage.md

Lines changed: 34 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
Complete end-to-end triage workflow for StackRox/ACS JIRA issues. Fetches untriaged issues, classifies by type, performs specialized analysis, assigns teams with confidence scoring, and generates comprehensive reports.
66

77
**Options:**
8-
- `/triage` - Full triage pipeline for filter 103399 (READ-ONLY, no JIRA writes)
9-
- `/triage --comment` - Full triage + post comments to JIRA issues
8+
- `/triage` - Full triage pipeline using JQL search (READ-ONLY, no JIRA writes)
9+
- `/triage --comment` - Full triage + post comments to JIRA + add auto-triaged label
1010
- `/triage ROX-12345` - Triage a specific issue by key
11-
- `/triage ROX-12345 --comment` - Triage specific issue and post comment
11+
- `/triage ROX-12345 --comment` - Triage specific issue, post comment, and add label
1212

1313
## Prerequisites
1414

1515
- JIRA MCP connection configured
16-
- Access to JIRA filter 103399 (current untriaged)
16+
- JIRA search capability (mcp__mcp-atlassian__jira_search)
17+
- JIRA update capability (mcp__mcp-atlassian__jira_update_issue) for label application
1718
- GitHub MCP for CODEOWNERS (optional, improves accuracy)
1819

1920
## Workflow Pipeline
@@ -45,10 +46,22 @@ Query JIRA for untriaged issues or fetch a specific issue.
4546
- Validate issue exists, exit with error if not found
4647

4748
**If no issue key (default behavior):**
48-
- Query JIRA filter 103399 (ONE query, order by priority DESC then created ASC)
49+
- Query JIRA using JQL (ONE query):
50+
```jql
51+
project = ROX AND
52+
(type = Bug OR type = Vulnerability OR type = Weakness OR type = Ticket) AND
53+
status = New AND
54+
parent is EMPTY AND
55+
Team is EMPTY AND
56+
assignee is EMPTY AND
57+
labels NOT IN (auto-triaged)
58+
ORDER BY created ASC
59+
```
4960
- Limit to 10-20 issues (timeout constraint: 300s)
5061
- Extract: key, summary, description, labels, components, priority, status, created, updated, affectedVersions, fixVersions, comments
51-
- **CRITICAL:** If filter returns 0 issues, exit immediately with message: "No untriaged issues found in filter 103399. Triage complete."
62+
- **CRITICAL:** If JQL search returns 0 issues, exit immediately with message: "No untriaged issues found. All issues either have auto-triaged label or don't match criteria. Triage complete."
63+
64+
**Label Exclusion:** Issues with `auto-triaged` label are excluded from search, ensuring idempotent workflow execution.
5265

5366
**Output:** Raw issue data in `artifacts/acs-triage/issues.json`
5467

@@ -190,21 +203,25 @@ Create output reports in two formats.
190203
}
191204
```
192205

193-
### Phase 7: Comment to JIRA (Optional)
206+
### Phase 7: Comment to JIRA and Add Label (Optional)
194207
Only if `--comment` flag is provided.
195208

196209
**Actions:**
197210
- For each issue with confidence ≥80%:
198-
- **Check if already triaged:** Search issue comments for "🤖 Automated Triage Analysis" or "_Generated by ACS Triage Workflow_"
199-
- **Skip if already triaged:** If existing triage comment found, do not post duplicate
200-
- **Post comment:** If not previously triaged, post structured comment with team recommendation, confidence, reasoning
201-
- Use comment format from `templates/jira-comment.md`
211+
- **Post comment:** Post structured comment with team recommendation, confidence, reasoning
212+
- Use comment format from `templates/jira-comment.md`
213+
- Use `mcp__mcp-atlassian__jira_add_comment`
214+
- **Add label:** After successful comment post, add `auto-triaged` label to the issue
215+
- Use `mcp__mcp-atlassian__jira_update_issue` with `labels` parameter
216+
- Append to existing labels (don't replace)
217+
- Example: `{"labels": ["auto-triaged"]}`
218+
- **Log:** Record issue key, team, confidence, comment status, and label status
202219
- Skip issues with low confidence (<80%)
203-
- Log all posted comments and skipped issues (with reason)
220+
- Log all posted comments, labels added, and skipped issues (with reason)
204221

205222
**Comment Template:** See `templates/jira-comment.md` for format and variable substitution.
206223

207-
**Duplicate Prevention:** Never post multiple triage comments to the same issue. Check existing comments first.
224+
**Idempotency:** Issues with `auto-triaged` label are excluded in Phase 1b search. This workflow is safe to run repeatedly - only new untriaged issues will be processed.
208225

209226
## Output
210227

@@ -249,9 +266,9 @@ After running this command, you should have:
249266

250267
## Error Handling
251268

252-
- **Empty filter results**: Exit immediately with "No untriaged issues found" message (don't proceed)
269+
- **Empty search results**: Exit immediately with "No untriaged issues found" message (don't proceed)
253270
- **Issue not found**: If specific issue key provided but doesn't exist, exit with error
254-
- **Already triaged**: If `--comment` flag and issue already has triage comment, skip posting (log as "Already triaged")
271+
- **Label application failure**: If comment posted but label add fails, log warning (issue may be re-triaged on next run - safe idempotency)
255272
- **JIRA timeout**: Process what you have, note incomplete in report
256273
- **Unknown issue type**: Mark as UNKNOWN, include raw description for manual triage
257274
- **No team match**: Use "Needs Manual Assignment" with evidence summary
@@ -266,8 +283,9 @@ After running this command, you should have:
266283
- Load reference files (CODEOWNERS, error-signatures.md, etc.) once and cache in memory
267284

268285
**JIRA Queries:**
269-
- Primary fetch: ONE query for filter 103399 (Phase 1b)
286+
- Primary fetch: ONE JQL search query (Phase 1b) - excludes auto-triaged issues
270287
- Similar issue searches (Phase 5): Batch by component, cache results (max 3-5 batched queries)
288+
- Label updates (Phase 7): One update per issue (only when --comment flag used)
271289
- Do NOT query JIRA separately for each issue
272290

273291
**Parallel Execution:**

workflows/acs-triage/CLAUDE.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,13 @@ This is a **single-purpose workflow** for automated triage of StackRox/ACS JIRA
1818
The workflow provides 2 main commands:
1919

2020
- `/triage` - Complete end-to-end triage pipeline: setup → fetch → classify → analyze → assign → report (READ-ONLY)
21-
- `/triage --comment` - Full triage pipeline + post analysis comments to JIRA (⚠️ WRITES to JIRA)
21+
- `/triage --comment` - Full triage pipeline + post analysis comments to JIRA + add auto-triaged label (⚠️ WRITES to JIRA)
2222
- `/comment-issues` - Standalone command to add triage comments to JIRA (requires prior /triage run)
2323

2424
**Simplified Design:** All triage steps are consolidated into a single `/triage` command for ease of use.
2525

26+
**Idempotent Execution:** The workflow uses JQL search with `labels NOT IN (auto-triaged)` exclusion. After triaging an issue and posting a comment, the `auto-triaged` label is added. This makes the workflow safe to run repeatedly - only new untriaged issues will be processed.
27+
2628
## Directory Structure
2729

2830
```
@@ -75,7 +77,8 @@ The workflow is configured in `.ambient/ambient.json`:
7577
"config": {
7678
"jira": {
7779
"project": "ROX",
78-
"filter": 103399
80+
"jql": "project = ROX AND (type = Bug OR type = Vulnerability OR type = Weakness OR type = Ticket) AND status = New AND parent is EMPTY AND Team is EMPTY AND assignee is EMPTY AND labels NOT IN (auto-triaged) ORDER BY created",
81+
"autoTriagedLabel": "auto-triaged"
7982
},
8083
"timeout": 300,
8184
"maxIssues": 20
@@ -85,6 +88,8 @@ The workflow is configured in `.ambient/ambient.json`:
8588

8689
**Simplified Execution**: The `/triage` command internally handles all phases sequentially, with parallel execution for type-specific analysis (CI/vuln/flaky) to save 60-80 seconds.
8790

91+
**Idempotent Design**: Uses JQL search to exclude issues with `auto-triaged` label. After triage+comment, label is added to prevent re-processing.
92+
8893
## Version Mismatch Handling
8994

9095
The triage workflow clones latest `main` branch from StackRox repo. Issues with older `affectedVersions` may have:

0 commit comments

Comments
 (0)