#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[non_exhaustive]
pub struct SpecDefect {
pub id: &'static str,
pub field: &'static str,
pub specification_says: &'static str,
pub reality: &'static str,
pub consequence: &'static str,
pub upstream_issue: &'static str,
pub resolution: &'static str,
}
pub const SPEC_DEFECTS: &[SpecDefect] = &[
SpecDefect {
id: "OICP23-D001",
field: "ChargingFacility.Amperage",
specification_says: "Integer of at most two digits — 0 to 99 A",
reality: "A 350 kW CCS charger draws around 500 A, and liquid-cooled cables carry more. \
Even a 22 kW three-phase AC point is 32 A, which fits; anything DC does not.",
consequence: "A CPO cannot describe its DC fleet accurately. Publishing the true amperage \
risks rejection; publishing 99 misinforms every EMP's driver app about what \
the charging point can deliver.",
upstream_issue: "https://github.com/hubject/oicp/issues/153",
resolution: "Reported as OutOfRange, with a message naming this defect so the partner knows \
the specification is the problem. The value itself is preserved and sent.",
},
SpecDefect {
id: "OICP23-D002",
field: "ChargingFacility.Voltage",
specification_says: "Integer of at most three digits — 0 to 999 V",
reality: "An 800 V vehicle architecture charges at around 920 V, and the Megawatt Charging \
System runs at up to 1250 V. Both exceed the cap.",
consequence: "As above: the fastest charging points in a fleet are the ones that cannot be \
described.",
upstream_issue: "https://github.com/hubject/oicp/issues/153",
resolution: "Reported as OutOfRange, naming this defect. The value is preserved and sent.",
},
SpecDefect {
id: "OICP23-D003",
field: "ChargeDetailRecord.SignedMeteringValues[].SignedMeteringValue",
specification_says: "At most 3000 characters, and at most ten values per CDR",
reality: "A transparency-software blob from a high-power charging point that signs a reading \
every two minutes exceeds 3000 characters, and a long session produces more than \
ten readings.",
consequence: "The CPO must either truncate the signed data — which destroys the signature, \
and with it the driver's ability to verify the bill under German calibration \
law — or send a record Hubject may reject.",
upstream_issue: "https://github.com/hubject/oicp/issues/143",
resolution: "Reported as TooLong / TooManyItems, naming this defect. The signed value is \
never truncated or rewritten: a mangled signature is worse than a long one.",
},
SpecDefect {
id: "OICP23-D004",
field: "Plug",
specification_says: "A closed list of eighteen connector types, last extended before MCS",
reality: "The Megawatt Charging System is deployed at truck charging sites and has no value \
in the list.",
consequence: "A CPO with such a charging point has no conformant way to describe its \
connector.",
upstream_issue: "https://github.com/hubject/oicp/issues/152",
resolution: "Plug is an open enum: an unlisted connector is preserved verbatim in \
Plug::Custom and forwarded intact, so the value survives the round trip. \
Validate still reports it, because a peer that has not agreed on it will not \
understand it.",
},
];
impl SpecDefect {
#[must_use]
pub fn get(id: &str) -> Option<&'static Self> {
SPEC_DEFECTS.iter().find(|d| d.id == id)
}
#[must_use]
pub fn note(&self) -> String {
format!(
"this is a known defect in OICP 2.3 rather than a mistake in your data — see {} ({}); \
the value is preserved and sent, but Hubject validates against the specification",
self.id, self.upstream_issue
)
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn defect_ids_are_unique_and_well_formed() {
let mut seen = std::collections::HashSet::new();
for defect in SPEC_DEFECTS {
assert!(seen.insert(defect.id), "duplicate defect id {}", defect.id);
assert!(defect.id.starts_with("OICP23-D"), "{} is not a well-formed id", defect.id);
assert!(
defect.upstream_issue.starts_with("https://github.com/hubject/oicp/issues/"),
"{} does not cite a partner report",
defect.id
);
assert!(!defect.consequence.is_empty());
}
}
#[test]
fn the_note_names_the_defect_and_the_issue() {
let defect = SpecDefect::get("OICP23-D001").expect("registered");
let note = defect.note();
assert!(note.contains("OICP23-D001"));
assert!(note.contains("issues/153"));
assert!(note.contains("preserved and sent"));
}
#[test]
fn lookup_by_id_works() {
assert_eq!(SpecDefect::get("OICP23-D002").unwrap().field, "ChargingFacility.Voltage");
assert!(SpecDefect::get("OICP23-D999").is_none());
}
}