The global QuotaTrackerRegistry singleton persists across the process lifetime.
When tests spin up multiple proxy app instances in the same process, each call
to startup() tries to register the same tracker keys (subscription_window,
codex_rate_limits, copilot_quota) into the same registry, triggering:
ValueError: A tracker with key 'subscription_window' is already registered.
Fix: call reset_quota_registry() at the start of startup() so each server
instance begins with a clean registry, then re-registers and re-starts all
trackers fresh. The tracker singletons themselves (configure_subscription_tracker,
get_codex_rate_limit_state, get_copilot_quota_tracker) remain alive and their
state is preserved across restarts.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Three fixes for Docker-native install with --memory:
1. Add sqlite-vec to proxy extras — memory's vector index now installs
with pip install headroom-ai[proxy]. No separate pip install needed.
2. Fix AUTO vector backend fallback — was: SQLITE_VEC → HNSW → crash.
Now: SQLITE_VEC → HNSW → clear error message listing install options.
3. Fix ONNX pthread_setaffinity_np error in Docker containers — set
intra/inter thread count to 1 in SessionOptions. Prevents the
"Invalid argument" error on containers with limited CPU affinity.
Passively capture x-codex-* response headers from proxied Codex API
calls and surface them in /stats and the dashboard.
Unlike Anthropic subscription window tracking (which polls a dedicated
OAuth endpoint), Codex embeds rate-limit data directly in every API
response header — no polling, no new credentials needed.
Changes:
- headroom/subscription/codex_rate_limits.py: new module with
CodexRateLimitWindow, CodexCreditsSnapshot, CodexRateLimitSnapshot
data models and a thread-safe CodexRateLimitState singleton;
parse_codex_rate_limits() parses x-codex-primary/secondary-used-percent,
window-minutes, reset-at, credits, limit-name, and promo-message headers
- headroom/subscription/__init__.py: re-export new public symbols
- headroom/proxy/handlers/openai.py: call
get_codex_rate_limit_state().update_from_headers() after each
proxied /v1/chat/completions and /v1/responses response
- headroom/proxy/server.py: add codex_rate_limits key to /stats
via _get_codex_rate_limit_stats() helper
- headroom/dashboard/templates/dashboard.html: new OpenAI Codex
Rate-Limit Window panel (primary + secondary progress bars, credits
balance, limit name, reset countdown); hidden when no data
- tests/test_codex_rate_limits.py: 25 unit tests covering parsing,
window labels, reset time, credits, state updates
- docs/screenshots/subscription_window_active.png: updated screenshot
showing both Anthropic and Codex panels in the real dashboard
Header schema (from codex-rs/codex-api/src/rate_limits.rs):
x-codex-primary-used-percent / x-codex-primary-window-minutes /
x-codex-primary-reset-at (and secondary- variants)
x-codex-credits-has-credits / -unlimited / -balance
x-codex-limit-name / x-codex-promo-message
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Active state shows the full headroom dashboard with the Anthropic
Subscription Window panel integrated in-line after Savings Breakdown,
including 5h/7d utilisation bars, overage credit bar, Headroom
contribution grid, and anomaly detection alert.
Inactive state shows the standard dashboard without the panel —
it is conditionally rendered only when subscription_window data
is present in /stats.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
No manual install needed. headroom wrap claude --code-graph:
1. Checks if binary exists (PATH or ~/.local/bin/)
2. Downloads from GitHub releases if not found (~15MB, one-time)
3. Indexes project + starts file watcher
Same pattern as rtk auto-download. Platform-aware:
darwin-arm64, darwin-amd64, linux-arm64, linux-amd64, windows-amd64.
Also: add watchdog>=4.0.0 to proxy extras.
Single flag: --code-graph does everything:
1. Indexes project via codebase-memory-mcp at startup
2. Starts background file watcher (watchdog) in the proxy
3. On source file changes: debounced incremental reindex (~0.4s)
4. Cross-platform: FSEvents (macOS), inotify (Linux), Windows
The watcher is agent-agnostic — watches the filesystem, not agent
hooks. Works for Claude Code, Codex, Gemini, Cursor, Aider, anything.
Removed --code-aware flag (broken AST compressor). One flag for code
intelligence, not two confusing options.
New module: headroom/graph/watcher.py (CodeGraphWatcher)
- Debounce: waits 2s after last change before reindexing
- Filters: only source file extensions, ignores .git/node_modules/etc.
- Stats: tracks reindex count, integrates with proxy lifecycle
Make Unix-only file locking imports type-safe on Windows, tighten beacon lock cleanup, and fix the remaining exposed typing issues so the repository's mypy check passes cleanly on Windows again.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add focused regression coverage for install, runtime, provider, state, health, supervisor, and persistent wrap flows so the new persistent deployment surfaces are exercised more thoroughly in CI.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Align Docker-native wrapper help and runtime behavior with the Python install contract, including persistent deployment metadata, baked install-image defaults, and explicit unsupported wrap targets.
Harden the Python persistent-install path with profile validation, safer provider-scope handling, Windows environment restoration, runtime parity improvements, and rollback-safe apply/update behavior.
Update README, Docker install docs, CI, and focused regressions to cover the Windows BOM failure, wrapper parity, compose coverage, and Docker-native wrap behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Tighten Docker-native bash and PowerShell wrapper validation for wrap and proxy flows, pin the bash wrapper to the install-time interpreter, clean up failed persistent container starts, and extend docs, CI, e2e, and native installer coverage for persistent Docker installs.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Change codebase-memory-mcp from default to opt-in:
- --no-code-graph → --code-graph (explicit enable)
- No regression risk: code graph only activates when user wants it
- With Claude Code's MCP Tool Search, tool tax is ~200 tokens
when enabled (lazy-loaded, not all 14 tools in every prompt)
Update README wrap examples to show --code-graph flag.
Code graph (codebase-memory-mcp):
- Auto-index project at wrap time via _setup_code_graph()
- --no-code-graph flag on wrap claude/codex/aider to skip
- Silently skips if binary not installed (not a hard dependency)
- With Claude Code's MCP Tool Search, 14 graph tools add ~200
tokens/request (lazy-loaded), not the full ~1,915
CodeCompressor disabled:
- code_aware_enabled defaults to False in ProxyConfig
- enable_code_aware + prefer_code_aware_for_code default False
in ContentRouterConfig
- Code passes through uncompressed (LLMs handle code well)
- Headroom focuses on compressing non-code content (JSON, logs,
tool outputs) where the real waste is
Add headroom wrap copilot with backend-aware provider routing, health metadata for running proxy detection, focused Copilot tests, and docs updates across the main integration surfaces.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Separate the Docker-native parity legend from the table header so Markdown renders the matrix correctly in cli.md.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add host-managed OpenClaw wrap and unwrap flows to the Docker-native wrappers so the installed headroom script can configure the OpenClaw plugin on the host while keeping Headroom itself in Docker. Reuse hidden prepare-only hooks for OpenClaw config payloads, preserve existing plugin metadata on unwrap, and update the Docker-native and integration docs to reflect the supported flow.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Add system-native install scripts and host wrappers for running Headroom from Docker while keeping wrapped tools on the host. Document the Docker-native path, add a complete CLI reference with help output and parity details, and add support for root help/version aliases and proxy env-based binding behavior.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>