Preserve installed operator workspace before consolidation
Local preservation snapshot, not a new deployment or simulation acceptance.
This commit is contained in:
@@ -0,0 +1,114 @@
|
||||
"""Bounded P3 graph/mission qualification; synthetic pose replay, no vehicle IO."""
|
||||
|
||||
import argparse
|
||||
import hashlib
|
||||
import json
|
||||
import sys
|
||||
import time
|
||||
from datetime import UTC, datetime
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).resolve().parents[2] / "src"))
|
||||
|
||||
|
||||
def main():
|
||||
from k1link.simulation.ai_polygon.mission_policy import WaypointMission
|
||||
from k1link.simulation.ai_polygon.robots import select_robot
|
||||
from k1link.simulation.ai_polygon.route_graph import build_route
|
||||
from k1link.simulation.ai_polygon.route_mission import mission_for_inputs
|
||||
from k1link.simulation.ai_polygon.run_inputs import validate_run_inputs
|
||||
|
||||
parser = argparse.ArgumentParser()
|
||||
parser.add_argument("--cases", type=Path, required=True)
|
||||
parser.add_argument("--sha256", required=True)
|
||||
parser.add_argument("--output", type=Path, required=True)
|
||||
args = parser.parse_args()
|
||||
if args.cases.stat().st_size > 4 * 1024 * 1024:
|
||||
raise ValueError("Fixture budget exceeded")
|
||||
raw = args.cases.read_bytes()
|
||||
if hashlib.sha256(raw).hexdigest() != args.sha256:
|
||||
raise ValueError("Qualification fixture identity changed")
|
||||
cases = json.loads(raw)
|
||||
if not 1 <= len(cases) <= 20 or any(len(c["trace"]) > 2000 for c in cases):
|
||||
raise ValueError("Qualification case budget exceeded")
|
||||
args.output.mkdir(parents=True, exist_ok=False)
|
||||
started, results = time.monotonic(), []
|
||||
robot = select_robot("dcd006-v020")
|
||||
for case in cases:
|
||||
inputs = validate_run_inputs(case["inputs"], robot)
|
||||
route = build_route(inputs)
|
||||
mission = mission_for_inputs(inputs)
|
||||
baseline = WaypointMission(inputs["mission"]["route_xy"])
|
||||
trace = []
|
||||
for row in case["trace"]:
|
||||
if time.monotonic() - started > 60:
|
||||
raise TimeoutError("Route qualification deadline")
|
||||
|
||||
def observed(target, *_, visible=row["visible"]):
|
||||
# Explicit observation stub isolates route progress from RGB,
|
||||
# range and physics. It cannot qualify actual obstacle avoidance.
|
||||
return [*target, 0] if visible else None
|
||||
|
||||
goal, intent = mission.update(row["pose"], row["seconds"], observed)
|
||||
baseline.update(row["pose"], row["seconds"], observed)
|
||||
if row.get("admit"):
|
||||
mission.confirm_arrival(row["pose"], row["seconds"], mission.index, admitted=True)
|
||||
trace.append(dict(seconds=row["seconds"], goal=goal, intent=intent))
|
||||
actual = dict(
|
||||
route_status=route["legs"][0]["status"],
|
||||
state=mission.state if mission.fault else trace[-1]["intent"]["state"],
|
||||
fault=mission.fault,
|
||||
route_failure=mission.route_failure,
|
||||
max_recovery=max(r["intent"]["recovery_attempt"] for r in trace),
|
||||
baseline_fault=baseline.fault,
|
||||
)
|
||||
# Terminal mission.fault is authoritative; state can lag a stopped
|
||||
# update on legacy WaypointMission, which reports intent immediately.
|
||||
actual["state"] = mission.fault or trace[-1]["intent"]["state"]
|
||||
checks = {key: actual[key] == value for key, value in case["expected"].items()}
|
||||
results.append(
|
||||
dict(
|
||||
name=case["name"],
|
||||
passed=all(checks.values()),
|
||||
checks=checks,
|
||||
actual=actual,
|
||||
route=route,
|
||||
trace=trace,
|
||||
)
|
||||
)
|
||||
report = dict(
|
||||
schema_version="missioncore.route-qualification/v1",
|
||||
utc=datetime.now(UTC).isoformat(),
|
||||
monotonic=started,
|
||||
wall_seconds=time.monotonic() - started,
|
||||
fixtures_sha256=args.sha256,
|
||||
source_sha256=hashlib.sha256(Path(__file__).read_bytes()).hexdigest(),
|
||||
scope="Graph and mission on synthetic poses/observations/admission stubs; "
|
||||
"no CMU, physics, RGB inference, physical device or independent holdout",
|
||||
passed=all(r["passed"] for r in results),
|
||||
cases=results,
|
||||
)
|
||||
(args.output / "report.json").write_text(json.dumps(report, indent=2), encoding="utf-8")
|
||||
(args.output / "manifest.json").write_text(
|
||||
json.dumps(
|
||||
{"report.json": hashlib.sha256((args.output / "report.json").read_bytes()).hexdigest()}
|
||||
),
|
||||
encoding="utf-8",
|
||||
)
|
||||
print(
|
||||
json.dumps(
|
||||
dict(
|
||||
passed=report["passed"],
|
||||
cases=[
|
||||
dict(name=r["name"], passed=r["passed"], actual=r["actual"]) for r in results
|
||||
],
|
||||
)
|
||||
),
|
||||
flush=True,
|
||||
)
|
||||
if not report["passed"]:
|
||||
raise RuntimeError("Route qualification rejected")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user