refactor: remove test-only compatibility helpers in rollout and agent_savings

Remove rollout.current_rollout(), rollout.feature_enabled(), the Rollout = RolloutSnapshot alias, and agent_savings.with_target_savings(). Their only callers were their own tests. test_rollout now calls resolve_rollout(), which is what the helpers wrapped. The with_target_savings test goes with the function.

None of these modules has an __all__ or re-exports these names. None of the names is documented, and no consumer repo imports headroom.rollout or headroom.agent_savings. The Rollout alias's own comment called it an undocumented in-branch shim.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tejas Chopra
2026-10-09 17:17:15 -07:00
co-authored by Claude Opus 5.5
parent a9815bbb5f
commit af71b61ab2
4 changed files with 8 additions and 57 deletions
+1 -16
View File
@@ -5,7 +5,7 @@ from __future__ import annotations
import logging
import os
from collections.abc import MutableMapping
from dataclasses import dataclass, replace
from dataclasses import dataclass
from typing import Protocol
logger = logging.getLogger(__name__)
@@ -408,18 +408,3 @@ def seed_proxy_env_defaults(
# already in the env and otherwise falls back to DEFAULT_PROFILE (coding).
apply_agent_savings_env_defaults(target)
return frozenset(key for key in target if key not in before)
def with_target_savings(
profile: AgentSavingsProfile,
target_savings: float,
) -> AgentSavingsProfile:
"""Return a copy of ``profile`` adjusted to a specific savings target."""
if not 0 < target_savings < 1:
raise ValueError("target_savings must be between 0 and 1")
return replace(
profile,
target_savings=target_savings,
target_ratio=round(1 - target_savings, 4),
)
-23
View File
@@ -478,26 +478,3 @@ def _resolve_snapshot(
config=config,
decisions=tuple(decisions),
)
def current_rollout(environ: Mapping[str, str] | None = None) -> RolloutSnapshot:
"""Compatibility name for resolving a snapshot at a composition boundary."""
return resolve_rollout(environ)
def feature_enabled(
feature: str,
*,
explicit: bool = False,
environ: Mapping[str, str] | None = None,
) -> bool:
"""Compatibility helper for composition roots; do not use in deep components."""
requested = (feature,) if explicit else ()
return resolve_rollout(environ, requested=requested).is_enabled(feature)
# The PR was never released, but this narrow source alias keeps in-branch callers
# importable while the correction migrates them. It is intentionally undocumented.
Rollout = RolloutSnapshot
-8
View File
@@ -17,7 +17,6 @@ from headroom.agent_savings import (
get_agent_savings_profile,
proxy_pipeline_kwargs,
seed_proxy_env_defaults,
with_target_savings,
)
from headroom.cli import wrap as wrap_module
from headroom.cli.main import main
@@ -210,13 +209,6 @@ def test_unknown_agent_savings_profile_falls_back_to_default(
assert DEFAULT_PROFILE in caplog.text
def test_with_target_savings_recomputes_target_ratio() -> None:
profile = with_target_savings(get_agent_savings_profile("balanced"), 0.85)
assert profile.target_savings == 0.85
assert profile.target_ratio == 0.15
def test_agent_savings_cli_renders_shell_exports() -> None:
result = CliRunner().invoke(main, ["agent-savings", "--profile", "agent-90"])
+7 -10
View File
@@ -16,8 +16,6 @@ from headroom.rollout import (
RolloutChannel,
RolloutConfigurationError,
RolloutSnapshot,
current_rollout,
feature_enabled,
registry_digest,
resolve_rollout,
)
@@ -323,8 +321,8 @@ def test_worker_rollout_handoff_rejects_non_object_state() -> None:
RolloutSnapshot.from_internal_dict([]) # type: ignore[arg-type]
def test_snapshot_query_and_compatibility_helpers() -> None:
snapshot = current_rollout(
def test_snapshot_query_helpers() -> None:
snapshot = resolve_rollout(
{
"HEADROOM_ROLLOUT_CHANNEL": "canary",
"HEADROOM_FEATURES": "tool_result_interceptors",
@@ -335,12 +333,11 @@ def test_snapshot_query_and_compatibility_helpers() -> None:
assert snapshot.is_available("tool-result-interceptors") is True
assert snapshot.enabled == frozenset({"tool_result_interceptors"})
assert snapshot.disabled == frozenset({"read_maturation"})
assert feature_enabled(
"tool_result_interceptors",
explicit=True,
environ={"HEADROOM_ROLLOUT_CHANNEL": "canary"},
)
assert not feature_enabled("tool_result_interceptors", environ={})
assert resolve_rollout(
{"HEADROOM_ROLLOUT_CHANNEL": "canary"},
requested=("tool_result_interceptors",),
).is_enabled("tool_result_interceptors")
assert not resolve_rollout({}).is_enabled("tool_result_interceptors")
with pytest.raises(KeyError, match="missing"):
snapshot.decision("missing")