headroom/tests
JerrettDavis bb91cfe688 feat(init): add -v/--verbose flag for debug diagnostics
When users hit an init regression it's opaque why: no visible state
about which agents were probed, which paths were written, which
subprocesses ran. Add a top-level flag to ``headroom init`` that routes
debug-level logging from the ``headroom.cli.init`` logger to stderr.

Instrumented decision points:

* detect_init_targets / _probe_init_targets — scope + per-target
  shutil.which result
* _write_json, _ensure_claude_hooks, _ensure_copilot_hooks,
  _ensure_codex_hooks, _ensure_codex_provider — file paths being written
* _apply_user_env — chosen scope (windows vs unix) and env-var keys
* _run_checked — each subprocess command + exit code + truncated
  stdout/stderr (useful when ``claude plugin install`` fails)
* _run_init_targets — target dispatch order and resolved profile
* top-level init callback — all flag values and invoked_subcommand

Log output goes to stderr so stdout stays clean for pipes. The handler
attached by ``_enable_verbose_logging`` is idempotent - nested
subcommand invocations don't duplicate output. The logger does not
propagate to the root logger, so enabling ``headroom init -v`` does not
affect the rest of the process.

The flag is declared on the parent Click group. Subcommands (claude,
codex, copilot, openclaw) inherit the enabled logger automatically
because the group callback runs before dispatch.

Added tests cover:

* ``init -v`` emits the expected markers to stderr, including
  ``detect_init_targets``, ``global_scope=True``, and each agent name
* ``_enable_verbose_logging`` is safe to call repeatedly (handler
  remains singular)

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-23 15:59:57 -05:00
..
cli Add Click-based CLI with memory management commands 2026-01-29 21:30:21 -08:00
integrations/test_strands feat: Add AWS Strands Agents SDK integration 2026-01-31 00:31:37 -08:00
test_cache fix: eliminate prefix cache busts from frozen count underestimation 2026-04-07 17:10:20 -07:00
test_cli feat(init): add -v/--verbose flag for debug diagnostics 2026-04-23 15:59:57 -05:00
test_compression Remove LLMLingua: Kompress is the sole text compressor 2026-03-26 11:11:00 -07:00
test_dashboard test(dashboard): fix playwright importorskip placement 2026-04-21 00:10:05 -05:00
test_evals Remove LLMLingua: Kompress is the sole text compressor 2026-03-26 11:11:00 -07:00
test_install test: avoid global platform leaks in install tests 2026-04-23 08:15:41 -05:00
test_integrations fix: remove unused imports in test_langgraph.py (ruff F401) 2026-03-30 09:27:49 -07:00
test_learn style(learn): ruff format test_analyzer.py 2026-04-23 13:24:46 +02:00
test_memory test(learn): cover flush_to_file, backend edge cases, and hydrate/bump error paths 2026-04-22 20:06:44 +02:00
test_providers style: match CI ruff formatting 2026-04-22 22:21:00 -05:00
test_proxy fix(proxy): strip cache_control before hashing turn_id 2026-04-23 16:04:57 +02:00
test_scripts fix(ci): restore repro harness test in dev installs 2026-04-20 22:12:01 +07:00
test_storage Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_transforms Update number array tests for schema-preserving compression 2026-04-15 19:00:43 -07:00
__init__.py Initial commit: Headroom SDK - LLM context optimization toolkit 2026-01-06 23:16:58 -08:00
conftest.py Add global httpx.ReadTimeout handler for all tests 2026-01-30 16:37:34 -08:00
test_acceptance.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_adapter_hooks.py Add pluggable adapter hooks for CCR, Storage, and TOIN backends 2026-02-15 17:47:30 -08:00
test_adaptive_sizer.py Diversity-aware SmartCrusher: keep unique items, compress text within 2026-03-25 23:57:24 -07:00
test_anthropic_pre_upstream_backpressure.py test(backpressure): harden livez-under-backpressure against CI jitter 2026-04-23 10:08:04 +02:00
test_anthropic_stage_timings.py feat(proxy): add per-stage timings for Codex WS and Anthropic HTTP paths 2026-04-20 22:01:41 +07:00
test_backend_anyllm.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_backend_bugs.py Fix Bedrock/Vertex auth regression: don't forward api_key for env-auth providers (#105) 2026-04-07 14:24:19 -07:00
test_bedrock_region.py Fix ruff lint errors in test files 2026-03-24 15:54:12 -07:00
test_binaries.py fix: docker install fails with PermissionError in readonly cache dir 2026-04-20 17:36:44 -07:00
test_bundled_tools_savings.py fix: bundle ast-grep/difftastic/scc + generic tool_result interceptor framework 2026-04-20 17:36:44 -07:00
test_canonical_pipeline.py test: expand provider pipeline coverage 2026-04-21 23:54:28 -05:00
test_ccr.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_ccr_batch_processor.py Harden Anthropic prefix cache stability across proxy and batch paths 2026-04-04 13:45:37 -05:00
test_ccr_batch_store.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_ccr_context_tracker.py v0.2.2: Add CCR Response Handler, Context Tracker, and restructure docs 2026-01-14 13:03:41 -08:00
test_ccr_feedback.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_ccr_mcp_server.py fix: restore Windows mypy compatibility 2026-04-11 18:40:53 -05:00
test_ccr_response_handler.py Fix security vulnerabilities in memory and CCR systems 2026-02-04 12:05:50 -08:00
test_ccr_response_handler_extra.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_ccr_tool_injection.py Remove LLMLingua: Kompress is the sole text compressor 2026-03-26 11:11:00 -07:00
test_claude_session_branch_compare.py Harden anthropic cache-mode replay stability 2026-04-05 16:11:39 -05:00
test_claude_session_mode_benchmark.py Harden cache validation reporting and TTL analysis 2026-04-06 20:11:21 -05:00
test_cli_learn.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_cli_proxy_env.py feat(cli): add Docker-native install flow and parity docs 2026-04-10 23:27:24 -05:00
test_cli_tools.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_codex_rate_limits.py feat: add OpenAI Codex rate-limit window tracking 2026-04-11 23:34:19 -05:00
test_compress_api.py fix: restore release and compress regressions 2026-04-18 16:01:57 -05:00
test_compress_failure.py test: add focused pipeline coverage 2026-04-21 23:54:28 -05:00
test_compression_cache.py fix(ci): harden wrap e2e validation 2026-04-07 23:27:31 -05:00
test_compression_store.py chore: add nosec B324 annotations to non-cryptographic MD5 usages and update temporary database path to use system temp directory 2026-04-07 13:07:26 +06:00
test_compression_summary.py Add compression summaries, multi-provider headers, Dockerfile fix 2026-02-18 16:54:20 -08:00
test_compression_summary_eval.py Add compression summaries, multi-provider headers, Dockerfile fix 2026-02-18 16:54:20 -08:00
test_compression_summary_hard_eval.py Add compression summaries, multi-provider headers, Dockerfile fix 2026-02-18 16:54:20 -08:00
test_compression_summary_integration.py Add Query Echo: re-inject user question after compressed tool outputs 2026-02-18 23:39:26 -08:00
test_compression_summary_tool_eval.py Add compression summaries, multi-provider headers, Dockerfile fix 2026-02-18 16:54:20 -08:00
test_config.py fix: dashboard metrics, TTFB tracking, eager LLMLingua loading, and multi-provider consistency 2026-03-07 23:33:45 -08:00
test_copilot_auth.py test: cover copilot auth branches 2026-04-22 00:23:28 -05:00
test_copilot_quota.py fix(subscription): stop leaking Event.wait tasks from poll loops 2026-04-20 22:02:41 +07:00
test_cost_tracker_counterfactual.py Fix dashboard cost savings: use model list price, not moving average 2026-03-31 08:50:25 -07:00
test_critical_fixes.py Add Query Echo: re-inject user question after compressed tool outputs 2026-02-18 23:39:26 -08:00
test_critical_gaps.py Update test for lowered TOIN confidence threshold default 2026-01-21 21:40:11 -08:00
test_crushability.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_dashboard_cache_ttl_playwright.py Add observed cache TTL metrics and dashboard coverage 2026-04-06 21:13:30 -05:00
test_evals_datasets.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_evals_metrics.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_exceptions.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_google_multimodal.py Fix Google Gemini conversion to preserve non-text content (Gap #4) 2026-01-24 12:20:13 -08:00
test_google_multimodal_e2e.py Add E2E tests for Google multimodal content preservation 2026-01-24 21:01:25 -08:00
test_graph.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_hnsw_only.py Add bounded memory support to HNSWVectorIndex with LRU eviction 2026-02-01 21:12:06 -08:00
test_hooks.py Add Compression Hooks — extension points for SaaS and advanced customization 2026-02-19 08:17:30 -08:00
test_image_compression.py Skip image tests when Pillow not installed (CI fix) 2026-04-09 16:24:15 -07:00
test_image_compressor.py Slim core dependencies: 2.5GB → 195MB install size 2026-03-13 15:35:49 -07:00
test_log_compressor.py fix: improve error handling and add comprehensive test coverage 2026-01-27 16:08:36 -08:00
test_memory_bridge.py Add Memory Bridge: bidirectional sync between markdown files and Headroom memory 2026-02-23 22:45:38 -08:00
test_memory_eval.py Add hierarchical memory system with graph + vector storage 2026-01-26 21:58:47 -08:00
test_memory_handler_concurrent_init.py fix: add anthropic pre-upstream timeouts 2026-04-21 09:48:32 +07:00
test_memory_handler_native_ops.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_memory_integration.py Add centralized ML model configuration 2026-02-01 23:47:42 -08:00
test_memory_sync.py Fix CI lint errors and test failures 2026-04-14 18:23:06 -07:00
test_memory_system.py Fix CI: guard starlette imports, asyncio.run(), deprecate datetime.utcnow() 2026-02-19 11:03:24 -08:00
test_memory_tracker.py Add memory observability system (Phase 1) 2026-02-01 19:49:53 -08:00
test_memory_tracker_integration.py Add wrap commands for Codex/Cursor/Aider with rtk instructions, fix savings metrics 2026-03-13 22:02:47 -07:00
test_memory_usage_integration.py Add SQLite vector backend as default and fix HNSW test skipping 2026-02-01 22:12:45 -08:00
test_memory_wrapper.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_models.py Fix pricing lookup for retired Claude models 2026-03-12 21:11:18 -07:00
test_oauth_bearer_routing.py style: fix ruff lint/format and mypy errors for CI 3.12 pass 2026-04-20 13:23:20 -05:00
test_observability_metrics.py feat: add OTEL observability core 2026-04-09 21:20:34 -05:00
test_observability_tracing.py feat: add OTEL observability core 2026-04-09 21:20:34 -05:00
test_onnx_runtime.py fix(onnx): reduce retained cpu memory 2026-04-20 22:31:48 +00:00
test_openai_codex_routing.py fix(proxy): retry responses transport without bypassing compression 2026-04-20 22:01:39 +07:00
test_openai_codex_ws_lifecycle.py fix(ci): restore repro harness test in dev installs 2026-04-20 22:12:01 +07:00
test_openai_codex_ws_timings.py feat(proxy): add per-stage timings for Codex WS and Anthropic HTTP paths 2026-04-20 22:01:41 +07:00
test_openai_streaming_backend.py Commit message: 2026-03-13 16:49:18 -07:00
test_package_init_lazy.py Fix CI lint errors and test failures 2026-04-14 18:23:06 -07:00
test_parser.py Add multi-provider memory system with auto-detection 2026-02-01 14:42:50 -08:00
test_paths.py test(paths): close coverage gaps for derived-only helpers 2026-04-16 19:59:30 -05:00
test_paths_backward_compat.py test(paths): add adversarial backward-compat stress suite 2026-04-16 19:59:47 -05:00
test_pipeline.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_plugin_manifests.py build: sync agent hook manifests to repo semver 2026-04-21 20:03:14 -05:00
test_pr208_changes.py test(pr208): add coverage for is_anthropic_auth, file logging, repro helpers, and wrap paths 2026-04-20 14:13:45 -05:00
test_pricing.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_pricing_litellm.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_prometheus_stage_timing_concurrency.py perf(proxy): reduce lock contention on stage-timing metrics 2026-04-20 22:08:09 +07:00
test_provider_aider.py test: expand provider slice coverage 2026-04-22 21:58:03 -05:00
test_provider_claude.py test: expand provider slice coverage 2026-04-22 21:58:03 -05:00
test_provider_codex_runtime.py test: add focused pipeline coverage 2026-04-21 23:54:28 -05:00
test_provider_copilot_wrap.py test: expand provider slice coverage 2026-04-22 21:58:03 -05:00
test_provider_cursor.py test: remove provider diff churn 2026-04-22 22:13:13 -05:00
test_provider_model_fallback.py Fix CI regressions for cache benchmark work 2026-04-04 22:33:44 -05:00
test_provider_openclaw_wrap.py test: expand provider slice coverage 2026-04-22 21:58:03 -05:00
test_provider_package_init.py test: clean up lazy provider export cache 2026-04-22 22:35:56 -05:00
test_provider_proxy_routes.py test: expand provider slice coverage 2026-04-22 21:58:03 -05:00
test_provider_registry.py test: remove provider diff churn 2026-04-22 22:13:13 -05:00
test_provider_registry_extended.py test: expand provider pipeline coverage 2026-04-21 23:54:28 -05:00
test_proxy_anthropic_cache_stability.py Fix 19 test failures: missing security attr, nosec inside f-strings, stale test mock 2026-04-07 18:30:29 -07:00
test_proxy_batch_integration.py Add multi-provider batch API support with CCR post-processing 2026-01-24 11:41:18 -08:00
test_proxy_cache_ttl_metrics.py feat: expose proxy OTEL metrics and Langfuse status 2026-04-09 21:20:46 -05:00
test_proxy_ccr.py Fix ruff formatting 2026-01-17 17:14:12 -08:00
test_proxy_codex_route_aliases.py chore: format proxy route tests with ruff 2026-04-21 19:38:32 +00:00
test_proxy_compress_endpoint.py Add TypeScript SDK (headroom-ai npm package) 2026-03-26 15:41:56 -07:00
test_proxy_compression_headers.py fix: strip accept-encoding from forwarded proxy headers 2026-04-15 11:40:11 -07:00
test_proxy_copilot_auth_hooks.py Merge upstream/main into feat/canonical-pipeline 2026-04-22 13:10:53 -05:00
test_proxy_count_tokens_integration.py Add multi-provider batch API support with CCR post-processing 2026-01-24 11:41:18 -08:00
test_proxy_dashboard_stats_cache.py fix: cache dashboard stats snapshots 2026-04-22 09:30:19 +00:00
test_proxy_debug_endpoints.py fix: add anthropic pre-upstream timeouts 2026-04-21 09:48:32 +07:00
test_proxy_gemini_integration.py Add multi-provider batch API support with CCR post-processing 2026-01-24 11:41:18 -08:00
test_proxy_gemini_native_integration.py Add multi-provider batch API support with CCR post-processing 2026-01-24 11:41:18 -08:00
test_proxy_google_cloudcode_route_aliases.py chore: format proxy route tests with ruff 2026-04-21 19:38:32 +00:00
test_proxy_handler_helpers.py test: add focused pipeline coverage 2026-04-21 23:54:28 -05:00
test_proxy_handlers_batch.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_proxy_healthchecks.py fix: add anthropic pre-upstream timeouts 2026-04-21 09:48:32 +07:00
test_proxy_hooks_regression.py fix: restore anthropic compression when hooks enabled 2026-03-30 11:25:15 +02:00
test_proxy_intelligent_context.py feat(toin): add TOIN + CCR integration to IntelligentContextManager 2026-01-27 16:08:36 -08:00
test_proxy_memory_integration.py fix: correct cost calculation for cache tokens and simplify memory DevEx 2026-01-26 22:49:31 -08:00
test_proxy_mode_benchmark.py Rebrand proxy modes to token/cache and harden cache-mode stability 2026-04-04 14:32:07 -05:00
test_proxy_modes.py Harden cache-mode immutability for OpenAI and fix stats mode reporting 2026-04-04 14:36:29 -05:00
test_proxy_openai_cache_stability.py Fix CI regressions for cache benchmark work 2026-04-04 22:33:44 -05:00
test_proxy_openai_responses_integration.py Add compression for OpenAI Responses API (/v1/responses) 2026-03-30 20:13:00 -07:00
test_proxy_passthrough_integration.py Add multi-provider batch API support with CCR post-processing 2026-01-24 11:41:18 -08:00
test_proxy_pipeline_lifecycle.py test: add focused pipeline coverage 2026-04-21 23:54:28 -05:00
test_proxy_savings_history.py fix: resolve rebased ci regressions 2026-04-21 23:54:28 -05:00
test_proxy_scalability.py Fix Codex WebSocket HTTP 500: ChatGPT auth routing, correct beta header, HTTP fallback (#71) 2026-04-06 12:48:46 -07:00
test_proxy_streaming_ratelimit_headers.py chore: format proxy route tests with ruff 2026-04-21 19:38:32 +00:00
test_proxy_streaming_request_logger.py fix(proxy): log streaming Anthropic requests so feed populates 2026-04-22 14:16:35 +02:00
test_proxy_streaming_resilience.py Refactor: extract 7 modules from server.py (Steps 2-4) 2026-04-03 16:18:08 -07:00
test_proxy_telemetry_env.py feat: allow overriding proxy telemetry sdk via HEADROOM_SDK 2026-03-27 14:23:32 +01:00
test_proxy_warmup.py fix(ci): restore repro harness test in dev installs 2026-04-20 22:12:01 +07:00
test_quality_retention.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_query_echo.py Add Query Echo: re-inject user question after compressed tool outputs 2026-02-18 23:39:26 -08:00
test_quota_registry.py feat: pluggable QuotaTracker ABC + QuotaTrackerRegistry 2026-04-12 00:58:01 -05:00
test_release_version.py fix(tests): scope sys.modules mutation and unpin hardcoded version 2026-04-22 12:37:22 +02:00
test_release_workflows.py fix: stabilize cli test isolation 2026-04-22 11:28:30 +00:00
test_relevance.py Fix all mypy type errors and flaky embedding test 2026-01-10 18:27:33 -08:00
test_relevance_extra.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_reporting.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_responses_converter.py Add compression for OpenAI Responses API (/v1/responses) 2026-03-30 20:13:00 -07:00
test_rtk_installer.py feat(cli): add Docker-native install flow and parity docs 2026-04-10 23:27:24 -05:00
test_search_compressor.py fix: improve error handling and add comprehensive test coverage 2026-01-27 16:08:36 -08:00
test_security_validations.py Fix security vulnerabilities in memory and CCR systems 2026-02-04 12:05:50 -08:00
test_shared_context.py Add SharedContext for multi-agent, rewrite README, fix proxy cleanup 2026-03-17 16:31:04 -07:00
test_sqlite_graph_store.py Add SQLiteGraphStore for bounded, persistent graph storage 2026-02-01 20:48:57 -08:00
test_sqlite_vector_index.py Add SQLiteVectorIndex using sqlite-vec for bounded vector search 2026-02-01 21:23:09 -08:00
test_stage_timer.py feat(proxy): add per-stage timings for Codex WS and Anthropic HTTP paths 2026-04-20 22:01:41 +07:00
test_storage_backends.py test: apply linux ruff formatting 2026-04-23 08:49:50 -05:00
test_strands_tokenizer.py Count Strands reasoningContent, image, document, video tokens (#111 follow-up) 2026-04-08 17:31:00 -07:00
test_subscription_base.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_subscription_client.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_subscription_tracker.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_tag_protection_integration.py Fix API integration test: use tool output not user message for tags 2026-03-26 11:46:55 -07:00
test_telemetry.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_telemetry_context.py refactor(telemetry): centralize stack slug validation + cardinality cap 2026-04-17 18:42:41 +02:00
test_telemetry_warning.py fix: format telemetry warning tests for CI 2026-04-09 23:29:56 -05:00
test_text_compressors.py Enhanced MCP server with compress/stats tools, fix proxy torch crash 2026-03-16 22:56:30 -07:00
test_toin.py Add comprehensive evaluation framework for compression accuracy 2026-01-22 09:31:54 -08:00
test_toin_feedback.py fix: close TOIN feedback loop — retrievals now flow back for learning 2026-03-22 14:18:30 -07:00
test_toin_field_learning.py Fix ruff formatting 2026-01-17 17:14:12 -08:00
test_toin_fixes.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_toin_full_integration.py Update test for lowered TOIN confidence threshold default 2026-01-21 21:40:11 -08:00
test_toin_integration.py Add pluggable storage backend abstraction for CompressionStore 2026-01-20 23:25:28 -08:00
test_token_headroom_mode.py Rebrand proxy modes to token/cache and harden cache-mode stability 2026-04-04 14:32:07 -05:00
test_tokenizer.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_tokenizers.py Fix all ruff lint and format errors for CI 2026-01-10 15:33:44 -08:00
test_tool_result_interceptors.py fix(review-3): address third-pass PR #210 feedback 2026-04-20 20:24:47 -07:00
test_transforms_content_detection.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_transforms_content_router.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_transforms_log_compressor.py test: fix PR formatting and cover log compressor 2026-04-23 07:49:27 -05:00
test_transforms_package.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_transforms_search_compressor.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_utils.py test: expand coverage across helper slices 2026-04-23 07:39:52 -05:00
test_ws_http_fallback.py fix(proxy): retry responses transport without bypassing compression 2026-04-20 22:01:39 +07:00
test_ws_memory_relay.py Fix CI lint errors and test failures 2026-04-14 18:23:06 -07:00
test_ws_session_registry.py feat(proxy): track Codex WS sessions and cancel relay tasks deterministically 2026-04-20 22:01:41 +07:00