mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-11-22 15:10:00 +08:00
feat/https-compose-caddy
6
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
023dd1bc54 |
fix(logs): count omitted levels from dropped lines (#4141)
## Description Closes #4070. The omission marker previously counted severities in the whole input, including retained errors. It now counts ERROR/FAIL/WARN/INFO only on dropped line identities. Selection and whole-input result.stats are unchanged. If no dropped line has a recognized severity, the marker is simply `[N lines omitted]`, not a severity breakdown. CCR retains the exact original. ## Type of Change - [x] Bug fix (non-breaking) - [x] Documentation update ## Changes Made - Keep the existing retained-line identity set and a single-pass fixed stack histogram; no omitted-line collection or repeated full scans. - Restore complete structured-marker assertions in Rust and Python, including bounded failure names, repeated ids, whole-input totals, and non-severity omissions. - Restore parity fixture `3bc015edc0a36387.json` using its original input, explicit configuration and input digest. Output and compression ratio were re-recorded through the freshly built native extension rather than manually copied. New runtime-frame defaults remain implicit in the legacy configuration. - Remove the constructor-only result-copy test; retain consumer behavior regressions. - Document omitted-versus-input counts and the exact bare-marker form in the existing text/log guide. No manual changelog change. ## Testing - [x] Scoped Rust and Python tests passed - [x] Normal touched-file Ruff and repository mypy hooks passed - [x] Actual native recorder and parity CLI exercised Head `6c472f6b` includes upstream main `f1bc2609`. - Focused Rust log-compressor tests: **41 passed**. - Python public-transform tests: **11 passed**, using the freshly built native extension. - Actual parity CLI: **20 matched, 0 skipped, 0 differences**, including the restored original-input fixture: ```text cargo run --locked -p headroom-parity --bin parity-run -- run --fixtures tests/parity/fixtures --only log_compressor [log_compressor ] total=20 matched=20 skipped=0 diffed=0 ``` ## Real Behavior Proof - Environment: Linux x86_64, Python 3.13.14, native extension freshly built from this worktree. - Exact command / steps: Re-record the original log fixture through LogCompressor.compress with its original explicit configuration, then run the actual parity CLI shown above. - Observed result: The real native recorder produced `[297 lines omitted: 297 INFO]` while whole-input statistics remained 300 INFO / one ERROR / 305 total / eight selected. The exact original was unchanged and the measured compression ratio is `0.024777201057682892`. The original fixture digest remains `3bc015edc0a36387194d075139845c120a308afb314bae436ab454906b431d84`. Normal commit and full pre-push hooks passed without bypass: Rust formatting, warnings-as-errors Clippy, workspace tests, native editable rebuild/import verification, **181 critical Python tests**, and branch-range commitlint. The critical Python run reported five dependency/provider warnings, no failures. These local results do not claim that hosted checks have finished. - Not tested: New Windows/macOS runs, live-provider sessions and the full Python suite. Earlier before/after actual-native CCR qualification showed the retained ERROR was not counted as omitted, whole-input totals stayed unchanged, and retrieval recovered the exact original. That historical implementation evidence is in the review discussion; the explicit results above qualify this follow-up head. No new Windows/macOS or live-provider qualification is claimed. ## Runtime Rollout Safety - Rollout-managed feature(s): Existing LogCompressor and CCR; no new feature or gate. - Minimum rollout channel: Unchanged (stable); no channel promotion. - Stable/default behavior changed: Yes, omitted-severity accounting is corrected; selection and stored originals remain unchanged. - Kill switch / disable path: ContentRouterConfig(enable_log_compressor=False) disables the log route; existing CCR settings disable retrieval separately. - Unsafe override required: No. - Qualification impact: The scoped native/Python/parity proof and required normal push gate above cover this marker path. No new platform/live-provider qualification is claimed. - Rollback path: Revert the fix; no schema or stored-original migration. ## Review Readiness - [x] I have performed a self-review - [x] This PR is ready for human review - [x] Existing style and documentation conventions followed - [x] Consumer-visible regressions and actual native/CLI paths exercised - [x] Normal hooks passed; no bypass - [x] No manual CHANGELOG edit AI-assisted: omp / GPT-6.1 Sol. This review follow-up was completed without subagents. No manual human-validation or full Python-suite claim; scoped tests and the required push gate are reported separately. --------- Co-authored-by: JerrettDavis <mxjerrett@gmail.com> |
||
|
|
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 @
|
||
|
|
d90b32008d |
fix(log_compressor): keep and name pytest short-summary failures (#3828)
## Description A pytest log with more than `max_errors` failures in its `short test summary info` section loses the middle `FAILED` lines. `LogCompressor` keeps the first `max_errors + 2` and the last 3 (`select_with_first_last`), and the omission marker only gives a count, so nothing names the dropped tests. `keep_summary_lines=False` changes nothing, because these lines were never classified as summary lines. This implements **both** options from the issue: 1. **Keep:** short-summary entries count as summary lines, so they're exempt from `max_errors` and survive preferentially when the adaptive global cap cuts. 2. **Name:** any short-summary entry that is still dropped is named in the existing marker. Closes #3814 ## Type of Change - [x] 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 - [ ] Code refactoring (no functional changes) ## Changes Made - **`crates/headroom-core/src/transforms/log_compressor.rs`**: a private helper, `pytest_short_summary_entries()`, finds the short-summary section: - The section starts at a complete `=== … short test summary info … ===` separator and ends at the next `===` line or EOF. LF and CRLF both work. - A diagnostic line that happens to mention the phrase (e.g. `=== diagnostic: short test summary info unavailable`) does **not** open a section. - It returns line number → node id for `FAILED <nodeid>` / `ERROR <nodeid>` lines. For the long form `FAILED <nodeid> - <msg>`, the id is everything before ` - `. - The helper is used in three places: - `parse_lines`: sets the existing `is_summary` flag on those entries. - `select_lines`: under `keep_summary_lines`, the entries go into the summaries bucket, which exempts them from `max_errors`. When the adaptive global cap truncates, the sort order is score desc, then short-summary status, then line number, so these entries win equal-score ties. With `keep_summary_lines=False`, selection is exactly as before. - Cap reserve: when the cap binds, `keep_summary_lines` is on and a short-summary section exists, the section's `=== N failed, M passed ===` totals line and the first `E ` assertion line before the summary get reserved slots. Entries fill the remaining slots. Without this, a long summary (about 60+ failures in the issue's reproduction) crowded out both lines, and the pre-fix output had kept them. - `format_output`: when any short-summary entry is omitted, the existing bracket gets `; omitted: id1, …, id5, +K more` appended. It lists at most 5 ids in log order, and `+K more` appears only when K > 0. - **Unchanged:** - `score_log_line`, including its 1.0 cap - the CCR descriptor (`summarize_omitted` / `Retrieve more: hash=`) - the public `LogLine` struct and the PyO3 surface in `crates/headroom-py` - output for non-pytest logs, and for pytest logs where no short-summary entry is omitted and no cap tie involves one - **`headroom/transforms/log_compressor.py`**: the legacy helpers (`_parse_lines`, `_select_lines`, `_format_output`) mirror the same behaviour. No dataclass field changes. - **Tests:** - Rust unit tests cover: - 15, 16, 20 and 200 failures, including mixed ERROR+FAILED entries - `keep_summary_lines=False`, with exact pre-fix selection and naming - a binding global cap, with `lines_dropped_by_global_cap > 0`, against a non-binding one - the cap reserve: at 60 and 200 failures the totals line and the first failure's `E ` line survive, and kept + named == total (this test fails with the reserve removed) - the `+K more` count - malformed separators and CRLF - unchanged output for non-pytest logs and for logs with ≤ `max_errors` failures - `tests/test_transforms_log_compressor.py` adds Python regressions, including the issue's reproduction through the real Rust-backed `compress()`. - `CHANGELOG.md` is not edited, and no parity fixtures changed. ## Testing - [x] Unit tests pass (`pytest`): the log-compressor suites (see "Not tested" for the full suite) - [x] Linting passes (`ruff check .`): on the touched files, plus the repo pre-commit hooks - [x] Type checking passes (`mypy headroom`): `mypy headroom/transforms/log_compressor.py` plus the repo's mypy pre-commit hook - [x] New tests added for new functionality - [x] Manual testing performed ### Test Output ```text $ cargo fmt --all -- --check # clean $ cargo clippy -p headroom-core -- -D warnings # clean $ cargo test -p headroom-core --lib log_compressor test result: ok. 38 passed; 0 failed; 0 ignored; 0 measured; 920 filtered out $ cargo run -p headroom-parity -- run --only log_compressor [log_compressor ] total=20 matched=20 skipped=0 diffed=0 $ uv sync --extra dev --reinstall-package headroom-ai && uv run pytest tests/test_transforms_log_compressor.py tests/test_log_compressor.py ============================== 67 passed in 1.14s ============================== $ uv run ruff check <touched .py> && uv run ruff format --check <touched .py> All checks passed! 2 files already formatted $ uv run pre-commit run --files <touched files> Sync plugin versions / Verify Ruff version alignment / check for merge conflicts / ruff / ruff format / mypy .... Passed $ uv run mypy headroom/transforms/log_compressor.py Success: no issues found in 1 source file ``` ## Real Behavior Proof - Environment: macOS 26.6.2 arm64. Python 3.12.14 (uv venv). Rust 1.95.0, the pinned toolchain. Extension built from this branch with `uv sync --extra dev --reinstall-package headroom-ai` (maturin). A plain `uv sync` may reuse a stale build after Rust edits. Default `LogCompressorConfig()`. - Exact command / steps: the reproduction script from the issue, unchanged, run first against the published `headroom-ai==0.39.1` wheel (`uv run --no-project --with headroom-ai==0.39.1 python repro_3814.py`) and then against this branch (`uv run python repro_3814.py`). I also ran the same script with 200 failures to exercise the binding global cap. - Observed result: 0.39.1 silently dropped entries once the cap bound; this branch keeps or names every short-summary entry (full before/after output below). Before (0.39.1 wheel): ```text 15 FAILED in -> 15 kept, missing [] marker: [120 lines omitted: 16 FAIL, 1 INFO] 16 FAILED in -> 15 kept, missing [13] marker: [127 lines omitted: 17 FAIL, 1 INFO] 20 FAILED in -> 15 kept, missing [13, 14, 15, 16, 17] marker: [155 lines omitted: 21 FAIL, 1 INFO] ``` After (this branch): ```text 15 FAILED in -> 15 kept, missing [] marker: [120 lines omitted: 16 FAIL, 1 INFO] 16 FAILED in -> 16 kept, missing [] marker: [126 lines omitted: 17 FAIL, 1 INFO] 20 FAILED in -> 20 kept, missing [] marker: [150 lines omitted: 21 FAIL, 1 INFO] ``` With enough failures the adaptive cap binds. The totals line and the first failure's `E ` line keep reserved slots, entries fill the rest, and every entry that doesn't fit is named. Same script, counting what survives: ```text 0.39.1 (before) this branch (after) failures summary kept E/traceback totals line summary kept E/traceback totals line 16 15 3 yes 16 3 yes 20 15 3 yes 20 3 yes 60 15 3 yes 49 1 yes 200 15 3 yes 49 1 yes ``` At 200 failures, the 151 entries that don't fit are named rather than dropped silently: 5 listed + 146 = 151. - Not tested: full-suite pytest and full mypy (only the log-compressor suites plus the touched module), Linux/Windows hosts, and live proxy traffic (details below). - The full `uv run pytest` suite and a full `mypy headroom`; I ran only the log-compressor suites and mypy on the touched module. - Linux and Windows hosts. CRLF input is covered by unit tests on macOS only. - Real pytest runs piped through the proxy; I used the issue's synthetic log. ## Runtime Rollout Safety - Rollout-managed feature(s): none - Minimum rollout channel: n/a - Stable/default behavior changed: yes, for pytest logs only. A short summary with more than `max_errors` entries now keeps every entry where the cap allows, and any entry still dropped is named in the marker. Output is unchanged for other logs, and for pytest logs where no short-summary entry is omitted and no cap tie involves one. - Kill switch / disable path: `keep_summary_lines=False` restores pre-fix selection. The marker still names omitted ids, which only adds text. - Unsafe override required: no - Qualification impact: none expected; the 20 log_compressor parity fixtures are unchanged - Rollback path: revert this commit ## 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 performed a self-review of my code - [x] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation (n/a, no documented behavior changes) - [x] My changes generate no new warnings - [x] I have added tests that prove my fix is effective or that my feature works - [x] New and existing unit tests pass locally with my changes - [x] I did **not** edit `CHANGELOG.md`; it is generated by release-please from my Conventional Commit PR title (a CI guard enforces this) ## Additional Notes The issue asked whether option 2 counts as a behaviour change. It does change default retention for large pytest short summaries, which is the point. It's scoped tightly: only lines inside a real short-summary section are affected, and `keep_summary_lines=False` gives the old selection back. If you'd rather ship only option 1 (naming) first, the selection change is separable. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com> Co-authored-by: JerrettDavis <mxjerrett@gmail.com> |
||
|
|
45720301e5 |
feat(rust): port log_compressor to Rust + bug fixes (Phase 3e.5)
Ports `headroom.transforms.log_compressor` to Rust. The biggest-by- impact remaining compressor port: build/test logs are where the 10-50x compression wins live. * Stack-trace state machine: per-flavor dispatcher (Python Traceback, JS, Java, Rust error, Go); each flavor has its own termination rule. Python terminated on any blank line, dropping mid-trace lines from chained-exception traces. * Conservative dedupe: preserves message prefix (everything before first `:` or `=`); only trailing region is tokenised. Python's blanket normalisation collapsed segfaults at different addresses. * Loud CCR failures: `tracing::warn!` + `logger.warning` instead of bare `except: pass`. * `LogLevel::FAIL` documented as cosmetic-equivalent to ERROR. Same shape as search_compressor port. Rust `LogCompressor` orchestrates format detect -> classify -> score -> select -> format -> CCR. Inline static-table format detector (YAGNI), aho-corasick level classifier with word-boundary post-filter (`signals::keyword_detector` technique), hand-rolled per-flavor stack-trace state machine. `signals::LineImportanceDetector` NOT consumed -- log levels are structural, not prose-style importance. `headroom.transforms.log_compressor` becomes a thin shim: `compress()` delegates to Rust end-to-end; internal helpers preserved for the existing 50-test surface. Two existing tests updated for new dedupe semantics + new compress orchestration. * 17 Rust unit tests * 50 Python tests pass * `make ci-precheck` clean |
||
|
|
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> |
||
|
|
6e9ea54a04 |
test: fix PR formatting and cover log compressor
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> |