Files
gps-denied-onboard/src/gps_denied/schemas/rotation.py
T
Yuzviak f67c5f3cd0 refactor(01-01): convert hot-path schemas/*.py to hot_types re-export shims
- schemas/eskf.py: keep ConfidenceTier + ESKFConfig; re-export IMUSample
  and ESKFState from hot_types (define ConfidenceTier BEFORE the
  hot_types imports to avoid circular import — eskf_state.py imports
  ConfidenceTier from this module). Legacy alias IMUMeasurement = IMUSample.
- schemas/vo.py: re-export Features, Matches, RelativePose, Motion,
  VOEstimate from hot_types.vo_estimate.
- schemas/satellite.py: re-export TileCoords, TileBounds, SatelliteAnchor.
- schemas/metric.py: keep LiteSAMConfig; re-export AlignmentResult,
  ChunkAlignmentResult, Sim3Transform.
- schemas/rotation.py: keep HeadingHistory + RotationConfig; re-export
  RotationResult.

Auto-fixes (Rules 1 + 3) needed to keep the 216-test floor green:
- core/rotation.py: refactor try_rotation_steps to use
  dataclasses.replace instead of attribute assignment on RotationResult
  (Rule 1 — frozen dataclass forbids mutation; Pydantic silently allowed
  it). PATTERNS.md §6.1 already flagged Pose mutation but missed this site.
- hot_types/vo_estimate.py: add Optional `covariance: np.ndarray` field
  to RelativePose (Rule 3 — five test sites construct RelativePose with
  `covariance=np.eye(6)`; Pydantic v2 silently accepted the extra kwarg
  via default `extra="ignore"`. Declaring the field preserves the
  construction contract under the dataclass migration without editing
  tests).

Verification: pytest tests/ -q --ignore=tests/e2e → 216 passed, 8 skipped
(matches baseline). Accuracy bench (23 tests) passes.
2026-05-10 22:47:56 +03:00

38 lines
938 B
Python

"""Rotation schemas (Component F06).
Phase 1 shim — hot-path `RotationResult` lives in
`gps_denied.hot_types.rotation_result`. `HeadingHistory` (mutable
bookkeeping) and `RotationConfig` (config) stay here as Pydantic.
"""
from datetime import datetime
from typing import Optional
from pydantic import BaseModel
from gps_denied.hot_types.rotation_result import RotationResult # noqa: F401
class HeadingHistory(BaseModel):
"""Flight heading tracking history."""
flight_id: str
current_heading: Optional[float] = None
heading_history: list[float] = []
last_update: Optional[datetime] = None
sharp_turns: int = 0
class RotationConfig(BaseModel):
"""Configuration for rotation sweeps."""
step_angle: float = 30.0
sharp_turn_threshold: float = 45.0
confidence_threshold: float = 0.7
history_size: int = 10
__all__ = [
"HeadingHistory",
"RotationConfig",
"RotationResult",
]