elastic / elastic/ai-github-actions
[autonomy-atomicity] Scope Claude PR review comment queue per run
- Dominant language
- Python
- Stars
- 11
- Forks
- 16
- Avg merge
- 22h 9m
- Merged PRs (30d)
- 31
Description
## Autonomy / Atomicity Findings
### 1. Claude PR review helpers share a fixed comment queue
**Category:** Global state
**File(s):** `claude-workflows/pr-review/ro/action.yml`, `claude-workflows/pr-review/rwx/action.yml`, `claude-workflows/mention-in-pr/rwx/action.yml`, `claude-workflows/mention-in-pr/rwxp/action.yml`, `claude-workflows/pr-review/scripts/pr-comment.sh`, `claude-workflows/pr-review/scripts/pr-review.sh`
**Problem:** The Claude PR review and mention-in-PR composite actions all set `PR_REVIEW_COMMENTS_DIR` to the same fixed path, `/tmp/pr-review-comments` (`claude-workflows/pr-review/ro/action.yml:101`, `claude-workflows/pr-review/rwx/action.yml:101`, `claude-workflows/mention-in-pr/rwx/action.yml:94`, `claude-workflows/mention-in-pr/rwxp/action.yml:94`). `pr-comment.sh` writes every queued review comment into that directory (`claude-workflows/pr-review/scripts/pr-comment.sh:194-225`) and the JSON it writes contains only path/line/body metadata, not the repository, PR, run, or attempt (`claude-workflows/pr-review/scripts/pr-comment.sh:227-252`). `pr-review.sh` then reads every `comment-*.json` from the same directory without filtering by run or PR (`claude-workflows/pr-review/scripts/pr-review.sh:119-128`). Cleanup happens only after a successful review submission (`claude-workflows/pr-review/scripts/pr-review.sh:278-288`), so a failed submission or a later invocation in the same reusable runner/job can leave stale queued comments for another review.
When two developers or agents change PR-review behavior concurrently, they are coupled through this implicit global queue: fixes to queueing, removal, and submission all have to preserve the same unscoped directory contract, and stale files can cause comments from one PR review invocation to be submitted with another.
**Suggested fix:** Scope the queue to the workflow invocation and PR, for example `${RUNNER_TEMP}/pr-review-comments/${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}-${PR_REVIEW_REPO//\//_}-${PR_REVIEW_PR_NUMBER}`, create/clean it at action start, and include run/PR metadata in queued comment files so `pr-review.sh` can ignore mismatches defensively.
## Suggested Actions
- [ ] Replace the fixed `/tmp/pr-review-comments` environment value in all four composite actions with a run/PR-scoped directory under `RUNNER_TEMP`.
- [ ] Have `pr-comment.sh` include repository, PR number, run ID, and run attempt metadata in queued comment JSON.
- [ ] Have `pr-review.sh` ignore or fail fast on queued comments whose metadata does not match the current review context.
- [ ] Clean the scoped queue at action start and after successful submission so retries do not inherit stale comments.
---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Trigger Autonomy Atomicity Analyzer](https://github.com/elastic/ai-github-actions/actions/runs/27971906540)
Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.
Contributor guide
Research direction
Read the four composite action.yml files to trace how PR_REVIEW_COMMENTS_DIR is set, then follow queue creation in pr-comment.sh and consumption and cleanup in pr-review.sh. Done means the queue and comment metadata are scoped to the workflow run and PR, mismatches are handled defensively, and stale files cannot leak across retries or invocations.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bash, github-actions
- Domain
- ci-cd, tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 52/100