test: stop the suite POSTing beacon events to production

_scrub_developer_headroom_env deletes every HEADROOM_* var so tests are
hermetic. That now includes HEADROOM_BEACON, which defaults to on — so the
fixture that exists for isolation is exactly what switched the beacon on,
and with HEADROOM_TELEMETRY_ENDPOINT scrubbed too it fell back to the real
production endpoint.

Every test reaching the outcome funnel POSTed a live session event. Caught
by finding 10 unexplained objects in the corpus after a local run; CI would
have done the same on every push.

Adds an autouse fixture pinning HEADROOM_BEACON=off, ordered after the
scrub by depending on it. Tests that want the beacon on set the var
themselves.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra 2026-08-03 05:34:38 -07:00
parent be96e16d30
commit 36a97658c0

View file

@ -30,6 +30,21 @@ def _scrub_developer_headroom_env(monkeypatch):
monkeypatch.delenv("ANTHROPIC_CUSTOM_HEADERS", raising=False)
# The scrub above deletes every HEADROOM_* var — which includes HEADROOM_BEACON,
# and the beacon defaults to ON. So scrubbing for hermeticity is precisely what
# switches it on, and with HEADROOM_TELEMETRY_ENDPOINT scrubbed too it falls back
# to the real production endpoint. Every test that reaches the outcome funnel
# then POSTs a session event for real: observed writing into the live corpus
# during a local run, and CI would do the same on every push.
#
# Depends on the scrub fixture so it is guaranteed to run after it rather than
# relying on declaration order. A test that wants the beacon on just sets the
# var itself — monkeypatch inside the test wins over this.
@pytest.fixture(autouse=True)
def _disable_telemetry_beacon(monkeypatch, _scrub_developer_headroom_env):
monkeypatch.setenv("HEADROOM_BEACON", "off")
# The MCP install ledger defaults to ``~/.headroom/mcp_installs.json``, so any
# test that registers a server (directly or through `wrap`) writes into the
# developer's REAL ledger — observed adding a live `claude/serena` entry during a