headroom/tests/parity/fixtures/content_detector
chopratejas 625290cfbc chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge
Faithful port of `headroom/transforms/content_detector.py` into
`headroom-core`. Same regex patterns, dispatch order, confidence
formulas, and line-count caps; lockstep with Python via 21 recorded
parity fixtures (every dispatch branch exercised).

- crates/headroom-core/src/transforms/content_detector.rs: regex-only
  detector (no ML); ContentType/DetectionResult mirror Python's enum +
  dataclass surface; metadata uses serde_json::Map for clean PyO3
  bridging.
- Tie-break in code detection: track scores in first-match insertion
  order (matches Python dict iteration semantics on `max()` ties).
- TypeScript second pattern is start-anchored — Python's
  `pattern.match(line)` is start-anchored, but the regex crate's
  `is_match` is unanchored, so the literal `:` prefix is required for
  parity.
- crates/headroom-parity: ContentDetectorComparator + universal f64
  normalization in `compare_fixture` (serde_json's lossy parse vs
  full-precision serialize creates a 1-ULP asymmetry that broke
  comparison; round-trip the actual through to_string/from_str).
- crates/headroom-py: detect_content_type/is_json_array_of_dicts and
  PyDetectionResult exposed via PyO3 with GIL released during scan.
- tests/parity/recorder.py: new `_wrap_function` for free-function
  recording; content_detector hook + 21 varied inputs covering JSON
  arrays, diffs, HTML, search, build/log, six languages, and fallbacks.

Sets up PR2 (ContentRouter scaffold) to call into Rust ContentDetector
in-process via the bridge.
2026-04-27 23:57:39 -07:00
..
3a0b14d2dea7c876.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
3ba74a1f57c5351e.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
4efe946303371867.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
5e8e1bc29f6c71c5.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
7e145153192c11a1.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
7fde660489bc47aa.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
9fb76321d31ed64c.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
37c86907c057e293.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
67f4b1a1697c8aa9.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
70fbb444a583fe3c.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
71d648a39e151a72.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
79e6b68a05a1c639.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
552d30c30c2a6793.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
628c8985c40adb7d.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
837b272f1604eaaa.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
53400da2b7dd2428.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
247811aecfdec556.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
bc4488ce189d1c86.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
bf9b9ceb4b70dcd0.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
cabc55445af63e2f.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00
d100a9ac7a3671da.json chore(rust): port ContentDetector to Rust + parity harness + PyO3 bridge 2026-04-27 23:57:39 -07:00