mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 15:10:00 +08:00
feat/https-compose-caddy
2
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
a20c76c26b |
refactor(transforms): drop the Python mirror of the Rust log selector (#4096)
## Description
`LogCompressor.compress()` runs entirely in Rust. The class still
carried a Python re-implementation of the line parser, scorer, selector,
deduper, context adder and formatter, plus the pytest short-summary
helpers and a `_store_in_ccr` shim. Production never ran them, and
`_store_in_ccr` still had the #816 bug that the live path fixed (no
`explicit_hash`). All removed names are private.
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
- Remove the private helpers listed above: about 400 lines.
- Format-detection tests now call `headroom._core.detect_log_format`,
which `compress()` uses.
- Level counts, and the JS and rustc stack-trace shapes, become
`compress()`-level tests. The stack-trace tests run with
`error_context_lines=0`, so only trace detection can keep the frames.
- Two Rust unit tests are added for behaviour no Rust test pinned:
`level_classifier_covers_every_level` (FAIL, DEBUG, TRACE, unknown) and
`score_line_orders_levels_and_boosts`.
- Helper tests whose behaviour Rust already unit-tests are deleted:
dedupe, pytest short-summary recognition and CRLF, the malformed
diagnostic, cap precedence and reservation, omission naming, select
first/last, and the Go/Rust/.NET/Java trace openers.
## 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
$ cargo test -p headroom-core --lib log_compressor
test result: ok. 40 passed; 0 failed
$ pytest tests/test_log_compressor.py tests/test_transforms_log_compressor.py tests/test_transforms_stack_traces.py tests/test_ccr_rust_marker_hash_bridge.py tests/test_transforms_content_router.py tests/test_adaptive_sizer.py tests/test_transforms_search_compressor.py tests/test_search_compressor.py
223 passed in 7.52s
$ ruff check / format: All checks passed; mypy log_compressor.py: 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) a real `LogCompressor.compress()` with
`error_context_lines=0` on 100 filler lines, a JS stack trace, and 100
more filler lines.
- Observed result: The proxy serves both requests (200) with the same
savings as main. The direct check keeps exactly the three trace lines
and reports the level counts from Rust. Output below.
- Not tested: Nothing beyond the listed files.
```text
branch: cleanup/transforms-log-drop-python-mirror @
|
||
|
|
d3298368bf |
fix: improve error handling and add comprehensive test coverage
Bug fixes: - Replace bare except handlers with specific exception types and logging in proxy/server.py (6 instances for CCR, SSE parsing, cost tracking) - Fix session_id filtering security bug in memory/backends/local.py (sessions were not properly isolated in vector search) New tests (344 total): - test_ccr_batch_processor.py: 51 tests for batch result processing - test_compression_store.py: 76 tests for compression cache - test_log_compressor.py: 47 tests for log format detection/compression - test_search_compressor.py: 48 tests for grep output compression - test_integrations/langchain/: 122 tests for LangChain integration (agents, memory, retriever, streaming) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> |