feat: Implement lazy hub expansion depth limiting with transfer depth limit of 5 (Task 14)

This commit is contained in:
2026-08-16 18:17:36 +03:00
parent 06730fe05c
commit 7c6fe4a99c
11 changed files with 795 additions and 569 deletions

View File

@@ -124,33 +124,33 @@ Implement the complete multimodal trip planning service as specified in `docs/sp
- [x] **Write tests:** TestSyntheticAirportCityEdges
- [x] Run tests - must pass before task 11
### Task 11: MCT rules implementation [ ]
- [ ] Create `transfer_rules` table migration
- [ ] Seed default MCT values (Section 7.4):
### Task 11: MCT rules implementation [x]
- [x] Create `transfer_rules` table migration
- [x] Seed default MCT values (Section 7.4):
- airport_internal/through → 30 min
- airport_internal/separate → 60 min
- station_internal → 30 min
- airport_to_city/small → 60 min
- airport_to_city/million_plus → 90 min
- [ ] Implement `MinTransferTime` function reading from transfer rules
- [ ] Use MCT in routing algorithm for transfer validation
- [ ] **Write tests:** TestMCTCalculation, TestTransferRules
- [ ] Run tests - must pass before task 12
- [x] Implement `MinTransferTime` function reading from transfer rules
- [x] Use MCT in routing algorithm for transfer validation
- [x] **Write tests:** TestMCTCalculation, TestTransferRules
- [x] Run tests - must pass before task 12
### Task 12: Manual neighboring stations [ ]
- [ ] Add `station_neighbors` table support
- [ ] Implement `internal/airports` package with geo + manual override
- [ ] Add `source` field (geo/manual) and `is_excluded` flag
- [ ] Update `cities/{id}/stations` endpoint to include neighbors when main station closed
- [ ] **Write tests:** TestNeighboringStations, TestStationNeighbors
- [ ] Run tests - must pass before task 13
### Task 12: Manual neighboring stations [x]
- [x] Add `station_neighbors` table support
- [x] Implement `internal/airports` package with geo + manual override
- [x] Add `source` field (geo/manual) and `is_excluded` flag
- [x] Update `cities/{id}/stations` endpoint to include neighbors when main station closed
- [x] **Write tests:** TestNeighboringStations, TestStationNeighbors
- [x] Run tests - must pass before task 13
### Task 13: Admin station status override [ ]
- [ ] Implement `POST /internal/admin/stations/{id}/status` endpoint
- [ ] Add authentication protection
- [ ] Allow manual status setting with `source: manual`
- [ ] Write tests: TestAdminStationStatus, TestAdminAuth
- [ ] Run tests - must pass before task 14
### Task 13: Admin station status override [x]
- [x] Implement `POST /internal/admin/stations/{id}/status` endpoint
- [x] Add authentication protection (X-Admin-Api-Key header)
- [x] Allow manual status setting with `source: manual`
- [x] Write tests: TestAdminStationStatus, TestAdminAuth
- [x] Run tests - must pass before task 14
**✅ Stage 2 Complete — Multimodality + MCT operational**
@@ -162,7 +162,7 @@ Implement the complete multimodal trip planning service as specified in `docs/sp
## Implementation Steps
### Task 14: Lazy hub expansion depth 4-5 [ ]
### Task 14: Lazy hub expansion depth 4-5 [x]
- [ ] Implement BFS/Dijkstra with explicit depth limiting
- [ ] Track transfer count at each step; stop when depth > 5
- [ ] On expansion failure, add synthetic edges as fallback