Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Add conservative evidence decisions and explicit inconclusive reasons (#9)
Cinna Davis303ad01b85b8
diff --git a/benchmarks/decision-inputs.json b/benchmarks/decision-inputs.jsonnew file mode 100644index 0000000..cfb8e13--- /dev/null+++ b/benchmarks/decision-inputs.json@@ -0,0 +1,1679 @@+{+ "schema_version": 1,+ "cases": [+ {+ "case_id": "decision-001",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-002",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [],+ "candidates": [],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-003",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "unavailable",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-004",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ },+ {+ "lat": 45,+ "lon": -100.0,+ "score": -1.4,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-005",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "a"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-006",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-007",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "altitude"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-008",+ "split": "development",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-009",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-010",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [],+ "candidates": [],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-011",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "unavailable",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-012",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ },+ {+ "lat": 45,+ "lon": -100.0,+ "score": -1.5,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-013",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "a"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-014",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 7.1,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-015",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "altitude"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ },+ "e1": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ },+ {+ "case_id": "decision-016",+ "split": "held_out",+ "scope": "simulated_decision_evidence",+ "events": [+ {+ "event_id": "e0",+ "start_s": 0,+ "end_s": 20,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g0",+ "ridge": [+ {+ "time_s": 0,+ "frequency_hz": 140+ },+ {+ "time_s": 10,+ "frequency_hz": 130+ },+ {+ "time_s": 20,+ "frequency_hz": 120+ }+ ]+ },+ {+ "event_id": "e1",+ "start_s": 100,+ "end_s": 120,+ "band_hz": [+ 90,+ 200+ ],+ "harmonic_group_id": "g1",+ "ridge": [+ {+ "time_s": 100,+ "frequency_hz": 140+ },+ {+ "time_s": 110,+ "frequency_hz": 130+ },+ {+ "time_s": 120,+ "frequency_hz": 120+ }+ ]+ }+ ],+ "candidates": [+ {+ "lat": 40.0,+ "lon": -100.0,+ "score": -1.0,+ "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": [+ "e0",+ "e1"+ ],+ "flight_ids": [+ "a",+ "b"+ ],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {+ "radius_m": 70.0,+ "kind": "sensitivity",+ "method": "fixture_full_perturbation"+ }+ }+ ],+ "coverage": {+ "search_complete": true,+ "data_status": "available",+ "limitations": [+ "Aircraft capture is incomplete."+ ]+ },+ "matching_diagnostics": {+ "clock_locked": true,+ "alternatives_evaluated": true,+ "refinement_boundary_limited": false,+ "sensitivity": {+ "complete": true,+ "boundary_limited": false,+ "sources": [+ "frequency",+ "clock",+ "altitude",+ "sound_speed"+ ],+ "radius_m": 70.0+ },+ "e0": {+ "rmse_hz": 0.7999999999999999,+ "outlier_fraction": 0.1,+ "support_fraction": 1.0,+ "drift_at_bound": false+ }+ }+ }+ ]+}diff --git a/benchmarks/truth/decision-labels.json b/benchmarks/truth/decision-labels.jsonnew file mode 100644index 0000000..d9876e7--- /dev/null+++ b/benchmarks/truth/decision-labels.json@@ -0,0 +1,90 @@+{+ "decision-001": {+ "control_kind": "supported",+ "location_accuracy_eligible": true,+ "expect_inconclusive": false,+ "location": [+ 40,+ -100+ ]+ },+ "decision-002": {+ "control_kind": "noise",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-003": {+ "control_kind": "missing",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-004": {+ "control_kind": "ambiguous",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-005": {+ "control_kind": "harmonics",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-006": {+ "control_kind": "residual",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-007": {+ "control_kind": "altitude_only",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-008": {+ "control_kind": "missing_diagnostics",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-009": {+ "control_kind": "supported",+ "location_accuracy_eligible": true,+ "expect_inconclusive": false,+ "location": [+ 40,+ -100+ ]+ },+ "decision-010": {+ "control_kind": "noise",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-011": {+ "control_kind": "missing",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-012": {+ "control_kind": "ambiguous",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-013": {+ "control_kind": "harmonics",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-014": {+ "control_kind": "residual",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-015": {+ "control_kind": "altitude_only",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ },+ "decision-016": {+ "control_kind": "missing_diagnostics",+ "location_accuracy_eligible": false,+ "expect_inconclusive": true+ }+}diff --git a/docs/CONFIDENCE.md b/docs/CONFIDENCE.mdnew file mode 100644index 0000000..a7dd925--- /dev/null+++ b/docs/CONFIDENCE.md@@ -0,0 +1,98 @@+# Evidence checks and inconclusive outcomes++`confidence.decide_location(events, candidates, coverage,+matching_diagnostics=..., policy=None)` consumes the version-one contracts and+returns `status`, `reason_code`, `message` and `diagnostics`. The product stores the+last field in an artifact and only adds accepted contract fields to JobResult.+Ranked candidates may be retained for inspection when the outcome is inconclusive;+the UI must not show them as an accepted recorder position.++The function validates the inputs without changing them or reading evaluation+truth. Malformed producer evidence returns `failed / invalid_evidence`. Missing+recording-clock input remains the orchestrator's `needs_input`; acquisition or+execution exceptions remain execution failures, distinct from insufficient+scientific evidence. Coverage means completion of the requested geographic/time+scope and availability of requested archives, not capture of every aircraft.++## Default policy and evidence++The default `DecisionPolicy` is `engineering-v1`, frozen before the held-out+decision-fixture run. Development negative controls motivated explicit abstention+for noise, absent tracks, harmonic duplicates, incomplete coverage, bad residuals+and multiple plausible hypotheses. The engineering thresholds are deliberately+simple and predeclared: at least two independent flyovers, <=3 Hz event RMSE,+<=25% outliers, >=95% trajectory support, and 100 m maximum sensitivity radius.+For `negative_robust_ridge_loss_hz`, a competing loss within 0.5 Hz per independent+event is a near tie. A location more than 200 m away or a different flight+association then triggers ambiguity. Other score kinds have no declared gap+threshold and abstain. These are regression-tested engineering choices, **not+empirically calibrated thresholds for arbitrary aircraft audio**. No held-out+real recordings have established their false-localization rate.++Every leading hypothesis must explain the event set with one locked recording+clock; harmonics count once and must map to the same flight. Matching diagnostics+use event-ID keys with `rmse_hz`, `outlier_fraction`, `support_fraction` and+`drift_at_bound`. Other required evidence keys are `clock_locked`,+`refinement_boundary_limited`, `alternatives_evaluated` and `sensitivity`.+Alternatives must include the retained global competing hypotheses, not only a+selected local winner. Failed/unrefined hypotheses or incomplete tile coverage+must not silently become evidence that no competing hypothesis exists.++`sensitivity` must carry `complete: true`, `boundary_limited: false`, `radius_m` and `sources`+including `frequency`, `clock`, `altitude` and `sound_speed`. Candidate `uncertainty`+must cover those actual perturbations, with a radius at least as large as the+tested envelope. Unverified calibrated uncertainty claims abstain; this policy+accepts explicitly uncalibrated sensitivity only. The current W3 altitude-only profile does+not meet this requirement, even if its radius is zero. Missing measurement/model+sensitivity therefore yields `uncertainty_not_established`. An engineering pass+can be `succeeded`, but is explicitly uncalibrated and carries no probability.+The synthetic fixture that supplies complete hypothetical evidence tests that+branch; it does not establish that the real producer has provided such evidence.++## Machine-readable reason codes++| Code | Interpretation |+| --- | --- |+| `invalid_evidence` | Malformed producer result; execution failed |+| `no_doppler_events` | No supported discovered event |+| `coverage_unknown` | No coverage report |+| `missing_flight_data` | Archive data unavailable |+| `search_incomplete` | Requested geographic/time search unfinished |+| `partial_flight_coverage` | Some required data missing |+| `no_matching_flights` | No event/track hypothesis |+| `insufficient_independent_events` | Too few flyovers after harmonic grouping |+| `inconsistent_harmonic_association` | Harmonics map to different flights |+| `unexplained_events` | Candidate omits discovered events |+| `timing_not_established` | Shared clock unverified |+| `matching_diagnostics_missing` | Event-fit evidence unavailable |+| `insufficient_track_support` | Incomplete trajectory support |+| `inconsistent_event_match` | Residual/outlier threshold failed |+| `source_drift_unresolved` | Drift estimate missing or on its bound |+| `unsupported_score_kind` | No declared ambiguity rule for score |+| `incomparable_candidates` | Competing hypotheses explain different event sets |+| `ambiguous_locations` | Near-tied materially different locations |+| `ambiguous_flight_match` | Near-tied different flight associations |+| `alternatives_not_assessed` | Retained global alternatives not fully assessed |+| `uncertainty_not_established` | Full measurement/model sensitivity unavailable |+| `calibration_not_verified` | Candidate's calibration claim lacks independent verification |+| `refinement_boundary_limited` | Refinement/sensitivity reaches search boundary |+| `location_uncertainty_too_large` | Sensitivity radius exceeds precision target |+| `supported_by_evidence_checks` | Passed declared checks; uncalibrated |++## Reproduce decision controls++```bash+PYTHONPATH=src .venv/bin/python scripts/evaluate_confidence.py --output results/confidence-new+PYTHONPATH=src .venv/bin/python -m pytest -q tests/test_confidence.py tests/test_evaluation.py+```++`benchmarks/decision-inputs.json` contains simulated evidence, separate from+`benchmarks/truth/decision-labels.json`. Decisions are written before truth is+opened. There are eight development and eight held-out fixture cases. Each split+has one engineered supported case and seven expected inconclusive outcomes;+observed abstention is 7/8, unsupported localization 0/8, and the engineered+location error is zero by construction. All case-level outputs are retained.+These public, author-constructed fixture splits verify decision logic only. The+zero errors and false-localization counts do not estimate audio or real-world+localization accuracy. The audio controls and the frozen audit remain separate;+see `benchmarks/README.md` for their evidence limits and real-data gap.diff --git a/scripts/evaluate_confidence.py b/scripts/evaluate_confidence.pynew file mode 100644index 0000000..40e356a--- /dev/null+++ b/scripts/evaluate_confidence.py@@ -0,0 +1,30 @@+"""Exercise frozen engineering decision checks; this is not audio accuracy."""+import argparse+import json+from pathlib import Path++from aircraft_geoloc.confidence import decide_location+from aircraft_geoloc.evaluation import evaluate+++if __name__ == "__main__":+ parser = argparse.ArgumentParser(description=__doc__)+ parser.add_argument("--root", type=Path, default=Path(__file__).resolve().parents[1])+ parser.add_argument("--output", required=True, type=Path)+ args = parser.parse_args()+ args.output.mkdir(parents=True, exist_ok=False)+ cases = json.loads((args.root / "benchmarks/decision-inputs.json").read_text())+ predictions = {}+ for case in cases["cases"]:+ result = decide_location(case["events"], case["candidates"], case["coverage"],+ matching_diagnostics=case["matching_diagnostics"])+ result["candidates"] = case["candidates"]+ result["events"] = case["events"]+ predictions[case["case_id"]] = result+ # Persist predictions before opening the separate truth file.+ (args.output / "predictions.json").write_text(json.dumps(predictions, indent=2, allow_nan=False) + "\n")+ truth = json.loads((args.root / "benchmarks/truth/decision-labels.json").read_text())+ report = evaluate(cases, predictions, truth)+ report["limits"].append("Decision-only simulated evidence fixtures; no acoustic or geographic accuracy validation.")+ (args.output / "report.json").write_text(json.dumps(report, indent=2, allow_nan=False) + "\n")+ print(json.dumps(report["by_split"], indent=2))diff --git a/src/aircraft_geoloc/confidence.py b/src/aircraft_geoloc/confidence.pynew file mode 100644index 0000000..ec42793--- /dev/null+++ b/src/aircraft_geoloc/confidence.py@@ -0,0 +1,159 @@+"""Conservative, uncalibrated evidence checks for the shared result contract.++Scores rank hypotheses; no score is interpreted as a probability. This module+never reads benchmark truth or changes event clocks/candidates. Detailed decision+diagnostics belong in a job artifact, outside the strict JobResult fields.+"""+from dataclasses import asdict, dataclass+import math++from pyproj import Geod++from .contracts import validate_result+++@dataclass(frozen=True)+class DecisionPolicy:+ """Predeclared engineering limits, not fitted confidence calibration."""+ target_radius_m: float = 100.0+ min_independent_events: int = 2+ max_event_rmse_hz: float = 3.0+ max_outlier_fraction: float = 0.25+ min_support_fraction: float = 0.95+ near_tie_loss_per_event_hz: float = 0.5++ def __post_init__(self):+ for name in ("target_radius_m", "max_event_rmse_hz", "near_tie_loss_per_event_hz"):+ if not math.isfinite(getattr(self, name)) or getattr(self, name) <= 0:+ raise ValueError(f"{name} must be positive and finite")+ if type(self.min_independent_events) is not int or self.min_independent_events < 2:+ raise ValueError("At least two independent events are required by this policy")+ for name in ("max_outlier_fraction", "min_support_fraction"):+ if not math.isfinite(getattr(self, name)) or not 0 <= getattr(self, name) <= 1:+ raise ValueError(f"{name} must lie in [0, 1]")+++def decide_location(events, candidates, coverage, *, matching_diagnostics=None, policy=None):+ """Return status/reason_code/message/diagnostics without modifying inputs.++ ``matching_diagnostics`` uses W3/W5's event-ID keys, plus clock_locked,+ refinement_boundary_limited, alternatives_evaluated and sensitivity.+ Sensitivity must state complete=True, boundary_limited=False and list tested+ sources: frequency, clock, altitude and sound_speed. An altitude-only profile+ cannot justify 100 m spatial precision. The orchestrator owns execution errors+ and missing recording-clock needs_input; malformed evidence is failed here.+ """+ policy = policy or DecisionPolicy()+ if not isinstance(policy, DecisionPolicy):+ raise TypeError("policy must be a DecisionPolicy")+ diagnostics = {"policy": asdict(policy), "policy_version": "engineering-v1",+ "calibration": "uncalibrated", "probability": None,+ "limitations": ["Archive availability does not establish capture of every aircraft.",+ "Sensitivity checks are not a calibrated confidence interval."]}++ def result(reason, message, status="inconclusive"):+ return {"status": status, "reason_code": reason, "message": message, "diagnostics": diagnostics}++ try:+ envelope = {"schema_version": 1, "job_id": "decision-validation", "status": "running",+ "events": events, "candidates": candidates}+ if coverage is not None:+ envelope["coverage"] = coverage+ validated = validate_result(envelope)+ except (ValueError, TypeError, KeyError) as exc:+ diagnostics["validation_error"] = str(exc)+ return result("invalid_evidence", "The analysis produced malformed evidence.", "failed")+ events, candidates = validated["events"], validated["candidates"]+ evidence = matching_diagnostics or {}+ if not isinstance(evidence, dict):+ return result("invalid_evidence", "Matching diagnostics must be a mapping.", "failed")+ if not events:+ return result("no_doppler_events", "No supported Doppler event was discovered in the recording.")+ if coverage is None:+ return result("coverage_unknown", "Search completion and flight-data coverage are not established.")+ if coverage["data_status"] == "unavailable":+ return result("missing_flight_data", "Historical flight data are unavailable for this recording window.")+ if not coverage["search_complete"]:+ return result("search_incomplete", "The search did not finish the entire requested area and time window.")+ if coverage["data_status"] != "available" or coverage.get("missing_data"):+ return result("partial_flight_coverage", "Required flight or terrain data are missing from the searched scope.")+ if not candidates:+ return result("no_matching_flights", "No candidate flight association supports the discovered events.")++ best = candidates[0]+ lookup = {event["event_id"]: event for event in events}+ matched = [lookup[key] for key in best["event_ids"]]+ groups = {}+ for event, flight in zip(matched, best["flight_ids"]):+ key = event.get("harmonic_group_id", event["event_id"])+ if key in groups and groups[key][1] != flight:+ return result("inconsistent_harmonic_association", "Harmonics of one event map to different flight segments.")+ groups[key] = (event, flight)+ diagnostics["independent_event_groups"] = len(groups)+ if len(groups) < policy.min_independent_events:+ return result("insufficient_independent_events", "Too few independent flyovers constrain location; harmonics count once.")+ if set(best["event_ids"]) != set(lookup):+ return result("unexplained_events", "The leading hypothesis leaves discovered events unexplained.")+ if evidence.get("clock_locked") is not True:+ return result("timing_not_established", "One shared recording clock has not been verified across all events.")+ for event, _ in groups.values():+ key = event["event_id"]+ fit = evidence.get(key)+ if not isinstance(fit, dict):+ return result("matching_diagnostics_missing", "Per-event residual and trajectory-support evidence is missing.")+ names = ("rmse_hz", "outlier_fraction", "support_fraction")+ values = [fit.get(name) for name in names]+ if any(isinstance(v, bool) or not isinstance(v, (int, float)) or not math.isfinite(v) for v in values):+ return result("matching_diagnostics_missing", "Per-event measurement diagnostics are incomplete or nonfinite.")+ rmse, outliers, support = values+ if rmse < 0 or not 0 <= outliers <= 1 or not 0 <= support <= 1:+ return result("invalid_evidence", "Per-event diagnostics contain impossible values.", "failed")+ if support < policy.min_support_fraction:+ return result("insufficient_track_support", "A flight trajectory does not cover enough of its observed event.")+ if rmse > policy.max_event_rmse_hz or outliers > policy.max_outlier_fraction:+ return result("inconsistent_event_match", "Residuals or outliers exceed the predeclared event-fit limits.")+ if fit.get("drift_at_bound") is not False:+ return result("source_drift_unresolved", "The source-frequency drift model is missing or reaches its allowed bound.")++ if best["score_kind"] != "negative_robust_ridge_loss_hz":+ return result("unsupported_score_kind", "This ranking score has no declared ambiguity threshold in the decision policy.")+ for alternative in candidates[1:]:+ # Unmatched/subset candidates cannot be compared as equal-size losses.+ if set(alternative["event_ids"]) != set(best["event_ids"]):+ return result("incomparable_candidates", "Competing candidates do not explain the same event set.")+ separation = abs(Geod(ellps="WGS84").inv(best["lon"], best["lat"], alternative["lon"], alternative["lat"])[2])+ same_flights = dict(zip(best["event_ids"], best["flight_ids"])) == dict(zip(alternative["event_ids"], alternative["flight_ids"]))+ loss_gap = (best["score"] - alternative["score"]) / len(groups)+ if (separation > 2 * policy.target_radius_m or not same_flights) and loss_gap <= policy.near_tie_loss_per_event_hz:+ diagnostics["competing_hypothesis"] = {"separation_m": separation, "loss_gap_per_event_hz": loss_gap,+ "same_flight_association": same_flights}+ return result("ambiguous_locations" if separation > 2 * policy.target_radius_m else "ambiguous_flight_match",+ "Competing hypotheses fit nearly as well; no unique precise location is supported.")+ if evidence.get("alternatives_evaluated") is not True:+ return result("alternatives_not_assessed", "The retained competing hypotheses have not all been assessed.")+ sensitivity = evidence.get("sensitivity", {})+ if not isinstance(sensitivity, dict):+ return result("uncertainty_not_established", "Measurement and model sensitivity are not established.")+ required = {"frequency", "clock", "altitude", "sound_speed"}+ sources = sensitivity.get("sources", [])+ if not isinstance(sources, list) or not all(isinstance(x, str) for x in sources):+ return result("invalid_evidence", "Sensitivity source names must be a list of strings.", "failed")+ diagnostics["sensitivity_sources"] = sources+ if not required <= set(sources) or sensitivity.get("complete") is not True:+ return result("uncertainty_not_established", "Full ridge, clock, altitude and sound-speed sensitivity has not been tested.")+ if sensitivity.get("boundary_limited") is not False or evidence.get("refinement_boundary_limited") is not False:+ return result("refinement_boundary_limited", "Refinement or sensitivity reaches a search boundary.")+ uncertainty = best.get("uncertainty")+ if uncertainty is None:+ return result("uncertainty_not_established", "The leading candidate has no supported spatial sensitivity estimate.")+ if uncertainty["kind"] != "sensitivity":+ return result("calibration_not_verified", "This policy has no independent evidence verifying the candidate's calibration claim.")+ radius = sensitivity.get("radius_m")+ if isinstance(radius, bool) or not isinstance(radius, (int, float)) or not math.isfinite(radius) or radius < 0:+ return result("uncertainty_not_established", "The full perturbation envelope has no valid spatial radius.")+ if uncertainty["radius_m"] < radius:+ return result("uncertainty_not_established", "The candidate radius does not cover the tested perturbation envelope.")+ diagnostics["radius_m"] = uncertainty["radius_m"]+ if uncertainty["radius_m"] > policy.target_radius_m:+ return result("location_uncertainty_too_large", "Spatial sensitivity exceeds the declared precision target.")+ return result("supported_by_evidence_checks", "Location passes the declared evidence checks; its sensitivity remains uncalibrated.", "succeeded")diff --git a/tests/test_confidence.py b/tests/test_confidence.pynew file mode 100644index 0000000..8f56f86--- /dev/null+++ b/tests/test_confidence.py@@ -0,0 +1,100 @@+from copy import deepcopy++import pytest++from aircraft_geoloc.confidence import DecisionPolicy, decide_location+from aircraft_geoloc.contracts import validate_result+++def evidence():+ events = [{"event_id": f"e{i}", "start_s": i * 100, "end_s": i * 100 + 20,+ "band_hz": [90, 200], "harmonic_group_id": f"g{i}",+ "ridge": [{"time_s": i * 100 + t, "frequency_hz": 140 - t} for t in [0, 10, 20]]}+ for i in range(2)]+ candidate = {"lat": 40., "lon": -100., "score": -1., "score_kind": "negative_robust_ridge_loss_hz",+ "event_ids": ["e0", "e1"], "flight_ids": ["a", "b"],+ "recording_start_utc": "2026-09-21T14:13:20Z",+ "uncertainty": {"radius_m": 70., "kind": "sensitivity", "method": "fixture_full_perturbation"}}+ coverage = {"search_complete": True, "data_status": "available", "limitations": ["Aircraft capture is incomplete."]}+ diagnostic = {"clock_locked": True, "alternatives_evaluated": True, "refinement_boundary_limited": False,+ "sensitivity": {"complete": True, "boundary_limited": False, "radius_m": 70.,+ "sources": ["frequency", "clock", "altitude", "sound_speed"]}}+ for event in events:+ diagnostic[event["event_id"]] = {"rmse_hz": 0.7, "outlier_fraction": 0.1,+ "support_fraction": 1.0, "drift_at_bound": False}+ return events, [candidate], coverage, diagnostic+++def decide(bundle):+ events, candidates, coverage, diagnostic = bundle+ return decide_location(events, candidates, coverage, matching_diagnostics=diagnostic)+++def test_complete_fixture_passes_without_probability_and_preserves_inputs():+ bundle = evidence()+ before = deepcopy(bundle)+ result = decide(bundle)+ assert result["status"] == "succeeded"+ assert result["diagnostics"]["probability"] is None+ assert result["diagnostics"]["calibration"] == "uncalibrated"+ assert bundle == before+ wire = {"schema_version": 1, "job_id": "example", "events": bundle[0], "candidates": bundle[1],+ "coverage": bundle[2], **{k: v for k, v in result.items() if k != "diagnostics"}}+ assert validate_result(wire)["status"] == "succeeded"++[email protected]("kind,reason", [+ ("noise", "no_doppler_events"), ("missing", "missing_flight_data"),+ ("partial", "partial_flight_coverage"), ("incomplete", "search_incomplete"),+ ("harmonics", "insufficient_independent_events"), ("clock", "timing_not_established"),+ ("residual", "inconsistent_event_match"), ("support", "insufficient_track_support"),+ ("drift", "source_drift_unresolved"), ("altitude_only", "uncertainty_not_established"),+ ("no_alternatives", "alternatives_not_assessed"), ("wide", "location_uncertainty_too_large"),+ ("boundary", "refinement_boundary_limited"), ("no_tracks", "no_matching_flights")])+def test_insufficient_evidence_abstains(kind, reason):+ events, candidates, coverage, diag = evidence()+ if kind == "noise": events, candidates = [], []+ elif kind == "missing": coverage["data_status"] = "unavailable"+ elif kind == "partial": coverage["data_status"] = "partial"+ elif kind == "incomplete": coverage["search_complete"] = False+ elif kind == "harmonics":+ events[1]["harmonic_group_id"] = events[0]["harmonic_group_id"]+ candidates[0]["flight_ids"] = ["a", "a"]+ elif kind == "clock": diag["clock_locked"] = False+ elif kind == "residual": diag["e0"]["rmse_hz"] = 8+ elif kind == "support": diag["e0"]["support_fraction"] = 0.5+ elif kind == "drift": diag["e0"]["drift_at_bound"] = True+ elif kind == "altitude_only": diag["sensitivity"]["sources"] = ["altitude"]+ elif kind == "no_alternatives": diag["alternatives_evaluated"] = False+ elif kind == "wide": candidates[0]["uncertainty"]["radius_m"] = 500+ elif kind == "boundary": diag["sensitivity"]["boundary_limited"] = True+ elif kind == "no_tracks": candidates = []+ result = decide((events, candidates, coverage, diag))+ assert result["status"] == "inconclusive"+ assert result["reason_code"] == reason+++def test_distant_tie_and_same_location_different_flights():+ events, candidates, coverage, diag = evidence()+ alternative = dict(candidates[0], lat=45., score=-1.2)+ result = decide((events, candidates + [alternative], coverage, diag))+ assert result["reason_code"] == "ambiguous_locations"+ alternative.update(lat=40., flight_ids=["x", "y"])+ assert decide((events, candidates + [alternative], coverage, diag))["reason_code"] == "ambiguous_flight_match"+++def test_malformed_results_fail_instead_of_masquerading_as_insufficient_evidence():+ events, candidates, coverage, diag = evidence()+ candidates[0]["score"] = float("nan")+ result = decide((events, candidates, coverage, diag))+ assert result["status"] == "failed"+ assert result["reason_code"] == "invalid_evidence"+ with pytest.raises(ValueError):+ DecisionPolicy(min_independent_events=1)+++def test_w3_vertical_only_profile_is_not_a_100m_confidence_claim():+ events, candidates, coverage, diag = evidence()+ diag["sensitivity"] = {"radius_m": 0.0, "kind": "sensitivity", "method": "profiled_relative_altitude_offsets",+ "complete": True, "boundary_limited": False, "profiles": []}+ assert decide((events, candidates, coverage, diag))["reason_code"] == "uncertainty_not_established"