# Feature: Chunk Data Retrieval

## Name
Chunk Data Retrieval

## Description
Query operations for retrieving chunk data including frame lists, images, estimated bounds, and composite descriptors. These methods provide data to other components (F08, F09, F11) for matching and recovery operations. The feature handles data aggregation and transformation without modifying chunk state.

## Component APIs Implemented

### `get_chunk_frames(chunk_id: str) -> List[int]`
Retrieves ordered list of frame IDs in a chunk.
- Returns frames list from ChunkHandle
- Ordered by sequence (insertion order)

### `get_chunk_images(chunk_id: str) -> List[np.ndarray]`
Retrieves images for all frames in a chunk.
- Calls F05.get_image_by_sequence() for each frame
- Returns images in frame order

### `get_chunk_bounds(chunk_id: str) -> ChunkBounds`
Estimates GPS bounds of a chunk based on VO trajectory.
- Computes estimated center from relative poses
- Calculates radius from trajectory extent
- Returns confidence based on anchor status

### `get_chunk_composite_descriptor(chunk_id: str) -> np.ndarray`
Computes aggregate DINOv2 descriptor for semantic matching.
- Retrieves chunk images
- Calls F08.compute_chunk_descriptor() with aggregation strategy
- Returns 4096-dim or 8192-dim vector

## External Tools and Services
- **F05 Image Input Pipeline**: `get_image_by_sequence()`
- **F08 Global Place Recognition**: `compute_chunk_descriptor()`

## Internal Methods

### `_compute_trajectory_extent(chunk_id: str) -> Tuple[float, float]`
Calculates trajectory spread from VO poses for bounds estimation.

### `_estimate_center_from_poses(chunk_id: str) -> GPSPoint`
Estimates center GPS from accumulated relative poses and last known anchor.

### `_calculate_bounds_confidence(chunk_id: str) -> float`
Returns confidence (0.0-1.0) based on anchor status and trajectory length.

## Unit Tests

### Test: get_chunk_frames_returns_ordered_list
- Create chunk, add frames 10, 11, 12
- Assert get_chunk_frames() returns [10, 11, 12]

### Test: get_chunk_frames_empty_chunk
- Create chunk without adding frames
- Assert get_chunk_frames() returns [start_frame_id] only

### Test: get_chunk_frames_nonexistent_chunk
- Call get_chunk_frames("invalid_id")
- Assert returns empty list or raises exception

### Test: get_chunk_images_returns_correct_count
- Create chunk with 5 frames
- Mock F05.get_image_by_sequence()
- Assert get_chunk_images() returns 5 images

### Test: get_chunk_images_preserves_order
- Create chunk with frames [10, 11, 12]
- Assert images returned in same order as frames

### Test: get_chunk_bounds_unanchored
- Create unanchored chunk with 10 frames
- Assert get_chunk_bounds().confidence < 0.5
- Assert estimated_radius > 0

### Test: get_chunk_bounds_anchored
- Create chunk, mark as anchored
- Assert get_chunk_bounds().confidence > 0.7

### Test: get_chunk_composite_descriptor_shape
- Create chunk with 10 frames
- Mock F08.compute_chunk_descriptor()
- Assert descriptor has expected dimensions (4096 or 8192)

### Test: get_chunk_composite_descriptor_calls_f08
- Create chunk
- Call get_chunk_composite_descriptor()
- Assert F08.compute_chunk_descriptor() called with chunk images

## Integration Tests

### Test: chunk_descriptor_computation
1. Create chunk with 10 frames
2. get_chunk_images() → 10 images
3. get_chunk_composite_descriptor() → aggregated descriptor
4. Verify descriptor shape and non-zero values

### Test: chunk_bounds_accuracy
1. Create chunk with known anchor
2. Add 10 frames with VO results
3. get_chunk_bounds() → verify center near anchor
4. Verify radius reasonable for trajectory length

