Marked delivered 2 km from the address
Goal Spot each parcel marked delivered far from its address, or with no scan position, as soon as the carrier's file arrives.
"Parcel marked delivered, never received" recurs before the e-commerce mediator, and the seller owes a conforming delivery. The proof-of-delivery file holds the address's position and the scan's on one row. Nobody compares them: lumnik does.
- the distance measured at the door by the operator's script
- beyond 200 m: a decision
- with no scan position: another
tracking_no;recipient;address;address_lat;address_lon;scan_lat;scan_lon;scanned_at;status CL-90011;M. Bernard;14 rue Paul Bert, Lyon;45.75780;4.84320;45.75795;4.84305;2026-11-20 10:12;LIVRE CL-90012;Mme Faure;3 place Bellecour, Lyon;45.75780;4.83200;45.76210;4.83950;2026-11-20 11:40;LIVRE
manifests/scan-distance.kts
// Operator-provided: how far from the delivery address the driver's scan was taken, in metres (haversine, the Earth// as a sphere of 6,371,008.8 m). A point missing or out of range gives no distance, and distance_issue says why.@Suppress("UNCHECKED_CAST")val cells = bindings["cells"] as MutableMap<String, Any?>fun coord(name: String, limit: Double): Double? = (cells[name] as String?)?.trim()?.replace(',', '.')?.toDoubleOrNull()?.takeIf { kotlin.math.abs(it) <= limit }val lat1 = coord("address_lat", 90.0); val lon1 = coord("address_lon", 180.0)val lat2 = coord("scan_lat", 90.0); val lon2 = coord("scan_lon", 180.0)if (lat1 == null || lon1 == null || lat2 == null || lon2 == null) { cells["distance_m"] = null cells["distance_issue"] = if (lat2 == null || lon2 == null) "no scan position" else "no address position"} else { val r = 6_371_008.8 val dLat = Math.toRadians(lat2 - lat1); val dLon = Math.toRadians(lon2 - lon1) val a = Math.pow(Math.sin(dLat / 2), 2.0) + Math.cos(Math.toRadians(lat1)) * Math.cos(Math.toRadians(lat2)) * Math.pow(Math.sin(dLon / 2), 2.0) cells["distance_m"] = Math.round(2 * r * Math.asin(Math.sqrt(a))).toString() cells["distance_issue"] = null}manifests/10-pod.yaml
apiVersion: connectors.lumnik.io/v1kind: Connectormetadata: name: scenario-pod-a connector_type: csv-file scopes: [livraison-a]spec: transport: kind: sftp host: host.docker.internal port: 2230 user: transporteur path: /pod/pod-*.csv password_env: SCENARIO_POD_A_SFTP # The fingerprint the carrier's server presents, read out of band (ssh-keyscan | ssh-keygen -lf -). host_key_fingerprint: "SHA256:FINGERPRINT_READ_AT_REPLAY" parser: has_header: true delimiter: ";" encoding: UTF-8 after_process: none mapping: cell: - kotlin: script: hooks:scan-distance-a.kts # the operator's script: metres between the scan and the address - parse-number: { column: distance_m, integer: true }manifests/20-far-from-address.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata: name: scenario-pod-far-aspec: scope: livraison-a on: event: data.row.changed table: connector.t_scenario_pod_a when: - status=LIVRE - distance_m>200 # beyond what a building's entrance or a GPS error explains emit: type: decision.pod-far-a key: tracking_no message: "{tracking_no} for {recipient}, {address}: marked delivered {distance_m} m from the address — ask the carrier for its proof" fields: [scanned_at, scan_lat, scan_lon]manifests/30-no-scan-position.yaml
apiVersion: apps.lumnik.io/v1kind: Processmetadata: name: scenario-pod-noscan-aspec: scope: livraison-a on: event: data.row.changed table: connector.t_scenario_pod_a when: - status=LIVRE - distance_issue=no scan position # no position: no distance can raise it, so it is raised for that emit: type: decision.pod-noscan-a key: tracking_no message: "{tracking_no} for {recipient}, {address}: marked delivered with no scan position — the proof has no place"$ lm hook scripts
NAME SIZE SHA256
cfonb-amount-b.kts 784 3f94b73a8a923324f6750648e230e3d91026299ed636627a4562b14552d493ba
cfonb-amount-c.kts 784 3f94b73a8a923324f6750648e230e3d91026299ed636627a4562b14552d493ba
coordinates-c.kts 5076 cc87f4a8e8ccbb38f3306d4dce5a013dab984c36a8cd72afd72e8bd142504542
ean-check-b.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-check-c.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-check-d.kts 477 58c3d6b83a0df5c9ae779aada8604f6bd850db7c52ca258b5bc6dc45fd8ea23c
ean-draft-b.kts 476 c8692d84859f810de8903ded14a03a1ec4db93e1282aa88b4fb9f5e42b6586ea
ean-draft-c.kts 476 c8692d84859f810de8903ded14a03a1ec4db93e1282aa88b4fb9f5e42b6586ea
ean-draft-d.kts 526 90a58aae66c5feec5e52017e90d86b9ee93e46ce7d97dc0c1eb4b5faefb636a7
promised-date-b.kts 1407 44ceece5d17c40d337374d02f942aef41b092b6708ff7dbc48efc8b43aef1ac9
scan-distance-a.kts 1223 5d678bbeef4433366b672de42bd162c8a79944c9932ccd5fafa6828e8768a398
shipping-fee-c.kts 333 c1c59e5c7b81302d5a284c9c722ca8cacaca0fe859c8ae1c393cd1d54a1ad9ad
shipping-fee-p.kts 333 c1c59e5c7b81302d5a284c9c722ca8cacaca0fe859c8ae1c393cd1d54a1ad9ad
$ lm apply -f 10-pod.yaml
Applied connector "scenario-pod-a" — 1 endpoint
$ lm connector run scenario-pod-a
run scheduled: 4d39da22-913d-47df-b8e4-54c0c5200128
$ lm run get 4d39da22-913d-47df-b8e4-54c0c5200128 --wait-evaluated
ID CONNECTOR ENDPOINT STATUS IN OUT SKIPPED DEAD-LETTERS STARTED ENDED EVALUATED
4d39da22 scenario-pod-a default Completed 2 2 0 0 2026-11-21 23:38 2026-11-21 23:38 yes
• script hooks:scan-distance-a.kts sha256 5d678bbeef4433366b672de42bd162c8a79944c9932ccd5fafa6828e8768a398
$ lm process apply -f 20-far-from-address.yaml
Applied process "scenario-pod-far-a" → table connector.t_scenario_pod_a, emits decision.pod-far-a
$ lm process apply -f 30-no-scan-position.yaml
Applied process "scenario-pod-noscan-a" → table connector.t_scenario_pod_a, emits decision.pod-noscan-a- run
- IN 2 · OUT 2
- decisions
- 0: these rows came before the rules
evidence: replay.log, 00-check-distances.txt, 00-hook-scripts.txt, 01-far.json, 02-noscan.json, run-day1.txt, run-day2.txt · transform v1
tracking_no;recipient;address;address_lat;address_lon;scan_lat;scan_lon;scanned_at;status CL-90021;Mme Girard;8 rue de la République, Lyon;45.76270;4.83570;45.76281;4.83590;2026-11-21 09:05;LIVRE CL-90022;M. Chevalier;22 cours Lafayette, Lyon;45.76350;4.85230;45.77920;4.87110;2026-11-21 09:48;LIVRE CL-90023;Mme Roussel;5 quai Saint-Antoine, Lyon;45.76390;4.83010;45.76470;4.83110;2026-11-21 10:31;LIVRE CL-90024;M. Leclerc;40 avenue Berthelot, Lyon;45.74540;4.84280;;;2026-11-21 11:02;LIVRE
$ lm connector run scenario-pod-a
run scheduled: b62ef203-40b2-409c-80ff-1fdc245757b9
$ lm run get b62ef203-40b2-409c-80ff-1fdc245757b9 --wait-evaluated
ID CONNECTOR ENDPOINT STATUS IN OUT SKIPPED DEAD-LETTERS STARTED ENDED EVALUATED
b62ef203 scenario-pod-a default Completed 4 4 0 0 2026-11-21 23:38 2026-11-21 23:38 yes
• script hooks:scan-distance-a.kts sha256 5d678bbeef4433366b672de42bd162c8a79944c9932ccd5fafa6828e8768a398
$ lm inbox --process scenario-pod-far-a
ID WHEN PROCESS MESSAGE ENTITY_KEY
31773 just now scenario-pod-far-a CL-90022 for M. Chevalier, 22 cours Lafayette, Lyon: marked delivered 2275 m from the address — ask the carrier for its proof CL-90022
$ lm inbox --process scenario-pod-noscan-a
ID WHEN PROCESS MESSAGE ENTITY_KEY
31774 just now scenario-pod-noscan-a CL-90024 for M. Leclerc, 40 avenue Berthelot, Lyon: marked delivered with no scan position — the proof has no place CL-90024- run
- IN 4 · OUT 4
- CL-90021
- 20 m
- CL-90022
- 2275 m
- CL-90023
- 118 m
- CL-90024
- no scan position
- > 200 m
- CL-90022 for M. Chevalier, 22 cours Lafayette, Lyon: marked delivered 2275 m from the address — ask the carrier for its proof
- no scan
- CL-90024 for M. Leclerc, 40 avenue Berthelot, Lyon: marked delivered with no scan position — the proof has no place
evidence: replay.log, 00-check-distances.txt, 00-hook-scripts.txt, 01-far.json, 02-noscan.json, run-day1.txt, run-day2.txt · transform v1
Limits
- No transformer measures a distance: it needs the operator's script, installed in the hooks directory.
- 200 m is a choice: a large site, a locker or a relay point needs its own threshold.
- A far scan is not a fraud: the decision asks for the proof.
- The mediator's report gives no figure on these cases: this proof is weaker than others.
- Six synthetic deliveries in Lyon.
This scenario runs on lumnik Open, free and open source.
Try lumnik Open →