Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)
Python acoustic-geolocationads-baircraft-trackingairplaneaudio-forensicsdoppler-effectdoppler-shiftgeolocationosintsignal-processing
Enclose qualified near-tied finite modes in the reported sensitivity
Cinna Davisef1c6ea2c9b3
diff --git a/docs/FINITE_SEARCH_DECISION.md b/docs/FINITE_SEARCH_DECISION.mdindex aaf4c30..005d4ce 100644--- a/docs/FINITE_SEARCH_DECISION.md+++ b/docs/FINITE_SEARCH_DECISION.md@@ -1,6 +1,6 @@# Proposed finite-search decision evidence-This additive consumer is a proposal for W2/W4/W5 agreement in+This additive consumer implements the conditional scope agreed in[the finite-search topic](https://github.com/1337isnot1337/DOPPLERGEIST/discussions/39#discussioncomment-19363838).W2 owns computing search/retention evidence, W5 owns stable mode mappings andactual assessment completion, and W4 owns this interpretation. It does not change@@ -34,7 +34,7 @@ W5 forwards W2's object verbatim as `matching_diagnostics.finite_search_evidence}```-Every retained spatial/clock/association seed has one unique stable ID. Preserve+Every retained spatial/clock/event-subset/association seed has one unique stable ID. Preservethat ID through its refinement. `event_groups` counts independent flyovers,including all supported later events; harmonics/fragments count once.`max_event_groups` bounds every retained or discarded evaluated hypothesis.@@ -47,7 +47,15 @@ maximum higher-is-better score. It is null exactly when no candidate was discardExact duplicate stable IDs merged while retaining their highest score are notcompeting retention drops. Count deduplications separately if needed; association-only or approximate spatial collapse cannot be treated as exact duplication.-It bounds evaluated parameter points only, not unvisited positions or unperformed+The receiver-grid/pass-association score may be the best over the declared bounded+clock/frequency/drift evaluations at that same location/association. Its domain+must be recorded. Every trial must be classified: evaluated admissible rejection+is distinct from unknown support/model/optimizer work, including all-negative-+infinite outcomes. Unknown trials cannot be hidden behind one successful trial+or assigned an optimistic discard bound. W2 exposes completed core seed IDs as+`core_assessed_mode_ids`; W5 forwards only those classified assessments.++The bound applies to evaluated parameter points only, not unvisited positions or unperformedrefinements. Missing accounting cannot become zero discards or complete evidence.## Assessment mappings@@ -88,7 +96,32 @@ undergoes the existing position/association near-tie checks against the actualreturned radius. Full measurement/model sensitivity and optimizer/boundary guardsremain mandatory.-An accepted finite object uses policy version `engineering-v4-finite-grid` and+## Same-association finite envelope++After valid finite accounting and successful complete leading refinement/model+sensitivity, near-tied same-association points may require a wider honest radius+than the local leading profile. Keep the fitted point, clock, score, association+and order fixed. Form the union of those evaluated points and every actually+reported applicable uncertainty envelope:++`radius = max(leading tested radius, distance to each near-tied point + its reported radius if present)`.++An absent competitor profile contributes only its evaluated point, never an+imputed profile. Unknown off-grid/profile behavior remains an explicit limitation.+A different flight/event association still vetoes. Discarded near ties still veto.+If the union exceeds the precision target, abstain. Incomplete, clipped or failed+leading profiles cannot be repaired by this enlargement. Calls without the finite+object keep the original returned-radius containment behavior, including #36.++The hook returns copied `candidates` with the leading uncertainty method+`finite_mode_and_tested_profile_union`, kind `sensitivity`, and computed radius.+W5 must preserve that returned array (`setdefault` fallback only). The API/UI must+read back the computed radius, not overwrite it with the smaller input profile.+Diagnostics preserve the base profile radius, finite extent, included candidate+indices/mode IDs and limitations. No test set, fitting parameter or historical+outcome is revised.++An accepted finite object uses policy version `engineering-v5-finite-envelope` andrecords its grid resolutions, counts, bound, limitationsand `continuous_space_uniqueness: not established` in the decision artifact. Apassing result supports only these declared assumptions. There is no new claimdiff --git a/src/aircraft_geoloc/confidence.py b/src/aircraft_geoloc/confidence.pyindex a7ccc0d..c43025f 100644--- a/src/aircraft_geoloc/confidence.py+++ b/src/aircraft_geoloc/confidence.py@@ -238,11 +238,25 @@ def decide_location(events, candidates, coverage, *, matching_diagnostics=None,subset_scores = best["score_kind"] == "matched_group_support_minus_normalized_residual"if best["score_kind"] != "negative_robust_ridge_loss_hz" and not subset_scores:return result("unsupported_score_kind", "This ranking score has no declared ambiguity threshold in the decision policy.")+ finite = evidence.get("finite_search_evidence")+ if finite is not None:+ diagnostics["policy_version"] = "engineering-v5-finite-envelope"+ try:+ counts = [len({lookup[key].get("harmonic_group_id", key) for key in candidate["event_ids"]}) for candidate in candidates]+ reason, details = _finite_search(finite, evidence, candidates, counts, policy)+ except ValueError as exc:+ diagnostics["validation_error"] = str(exc)+ return result("invalid_evidence", "The finite-search evidence is malformed.", "failed")+ diagnostics["finite_search"] = details+ if reason:+ return result(reason, "The finite search does not yet exclude unassessed or discarded competing hypotheses.")+ diagnostics["limitations"].append("Only the declared finite grids/refinements were compared; continuous-space uniqueness is not established.")# Alternatives must fit inside the envelope around the returned point.# Two overlapping target-radius circles do not establish that containment.ambiguity_radius_m = min(policy.target_radius_m,best.get("uncertainty", {}).get("radius_m", policy.target_radius_m))- for alternative in candidates[1:]:+ near_points = [(0, 0.0)]+ for index, alternative in enumerate(candidates[1:], 1):# Raw losses require equal event sets; subset support has declared units.if not subset_scores and set(alternative["event_ids"]) != set(best["event_ids"]):return result("incomparable_candidates", "Competing candidates do not explain the same event set.")@@ -252,25 +266,15 @@ def decide_location(events, candidates, coverage, *, matching_diagnostics=None,gap = (best["score"] - alternative["score"]) / max(len(groups), len(alternative_groups))threshold = policy.near_tie_support_per_group if subset_scores else policy.near_tie_loss_per_event_hzunits = "support_units_per_group" if subset_scores else "loss_hz_per_group"- if (separation > ambiguity_radius_m or not same_flights) and _near_tied(gap, threshold):+ tied = _near_tied(gap, threshold)+ if tied and (not same_flights or (finite is None and separation > ambiguity_radius_m)):diagnostics["competing_hypothesis"] = {"separation_m": separation, "score_gap": gap, "gap_units": units,"same_flight_association": same_flights, "checked_radius_m": ambiguity_radius_m}return result("ambiguous_locations" if separation > ambiguity_radius_m else "ambiguous_flight_match","Competing hypotheses fit nearly as well; no unique precise location is supported.")- finite = evidence.get("finite_search_evidence")- if finite is not None:- diagnostics["policy_version"] = "engineering-v4-finite-grid"- try:- counts = [len({lookup[key].get("harmonic_group_id", key) for key in candidate["event_ids"]}) for candidate in candidates]- reason, details = _finite_search(finite, evidence, candidates, counts, policy)- except ValueError as exc:- diagnostics["validation_error"] = str(exc)- return result("invalid_evidence", "The finite-search evidence is malformed.", "failed")- diagnostics["finite_search"] = details- if reason:- return result(reason, "The finite search does not yet exclude unassessed or discarded competing hypotheses.")- diagnostics["limitations"].append("Only the declared finite grids/refinements were compared; continuous-space uniqueness is not established.")- elif evidence.get("alternatives_evaluated") is not True:+ if tied:+ near_points.append((index, separation))+ if finite is None and 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):@@ -297,6 +301,26 @@ def decide_location(events, candidates, coverage, *, matching_diagnostics=None,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.")+ if finite is not None:+ base_radius = uncertainty["radius_m"]+ union_radius = max(distance + candidates[index].get("uncertainty", {}).get("radius_m", 0.)+ for index, distance in near_points)+ union_radius = max(base_radius, union_radius)+ diagnostics["finite_envelope"] = {+ "base_profile_radius_m": radius, "base_reported_radius_m": base_radius,+ "finite_point_extent_m": max(distance for _, distance in near_points),+ "radius_m": union_radius, "included_candidate_indices": [index for index, _ in near_points],+ "included_mode_ids": sorted({evidence["candidate_mode_ids"][index] for index, _ in near_points}),+ "limitations": ["Union covers evaluated same-association points and actually reported test envelopes.",+ "Unperformed competitor profiles/refinements remain unbounded; no coverage probability is inferred."]}+ diagnostics["radius_m"] = union_radius+ if union_radius > policy.target_radius_m:+ return result("ambiguous_locations", "Near-tied finite hypotheses and reported test envelopes exceed the precision target.")+ best["uncertainty"] = {"kind": "sensitivity", "radius_m": union_radius,+ "method": "finite_mode_and_tested_profile_union"}message = ("Location passes the evaluated finite-grid and sensitivity checks; its uncertainty remains uncalibrated."if finite is not None else "Location passes the declared evidence checks; its sensitivity remains uncalibrated.")- return result("supported_by_evidence_checks", message, "succeeded")+ decision = result("supported_by_evidence_checks", message, "succeeded")+ if finite is not None:+ decision["candidates"] = candidates+ return decisiondiff --git a/tests/test_confidence.py b/tests/test_confidence.pyindex 4016ece..8756b43 100644--- a/tests/test_confidence.py+++ b/tests/test_confidence.py@@ -191,7 +191,7 @@ def test_finite_search_can_pass_without_claiming_continuous_exhaustion():bundle = finite_evidence()result = decide(bundle)assert result["status"] == "succeeded"- assert result["diagnostics"]["policy_version"] == "engineering-v4-finite-grid"+ assert result["diagnostics"]["policy_version"] == "engineering-v5-finite-envelope"assert result["diagnostics"]["finite_search"]["continuous_space_uniqueness"] == "not established"bundle[3]["sensitivity"]["sources"] = ["altitude"]assert decide(bundle)["reason_code"] == "uncertainty_not_established"@@ -236,3 +236,57 @@ def test_malformed_finite_flags_fail_instead_of_looking_like_insufficient_data()result = decide(bundle)assert result["status"] == "failed"assert result["reason_code"] == "invalid_evidence"+++def near_finite_points(distance_m=90.):+ from pyproj import Geod+ bundle = finite_evidence()+ best, alternative = bundle[1]+ alternative["lon"], alternative["lat"], _ = Geod(ellps="WGS84").fwd(best["lon"], best["lat"], 90., distance_m)+ alternative["score"] = -1.2+ bundle[3]["finite_search_evidence"]["retained_modes"][1]["score"] = -1.2+ return bundle+++def test_finite_near_cluster_returns_a_copied_honest_envelope():+ bundle = near_finite_points()+ before = deepcopy(bundle)+ result = decide(bundle)+ assert result["status"] == "succeeded"+ returned = result["candidates"]+ assert 159.999 < returned[0]["uncertainty"]["radius_m"] < 160.001+ assert returned[0]["uncertainty"]["kind"] == "sensitivity"+ assert returned[0]["uncertainty"]["method"] == "finite_mode_and_tested_profile_union"+ assert result["diagnostics"]["finite_envelope"]["included_mode_ids"] == ["a", "b"]+ for original, candidate in zip(before[1], returned):+ assert {k: v for k, v in original.items() if k != "uncertainty"} == {k: v for k, v in candidate.items() if k != "uncertainty"}+ assert bundle == before+ assert validate_result({"schema_version": 1, "job_id": "finite-envelope", "status": "succeeded",+ "events": bundle[0], "coverage": bundle[2], "candidates": returned})["candidates"] == returned+++def test_finite_union_keeps_distant_and_different_association_vetoes():+ distant = near_finite_points(2000.)+ assert decide(distant)["reason_code"] == "ambiguous_locations"+ different = near_finite_points(30.)+ different[1][1]["flight_ids"] = ["x", "y"]+ assert decide(different)["reason_code"] == "ambiguous_flight_match"+ narrow = near_finite_points()+ result = decide_location(*narrow[:3], matching_diagnostics=narrow[3], policy=DecisionPolicy(target_radius_m=100.))+ assert result["status"] == "inconclusive"+ assert result["reason_code"] == "ambiguous_locations"++[email protected]("kind,reason", [("incomplete", "uncertainty_not_established"),+ ("boundary", "refinement_boundary_limited"), ("missing_sources", "uncertainty_not_established"),+ ("missing_uncertainty", "uncertainty_not_established"), ("ledger", "finite_search_incomplete")])+def test_union_cannot_repair_missing_or_clipped_leading_evidence(kind, reason):+ bundle = near_finite_points()+ if kind == "incomplete": bundle[3]["sensitivity"]["complete"] = False+ elif kind == "boundary": bundle[3]["sensitivity"]["boundary_limited"] = True+ elif kind == "missing_sources": bundle[3]["sensitivity"]["sources"] = ["altitude"]+ elif kind == "missing_uncertainty": bundle[1][0].pop("uncertainty")+ elif kind == "ledger": bundle[3]["finite_search_evidence"]["complete"] = False+ result = decide(bundle)+ assert result["status"] == "inconclusive"+ assert result["reason_code"] == reason