mirror of
https://github.com/azaion/satellite-provider.git
synced 2026-06-21 15:11:14 +00:00
c646aa93e2
Foundation half of original AZ-503 (split during /autodev step 10 batch 2
on user choice; deferred work moved to AZ-505 with a Blocks link).
Adds deterministic tile identity (UUIDv5 over (z, x, y, source, flight_id))
shared cross-repo with gps-denied-onboard via the pinned TileNamespace
5b8d0c2e-7f1a-4d3b-9c5e-1f3a8e7d2b6c, switches the tiles UPSERT key from
floats to integers with per-flight separation, plumbs FlightId through
UavTileMetadata + handler, and writes UAV evidence to per-flight
on-disk directories so two flights at the same (z, x, y) coexist.
- Common: pure-C# RFC 9562 Uuidv5 (no third-party dep) + FlightId DTO
field; 10 Python-reference unit vectors verify byte parity.
- DataAccess: migration 014 adds flight_id (uuid NULL), location_hash
(uuid NOT NULL, backfilled via session-scoped pg_temp.uuidv5),
content_sha256 (bytea NULL), legacy_id (uuid NULL = preserves
pre-AZ-503 random id one cycle); drops idx_tiles_unique_location_source
(AZ-484) and adds idx_tiles_unique_identity keyed on
(tile_zoom, tile_x, tile_y, tile_size_meters, source,
COALESCE(flight_id, '00000000-...'::uuid)) + idx_tiles_location_hash.
- TileRepository: ColumnList + UPSERT updated; id never updated on
conflict (preserves AC-2 idempotence). UpdateAsync extended.
- Services: TileService and UavTileUploadHandler compute deterministic
Id + LocationHash + ContentSha256 before insert; UAV file path
becomes ./tiles/uav/{flight_id or 'none'}/{z}/{x}/{y}.jpg.
- Tests: Uuidv5Tests (10 reference vectors), UavTileFilePathTests
(per-flight + anonymous paths), UavTileUploadHandlerTests (AC-2,
AC-3, AC-7, AC-11 unit-level), UavUploadTests (AC-3 + AC-4
integration: multi-flight DB coexistence with shared location_hash
+ distinct file_path; float-different lat/lon collapse to 1 row),
MigrationTests (column shape, idx_tiles_unique_identity supersedes
AZ-484 index, deterministic backfill).
- IntegrationTests project references Common to reuse Uuidv5 in raw
SQL seeds.
- AZ-488 MultiSourceCoexistence seed fixed to populate location_hash
(otherwise migration 014's NOT NULL constraint fails).
ACs covered: AC-1, AC-2, AC-3, AC-4, AC-7, AC-8, AC-11.
ACs deferred to AZ-505: AC-5, AC-6, AC-9, AC-10, AC-12.
Co-authored-by: Cursor <cursoragent@cursor.com>
62 lines
2.5 KiB
C#
62 lines
2.5 KiB
C#
using FluentAssertions;
|
|
using SatelliteProvider.Common.Configs;
|
|
using SatelliteProvider.Services.TileDownloader;
|
|
|
|
namespace SatelliteProvider.Tests;
|
|
|
|
public class UavTileFilePathTests
|
|
{
|
|
[Theory]
|
|
[InlineData("./tiles", 18, 76800, 50331)]
|
|
[InlineData("/var/lib/sat/tiles", 16, 12345, 67890)]
|
|
public void BuildUavTileFilePath_AnonymousFlight_UsesNoneSegment(string root, int zoom, int x, int y)
|
|
{
|
|
// Arrange
|
|
var storage = new StorageConfig { TilesDirectory = root };
|
|
|
|
// Act
|
|
var path = UavTileUploadHandler.BuildUavTileFilePath(storage, zoom, x, y);
|
|
|
|
// Assert
|
|
var expected = Path.Combine(root, "uav", "none", zoom.ToString(), x.ToString(), y + ".jpg");
|
|
path.Should().Be(expected,
|
|
"AZ-503: flight-anonymous UAV paths use the literal `none` segment so they are visually distinct from real flight directories during ops triage");
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("./tiles", 18, 76800, 50331, "11111111-2222-3333-4444-555555555555")]
|
|
[InlineData("/var/lib/sat/tiles", 16, 12345, 67890, "aaaaaaaa-bbbb-cccc-dddd-eeeeeeeeeeee")]
|
|
public void BuildUavTileFilePath_PerFlight_UsesFlightIdDirectory(string root, int zoom, int x, int y, string flightIdString)
|
|
{
|
|
// Arrange
|
|
var storage = new StorageConfig { TilesDirectory = root };
|
|
var flightId = Guid.Parse(flightIdString);
|
|
|
|
// Act
|
|
var path = UavTileUploadHandler.BuildUavTileFilePath(storage, zoom, x, y, flightId);
|
|
|
|
// Assert
|
|
var expected = Path.Combine(root, "uav", flightIdString, zoom.ToString(), x.ToString(), y + ".jpg");
|
|
path.Should().Be(expected,
|
|
"AZ-503 AC-11: UAV file paths follow `./tiles/uav/{flight_id}/{zoom}/{x}/{y}.jpg` so per-flight evidence is structurally isolated on disk");
|
|
}
|
|
|
|
[Fact]
|
|
public void BuildUavTileFilePath_DifferentFlights_ProduceDifferentPaths()
|
|
{
|
|
// Arrange
|
|
var storage = new StorageConfig { TilesDirectory = "./tiles" };
|
|
var f1 = Guid.Parse("11111111-1111-1111-1111-111111111111");
|
|
var f2 = Guid.Parse("22222222-2222-2222-2222-222222222222");
|
|
|
|
// Act
|
|
var p1 = UavTileUploadHandler.BuildUavTileFilePath(storage, 18, 100, 200, f1);
|
|
var p2 = UavTileUploadHandler.BuildUavTileFilePath(storage, 18, 100, 200, f2);
|
|
|
|
// Assert
|
|
p1.Should().NotBe(p2, "AZ-503 AC-11: two flights uploading the same (z, x, y) cell must land at distinct paths");
|
|
p1.Should().Contain(f1.ToString());
|
|
p2.Should().Contain(f2.ToString());
|
|
}
|
|
}
|