headroom/tests/parity/fixtures/diff_compressor
chopratejas 48c13245c5 fix(diff): close ContentRouter routing gaps for merge diffs and long preambles
User audit caught three gaps that prevented DiffCompressor from being
invoked even when the input was a real diff. These complement the four
emit-time bugs fixed in the previous commit — those fixes only kick in
once DiffCompressor receives the input. Without these gap fixes, real
merge-commit diffs and `git log -p` outputs with long commit messages
were misrouted away from DiffCompressor entirely.

# The three gaps (each fixed in Python; gap 3 also fixed in Rust)

1. Detector scan window was hardcoded to first 50 lines.
   `_try_detect_diff` in content_detector.py only inspected
   `content.split("\n")[:50]`. `git log -p` outputs commonly have
   commit messages longer than 50 lines (releases, squashed commits,
   bots), pushing the `diff --git` header out of the detection window.
   Result: input was returned with `content_type=PLAIN_TEXT` and routed
   to the text compressor, never reaching DiffCompressor. Fix: window
   widened to 500 lines.

2. Detector regex didn't recognize merge-commit headers.
   `_DIFF_HEADER_PATTERN` matched `diff --git`, `--- a/`, and the
   regular `@@ -A,B +C,D @@` hunk header. Merge-commit diffs from
   `git log -p` use `diff --combined <path>`, `diff --cc <path>`, and
   combined-diff hunk headers `@@@+`. The shared `--- a/` line still
   triggered the detector with low confidence, but only barely. Fix:
   extended the regex to recognize all four merge-shaped header forms.

3. DiffCompressor parser only matched `^diff --git`.
   Even after fixing detection, the parser's `_DIFF_GIT_PATTERN`
   wouldn't match `diff --combined` or `diff --cc`, so merge diffs
   reached DiffCompressor and were treated as one giant pre-diff blob —
   passed through unchanged after the previous PR's pre-diff
   preservation fix. Fix: added `_DIFF_COMBINED_PATTERN` and
   `_DIFF_CC_PATTERN`; `_parse_diff` starts a new file section on any
   of the three header forms. Mirrored in Rust as `is_diff_header`
   helper that checks all three regexes.

# Why this matters end-to-end

DiffCompressor's value comes from being routed to. Detection +
parser-level coverage are upstream of the compressor — without them,
the compressor never sees the input. The previous PR's four bug fixes
(rename, combined-diff hunks, no-newline marker, pre-diff content) are
correct and necessary, but for merge commits and long-preamble diffs,
they were only firing on the rare cases where the detector misclicked
into DiffCompressor anyway. With these three gaps closed, the
ContentRouter→DiffCompressor pipeline actually engages on:
- `git log -p` outputs of any commit-message length
- Merge-commit diffs (`diff --combined`, `diff --cc`)
- Combined-diff snippets (`@@@`+ hunk-only inputs)

# New fixtures (3 added to the existing 24)

- `066bc82…` — `diff --combined` merge diff (3-way)
- `5d950a94…` — `diff --cc` merge diff (alternate form)
- `66c86f64…` — long pre-diff content (60-line commit message)
  followed by a rename diff (exercises detector scan widening +
  pre-diff preservation in tandem)

Parity: total=27 matched=27 skipped=0 diffed=0.

# Tests

- Python: 4 new tests across 2 new test classes —
  `TestRoutingGapMergeDiffs` (combined / cc parser) and
  `TestRoutingGapDetectorScanWindow` (long preamble detection +
  combined-diff regex recognition).
- Rust: 2 new tests covering combined / cc parser sections.

# Verification

- 27/27 parity fixtures byte-equal.
- Python: 41/41 tests pass (was 37).
- Rust: 18/18 transforms tests; 62/62 workspace; 5/5 proptests.
- `cargo fmt --check` clean; `cargo clippy --workspace --all-targets
  -- -D warnings` clean.
2026-04-26 09:13:08 -07:00
..
0cf5e189bd42fab1.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
1a4e35c597c7a001.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
1bdfa041108f0aad.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
1eeb1f7ae64c7744.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
2c07a365f52d6fa6.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
2cd095b132f5da3f.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
2eb4b13b37f376d6.json fix(diff_compressor): four silent information-loss paths in Python AND Rust 2026-04-26 09:13:08 -07:00
5d950a94b8c22480.json fix(diff): close ContentRouter routing gaps for merge diffs and long preambles 2026-04-26 09:13:08 -07:00
9b9a03215a7198bf.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
10f0106f40cbe2fa.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
066bc82007dc2dd4.json fix(diff): close ContentRouter routing gaps for merge diffs and long preambles 2026-04-26 09:13:08 -07:00
66c86f64baebfc3f.json fix(diff): close ContentRouter routing gaps for merge diffs and long preambles 2026-04-26 09:13:08 -07:00
88b4d4a7e93014e5.json fix(diff_compressor): four silent information-loss paths in Python AND Rust 2026-04-26 09:13:08 -07:00
97bde326d96a1165.json fix(diff_compressor): four silent information-loss paths in Python AND Rust 2026-04-26 09:13:08 -07:00
433b2d25303645ed.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
649fd65ad3511191.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
4844a5f9605b8425.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
b0b83d16366edfed.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
b605bd89e234cbff.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
c6b6d5c9fd7f1ad2.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
c72662c635d1defa.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
d0ba5cae330722be.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
d0e62d2f1493bd72.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
d4ed44a6fc667358.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
da9afe00e9846ce4.json fix(diff_compressor): four silent information-loss paths in Python AND Rust 2026-04-26 09:13:08 -07:00
e9c505e42b2b2edc.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00
ea99ab1ea7449acf.json feat(rust): scaffold workspace + parity harness (phase-0) 2026-04-24 13:39:48 -07:00