mirror of
https://github.com/azaion/gps-denied-onboard.git
synced 2026-06-21 08:51:12 +00:00
[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>
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
"""Alembic env.
|
||||
|
||||
Bootstrap (AZ-263) ships the minimal `env.py` so `alembic check` resolves
|
||||
`0001_initial.sql` as head. Concrete metadata wiring is added by AZ-304.
|
||||
"""
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
|
||||
from alembic import context
|
||||
from sqlalchemy import engine_from_config, pool
|
||||
|
||||
config = context.config
|
||||
|
||||
if "sqlalchemy.url" not in config.get_section(config.config_ini_section, {}):
|
||||
db_url = os.environ.get("DB_URL")
|
||||
if db_url:
|
||||
config.set_main_option(
|
||||
"sqlalchemy.url", db_url.replace("postgresql://", "postgresql+psycopg://", 1)
|
||||
)
|
||||
|
||||
|
||||
def run_migrations_offline() -> None:
|
||||
url = config.get_main_option("sqlalchemy.url")
|
||||
context.configure(url=url, literal_binds=True, dialect_opts={"paramstyle": "named"})
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
def run_migrations_online() -> None:
|
||||
connectable = engine_from_config(
|
||||
config.get_section(config.config_ini_section, {}),
|
||||
prefix="sqlalchemy.",
|
||||
poolclass=pool.NullPool,
|
||||
)
|
||||
with connectable.connect() as connection:
|
||||
context.configure(connection=connection)
|
||||
with context.begin_transaction():
|
||||
context.run_migrations()
|
||||
|
||||
|
||||
if context.is_offline_mode():
|
||||
run_migrations_offline()
|
||||
else:
|
||||
run_migrations_online()
|
||||
@@ -0,0 +1,26 @@
|
||||
"""${message}
|
||||
|
||||
Revision ID: ${up_revision}
|
||||
Revises: ${down_revision | comma,n}
|
||||
Create Date: ${create_date}
|
||||
"""
|
||||
from __future__ import annotations
|
||||
|
||||
from typing import Sequence, Union
|
||||
|
||||
from alembic import op
|
||||
import sqlalchemy as sa
|
||||
${imports if imports else ""}
|
||||
|
||||
revision: str = ${repr(up_revision)}
|
||||
down_revision: Union[str, None] = ${repr(down_revision)}
|
||||
branch_labels: Union[str, Sequence[str], None] = ${repr(branch_labels)}
|
||||
depends_on: Union[str, Sequence[str], None] = ${repr(depends_on)}
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
${upgrades if upgrades else "pass"}
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
${downgrades if downgrades else "pass"}
|
||||
@@ -0,0 +1,167 @@
|
||||
"""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")
|
||||
Reference in New Issue
Block a user