[AZ-351][AZ-352][AZ-363] Refactor 03 batch 1: critical defensive fixes
ci/woodpecker/push/01-test Pipeline was successful
ci/woodpecker/push/02-build-push Pipeline was successful

AZ-351: Resolve ILogger<DatabaseMigrator> directly from DI in
Program.cs instead of casting ILogger<Program> (which always
returned null). Migrator now logs through Serilog at startup.

AZ-352: Drop empty catch in
RouteProcessingService.ExtractTileCoordinatesFromFilename. Convert
the method from private static to internal instance so it can use
the existing _logger (per coderule: side-effecting code must not be
static). Add typed null-guard via ArgumentNullException.ThrowIfNull
so unexpected exceptions propagate. Adds InternalsVisibleTo on the
RouteManagement csproj for SatelliteProvider.Tests, plus 4 unit
tests in RouteProcessingServiceTests.cs covering AC-1 (valid /
malformed / non-numeric) and AC-2 (null path propagation).

AZ-363: Delete _totalEnqueued / _totalDequeued fields and the two
non-atomic ++ writes in RegionRequestQueue. Fields were write-only
dead code and a thread-safety hazard.

Tests: 44/44 unit + 5/5 smoke (scripts/run-tests.sh --smoke).
Code review verdict: PASS, 0 findings, 0 auto-fix attempts.
Batch report: _docs/03_implementation/batch_07_report.md.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Oleksandr Bezdieniezhnykh
2026-05-10 23:34:17 +03:00
parent ff030a9521
commit de4d4fa760
11 changed files with 201 additions and 26 deletions
@@ -0,0 +1,78 @@
# Batch Report
**Batch**: 7 (refactor 03-code-quality-refactoring · Phase 1 — critical defensive fixes, part 1/2)
**Tasks**: AZ-351, AZ-352, AZ-363
**Date**: 2026-05-10
**Total Story Points**: 5 (2 + 2 + 1)
## Task Results
| Task | Status | Files Modified | Tests | AC Coverage | Issues |
|------|--------|---------------|-------|-------------|--------|
| AZ-351 Fix null logger to DatabaseMigrator | Done | 1 | 44/44 unit + 5/5 smoke | 2/2 ACs | None |
| AZ-352 Replace empty catch in ExtractTileCoordinatesFromFilename | Done | 3 (svc + csproj + test) | 4 new + 44/44 unit + 5/5 smoke | 3/3 ACs | None |
| AZ-363 Delete write-only counters in RegionRequestQueue | Done | 1 | 44/44 unit + 5/5 smoke | 2/2 ACs | None |
## Files Changed
- `SatelliteProvider.Api/Program.cs` (AZ-351)
- `SatelliteProvider.Services.RegionProcessing/RegionRequestQueue.cs` (AZ-363)
- `SatelliteProvider.Services.RouteManagement/RouteProcessingService.cs` (AZ-352)
- `SatelliteProvider.Services.RouteManagement/SatelliteProvider.Services.RouteManagement.csproj` (AZ-352 — `InternalsVisibleTo` for test access)
- `SatelliteProvider.Tests/RouteProcessingServiceTests.cs` (AZ-352 — new test file, 4 tests)
## AC Test Coverage: All covered
| Task | AC | Test |
|------|----|------|
| AZ-351 | AC-1 (migrator receives real logger) | covered by smoke startup — any smoke test exercises `app.Services.GetRequiredService<ILogger<DatabaseMigrator>>()` |
| AZ-351 | AC-2 (tests stay green) | `scripts/run-tests.sh --smoke` passes (44 unit + 5 smoke) |
| AZ-352 | AC-1 (malformed filename → warning + sentinel) | `ExtractTileCoordinatesFromFilename_MalformedName_LogsWarningAndReturnsSentinel_AC1`, `..._TilePrefixWithNonNumericCoords_..._AC1`, `..._ValidName_ReturnsParsedCoordinates_AC1` |
| AZ-352 | AC-2 (unexpected exception propagates) | `ExtractTileCoordinatesFromFilename_NullPath_PropagatesArgumentNullException_AC2` |
| AZ-352 | AC-3 (tests stay green) | smoke green |
| AZ-363 | AC-1 (fields removed) | source verifies removal; `RegionRequestQueueTests` (4 tests) confirm queue behavior unchanged |
| AZ-363 | AC-2 (tests stay green) | smoke green |
## Code Review Verdict: PASS
### Phase 2 (Spec Compliance)
- All ACs satisfied with executed tests.
- No scope creep: each task touched only files declared in the change spec.
### Phase 3 (Code Quality)
- AZ-352 conversion `private static``internal` instance method aligns with `coderule.mdc` (side-effecting code must not be `static`).
- No new bare/empty catch blocks introduced.
- `ArgumentNullException.ThrowIfNull` used (modern .NET pattern).
### Phase 4 (Security)
- No new external input handling. Filename in log entry is local filesystem, not user-controlled secrets.
### Phase 5 (Performance)
- AZ-363 removes two non-atomic `++` ops; marginal positive (eliminates contended writes).
### Phase 6 (Cross-Task Consistency)
- Three tasks touch three disjoint components (Api, RouteManagement, RegionProcessing). Zero interaction.
### Phase 7 (Architecture Compliance)
- All edits stay within the owning component's `Owns` glob.
- `InternalsVisibleTo("SatelliteProvider.Tests")` added to RouteManagement — test-discovery hatch, not a compile-time consumer relation; does not violate Layer 3 sibling rule.
- Module-layout note "Internal: (none)" for RouteManagement is now slightly out-of-date (one method became `internal`). Deferred to AZ-315 docs sync (already In Progress).
## Auto-Fix Attempts: 0
## Stuck Agents: None
## Tracker Status (post-batch)
| Task | Pre-batch | Post-batch (after commit) |
|------|-----------|---------------------------|
| AZ-351 | In Progress | → In Testing |
| AZ-352 | In Progress | → In Testing |
| AZ-363 | In Progress | → In Testing |
## Next Batch
**Batch 8** (Phase 1 part 2): AZ-356 (501 stubs), AZ-354 (strict CORS), AZ-353 (sanitize 5xx via IExceptionHandler) — 7 story points, 3 tasks, all WebApi component.
## Commit
`[AZ-351][AZ-352][AZ-363] Refactor 03 batch 1: critical defensive fixes` (commit hash recorded post-commit).