CLI-547 Experiment with a new agentic workflow#350
CLI-547 Experiment with a new agentic workflow#350damien-urruty-sonarsource wants to merge 3 commits into
Conversation
|
|
||
| concurrency: ci-triage-${{ github.run_id }} | ||
|
|
||
| concurrency: night-owl |
There was a problem hiding this comment.
💡 Quality: ci-failure-triage-agent.md fully repurposed but keeps old name
The ci-failure-triage-agent.md workflow has been entirely replaced with the Night Owl logic (identical env vars, prompt, safe-outputs). This means the original CI failure triage functionality is lost. The workflow file name, the GitHub Actions name: field ("CI Failure Triage Agent"), and the run-name in the lock file are now misleading. Consider either:
- Keeping the CI failure triage agent intact and only adding the new
night-owl.mdworkflow, or - Renaming/removing the old file to avoid confusion.
The comment on line 124 says it's "temporarily repurposed", but having two identically-functioning workflows (night-owl.md and ci-failure-triage-agent.md) with the same concurrency group (night-owl) and the same cron schedule could cause unintended mutual cancellation.
Was this helpful? React with 👍 / 👎
10a4170 to
e5d065d
Compare
Agentic Analysis: Early ResultsAgentic Analysis and Context Augmentation are available on your project. Here are some issues that could have been prevented. Follow the links to learn how to put them into action. 19 issue(s) found across 1 file(s):
Analyzed by SonarQube Agentic Analysis in 3.5 s |
a9de2cd to
736b187
Compare
| issue_description_text() { | ||
| local issue_json="$1" | ||
| local description_text | ||
|
|
||
| description_text="$( | ||
| jq '.fields.description // .description // null' <<<"$issue_json" | adf_to_text | ||
| )" | ||
|
|
||
| if [ -n "$(compact_text "$description_text")" ]; then | ||
| printf '%s\n' "$description_text" | ||
| else | ||
| printf '_None provided._\n' | ||
| fi | ||
| } |
There was a problem hiding this comment.
💡 Security: Untrusted Jira content injected verbatim into autonomous agent prompt
prepare-jira-context.sh builds context_markdown from Jira ticket summary, description, comments, and linked-issue fields (issue_description_text/format_comments_markdown/format_links_markdown) and emits it to GITHUB_OUTPUT. Both night-owl.md and ci-failure-triage-agent.md then inline ${{ needs.night_owl_prepare.outputs.context_markdown }} directly into the agent prompt and instruct the agent to 'Treat the prepared Jira content above as the source of truth.' The agent has the create_pull_request safe output, so a Jira ticket (any CLI ticket labeled for-agent) whose description/comments contain adversarial instructions becomes an XPIA / prompt-injection vector that can steer autonomous code changes and PRs.
This is partially mitigated by the gh-aw xpia.md guard prompt, and the surface is not strictly new (Jira was previously read via MCP). However, the change moves the content into the static prompt body rather than tool results. Consider: (1) clearly delimiting the Jira content as untrusted data in the prompt rather than 'source of truth', and (2) tightening the agent job's firewall — it still allows api.atlassian.com / sonarsource.atlassian.net even though the agent no longer needs Jira access (the prepare job does), so those domains are unnecessary egress/exfiltration surface for the agent.
Was this helpful? React with 👍 / 👎
| has_open_pr_for_key() { | ||
| local key="$1" | ||
| local pattern="(^|[^A-Z0-9])${key}([^A-Z0-9]|$)" | ||
|
|
||
| jq -e --arg pattern "$pattern" ' | ||
| any( | ||
| .[]?; | ||
| ([.title // "", .body // "", .headRefName // ""] | join("\n")) | test($pattern; "i") | ||
| ) | ||
| ' <<<"$OPEN_PULL_REQUESTS_JSON" >/dev/null | ||
| } |
There was a problem hiding this comment.
💡 Edge Case: Open-PR dedup capped at 100 PRs and relies on exact key text match
OPEN_PULL_REQUESTS_JSON is fetched with gh pr list --state open --limit 100, and has_open_pr_for_key only matches the Jira key as a token in title/body/headRefName. If a repository has more than 100 open PRs, an in-flight ticket may not be found and Night Owl could start duplicate work on a ticket already covered by an open PR. The match also fails entirely if a previous night-owl PR did not embed the Jira key in its title/body/branch. Consider raising/removing the limit (or filtering by the night-owl label/author) and ensuring created PRs always embed the Jira key.
Was this helpful? React with 👍 / 👎
| --json number,title,body,headRefName,url | ||
| )" | ||
|
|
||
| SEARCH_RESULTS_JSON="$(search_workitems)" |
There was a problem hiding this comment.
💡 Quality: Malformed acli search output is silently reported as 'starving'
The candidate loop is fed by a process substitution: done < <(normalize_collection <<<"$SEARCH_RESULTS_JSON" | jq -c '.[]?'). With set -euo pipefail, a failure inside a process substitution does not abort the parent shell. If acli ... search returns output that is not valid JSON (or an unexpected shape normalize_collection cannot match), the pipeline fails/produces nothing, the loop iterates zero times, candidate_count stays 0, and the script emits a 'No Jira ticket matched' starving Slack message and exits 0 — masking an actual infrastructure/query error as routine starvation. Consider validating SEARCH_RESULTS_JSON parses as JSON (e.g. jq empty with explicit error handling) before the loop so genuine failures route to night_owl_prepare_failure_notify instead of the starving path.
Was this helpful? React with 👍 / 👎
736b187 to
90d00f1
Compare
90d00f1 to
667136a
Compare
667136a to
7405032
Compare
7405032 to
9ca58e9
Compare
Code Review 👍 Approved with suggestions 1 resolved / 5 findingsIntroduces the night-owl agentic workflow for Jira ticket processing and refactors CI triage infrastructure. Rename the repurposed 💡 Quality: ci-failure-triage-agent.md fully repurposed but keeps old name📄 .github/workflows/ci-failure-triage-agent.md:7 📄 .github/workflows/ci-failure-triage-agent.md:122-124 📄 .github/workflows/ci-failure-triage-agent.lock.yml:73 📄 .github/workflows/ci-failure-triage-agent.md 📄 .github/workflows/ci-failure-triage-agent.lock.yml:59 📄 .github/workflows/ci-failure-triage-agent.lock.yml:61-62 📄 .github/workflows/night-owl.lock.yml:61-62 📄 .github/workflows/night-owl.lock.yml:73 📄 .github/workflows/ci-failure-triage-agent.md:3-4 📄 .github/workflows/night-owl.md:3-4 📄 .github/workflows/night-owl.md:7 The
The comment on line 124 says it's "temporarily repurposed", but having two identically-functioning workflows ( 💡 Security: Untrusted Jira content injected verbatim into autonomous agent prompt📄 .github/scripts/night-owl/prepare-jira-context.sh:124-137 📄 .github/scripts/night-owl/prepare-jira-context.sh:151-165 📄 .github/scripts/night-owl/prepare-jira-context.sh:183-197 📄 .github/scripts/night-owl/prepare-jira-context.sh:434-446 📄 .github/workflows/night-owl.md:200 📄 .github/workflows/night-owl.md:217-219 📄 .github/workflows/night-owl.lock.yml:805
This is partially mitigated by the gh-aw 💡 Edge Case: Open-PR dedup capped at 100 PRs and relies on exact key text match📄 .github/scripts/night-owl/prepare-jira-context.sh:139-149 📄 .github/scripts/night-owl/prepare-jira-context.sh:274-280
💡 Quality: Malformed acli search output is silently reported as 'starving'📄 .github/scripts/night-owl/prepare-jira-context.sh:282 📄 .github/scripts/night-owl/prepare-jira-context.sh:289 📄 .github/scripts/night-owl/prepare-jira-context.sh:332 📄 .github/scripts/night-owl/prepare-jira-context.sh:334-338 The candidate loop is fed by a process substitution: ✅ 1 resolved✅ Security: Credentials in job output not masked with add-mask
🤖 Prompt for agentsOptionsAuto-apply is off → Gitar will not commit updates to this branch. Comment with these commands to change:
Was this helpful? React with 👍 / 👎 | Gitar |
|



Summary by Gitar
night-owlagentic workflow for automated Jira ticket processing.prepare-jira-context.shto automate Atlassian CLI authentication and Jira context gathering.night-owl.mdandnight-owl.lock.ymlto define the new workflow architecture.ci-failure-triage-agentto align with the newnight-owlconcurrency patterns and operational standards.CLAUDE.mdwith guidelines and instructions for implementing the new agentic workflow.This will update automatically on new commits.