Files
Jyotisha/scripts/rectification_purpose_gate/__main__.py
T

46 lines
1.6 KiB
Python

"""Evaluate a synthetic or public scope offline using the native engine."""
from __future__ import annotations
import argparse
import json
from pathlib import Path
from . import assess_use
from .native import native_scope_compute
from .providers import native_boundary_providers
from .scan import scan_scope
from .scope import build_scope_request
def evaluate_scope(packet: dict) -> dict:
scope = build_scope_request(
packet["question"], packet["original_input"], packet["remaining_ranges"],
packet["profiles"], packet["evaluated_at"],
)
assessment = scan_scope(scope, native_scope_compute(scope), native_boundary_providers(scope),
budget=packet.get("budget", 4000))
decision = assess_use(assessment, scope["binding"])
return {
**scope, "legacy_rectification_result": None,
"purpose_assessment": {**assessment, "decision": decision},
"interval_results": assessment["interval_results"],
}
def main() -> int:
parser = argparse.ArgumentParser(description=__doc__)
parser.add_argument("--input", required=True, type=Path, help="JSON with synthetic or public calculation inputs")
args = parser.parse_args()
try:
packet = json.loads(args.input.read_text(encoding="utf-8"))
result = evaluate_scope(packet)
except (KeyError, TypeError, ValueError):
parser.exit(2, "Invalid purpose scope input; check explicit time zones, profile and requested ranges.\n")
print(json.dumps(result, ensure_ascii=False, indent=2, allow_nan=False))
return 0
if __name__ == "__main__":
raise SystemExit(main())