# Patch: Vehicle Usage Interval Reconciliation This patch extends the already introduced runtime event-mixing architecture with an interval-level reconciliation step for tachograph vehicle-usage evidence. ## New module Added runtime module: ```text vehicle-usage-reconciliation ``` It runs after: ```text event-to-vehicle-usage-intervals ``` and before: ```text vehicle-usage-merge ``` ## Main behavior The module intentionally does not mix `CARD_VEHICLES_USED` and `IW_CYCLE` at event level. Instead, it reconciles the completed vehicle-usage intervals. Processing phases: 1. Split raw vehicle-usage intervals by source type: - `CARD_VEHICLES_USED` - `IW_CYCLE` - `OTHER` 2. Normalize `CARD_VEHICLES_USED` technical midnight splits. 3. Reconcile normalized `CARD_VEHICLES_USED` intervals with `IW_CYCLE` intervals. 4. Produce effective vehicle-usage intervals for downstream processing. ## CVU technical midnight split The technical midnight split is handled only for `CARD_VEHICLES_USED` / CVU intervals, not for `IW_CYCLE`. Pattern: ```text CARD_VEHICLES_USED interval A ends at 23:59:59 CARD_VEHICLES_USED interval B starts at 00:00:00 same driver same registration / compatible vehicle max gap: 1 second ``` Result: ```text A + B => one normalized CARD_VEHICLES_USED interval ``` ## CVU vs IW reconciliation After CVU normalization: ```text normalized CARD_VEHICLES_USED interval vs IW_CYCLE interval ``` Rule: ```text IW_CYCLE is primary for effective vehicle-usage identity. CARD_VEHICLES_USED is fallback or corroborating evidence. ``` Matching currently supports exact or compatible start/end boundaries with a 60-second tolerance. ## New classes ```text src/main/java/at/procon/eventhub/processing/eventprocessing/module/VehicleUsageReconciliationModule.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageIntervalDescriptor.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageIntervalDescriptorFactory.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageIntervalRole.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageIntervalSourceType.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageReconciliationDecisionDto.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageReconciliationResult.java src/main/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageReconciliationService.java src/test/java/at/procon/eventhub/processing/eventprocessing/vehicleusage/RuntimeVehicleUsageReconciliationServiceTest.java ``` ## Modified existing files ```text src/main/java/at/procon/eventhub/processing/eventprocessing/module/DriverWorkingTimeModuleKeys.java src/main/java/at/procon/eventhub/processing/eventprocessing/module/DriverVehicleUsageMergeModule.java src/main/java/at/procon/eventhub/processing/eventprocessing/plan/DriverWorkingTimeRuntimeProcessingPlan.java ``` ## Notes `vehicle-usage-merge` now consumes the effective intervals from `vehicle-usage-reconciliation` when that module has run. If the reconciliation module is omitted from a custom module list, `vehicle-usage-merge` falls back to raw `event-to-vehicle-usage-intervals` output. Tests were added for: - CVU technical midnight split coalescing - CVU + IW reconciliation with IW as primary - CVU fallback when IW is missing - IW primary when CVU is missing