mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
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. |
||
|---|---|---|
| .. | ||
| 3a0b14d2dea7c876.json | ||
| 3ba74a1f57c5351e.json | ||
| 4efe946303371867.json | ||
| 5e8e1bc29f6c71c5.json | ||
| 7e145153192c11a1.json | ||
| 7fde660489bc47aa.json | ||
| 9fb76321d31ed64c.json | ||
| 37c86907c057e293.json | ||
| 67f4b1a1697c8aa9.json | ||
| 70fbb444a583fe3c.json | ||
| 71d648a39e151a72.json | ||
| 79e6b68a05a1c639.json | ||
| 552d30c30c2a6793.json | ||
| 628c8985c40adb7d.json | ||
| 837b272f1604eaaa.json | ||
| 53400da2b7dd2428.json | ||
| 247811aecfdec556.json | ||
| bc4488ce189d1c86.json | ||
| bf9b9ceb4b70dcd0.json | ||
| cabc55445af63e2f.json | ||
| d100a9ac7a3671da.json | ||