fix: post-audit — runtime bugs, functional gaps, docs, hardening

Phase A — Runtime bugs:
  - SSE: add push_event() method to SSEEventStreamer (was missing, masked by mocks)
  - MAVLink: satellites_visible=10 (was 0, triggers ArduPilot failsafe)
  - MAVLink: horiz_accuracy=sqrt(P[0,0]+P[1,1]) per spec (was sqrt(avg))
  - MAVLink: MEDIUM confidence → fix_type=3 per solution.md (was 2)

Phase B — Functional gaps:
  - handle_user_fix() injects operator GPS into ESKF with noise=500m
  - app.py uses create_vo_backend() factory (was hardcoded SequentialVO)
  - ESKF: Mahalanobis gating on satellite updates (rejects outliers >5σ)
  - ESKF: public accessors (position, quaternion, covariance, last_timestamp)
  - Processor: no more private ESKF field access

Phase C — Documentation:
  - README: correct API endpoints, CLI command, 40+ env vars documented
  - Dockerfile: ENV prefixes match pydantic-settings (DB_, SATELLITE_, MAVLINK_)
  - tech_stack.md marked ARCHIVED (contradicts solution.md)

Phase D — Hardening:
  - JWT auth middleware (AUTH_ENABLED=false default, verify_token on /flights)
  - TLS config env vars (AUTH_SSL_CERTFILE, AUTH_SSL_KEYFILE)
  - SHA-256 tile manifest verification in SatelliteDataManager
  - AuthConfig, ESKFSettings, MAVLinkConfig, SatelliteConfig in config.py

Also: conftest.py shared fixtures, download_tiles.py, convert_to_trt.py scripts,
config wiring into app.py lifespan, config-driven ESKF, calculate_precise_angle fix.

Tests: 196 passed / 8 skipped. Ruff clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Yuzviak
2026-04-02 18:27:35 +03:00
parent d0009f012b
commit 78dcf7b4e7
22 changed files with 756 additions and 64 deletions
+3 -2
View File
@@ -64,7 +64,7 @@ def _confidence_to_fix_type(confidence: ConfidenceTier) -> int:
"""Map ESKF confidence tier to GPS_INPUT fix_type (MAV-02)."""
return {
ConfidenceTier.HIGH: 3, # 3D fix
ConfidenceTier.MEDIUM: 2, # 2D fix
ConfidenceTier.MEDIUM: 3, # 3D fix (VO tracking valid per solution.md)
ConfidenceTier.LOW: 0,
ConfidenceTier.FAILED: 0,
}.get(confidence, 0)
@@ -95,7 +95,7 @@ def _eskf_to_gps_input(
# Accuracy from covariance (position block = rows 0-2, cols 0-2)
cov_pos = state.covariance[:3, :3]
sigma_h = math.sqrt(max(0.0, (cov_pos[0, 0] + cov_pos[1, 1]) / 2.0))
sigma_h = math.sqrt(max(0.0, cov_pos[0, 0] + cov_pos[1, 1]))
sigma_v = math.sqrt(max(0.0, cov_pos[2, 2]))
speed_sigma = math.sqrt(max(0.0, (state.covariance[3, 3] + state.covariance[4, 4]) / 2.0))
@@ -124,6 +124,7 @@ def _eskf_to_gps_input(
speed_accuracy=round(speed_sigma, 2),
horiz_accuracy=round(sigma_h, 2),
vert_accuracy=round(sigma_v, 2),
satellites_visible=10,
)