feat(perception): integrate vegetation policy review

This commit is contained in:
DCCONSTRUCTIONS
2026-08-28 11:22:00 +03:00
parent 30080c51aa
commit c4c2392c79
17 changed files with 2388 additions and 105 deletions
@@ -0,0 +1,183 @@
#!/usr/bin/env python3
"""Build a clean-revision Worker 006 release for the DDRNet + M49 load gate."""
from __future__ import annotations
import argparse
import json
import re
import subprocess
import sys
import tempfile
from pathlib import Path
SCRIPT_ROOT = Path(__file__).resolve().parent
if str(SCRIPT_ROOT) not in sys.path:
sys.path.insert(0, str(SCRIPT_ROOT))
from build_m49_tgs_integrated_graph_worker_artifact import ( # noqa: E402
PATCH_ID,
REPOSITORY_ROOT,
WHEEL_NAME,
ArtifactBuildError,
build_wheel,
git_revision,
materialize_revision,
sha256_file,
write_archive,
)
from build_m49_tgs_integrated_graph_worker_artifact import ( # noqa: E402
SOURCES as M49_SOURCES,
)
SOURCES = M49_SOURCES + (
Path(
"experiments/perception/worker/lab_v1_vegetation_goose/"
"run_goose_vegetation_benchmark.py"
),
Path(
"experiments/perception/worker/lab_v1_vegetation_goose/"
"run_vegetation_integrated_load.py"
),
Path(
"experiments/perception/worker/m49_t3_travel/"
"build_vegetation_integrated_graph_evidence.py"
),
Path("config/perception/lab-v1-goose-vegetation-benchmark-v1.json"),
Path("config/perception/lab-v1-vegetation-mission-policy-v1.json"),
Path("config/perception/lab-v1-vegetation-provider-label-map-v1.json"),
Path("config/perception/lab-v1-vegetation-integrated-shadow-v1.json"),
)
def build_artifact(
patch_id: str,
output_directory: Path,
*,
revision: str | None = None,
source_root: Path | None = None,
) -> dict[str, object]:
if PATCH_ID.fullmatch(patch_id) is None:
raise ArtifactBuildError("patch id is invalid")
selected_revision = revision or git_revision()
if re.fullmatch(r"[a-f0-9]{40}", selected_revision) is None:
raise ArtifactBuildError("artifact revision is invalid")
with tempfile.TemporaryDirectory(prefix="mission-core-vegetation-integrated-") as directory:
stage = Path(directory)
snapshot = source_root
if snapshot is None:
snapshot = stage / "source"
materialize_revision(selected_revision, snapshot)
sources = tuple(snapshot / relative for relative in SOURCES)
if any(path.is_symlink() or not path.is_file() for path in sources):
raise ArtifactBuildError("release input is not a regular file")
payload = stage / "payload"
payload.mkdir()
wheel = build_wheel(snapshot, stage / "wheel")
copied: list[Path] = []
for source in sources:
destination = payload / source.name
if destination.exists():
raise ArtifactBuildError("release payload file names are not unique")
destination.write_bytes(source.read_bytes())
copied.append(destination)
wheel_destination = payload / WHEEL_NAME
wheel_destination.write_bytes(wheel.read_bytes())
copied.append(wheel_destination)
release = {
"schema_version": "missioncore.lab-v1-vegetation-integrated-worker-release/v1",
"patch_id": patch_id,
"transition": "lab-v1-vegetation-m49-integrated-shadow/v1",
"code_revision": selected_revision,
"worker_id": "worker-006",
"source_pack_sha256": (
"0685d24219d8236caf8b7f1685e93f6d6b59e7fd015a768d88a92bbe8b154944"
),
"expected_frames": 4489,
"requested_source_rate_hz": 12.0,
"native_engine_sha256": (
"b8a40b3580edff001ec9680de68707242294ff590ab296000fae371f1083f695"
),
"ddrnet_checkpoint_sha256": (
"b99c2838051bcd7b092fd3970aa62a77d5c0bbb809c9b9afb2ff4b0ebdaa4ee6"
),
"images": {
"travel": (
"sha256:7b412020f4d8392d1d1ed1b33beadc44140f0ea8f781e62dd69796042334300f"
),
"parity": (
"sha256:ceb13548617e4bd3f619766bfdff00af3fa5160946b367828da6d2233dcdcba0"
),
"runtime": (
"sha256:58df7489c3f2276f9591d500a012dee03e23d35543ce3c390b4c001e6bf90794"
),
"vegetation": (
"sha256:591cb382c099eeb05e7ec16e2371e0b2da54d2bb5c49ec0f4ac88dbf72b0f0cd"
),
},
"authority": {
"visual_quality_accepted": False,
"route_truth_available": False,
"traversability_accepted": False,
"physical_free_space_accepted": False,
"commands_enabled": False,
"actuation_allowed": False,
"navigation_or_safety_accepted": False,
"production_accepted": False,
},
"scope": {
"gauss_or_playcanvas_action": "none",
"durable_worker_action": "none",
"canonical_triton_action": "none",
"heavy_vegetation_candidates": ["ddrnet"],
},
"files": {
path.name: {"sha256": sha256_file(path), "bytes": path.stat().st_size}
for path in sorted(copied)
},
}
release_path = payload / "release.json"
release_path.write_text(
json.dumps(release, indent=2, sort_keys=True) + "\n", encoding="utf-8"
)
payload_files = sorted((*release["files"], release_path.name))
(stage / "manifest.env").write_text(
f"id={patch_id}\ncomponent=mission-core-worker\ntype=shadow-release\n",
encoding="utf-8",
)
(stage / "files.txt").write_text(
"\n".join(payload_files) + "\n", encoding="utf-8"
)
target = output_directory.resolve() / f"nodedc-{patch_id}.tgz"
write_archive(stage, target)
return {
"ok": True,
"patch_id": patch_id,
"artifact": str(target),
"sha256": sha256_file(target),
"code_revision": selected_revision,
"wheel_sha256": release["files"][WHEEL_NAME]["sha256"],
"payload_files": payload_files,
"transition": release["transition"],
}
def main() -> int:
parser = argparse.ArgumentParser()
parser.add_argument("patch_id")
parser.add_argument(
"--output-directory",
type=Path,
default=REPOSITORY_ROOT / ".runtime/worker-artifacts",
)
arguments = parser.parse_args()
try:
result = build_artifact(arguments.patch_id, arguments.output_directory)
except (ArtifactBuildError, OSError, subprocess.SubprocessError) as exc:
parser.error(str(exc))
print(json.dumps(result, indent=2, sort_keys=True))
return 0
if __name__ == "__main__":
raise SystemExit(main())