refactor(core): remove unreferenced helpers, attributes and a shadowed module

Nothing calls any of these: no product code, tests, docs, crates or private consumer repos.

- headroom/cli.py: the headroom/cli/ package shadows it, in both the published 0.40.0 wheel and an editable install, so it cannot be imported. Also drop its coverage omit entry.
- HeadroomClient._call_openai / _call_anthropic: _create calls call_client_transport directly since b17c6d81.
- copilot_auth.copilot_api_url: a wrapper that only forwards to _configured_api_url.
- perf.analyzer._litellm_cost; ccr.batch_processor.APIClient; BatchContextStore._cleanup_task and HeadroomMCPServer._compressor_initialized (set, never read); toin DEFAULT_TOIN_DIR / DEFAULT_TOIN_FILE; FieldSemantics.is_value_important.

Evidence: a word-boundary grep for each name across headroom, crates, plugins, sdk, scripts, docs, wiki, tests, pyproject.toml and the consumer clones finds only the definition.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Assisted-by: claude-code:claude-opus-5-5
Headline-Session: 6e77a807-8dd4-4a77-a2fa-ddce6dc2515e
Headline-AI-Share: 75% strict / 75% weighted
This commit is contained in:
Tejas Chopra
2026-10-09 16:49:47 -07:00
co-authored by Claude Opus 5.5
parent a9815bbb5f
commit 221984e807
10 changed files with 4 additions and 140 deletions
+1 -14
View File
@@ -23,7 +23,7 @@ from __future__ import annotations
import json
import logging
from dataclasses import dataclass
from typing import Any, Protocol
from typing import Any
import httpx
@@ -34,19 +34,6 @@ from .tool_injection import CCR_TOOL_NAME
logger = logging.getLogger(__name__)
class APIClient(Protocol):
"""Protocol for making API calls."""
async def post(
self,
url: str,
headers: dict[str, str],
json: dict[str, Any],
) -> httpx.Response:
"""Make a POST request."""
...
@dataclass
class BatchResultProcessorConfig:
"""Configuration for batch result processing."""
-1
View File
@@ -126,7 +126,6 @@ class BatchContextStore:
self._ttl = ttl
self._max_contexts = max_contexts
self._lock = asyncio.Lock()
self._cleanup_task: asyncio.Task | None = None
async def store(self, context: BatchContext) -> None:
"""Store a batch context.
-1
View File
@@ -388,7 +388,6 @@ class HeadroomMCPServer:
self._stats = SessionStats()
self._local_store: Any = None # Lazy-initialized CompressionStore
self._token_estimator: EstimatingTokenCounter | None = None
self._compressor_initialized = False
# File read cache: path → (content_hash, ccr_hash, line_count, token_count)
self._file_cache: dict[str, tuple[str, str, int, int]] = {}
-6
View File
@@ -1,6 +0,0 @@
"""Backwards compatibility - CLI moved to headroom.cli package."""
from headroom.cli import main
if __name__ == "__main__":
main()
-40
View File
@@ -642,46 +642,6 @@ class HeadroomClient:
self._storage.save(metrics)
raise
def _call_openai(
self,
*,
model: str,
messages: list[dict[str, Any]],
stream: bool,
metrics: RequestMetrics,
**kwargs: Any,
) -> Any:
"""Call OpenAI-style API."""
return call_client_transport(
"openai",
self,
model=model,
messages=messages,
stream=stream,
metrics=metrics,
**kwargs,
)
def _call_anthropic(
self,
*,
model: str,
messages: list[dict[str, Any]],
stream: bool,
metrics: RequestMetrics,
**kwargs: Any,
) -> Any:
"""Call Anthropic-style API."""
return call_client_transport(
"anthropic",
self,
model=model,
messages=messages,
stream=stream,
metrics=metrics,
**kwargs,
)
def _wrap_stream(
self,
stream: Iterator[Any],
-11
View File
@@ -281,17 +281,6 @@ def _configured_api_url() -> str:
return DEFAULT_API_URL
def copilot_api_url() -> str:
"""Return the configured Copilot API base URL without any network calls.
Resolves ``GITHUB_COPILOT_API_URL``, then the configured enterprise domain,
then ``api.githubcopilot.com``. Unlike :func:`resolve_copilot_api_url` this
performs no token exchange, so it is safe to call while routing a request.
"""
return _configured_api_url()
# GitHub's token exchange advertises the host that serves inline completions
# under ``endpoints.proxy``, alongside the ``endpoints.api`` chat host. It is
# recorded here when observed so completions routing uses GitHub's own answer
+3 -30
View File
@@ -67,12 +67,11 @@ _STAGE_TIMINGS_RE = re.compile(
# ---------------------------------------------------------------------------
# Cache-aware pricing via LiteLLM
# List pricing via LiteLLM
# ---------------------------------------------------------------------------
# LiteLLM already knows per-token costs for 100+ models including
# cache_read and cache_creation pricing. We call it directly instead
# of maintaining our own pricing tables.
# LiteLLM already knows per-token costs for 100+ models. We read it
# directly instead of maintaining our own pricing tables.
try:
import litellm as _litellm
@@ -82,32 +81,6 @@ except ImportError:
_LITELLM_AVAILABLE = False
def _litellm_cost(
model: str,
prompt_tokens: int,
cache_read_tokens: int = 0,
cache_write_tokens: int = 0,
) -> float | None:
"""Compute input cost via litellm.cost_per_token (cache-aware).
Returns total input cost in USD, or None if model not found.
"""
if not _LITELLM_AVAILABLE:
return None
resolved = resolve_litellm_model(model)
try:
input_cost, _ = _litellm.cost_per_token(
model=resolved,
prompt_tokens=prompt_tokens,
completion_tokens=0,
cache_read_input_tokens=cache_read_tokens,
cache_creation_input_tokens=cache_write_tokens,
)
return float(input_cost)
except Exception:
return None
def _get_list_price(model: str) -> float | None:
"""Get list input price per 1M tokens."""
if not _LITELLM_AVAILABLE:
-32
View File
@@ -633,38 +633,6 @@ class FieldSemantics:
self.inferred_type = inferred
self.confidence = confidence
def is_value_important(self, value_hash: str) -> bool:
"""Check if a specific value is considered important.
A value is important if:
1. It's in the important_value_hashes list (has been retrieved)
2. It's NOT the default value (for error_indicator type)
Args:
value_hash: SHA256[:8] hash of the value to check.
Returns:
True if this value should be preserved during compression.
"""
# If we don't have enough data, be conservative
if self.confidence < 0.3:
return False
# For error_indicator: non-default values are important
if self.inferred_type == "error_indicator":
if self.default_value_hash and value_hash != self.default_value_hash:
return True
# For any type: values that have been retrieved are important
if value_hash in self.important_value_hashes:
return True
# For status: check if this value has been retrieved
if self.inferred_type == "status":
return value_hash in self.value_retrieval_frequency
return False
@dataclass
class CompressionEvent:
-4
View File
@@ -78,10 +78,6 @@ logger = logging.getLogger(__name__)
# Environment variable for custom TOIN storage path
TOIN_PATH_ENV_VAR = "HEADROOM_TOIN_PATH"
# Default TOIN storage directory and file
DEFAULT_TOIN_DIR = ".headroom"
DEFAULT_TOIN_FILE = "toin.json"
# ── Aggregation-key defaults ────────────────────────────────────────────
# Used when callers haven't plumbed auth-mode / model-family detection
# (PR-F3 wires the real detectors). Shipping a real `"unknown"` slice is
-1
View File
@@ -541,7 +541,6 @@ markers = [
source = ["headroom"]
branch = true
omit = [
"headroom/cli.py",
"*/tests/*",
]