mirror of
https://github.com/headroomlabs-ai/headroom.git
synced 2026-08-27 14:17:10 -04:00
feat(rust): scaffold workspace + parity harness (phase-0)
Bootstrap the Rust port of Headroom. Additive only — no existing Python code modified. Ships the workshop, not the widgets. Layout Cargo.toml (workspace) + rust-toolchain.toml crates/headroom-core — transform library, stub only crates/headroom-proxy — axum binary, /healthz only crates/headroom-py — PyO3 cdylib, exposes headroom._core.hello() crates/headroom-parity — Rust-vs-Python oracle harness + parity-run CLI Tooling Makefile: test, test-parity, bench, build-proxy, build-wheel, fmt, lint .github/workflows/rust.yml: test, wheels (linux/mac), audit, parity-nightly deny.toml for cargo-deny Parity corpus tests/parity/recorder.py + scripts/record_fixtures.py 125 recorded fixtures across 5 leaf transforms (ccr, tokenizer, log_compressor, diff_compressor, cache_aligner) Docs RUST_DEV.md — developer setup and workspace reference docs/spec/022-rust-migration.md — migration plan and stage breakdown .gitignore: whitelist scripts/record_fixtures.py; ignore target/ Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
a1d9832e27
commit
0414cb70e4
148 changed files with 7292 additions and 0 deletions
59
scripts/record_fixtures.py
Normal file
59
scripts/record_fixtures.py
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
#!/usr/bin/env python3
|
||||
"""Entry point for recording Rust-vs-Python parity fixtures.
|
||||
|
||||
Usage:
|
||||
python scripts/record_fixtures.py
|
||||
|
||||
This driver:
|
||||
1. Monkey-patches the Phase-1 transform classes via
|
||||
`tests.parity.recorder.record_all()`.
|
||||
2. Runs a small deterministic synthetic workload (no network, no real LLM
|
||||
calls) that hits each transform at least 20 times with varied inputs.
|
||||
3. Prints a summary and exits non-zero if any transform was blocked.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import logging
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
# Make `tests/parity/recorder.py` importable without installing it.
|
||||
_REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||
sys.path.insert(0, str(_REPO_ROOT))
|
||||
|
||||
from tests.parity.recorder import record_all, run_default_workload # noqa: E402
|
||||
|
||||
|
||||
def main() -> int:
|
||||
logging.basicConfig(level=logging.INFO, format="%(levelname)s %(name)s: %(message)s")
|
||||
log = logging.getLogger("record_fixtures")
|
||||
|
||||
statuses = record_all()
|
||||
log.info("patch status:")
|
||||
blocked = []
|
||||
for name, status in statuses.items():
|
||||
log.info(" %-16s %s", name, status)
|
||||
if status.startswith("blocked:"):
|
||||
blocked.append((name, status))
|
||||
|
||||
counts = run_default_workload()
|
||||
log.info("fixture counts:")
|
||||
shortfall = []
|
||||
for name, n in counts.items():
|
||||
log.info(" %-16s %d", name, n)
|
||||
if n < 20:
|
||||
shortfall.append((name, n))
|
||||
|
||||
if blocked:
|
||||
log.error("blocked transforms: %s", blocked)
|
||||
if shortfall:
|
||||
log.error("transforms with <20 fixtures: %s", shortfall)
|
||||
|
||||
# Exit non-zero if anything was wholly blocked; short recordings are
|
||||
# a soft warning.
|
||||
return 1 if blocked else 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
raise SystemExit(main())
|
||||
Loading…
Add table
Add a link
Reference in a new issue