mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 23:11:13 +00:00
b12db61444
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>
168 lines
6.8 KiB
Python
168 lines
6.8 KiB
Python
"""Initial schema — tiles (mirrored from satellite-provider) + onboard tables.
|
|
|
|
Per `_docs/02_document/data_model.md § 2`. The `tiles` schema mirrors
|
|
`satellite-provider`'s canonical columns + the additive onboard-only columns;
|
|
the additive-only invariant (Principle #5) is enforced at the migration-review
|
|
level.
|
|
|
|
Revision ID: 0001_initial
|
|
Revises:
|
|
Create Date: 2026-05-11
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from collections.abc import Sequence
|
|
|
|
import sqlalchemy as sa
|
|
from alembic import op
|
|
|
|
revision: str = "0001_initial"
|
|
down_revision: str | None = None
|
|
branch_labels: str | Sequence[str] | None = None
|
|
depends_on: str | Sequence[str] | None = None
|
|
|
|
|
|
def upgrade() -> None:
|
|
# flights -----------------------------------------------------------------
|
|
op.create_table(
|
|
"flights",
|
|
sa.Column("id", sa.dialects.postgresql.UUID(as_uuid=True), primary_key=True),
|
|
sa.Column("companion_id", sa.Text(), nullable=False),
|
|
sa.Column(
|
|
"started_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.text("now()"),
|
|
),
|
|
sa.Column("landed_at", sa.DateTime(timezone=True), nullable=True),
|
|
sa.Column("metadata", sa.dialects.postgresql.JSONB(), nullable=True),
|
|
)
|
|
|
|
# sector_classifications --------------------------------------------------
|
|
op.create_table(
|
|
"sector_classifications",
|
|
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
|
sa.Column("sector_id", sa.Text(), nullable=False, unique=True),
|
|
sa.Column("classification", sa.Text(), nullable=False),
|
|
sa.Column("freshness_threshold_days", sa.Integer(), nullable=False),
|
|
)
|
|
|
|
# tiles (mirrored canonical columns + additive onboard-only) --------------
|
|
op.create_table(
|
|
"tiles",
|
|
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
|
# Canonical columns (mirrored from satellite-provider).
|
|
sa.Column("zoom_level", sa.Integer(), nullable=False),
|
|
sa.Column("tile_x", sa.Integer(), nullable=False),
|
|
sa.Column("tile_y", sa.Integer(), nullable=False),
|
|
sa.Column("latitude", sa.Float(), nullable=False),
|
|
sa.Column("longitude", sa.Float(), nullable=False),
|
|
sa.Column("tile_size_meters", sa.Float(), nullable=False),
|
|
sa.Column("tile_size_pixels", sa.Integer(), nullable=False),
|
|
sa.Column("capture_timestamp", sa.DateTime(timezone=True), nullable=False),
|
|
sa.Column("compression", sa.Text(), nullable=False, server_default=sa.text("'jpeg'")),
|
|
sa.Column("crs", sa.Text(), nullable=False, server_default=sa.text("'EPSG:3857'")),
|
|
sa.Column("source", sa.Text(), nullable=False),
|
|
# Additive onboard-only columns.
|
|
sa.Column(
|
|
"flight_id",
|
|
sa.dialects.postgresql.UUID(as_uuid=True),
|
|
sa.ForeignKey("flights.id"),
|
|
nullable=True,
|
|
),
|
|
sa.Column("companion_id", sa.Text(), nullable=True),
|
|
sa.Column("tile_quality_metadata", sa.dialects.postgresql.JSONB(), nullable=True),
|
|
sa.Column("voting_status", sa.Text(), nullable=True),
|
|
sa.Column("freshness_status", sa.Text(), nullable=False, server_default=sa.text("'fresh'")),
|
|
sa.Column("signature", sa.LargeBinary(), nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.text("now()"),
|
|
),
|
|
sa.Column(
|
|
"updated_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.text("now()"),
|
|
),
|
|
sa.CheckConstraint("zoom_level BETWEEN 10 AND 22", name="ck_tiles_zoom"),
|
|
sa.CheckConstraint("tile_size_meters > 0", name="ck_tiles_meters"),
|
|
sa.CheckConstraint("tile_size_pixels > 0", name="ck_tiles_pixels"),
|
|
sa.CheckConstraint("source IN ('googlemaps','onboard_ingest')", name="ck_tiles_source"),
|
|
sa.CheckConstraint(
|
|
"voting_status IS NULL OR voting_status IN ('pending','trusted','rejected')",
|
|
name="ck_tiles_voting_status",
|
|
),
|
|
sa.CheckConstraint(
|
|
"freshness_status IN ('fresh','stale_warn','stale_reject')",
|
|
name="ck_tiles_freshness_status",
|
|
),
|
|
)
|
|
|
|
op.create_index("ix_tiles_zxy", "tiles", ["zoom_level", "tile_x", "tile_y"])
|
|
op.create_index("ix_tiles_lat_lon", "tiles", ["latitude", "longitude"])
|
|
op.create_index(
|
|
"ix_tiles_voting_status_onboard",
|
|
"tiles",
|
|
["voting_status"],
|
|
postgresql_where=sa.text("source = 'onboard_ingest'"),
|
|
)
|
|
op.create_index("ix_tiles_flight_id", "tiles", ["flight_id"])
|
|
op.create_index("ix_tiles_created_at", "tiles", ["created_at"])
|
|
|
|
# manifests ---------------------------------------------------------------
|
|
op.create_table(
|
|
"manifests",
|
|
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
|
sa.Column("manifest_id", sa.Text(), nullable=False, unique=True),
|
|
sa.Column(
|
|
"flight_id",
|
|
sa.dialects.postgresql.UUID(as_uuid=True),
|
|
sa.ForeignKey("flights.id"),
|
|
nullable=False,
|
|
),
|
|
sa.Column("content_hash", sa.Text(), nullable=False),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.text("now()"),
|
|
),
|
|
sa.Column("payload", sa.dialects.postgresql.JSONB(), nullable=False),
|
|
)
|
|
|
|
# engine_cache_entries ----------------------------------------------------
|
|
op.create_table(
|
|
"engine_cache_entries",
|
|
sa.Column("id", sa.BigInteger(), primary_key=True, autoincrement=True),
|
|
sa.Column("engine_path", sa.Text(), nullable=False),
|
|
sa.Column("sm_arch", sa.Text(), nullable=False),
|
|
sa.Column("jetpack_version", sa.Text(), nullable=False),
|
|
sa.Column("tensorrt_version", sa.Text(), nullable=False),
|
|
sa.Column("precision", sa.Text(), nullable=False),
|
|
sa.Column("content_hash", sa.Text(), nullable=False, unique=True),
|
|
sa.Column("int8_calibration_path", sa.Text(), nullable=True),
|
|
sa.Column(
|
|
"created_at",
|
|
sa.DateTime(timezone=True),
|
|
nullable=False,
|
|
server_default=sa.text("now()"),
|
|
),
|
|
)
|
|
|
|
|
|
def downgrade() -> None:
|
|
op.drop_table("engine_cache_entries")
|
|
op.drop_table("manifests")
|
|
op.drop_index("ix_tiles_created_at", table_name="tiles")
|
|
op.drop_index("ix_tiles_flight_id", table_name="tiles")
|
|
op.drop_index("ix_tiles_voting_status_onboard", table_name="tiles")
|
|
op.drop_index("ix_tiles_lat_lon", table_name="tiles")
|
|
op.drop_index("ix_tiles_zxy", table_name="tiles")
|
|
op.drop_table("tiles")
|
|
op.drop_table("sector_classifications")
|
|
op.drop_table("flights")
|