#!/usr/bin/env python3 """Run TELEN L3 initial training only after every frozen gate passes.""" from __future__ import annotations import argparse import json import sys from pathlib import Path REPO_ROOT = Path(__file__).resolve().parents[1] sys.path.insert(0, str(REPO_ROOT / "src")) from telen.experiment import ( # noqa: E402 BundleValidationError, GateAuthorizationError, run_l3_development_pilot, ) def parse_args() -> argparse.Namespace: parser = argparse.ArgumentParser( description=( "Train the predeclared three-seed L3 development pilot. The command " "fails closed unless expert and base-score receipts authorize every " "hash-frozen input; test rows are rejected." ) ) parser.add_argument("--manifest", type=Path, required=True) parser.add_argument("--output-dir", type=Path, required=True) parser.add_argument("--device", default="cpu") return parser.parse_args() def main() -> None: args = parse_args() try: result = run_l3_development_pilot( args.manifest, args.output_dir, device=args.device ) except (GateAuthorizationError, BundleValidationError) as exc: print( json.dumps( { "artifact_type": "telen_l3_training_refusal", "authorized": False, "reason": str(exc), }, ensure_ascii=False, indent=2, ) ) raise SystemExit(2) from exc print(json.dumps(result, ensure_ascii=False, indent=2)) if __name__ == "__main__": main()