mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-23 02:49:17 +08:00
## Description Vanta/Dependabot report 64 open alerts on this repo. 59 of them are pillow, filelock and virtualenv versions that exist only in the Python 3.10 split of `uv.lock`: the patched releases (pillow 13, filelock 4.2) require Python 3.11, so Dependabot could not open a fix PR. Python 3.10 reached end of life in October 2026 and CI already tests only 3.11, 3.12 and 3.14. The second commit also fixes the two `security.yml` jobs that fail on `main` today: pip-audit (litellm CVE-2026-114612) and the e2e npm audit (three undici advisories published after #4453 for the copy bundled inside npm). ## Type of Change - [x] Breaking change: `pip install headroom-ai` now refuses Python 3.10 - [x] Bug fix: security patches ## Changes Made - `requires-python = ">=3.11"`; drop the 3.10 classifier and the `tomli` backport dependency - pillow override and filelock floor lose their `python_version` markers - mypy `python_version = "3.11"`; the three `tomli` import fallbacks in `headroom/` become plain `import tomllib` - ruff `target-version` stays `py310` with a note: moving it raises 213 pyupgrade findings (UP017/UP036/UP041/UP042), a separate mechanical PR - `uv.lock` re-resolved: pillow 13.0.0, filelock 4.2.4, virtualenv 21.14.13 (single entry each, the 3.10 fork is gone) - gitpython 3.1.62 → 3.2.1, strands-agents 1.24.0 → 1.62.0, litellm 1.101.0 → 1.101.3 - `e2e/wrap/tools/npm-audit-exceptions.json`: three further undici 6.x advisories added at the existing exact path and version, expiry unchanged (2026-11-15) - README, CONTRIBUTING and the Dockerfile comment updated Clears 61 of the 64 Dependabot alerts. The remaining 3 (undici, ip-address) live inside the bundled dependencies of the `npm` package in `e2e/wrap/tools/package-lock.json`; npm 12.2.1 is the newest release and still ships them, so there is no bump available yet. ## Dependencies & supply chain **gitpython 3.1.62 → 3.2.1.** Already a dependency; bumped for a security patch (CVE-2026-114145). Maintained by the gitpython-developers org (Sebastian Thiel), monthly-ish releases, long advisory history with prompt fixes. Install surface unchanged: pure-Python wheel (`py3-none-any`), one runtime dependency (`gitdb`), no native code, no install-time or runtime network of its own. **strands-agents 1.24.0 → 1.62.0.** Already a dependency behind the `[strands]` extra; bumped for a security patch (CVE-2026-115419, fixed in 1.43.0; the lock takes the current release). Maintained by AWS (strands-agents org, `opensource@amazon.com`), weekly releases. Install surface: pure-Python wheel, no native code. Declared dependencies grow by two, `httpx` and `pyyaml`, both already in the lock for other packages, so no new transitive packages are introduced. Runtime network is unchanged: it calls the model provider the user configures, as before. **litellm 1.101.0 → 1.101.3.** Already a core dependency; patch bump for CVE-2026-114612, the smallest fix that keeps the `filelock>=4.2.1` floor resolvable (litellm 1.106 caps filelock <4). No change to maintainers or install surface. **pillow, filelock, virtualenv.** No new packages; the lock now holds the single patched version the 3.11+ fork already had. ## Testing - [x] Linting passes (`ruff check .`, `ruff format --check .`) - [x] Type checking passes (`mypy headroom`): 1 error, identical to main (`langchain/chat_model.py:380`) - [x] Unit tests (targeted, see below) ### Test Output ```text $ pytest -q tests/test_litellm_optional.py tests/test_dependency_overrides.py tests/test_release_workflows.py tests/test_image_decoder_guard.py tests/test_optional_dependencies.py tests/test_onnx_dependency_contract.py 74 passed in 3.07s $ grep -rl -E "headroom\.release_version|headroom\.providers\.codex\.project_context|headroom\.cli\.wrap" tests | xargs pytest -q 4 failed, 1043 passed in 28.03s # same 4 in tests/test_cli/test_wrap_persistent.py fail on main $ uv run --extra strands --extra dev -m pytest -q tests/integrations/test_strands tests/test_strands_tokenizer.py 18 failed, 87 passed in 52.30s # the 18 are *Real classes needing live AWS Bedrock creds; main fails the same 18 on 1.24.0 $ uv export --frozen --no-dev --no-emit-project --no-hashes --extra all --format requirements-txt > requirements-prod.txt $ uvx pip-audit==2.10.1 -r requirements-prod.txt --no-deps --disable-pip No known vulnerabilities found $ cd e2e/wrap/tools && npm audit --package-lock-only --json > audit.json && <security.yml check script> unexpected: [] stale: [] seen: 6 ``` ## Real Behavior Proof - Environment: macOS 27.2 arm64; uv-managed CPython 3.11.16 and 3.10; the lock from this branch. - Exact command / steps: ```text $ uv run --python 3.11 --all-extras python -c "import sys, platform, headroom, PIL, filelock, virtualenv, git, strands, litellm, importlib.metadata as m; ..." $ uv venv -p 3.10 /tmp/py310-venv && uv pip install --python /tmp/py310-venv/bin/python --dry-run . ``` - Observed result: ```text macOS-27.2-arm64-arm-64bit python 3.11.16 pillow 13.0.0 filelock 4.2.4 virtualenv 21.14.13 gitpython 3.2.1 strands-agents 1.62.0 litellm 1.101.3 (3.10) ... headroom-ai==0.42.0 depends on Python>=3.11, we can conclude that headroom-ai==0.42.0 cannot be used. And because only headroom-ai==0.42.0 is available and you require headroom-ai, we can conclude that your requirements are unsatisfiable. ``` - Not tested: Linux and Windows installs (CI wheel matrix covers them); a live Bedrock run of the strands integration; the Docker image build. ## Runtime Rollout Safety - Rollout-managed feature(s): none - Minimum rollout channel: n/a - Stable/default behavior changed: installs on Python 3.10 are refused at resolve time; no runtime behavior change on 3.11+ - Kill switch / disable path: n/a - Unsafe override required: no - Qualification impact: none - Rollback path: revert the PR ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review ## Checklist - [x] My code follows the project's style guidelines - [x] I have made corresponding changes to the documentation - [x] My changes generate no new warnings - [x] New and existing unit tests pass locally with my changes (targeted runs above; pre-existing failures noted) - [x] I did **not** edit `CHANGELOG.md` - [ ] New tests added: n/a, dependency and metadata change; existing contract tests cover the floor and the pillow override ## Additional Notes Follow-ups, not in this PR: - ruff `target-version = "py311"` plus the pyupgrade fixes - remaining `tomli` fallbacks in `tests/` and the `sys.version_info < (3, 11)` branches they guard - `python_version < '3.11'` branches in the onnxruntime markers (now dead but harmless) - `pyo3` `abi3-py310` in `Cargo.toml` could move to `abi3-py311` - the 3 remaining Dependabot alerts (bundled undici/ip-address in npm) until an npm release replaces them 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Fable 5.1 <noreply@anthropic.com>
122 lines
4.4 KiB
Python
122 lines
4.4 KiB
Python
"""Installs on Python 3.14 must not need a compiler.
|
|
|
|
litellm below 1.93 declared requires-python <3.14 (GH #956), and 1.92 to 1.96.0
|
|
shipped wheels for only some platforms, so pip fell back to a Rust source build.
|
|
1.96.2 is the first release with prebuilt wheels for Python 3.10 to 3.14 on
|
|
Linux, macOS and Windows, so litellm is required everywhere from that floor.
|
|
|
|
watchdog 6.0.0 publishes no macOS wheel for Python 3.14. It only powers the
|
|
optional code graph watcher, so it is skipped there and the proxy must start
|
|
without it. litellm is still lazily imported, so the core paths keep degrading
|
|
gracefully when it is missing from an environment.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pathlib import Path
|
|
|
|
import pytest
|
|
|
|
try:
|
|
import tomllib
|
|
except ModuleNotFoundError: # Python 3.10
|
|
import tomli as tomllib # type: ignore[no-redef]
|
|
|
|
from packaging.requirements import Requirement
|
|
from packaging.version import Version
|
|
|
|
PYPROJECT = Path(__file__).resolve().parents[1] / "pyproject.toml"
|
|
SUPPORTED_PYTHONS = ("3.11", "3.12", "3.13", "3.14")
|
|
PLATFORMS = ("linux", "darwin", "win32")
|
|
LITELLM_FLOOR = Version("1.96.2")
|
|
|
|
|
|
def _requirements(name: str) -> list[Requirement]:
|
|
data = tomllib.loads(PYPROJECT.read_text(encoding="utf-8"))
|
|
specs = list(data["project"].get("dependencies", []))
|
|
for extra in data["project"].get("optional-dependencies", {}).values():
|
|
specs.extend(extra)
|
|
return [r for spec in specs if (r := Requirement(spec)).name == name]
|
|
|
|
|
|
def _applies(requirement: Requirement, python: str, platform: str) -> bool:
|
|
if requirement.marker is None:
|
|
return True
|
|
return requirement.marker.evaluate(
|
|
{"python_version": python, "sys_platform": platform, "extra": ""}
|
|
)
|
|
|
|
|
|
def test_litellm_is_required_on_every_supported_python() -> None:
|
|
reqs = _requirements("litellm")
|
|
assert reqs, "expected litellm to be declared in pyproject"
|
|
for r in reqs:
|
|
for python in SUPPORTED_PYTHONS:
|
|
for platform in PLATFORMS:
|
|
assert _applies(r, python, platform), f"{r}: skipped on {python}/{platform}"
|
|
|
|
|
|
def test_litellm_floor_has_wheels_for_python_314() -> None:
|
|
for r in _requirements("litellm"):
|
|
assert not r.specifier.contains("1.96.1"), f"{r}: allows litellm without 3.14 wheels"
|
|
assert r.specifier.contains(str(LITELLM_FLOOR)), f"{r}: excludes {LITELLM_FLOOR}"
|
|
|
|
|
|
def test_watchdog_is_skipped_only_where_it_has_no_wheel() -> None:
|
|
reqs = _requirements("watchdog")
|
|
assert reqs, "expected watchdog to be declared in pyproject"
|
|
for r in reqs:
|
|
assert not _applies(r, "3.14", "darwin"), f"{r}: needs a compiler on macOS 3.14"
|
|
assert _applies(r, "3.13", "darwin"), f"{r}: must still install on macOS 3.13"
|
|
assert _applies(r, "3.14", "linux"), f"{r}: must still install on Linux 3.14"
|
|
assert _applies(r, "3.14", "win32"), f"{r}: must still install on Windows 3.14"
|
|
|
|
|
|
@pytest.mark.proxy_dependency_gate
|
|
def test_proxy_starts_without_watchdog(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
from headroom.cli import proxy
|
|
|
|
requested: list[str] = []
|
|
|
|
from importlib.machinery import ModuleSpec
|
|
|
|
def fake_find_spec(name: str) -> ModuleSpec | None:
|
|
requested.append(name)
|
|
if name == "watchdog":
|
|
return None
|
|
return ModuleSpec(name, loader=None)
|
|
|
|
monkeypatch.setattr(proxy, "find_spec", fake_find_spec)
|
|
proxy.ensure_proxy_dependencies()
|
|
assert "fastapi" in requested
|
|
assert "watchdog" not in requested
|
|
|
|
|
|
def test_code_graph_watcher_skips_itself_without_watchdog(
|
|
monkeypatch: pytest.MonkeyPatch,
|
|
) -> None:
|
|
import builtins
|
|
|
|
from headroom.graph.watcher import CodeGraphWatcher
|
|
|
|
real_import = builtins.__import__
|
|
|
|
def no_watchdog(name: str, *args: object, **kwargs: object) -> object:
|
|
if name == "watchdog" or name.startswith("watchdog."):
|
|
raise ImportError(name)
|
|
return real_import(name, *args, **kwargs)
|
|
|
|
monkeypatch.setattr(builtins, "__import__", no_watchdog)
|
|
watcher = CodeGraphWatcher(Path.cwd(), cbm_binary="codebase-memory-mcp")
|
|
assert watcher.start() is False
|
|
|
|
|
|
def test_proxy_cost_degrades_without_litellm(monkeypatch: pytest.MonkeyPatch) -> None:
|
|
# With litellm absent from the environment, the proxy cost path must return
|
|
# None rather than raise.
|
|
from headroom.proxy import cost
|
|
|
|
monkeypatch.setattr(cost, "LITELLM_AVAILABLE", False)
|
|
monkeypatch.setattr(cost, "litellm", None)
|
|
assert cost._get_litellm_module() is None
|