fix(telemetry): keep install ID stateless (#3542)

## Summary

- keep `install_id()` process-local when Headroom is stateless
- prevent disabled telemetry setup from creating
`HEADROOM_WORKSPACE_DIR/config/install_id`
- add a regression test for the no-write invariant

## Reproduction

Start a stateless proxy with `HEADROOM_WORKSPACE_DIR` pointing at a
missing directory. Creating telemetry resource attributes calls
`install_id()` even when telemetry export is disabled, which creates
`config/install_id` under that directory.

## Real behavior proof

- Setup: Windows 10, Python 3.13.7, current `main` (`04cdf79a`),
`HEADROOM_STATELESS=true`
- Before fix: an mcodex-wrapped Headroom session created
`state/config/install_id`; the wrapper rejected the persistent state
root on exit.
- After fix:
- `uv run --frozen --extra dev pytest tests/test_stateless_writers.py
-q` → `13 passed`
- `uv run --frozen ruff check headroom/telemetry/session.py
tests/test_stateless_writers.py` → passed
- `uv run --frozen ruff format --check headroom/telemetry/session.py
tests/test_stateless_writers.py` → 2 files already formatted
- Not tested: non-Windows live proxy traffic against an external
provider.

<!-- devin-review-badge-begin -->

---

<a href="https://app.devin.ai/review/headroomlabs-ai/headroom/pull/3542"
target="_blank"><picture><source media="(prefers-color-scheme: dark)"
srcset="https://static.devin.ai/assets/gh-devin-review-dark.svg?v=4"><img
src="https://static.devin.ai/assets/gh-devin-review-light.svg?v=4"
alt="Devin Review"></picture></a>
<!-- devin-review-badge-end -->

### Maintainer current-main requalification

Exact head `807307d3b32ade50f0f44c0fef622999c119592d`, upstream main
`c01cf07d943d816cfd9d97e6838ed4e38f1ff9a4`.

Clean mechanical sync with upstream main
c01cf07d94. The resulting Git tree is
byte-identical to current main (tree
dfce1ea28e); there is no remaining
contributor source delta. Re-read prior Devin/maintainer discussion and
independently repeated the isolated stateless-to-stateful identity
probe: cached id remains ephemeral across that transition, and simulated
restart creates a new persisted id. Because the identical implementation
is already on main, that behavior is inherited and is not a reason to
withhold source approval of this empty delta. Fresh stateless/telemetry
tests pass; see local test log for exact count. No user identity files
touched (temporary workspace only), no contributor logic changed, no new
native build claimed. Formal approval awaits hosted qualification of
this exact merge head. Nothing merged.


Exact-head hosted checks are being handled by maintainers. No new
finding in the reviewed scope; formal approval awaits exact-head hosted
qualification; nothing merged.

Co-authored-by: JD Davis <mxjerrett@gmail.com>
This commit is contained in:
Syamsul Alam
2026-11-06 09:31:13 -06:00
committed by GitHub
co-authored by JD Davis
parent a538740ee4
commit 27bba79ff2

Diff Content Not Available