elastic / elastic/ai-github-actions

[autonomy-atomicity] Shared /tmp/pr-context path creates cross-run and cross-test coupling

Open
#1,816 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
11
Forks
16
Avg merge
22h 9m
Merged PRs (30d)
31

Description

## Autonomy / Atomicity Findings

### 1. Shared PR context workspace is a global mutable hotspot
**Category:** Global state / Config hotspot
**File(s):**
- `.github/workflows/gh-aw-fragments/pr-context.md` (notably lines 9, 13, 16, 23, 30, 42, 51, 57, 89, 127, 157, 163)
- `.github/workflows/gh-aw-fragments/safe-output-push-to-pr.md` (lines 17-21, 86-89)
- `tests/test_safe_input_ready_to_make_pr.py` (lines 424-435, 446-453)
- Workflow sources importing this fragment: `gh-aw-pr-review.md`, `gh-aw-pr-review-addresser.md`, `gh-aw-pr-conflict-addresser.md`, `gh-aw-mention-in-pr.md`, `gh-aw-mention-in-pr-no-sandbox.md`

**Problem:**
`pr-context.md` writes all PR metadata and derived artifacts to a fixed global location (`/tmp/pr-context/*`). Other logic reads this same fixed path (`safe-output-push-to-pr.md` reads `/tmp/pr-context/pr.json`), and tests also write/remove that same global file path directly.

This creates coupling between unrelated work:
1. Parallel runs on shared runners can clobber each other’s `/tmp/pr-context/*` files.
2. New behavior in one workflow that changes PR-context file layout/names can break other workflows that assume the same global location.
3. Tests rely on process-global `/tmp/pr-context/pr.json`, introducing ordering/shared-state risk when tests are parallelized or when cleanup fails.

**Suggested fix:**
Make PR context directory run-scoped and injectable.
- Create a unique directory per run (for example via `mktemp -d` or `${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}` suffix).
- Export it as a single env var (for example `PR_CONTEXT_DIR`) and replace hardcoded `/tmp/pr-context` reads/writes in all fragments.
- In tests, use `tmp_path` (or monkeypatched env) instead of fixed `/tmp/pr-context/pr.json`.

## Suggested Actions
- [ ] Introduce a run-scoped `PR_CONTEXT_DIR` in `gh-aw-fragments/pr-context.md` and write all artifacts there.
- [ ] Update consumers (including `safe-output-push-to-pr.md`) to read PR context via `PR_CONTEXT_DIR` only.
- [ ] Refactor `tests/test_safe_input_ready_to_make_pr.py` helpers to avoid fixed `/tmp/pr-context` paths and use test-scoped temporary directories.

---
[What is this?](https://ela.st/github-ai-tools) | [From workflow: Trigger Autonomy Atomicity Analyzer](https://github.com/elastic/ai-github-actions/actions/runs/31617119635)

Give us feedback! React with 🚀 if perfect, 👍 if helpful, 👎 if not.

Contributor guide

Open the contributing guide

Research direction

Start with .github/workflows/gh-aw-fragments/pr-context.md and trace its fixed /tmp/pr-context writes, then inspect safe-output-push-to-pr.md and the listed importing workflows for consumers. Review tests/test_safe_input_ready_to_make_pr.py helpers and their fixed paths. Done means all producers and consumers use an injectable run-scoped PR_CONTEXT_DIR and tests use test-scoped temporary directories without shared-state coupling.

Written by the indexing model from the issue text.

Assessment

Tech stack
github-actions, python
Domain
ci-cd, testing-qa
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
67/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.