Files
gps-denied-onboard/ci/opencv_pin_gate.py
T
Oleksandr Bezdieniezhnykh b12db61444 [AZ-263] Bootstrap: repo skeleton + Docker + CI + Alembic + Tier-1 tests
Implements the AZ-263 / E-BOOT initial structure task:

- Python src/-layout package `gps_denied_onboard/` with per-component
  interface stubs (14 components), type-only DTOs under `_types/`,
  shared helpers under `helpers/` (R14 LightGlue ownership), structured
  JSON logging, runtime composition root with env-var fail-fast gate,
  healthcheck module shared by Docker and CI smoke.
- CMake top-level + `cmake/{build_options,dependencies,strategies}.cmake`
  with the BUILD_* per-binary flags (ADR-002) and pinned external git
  refs for OKVIS2 / VINS-Mono / GTSAM / FAISS / OpenCV >=4.12.0.
- Three Dockerfiles (companion-tier1, operator-tooling,
  mock-suite-sat-service) + two compose files (dev + Tier-1 test).
- Four GitHub Actions workflows: ci.yml (lint/unit/integration/dual
  binary build/SBOM diff/security), ci-tier2.yml (self-hosted Jetson
  AC-bound NFTs), release.yml, cve-rescan.yml.
- Two CI gate scripts: `ci/sbom_diff.py` (deployment SBOM subset +
  R02 exclusion), `ci/opencv_pin_gate.py` (>=4.12.0 enforcement,
  D-CROSS-CVE-1).
- Alembic-driven Postgres 16 initial migration `0001_initial.py`
  mirroring satellite-provider tiles + flights + sector_classifications
  + manifests + engine_cache_entries (data_model.md s 2).
- Tier-1 test scaffolding: 95 passing unit tests covering every AC,
  per-component smoke tests, structured logging JSON output check,
  env-var gate check, healthcheck import check. Two CI-gated tests
  (cmake configure, actionlint) skip locally with explicit reasons.
- Batch report + code review report under `_docs/03_implementation/`.

Verdict: PASS_WITH_WARNINGS (two Low findings, both informational).
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-11 01:00:28 +03:00

66 lines
2.1 KiB
Python
Executable File

#!/usr/bin/env python3
"""OpenCV pin gate — D-CROSS-CVE-1 enforcement.
Asserts that the resolved `opencv-python` (or `opencv-contrib-python`) version
declared in `pyproject.toml` is `>= 4.12.0`. Runs without installing any deps.
"""
from __future__ import annotations
import argparse
import re
import sys
from pathlib import Path
MIN_VERSION = (4, 12, 0)
OPENCV_PACKAGES = ("opencv-python", "opencv-contrib-python")
def _parse_version(spec: str) -> tuple[int, ...]:
match = re.search(r"(\d+)\.(\d+)\.(\d+)", spec)
if match is None:
raise ValueError(f"Cannot parse a version from {spec!r}")
return tuple(int(g) for g in match.groups())
def main(argv: list[str] | None = None) -> int:
parser = argparse.ArgumentParser(description="OpenCV >=4.12.0 pin gate.")
parser.add_argument("--pyproject", type=Path, default=Path("pyproject.toml"))
args = parser.parse_args(argv)
text = args.pyproject.read_text()
found: list[tuple[str, tuple[int, ...]]] = []
for pkg in OPENCV_PACKAGES:
for line in text.splitlines():
stripped = line.strip().strip(",").strip('"').strip("'")
if stripped.startswith(pkg):
spec = stripped[len(pkg) :].strip()
if spec.startswith((">=", "==", "~=", ">")):
spec = spec.lstrip(">=~<")
if not spec:
continue
try:
parsed = _parse_version(spec)
except ValueError:
continue
found.append((pkg, parsed))
if not found:
print("FAIL: no OpenCV pin found in pyproject.toml.", file=sys.stderr)
return 2
for pkg, version in found:
if version < MIN_VERSION:
print(
f"FAIL: {pkg}=={'.'.join(str(v) for v in version)} "
f"< required {'.'.join(str(v) for v in MIN_VERSION)} (D-CROSS-CVE-1).",
file=sys.stderr,
)
return 1
print(f"OK: {pkg} >= {'.'.join(str(v) for v in MIN_VERSION)}")
return 0
if __name__ == "__main__":
raise SystemExit(main())