components assesment #2

add 2.15_components_assesment.md step
This commit is contained in:
Oleksandr Bezdieniezhnykh
2025-11-29 12:04:51 +02:00
parent 2037870f67
commit ef75cc5877
20 changed files with 557 additions and 1205 deletions
@@ -93,6 +93,19 @@ class IFlightDatabase(ABC):
@abstractmethod
def get_image_metadata(self, flight_id: str, frame_id: int) -> Optional[Dict]:
pass
# Chunk State Operations
@abstractmethod
def save_chunk_state(self, flight_id: str, chunk: ChunkHandle) -> bool:
pass
@abstractmethod
def load_chunk_states(self, flight_id: str) -> List[ChunkHandle]:
pass
@abstractmethod
def delete_chunk_state(self, flight_id: str, chunk_id: str) -> bool:
pass
```
## Component Description
@@ -342,7 +355,7 @@ waypoint_id: str
**Called By**:
- F02 Flight Processor
- F13 Result Manager
- F14 Result Manager
**Input**:
```python
@@ -475,7 +488,7 @@ Optional[FlightState]
**Description**: Saves frame processing result.
**Called By**:
- F13 Result Manager
- F14 Result Manager
**Input**:
```python
@@ -505,7 +518,7 @@ bool: True if saved
**Description**: Gets all frame results for flight.
**Called By**:
- F13 Result Manager
- F14 Result Manager
**Test Cases**:
1. Get results → returns all frames
@@ -646,6 +659,100 @@ Optional[Dict]: Metadata dictionary or None
---
## Chunk State Operations
### `save_chunk_state(flight_id: str, chunk: ChunkHandle) -> bool`
**Description**: Saves chunk state to database for crash recovery.
**Called By**:
- F12 Route Chunk Manager (after chunk state changes)
**Input**:
```python
flight_id: str
chunk: ChunkHandle:
chunk_id: str
start_frame_id: int
end_frame_id: Optional[int]
frames: List[int]
is_active: bool
has_anchor: bool
anchor_frame_id: Optional[int]
anchor_gps: Optional[GPSPoint]
matching_status: str
```
**Output**:
```python
bool: True if saved successfully
```
**Database Operations**:
```sql
INSERT INTO chunks (chunk_id, flight_id, start_frame_id, end_frame_id, frames,
is_active, has_anchor, anchor_frame_id, anchor_lat, anchor_lon,
matching_status, updated_at)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW())
ON CONFLICT (chunk_id) UPDATE SET ...
```
**Test Cases**:
1. **Save new chunk**: Persisted successfully
2. **Update existing chunk**: State updated
3. **Multiple chunks**: All persisted correctly
---
### `load_chunk_states(flight_id: str) -> List[ChunkHandle]`
**Description**: Loads all chunk states for a flight (for crash recovery).
**Called By**:
- F12 Route Chunk Manager (on flight resume)
- System startup (recovery)
**Input**:
```python
flight_id: str
```
**Output**:
```python
List[ChunkHandle]: All chunks for the flight
```
**Test Cases**:
1. **Load chunks**: Returns all chunks
2. **No chunks**: Returns empty list
3. **Crash recovery**: Chunks restored correctly
---
### `delete_chunk_state(flight_id: str, chunk_id: str) -> bool`
**Description**: Deletes chunk state from database.
**Called By**:
- F12 Route Chunk Manager (after chunk merged/deleted)
**Input**:
```python
flight_id: str
chunk_id: str
```
**Output**:
```python
bool: True if deleted
```
**Test Cases**:
1. **Delete chunk**: Removed from database
2. **Non-existent chunk**: Returns False
---
## Integration Tests
### Test 1: Complete Flight Lifecycle
@@ -809,6 +916,27 @@ CREATE TABLE flight_images (
FOREIGN KEY (flight_id) REFERENCES flights(id) ON DELETE CASCADE,
INDEX idx_images_flight (flight_id, frame_id)
);
-- Chunks table
CREATE TABLE chunks (
chunk_id VARCHAR(36) PRIMARY KEY,
flight_id VARCHAR(36) NOT NULL,
start_frame_id INT NOT NULL,
end_frame_id INT,
frames JSONB NOT NULL,
is_active BOOLEAN NOT NULL DEFAULT TRUE,
has_anchor BOOLEAN NOT NULL DEFAULT FALSE,
anchor_frame_id INT,
anchor_lat DECIMAL(10, 7),
anchor_lon DECIMAL(11, 7),
matching_status VARCHAR(50) NOT NULL DEFAULT 'unanchored',
created_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
updated_at TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (flight_id) REFERENCES flights(id) ON DELETE CASCADE,
INDEX idx_chunks_flight (flight_id),
INDEX idx_chunks_active (flight_id, is_active),
INDEX idx_chunks_matching (flight_id, matching_status)
);
```
---