mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 13:29:19 +08:00
feat/https-compose-caddy
3
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
9b1971dd82 |
refactor(transforms): deprecate the unused Python AnchorSelector port (#4104)
## Description
`headroom/transforms/anchor_selector.py` is the Python original of the
anchor selector that SmartCrusher now runs in Rust
(`crates/headroom-core/src/transforms/anchor_selector.rs`). Nothing in
Headroom calls it, it has no tests or docs, and no consumer repo imports
it. It is still exported from `headroom.transforms`, so this PR
deprecates it instead of deleting it. There is no replacement.
Refs #4136
## Type of Change
- [ ] Bug fix (non-breaking change that fixes an issue)
- [ ] New feature (non-breaking change that adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to change)
- [ ] Documentation update
- [ ] Performance improvement
- [x] Code refactoring (no functional changes)
## Changes Made
- Accessing `AnchorSelector`, `AnchorStrategy`, `AnchorWeights`,
`DataPattern`, `calculate_information_score` or `compute_item_hash`
through `headroom.transforms` emits one `DeprecationWarning`, attributed
to the caller.
- The resolved object is cached in the package globals, so a `from`
import (which looks the name up twice) warns once.
- Importing `headroom.transforms.anchor_selector` directly warns at
import.
- On Python 3.12+ the warning skips importlib's frames
(`skip_file_prefixes`), so `importlib.import_module()` is attributed to
its caller.
- Python 3.10 and 3.11 have no such option, so there the warning still
names importlib.
- `import headroom.transforms` and every other export stay quiet.
- The tests cover attribute, `from`, plain and dynamic imports. They
restore `sys.modules`, the parent-package attribute and the export cache
through monkeypatch.
- Evidence: `rg -n
'AnchorSelector|anchor_selector|compute_item_hash|calculate_information_score'
headroom plugins sdk examples benchmarks scripts docs tests`, plus the
consumer repos, finds only the module itself, its lazy exports, the Rust
port and an unpublished wiki design plan.
## Testing
- [x] Unit tests pass (`pytest`)
- [x] Linting passes (`ruff check .`)
- [x] Type checking passes (`mypy headroom`)
- [x] New tests added for new functionality
- [ ] Manual testing performed
### Test Output
```text
$ pytest tests/test_transforms_package.py tests/test_package_init_lazy.py tests/test_smart_crusher*.py tests/test_transforms/test_smart_crusher*.py
110 passed in 6.09s
$ pytest tests/test_transforms_package.py # with the previous commit's product code
3 failed, 2 passed (double warning on from-import; importlib-attributed dynamic import)
$ python3.10 -c "compile(anchor_selector.py)" # 3.10 fallback branch parses
3.10.21 compiles
$ ruff check / format: All checks passed; mypy: Success
```
## Real Behavior Proof
- Environment: macOS, Python 3.12, repo `.venv`, this branch's worktree
with the prebuilt `headroom._core`. Temp `HOME`,
`HEADROOM_WORKSPACE_DIR` and `CODEX_HOME`; nothing touched the real
home.
- Exact command / steps: (1) shared smoke harness: a real proxy from
this checkout against a local fake upstream, with one Anthropic and one
OpenAI request carrying a compressible tool result (`smoke.sh
<worktree>`); (2) `python -W always -c 'from headroom.transforms import
AnchorSelector'`, plus a script that calls
`importlib.import_module('headroom.transforms.anchor_selector')`.
- Observed result: The proxy serves both requests (200) with savings.
The from-import warns once at `<string>:2`, and the dynamic import is
attributed to `plugin_loader.py:2`, not to importlib. Output below.
- Not tested: The full test suite on Python 3.10/3.11 (only the fallback
branch was compile-checked there).
```text
branch: cleanup/transforms-deprecate-anchor-selector @
|
||
|
|
efd2ac1ca4 |
chore: renormalize line endings to LF
`.gitattributes` declares `*.py text eol=lf` and `*.sh text eol=lf`, but 74 files (73 .py, 1 .sh) are stored in the index with CRLF line endings, violating that contract. Every macOS/Linux clone reports these files as "modified" on fresh checkout because git's diff engine sees the stored bytes don't match the attribute contract, even though the working tree and index match byte-for-byte. Running `git add --renormalize .` rewrites each affected blob so the stored form matches the attribute declaration. No semantic changes — every affected file's diff is "N insertions, N deletions" with inserts and deletes being the same lines modulo line endings. Follow-up commit adds `.git-blame-ignore-revs` so `git blame` / GitHub blame skip this mechanical commit. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> |
||
|
|
38bf3e639c |
test: expand coverage across helper slices
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> |