fix(skm): accept floating-point population (JSON Struct inputs)
Some checks failed
CI / Linux x86_64 (Forgejo) (push) Has been cancelled

JSON inputs arriving via google.protobuf.Struct (the gRPC submit
path, HubClient.submit jsonInputs) are always floating-point, so a
u64 population field rejected `180000.0` with an INVALID_ARGUMENT.
Make population f64 — a count is exact in f64 up to 2^53, the SKM
product is f64 anyway, and Display still renders whole numbers
without a decimal. Unblocks live skm scoring from the Recl∆Im app.

Signed-off-by: flemming-it <sf@flemming.it>
This commit is contained in:
flemming-it 2026-06-19 02:38:27 +02:00
parent e518a2cc2b
commit 80f6620d42
2 changed files with 7 additions and 2 deletions

Binary file not shown.

View file

@ -22,7 +22,12 @@ struct InputDuties {
#[derive(Debug, Deserialize)] #[derive(Debug, Deserialize)]
struct InputDuty { struct InputDuty {
population: u64, // f64, not u64: JSON inputs arriving via google.protobuf.Struct
// (HubClient.submit jsonInputs) are always floating-point, so a
// u64 field rejects `180000.0`. A population is a count, but f64
// represents it exactly up to 2^53 and the SKM product is f64
// anyway. Display still renders whole numbers without a decimal.
population: f64,
frequency: f32, frequency: f32,
tariff_eur_per_hour: f32, tariff_eur_per_hour: f32,
time_hours_per_case: f32, time_hours_per_case: f32,
@ -59,7 +64,7 @@ pub fn invoke(_ctx: Context, inputs: Inputs) -> Result<Outputs, ModuleError> {
if d.frequency < 0.0 || d.tariff_eur_per_hour < 0.0 || d.time_hours_per_case < 0.0 { if d.frequency < 0.0 || d.tariff_eur_per_hour < 0.0 || d.time_hours_per_case < 0.0 {
return Err(ModuleError::invalid_input("negative P/F/T/h not allowed")); return Err(ModuleError::invalid_input("negative P/F/T/h not allowed"));
} }
let value = d.population as f64 let value = d.population
* d.frequency as f64 * d.frequency as f64
* d.tariff_eur_per_hour as f64 * d.tariff_eur_per_hour as f64
* d.time_hours_per_case as f64; * d.time_hours_per_case as f64;