eventhub/README_CVU_PATCH.md

2.6 KiB

Patch: Cross-representation CVU interval reconciliation

Problem

A request containing both TACHOGRAPH_FILE_SESSION and TACHOGRAPH_DB produced 22 final vehicle-usage intervals instead of 11.

The old sequence globally sorted all CARD_VEHICLES_USED intervals before technical-midnight normalization. A complete database interval could therefore appear between two file-session fragments:

file fragment ending 23:59:59
complete database interval
file continuation starting 00:00:00

The database interval interrupted adjacency, so the file fragments were not coalesced. The remaining file fragment and complete database interval both survived.

Fix

The reconciliation order is now:

  1. Classify reconstructed intervals by source type and physical representation.
  2. Normalize CVU technical-midnight fragments independently for DATABASE, FILE_SESSION, and UNKNOWN representations.
  3. Reconcile equivalent database and file-session CVU intervals.
    • exact/compatible boundaries use the existing 60-second tolerance;
    • driver and vehicle identity must be compatible;
    • non-null odometer boundaries may differ by at most 1 km;
    • the database interval is retained as primary;
    • file-session source IDs are attached as provenance.
  4. Reconcile the representation-neutral effective CVU intervals with IW_CYCLE.
  5. Continue with the existing final vehicle-usage merge.

Diagnostics

RuntimeVehicleUsageReconciliationResult now exposes:

representationReconciledCardVehicleUsedIntervals

The module metadata includes:

representationReconciledCardVehicleUsedIntervalCount

A new decision rule identifies suppressed cross-representation duplicates:

tachograph.vehicle-usage.card-vehicles-used.cross-representation-equivalent

Regression coverage

Tests cover:

  • the production ordering where a DB interval interrupts two file fragments;
  • DB-primary fusion with file-session provenance;
  • preservation of intervals when odometer boundaries meaningfully conflict;
  • existing CVU midnight normalization and CVU/IW reconciliation behavior.

A Java 21 harness using all 11 periods from the supplied result set produced:

raw intervals:                         51
representation-normalized CVU:        22
representation-reconciled CVU:        11
final effective vehicle usage:        11
suppressed cross-representation CVU:  11

Maven was not available in the execution environment, so the complete project suite was not run. The changed main classes and regression test were compiled with Java 21 dependency stubs, and the interval-level harness executed successfully.