eventhub/README_CVU_FINAL_MERGE_PATC...

31 lines
1.4 KiB
Markdown

# CVU final merge safeguard
## Problem
After cross-representation CVU reconciliation the supplied mixed execution still contained 12 effective vehicle-usage intervals instead of 11. The remaining pair represented the same usage period:
- file-session CVU: `2026-03-31T00:00:00Z` to `2026-04-02T12:27:15Z`, registration present, VIN missing;
- database CVU: `2026-04-01T00:00:00Z` to `2026-04-02T12:27:15Z`, same registration, VIN present.
The final `DriverVehicleUsageMergeModule` required exact `vehicleKey` equality, so `null` and the database VIN prevented coalescing even though registration and overlap proved compatible identity.
## Fix
`DriverVehicleUsageMergeModule` now:
- accepts complementary vehicle identity when registration or VIN matches and the other field is missing;
- merges overlapping as well as immediately adjacent effective intervals;
- rejects explicit registration/VIN conflicts;
- rejects materially conflicting odometers at identical boundaries;
- selects the richer interval as identity primary;
- preserves the earliest start, latest end, correct boundary odometers, and complete source provenance;
- reports `coalescedIntervalCount` metadata.
This is a generic final-interval safeguard and does not depend on tachograph representation enums.
## Expected supplied-data result
- vehicle usage intervals: `12 -> 11`
- VU card-absent intervals: remains `10`
- support geo events: remains `141`