elastic / elastic/ai-github-actions

[autonomy-atomicity] MkDocs hook global temp-dir state creates order-dependent build coupling

Open
#784 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. Global `_tmp_dir` mutable state in docs hook
**Category:** Global state | Ordering dependency
**File(s):** `docs/hooks.py`, `mkdocs.yml`

**Problem:**
The docs generation hook stores per-build state in a module-level mutable variable (`_tmp_dir`). This couples hook functions through implicit execution order (`on_pre_build` must run before `on_files`) and makes the behavior fragile when builds run concurrently or when hook invocation patterns change.

**Evidence:**
- `docs/hooks.py:17` defines global mutable state: `_tmp_dir: str | None = None`
- `docs/hooks.py:79-85` mutates that global in `on_pre_build(...)`
- `docs/hooks.py:101` uses `Path(_tmp_dir)` in `on_files(...)`
- `docs/hooks.py:108` passes `src_dir=_tmp_dir` into generated `File(...)`
- `mkdocs.yml:12-13` registers this hook module (`hooks: - docs/hooks.py`)

Because the temp directory is global module state, unrelated changes to docs generation logic must coordinate on the same shared variable and lifecycle, increasing parallel-change contention and risk of subtle ordering breakage.

**Suggested fix:**
Refactor to remove module-level `_tmp_dir`:
- Create temp dir per build in a state object attached to `config` (or equivalent explicit context)
- Pass that state explicitly to page generation/file appending logic
- Keep cleanup tied to that explicit state rather than global mutable variable

## Suggested Actions
- [ ] Replace global `_tmp_dir` with explicit per-build hook state
- [ ] Update `on_files` to read temp dir from explicit state/context instead of module global
- [ ] Add a focused test for hook lifecycle assumptions (pre-build/files order and isolation)

> [!NOTE]
>
> 🔒 Integrity filtering filtered 101 items
>
> Integrity filtering activated and filtered the following items during workflow execution.
> This happens when a tool call accesses a resource that does not meet the required integrity or secrecy level of the workflow.
>
> - issue:elastic/ai-github-actions#unknown (`search_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#783 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#782 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#781 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#780 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#779 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#778 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#777 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#776 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#775 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#774 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#773 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#771 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#770 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#769 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - issue:elastic/ai-github-actions#768 (`list_issues`: has lower integrity than agent requires. The agent cannot read data with integrity below "approved".)
> - ... and 85 more items
>
>

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

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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.