Skip to content

Python tool for aircraft Doppler audio geolocation using historical ADS-B flight data (Source-available)

Relay finite-search evidence with complete core mode assessments (#10)

Cinna Davis8c647f3d819b
diff --git a/docs/PRODUCT.md b/docs/PRODUCT.md
index c8c609f..28993e7 100644
--- a/docs/PRODUCT.md
+++ b/docs/PRODUCT.md
@@ -157,3 +157,29 @@ established real recording truth/time, and nationwide real accuracy at the curre
remain unverified. The measured ambiguity and partial-coverage outcomes must not
be promoted to that acceptance claim. The historical manually configured regional
result remains separate.
+
+## Accounted finite-search evidence
+
+The current integration consumes the optional artifact-only producer/decision
+contract in [FINITE_SEARCH_DECISION.md](FINITE_SEARCH_DECISION.md). The search
+producer assigns stable seed `mode_id` values including position, clock, event
+indices and flight/pass association, and records every lossy retention bound.
+The product relays `finite_search_evidence` unchanged, preserves seed IDs through
+refinement, and supplies `candidate_mode_ids` parallel to the wire candidates.
+
+For the explicitly declared evaluated-finite-grid scope, `assessed_mode_ids`
+requires an actually completed finite core score with full measured-trajectory
+support at the original seed/model and a valid trusted clock. It does not require
+jointly optimizing every retained point. Failed, missing or unsupported core
+records are unassessed. Raw and refined representations retain their original
+mode ID and original-or-improved score; no association-only deduplication is used.
+The accepted leading estimate still needs successful full sensitivity, datum,
+optimizer, clock, actual-radius and competing-mode checks.
+
+Unperformed refinements and continuous locations are outside that conditional
+finite claim. Their limitations are displayed in coverage and saved in the
+artifacts. The old `alternatives_evaluated` flag keeps its older meaning and is
+not flipped to force success. An absent finite object preserves old outcomes;
+missing mappings, incomplete work or an unaccounted near-tied discard remain
+inconclusive. Producer computation, consumer agreement and an actual integrated
+run are required before this optional path is considered deployed.
diff --git a/evidence/product-20261103/all-event-integration-tests.json b/evidence/product-20261103/all-event-integration-tests.json
new file mode 100644
index 0000000..13e9fb4
--- /dev/null
+++ b/evidence/product-20261103/all-event-integration-tests.json
@@ -0,0 +1,11 @@
+{
+ "source_commit": "f5c59a4f85b7a106e78530b3d87d20db4ad84b94",
+ "command": "PYTHONPATH=src /home/cinna/aircraft-audio-geolocation/.venv/bin/python -m pytest -q --junitxml=results/w5-all-event-checks-20261103/pytest.xml",
+ "tests": 240,
+ "failures": 0,
+ "errors": 0,
+ "skipped": 0,
+ "subtests_passed": 6,
+ "elapsed_s": 60.897,
+ "scope": "All-event producer integration and independent product controls; no new national replay or real localization acceptance."
+}
diff --git a/evidence/product-20261103/canonical-four-input-preparation.json b/evidence/product-20261103/canonical-four-input-preparation.json
new file mode 100644
index 0000000..c721f8a
--- /dev/null
+++ b/evidence/product-20261103/canonical-four-input-preparation.json
@@ -0,0 +1,45 @@
+{
+ "recording.mp3": {
+ "bytes": 3841100,
+ "sha256": "6c44970b812d9147146c2f712c5012efd255ce80bb240aa6c1d9f3a796c45e85"
+ },
+ "tracks.parquet": {
+ "bytes": 171645,
+ "sha256": "3c9465f1816ed71c097eda451db9c7c2f42fa317163cb406ca7fc0a7be25a258"
+ },
+ "request.json": {
+ "bytes": 227,
+ "sha256": "44f8c8ef67d150f10f6d55b87061d07ec3767c3f314d0df46b491680070c9c7d"
+ },
+ "coverage.json": {
+ "bytes": 241,
+ "sha256": "714632e98da102bdd1dc5138148dd7f401d5d68304208a2d0eaf9c2849b532bb"
+ },
+ "terrain.tif": {
+ "bytes": 2689,
+ "sha256": "27f022d8df74d62632b7ee789f42dd90b3d333ccc7e348ab3c2e5d02650a470b"
+ },
+ "geoid.tif": {
+ "bytes": 2509,
+ "sha256": "5e0de6d7e61a474a96993fdef7efe0aa2ca74ffc35c6d659c6020e5425bbcdae"
+ },
+ "index": {
+ "path": "flights-v2.sqlite",
+ "rows": 3252,
+ "segments": 12,
+ "input_hash": "53f37f0d9c43eca2bc384db97d26d2d615897a09b5be93a1b217f6022e9ee338",
+ "columns": [
+ "flight_id",
+ "time_s",
+ "lat",
+ "lon",
+ "alt_m",
+ "typecode",
+ "east_mps",
+ "north_mps",
+ "up_mps",
+ "altitude_basis"
+ ]
+ },
+ "scope": "Only the primary frozen input directory was copied; labels/generation/renderer were not read or copied."
+}
diff --git a/evidence/product-20261103/namespace-preflight.json b/evidence/product-20261103/namespace-preflight.json
new file mode 100644
index 0000000..e292261
--- /dev/null
+++ b/evidence/product-20261103/namespace-preflight.json
@@ -0,0 +1,11 @@
+{
+ "home_visible": false,
+ "auth_environment_visible": false,
+ "runtime_from_wheel": true,
+ "raster_readable": true,
+ "index_rows": 3252,
+ "index_segments": 12,
+ "input_mp3_sha256": "6c44970b812d9147146c2f712c5012efd255ce80bb240aa6c1d9f3a796c45e85",
+ "scope": "namespace import/input preflight only; no duplicate four-event search launched",
+ "wheel_sha256": "084490e7035b40982cf5a73c8ce7ddc7599b51d1c3b3c80b5186569919efef55"
+}
diff --git a/src/aircraft_geoloc/automatic.py b/src/aircraft_geoloc/automatic.py
index d8094d1..da35901 100644
--- a/src/aircraft_geoloc/automatic.py
+++ b/src/aircraft_geoloc/automatic.py
@@ -1,4 +1,5 @@
"""Automatic stage orchestration; scientific producers own their algorithms."""
+from copy import deepcopy
from datetime import datetime, timezone
import hashlib
import json
@@ -153,7 +154,14 @@ def _coverage(request, search, config):
limitations.append(search.get("event_limit_reason") or "Not every proposed flyover group was considered within the configured budget.")
if "constant_m" in config.get("terrain", {}):
limitations.append("A constant terrain model was supplied; real terrain and altitude-datum accuracy are not established.")
- if search.get("alternative_modes_exhaustively_assessed") is not True:
+ finite = search.get("finite_search_evidence")
+ if finite is not None:
+ descriptions = finite.get("limitations") if isinstance(finite, dict) else None
+ if isinstance(descriptions, list) and descriptions and all(isinstance(item, str) for item in descriptions):
+ limitations.extend(descriptions)
+ else:
+ limitations.append("Only evaluated grid points and bounded refinements are covered; continuous-space uniqueness is not established.")
+ elif search.get("alternative_modes_exhaustively_assessed") is not True:
limitations.append("Candidate retention is bounded; exhaustive alternative-location assessment is not established.")
missing = [str(item) for item in search.get("tile_failures", [])]
if not search.get("data_scope_complete"):
@@ -172,6 +180,8 @@ def _comparable_refinement(candidate, original, prepared_events):
candidate = association_score(candidate, chosen)
if not math.isfinite(candidate["score"]):
raise ValueError("Refinement no longer supports the matched event association")
+ if "mode_id" in original:
+ candidate = dict(candidate, mode_id=original["mode_id"])
return candidate
@@ -184,6 +194,21 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
refined, refinement_failures = [], []
window = state["recording"]["time_window"]
start_window = tuple(utc_timestamp(window[key]).timestamp() for key in ("start_utc", "end_utc"))
+ finite = search.get("finite_search_evidence")
+ assessed_ids = set()
+ if isinstance(finite, dict):
+ for row in raw:
+ identity = row.get("mode_id")
+ groups = row.get("event_indices", range(len(prepared_events)))
+ core = row.get("event_diagnostics", [])
+ if (isinstance(identity, str) and identity and row.get("score_kind") == finite.get("score_kind")
+ and math.isfinite(row["score"]) and start_window[0] <= row["recording_start_time_s"] <= start_window[1]
+ and len(groups) == len(row["flight_ids"]) == len(core) and len(core) > 0
+ and all(isinstance(fit, dict) and fit.get("support_fraction") == 1.
+ and not isinstance(fit.get("support_fraction"), bool)
+ and isinstance(fit.get("score"), (int, float)) and not isinstance(fit["score"], bool)
+ and math.isfinite(fit["score"]) for fit in core)):
+ assessed_ids.add(identity)
# Refine global competing approaches with their original whole trajectories.
# The index iterator is bounded by the same local acoustic support envelope.
def mode_key(row):
@@ -280,6 +305,10 @@ def _decide(search, events, prepared_events, measurements, indexes, terrain, sta
for event, evidence in zip(matched_events, best.get("event_diagnostics", [])):
for event_id in event.get("event_ids", [event["event_id"]]):
diagnostics[event_id] = evidence
+ if finite is not None:
+ diagnostics["finite_search_evidence"] = deepcopy(finite)
+ diagnostics["assessed_mode_ids"] = sorted(assessed_ids)
+ diagnostics["candidate_mode_ids"] = [row.get("mode_id") for row in rows]
write_json(output / "refined-candidates.json", {"ranked": rows, "matching_diagnostics": diagnostics})
decision_progress()
decision = decide_location(events, candidates, state["coverage"], matching_diagnostics=diagnostics)
diff --git a/tests/test_automatic_finite.py b/tests/test_automatic_finite.py
new file mode 100644
index 0000000..2ef6b8c
--- /dev/null
+++ b/tests/test_automatic_finite.py
@@ -0,0 +1,78 @@
+"""Finite-scope transport controls; producers are controlled, not location evidence."""
+from copy import deepcopy
+from types import SimpleNamespace
+
+import pytest
+
+from aircraft_geoloc import automatic, matching
+from aircraft_geoloc.jobs import read_json
+
+
[email protected]("bad_core", [None, "partial_support", "missing_core", "missing_id"])
+def test_finite_scope_assesses_supported_frozen_seeds_and_preserves_ids(tmp_path, monkeypatch, bad_core):
+ events = [{"event_id": f"event-{i}", "start_s": i*100., "end_s": i*100.+20., "band_hz": [90., 200.],
+ "ridge": [{"time_s": i*100.+t, "frequency_hz": 140.-t} for t in (0., 10., 20.)]} for i in range(2)]
+ rows = []
+ for identity, lat, score in (("mode-a", 40., -.1), ("mode-b", 41., -10.)):
+ fit = {"score": score/2, "rmse_hz": abs(score/2), "support_fraction": 1.,
+ "outlier_fraction": 0., "drift_at_bound": False}
+ rows.append({"mode_id": identity, "lat": lat, "lon": -100., "score": score,
+ "score_kind": "negative_robust_ridge_loss_hz", "flight_ids": ["a", "b"],
+ "recording_start_time_s": 1790000000., "event_diagnostics": [dict(fit), dict(fit)]})
+ if bad_core == "partial_support":
+ rows[1]["event_diagnostics"][0]["support_fraction"] = .5
+ elif bad_core == "missing_core":
+ rows[1]["event_diagnostics"] = []
+ elif bad_core == "missing_id":
+ rows[1].pop("mode_id")
+ evidence = {"schema_version": 1, "scope": "evaluated_finite_grid", "complete": True,
+ "score_kind": "negative_robust_ridge_loss_hz", "spacing_m": 1000., "refine_spacing_m": 100.,
+ "max_event_groups": 2, "retained_modes": [{"mode_id": "mode-a", "score": -.1, "event_groups": 2},
+ {"mode_id": "mode-b", "score": -10., "event_groups": 2}],
+ "discarded_count": 0, "best_discarded_score": None, "pruning_accounted_for": True,
+ "limitations": ["Evaluated points only; unperformed refinements and continuous space are not covered."]}
+ search = {"ranked": rows, "status": "complete", "scoring_time_is_locked": True,
+ "alternative_modes_exhaustively_assessed": False, "finite_search_evidence": evidence}
+ before = deepcopy(search)
+ state = {"recording": {"time_window": {"start_utc": "2026-09-21T14:13:20Z", "end_utc": "2026-09-21T14:13:20Z", "source": "user"}},
+ "coverage": {"search_complete": True, "data_status": "available", "limitations": []}}
+ tracks = [SimpleNamespace(id=name, time=[0., 1.], altitude_basis=["ellipsoidal"]) for name in ("a", "b")]
+ index = SimpleNamespace(query=lambda *args: tracks)
+ # Deliberately omit mode_id in producer returns: the orchestrator must retain
+ # the source seed identity without recomputing it from optimized coordinates.
+ def refine(row, *args, **kwargs):
+ return {key: value for key, value in row.items() if key != "mode_id"}
+ def profile(row, *args, **kwargs):
+ return dict(refine(row), sensitivity={"radius_m": 80., "kind": "sensitivity", "method": "declared_perturbation_profiles",
+ "complete": True, "boundary_limited": False, "sources": ["frequency", "clock", "altitude", "sound_speed"],
+ "settings": {"clock_bounds_s": [1790000000., 1790000000.]}})
+ monkeypatch.setattr(matching, "refine_candidate", refine)
+ monkeypatch.setattr(matching, "profile_candidate", profile)
+ def finish(status, reason_code=None, message=None, **fields):
+ return dict(status=status, reason_code=reason_code, **fields)
+ final = automatic._decide(search, events, events, [None]*2, [index], None, state, tmp_path,
+ {"refine_finalists": 1}, finish, lambda: None)
+ receipt = read_json(tmp_path/"refined-candidates.json")
+ diagnostics = receipt["matching_diagnostics"]
+ assert search == before
+ assert diagnostics["finite_search_evidence"] == evidence
+ assert diagnostics["alternatives_evaluated"] is False
+ assert diagnostics["unrefined_hypotheses"] == 1
+ assert len(diagnostics["candidate_mode_ids"]) == len(final["candidates"])
+ assert diagnostics["candidate_mode_ids"].count("mode-a") == 2
+ if bad_core is None:
+ assert final["status"] == "succeeded", final
+ assert diagnostics["assessed_mode_ids"] == ["mode-a", "mode-b"]
+ decision = read_json(tmp_path/"decision.json")
+ assert decision["diagnostics"]["finite_search"]["continuous_space_uniqueness"] == "not established"
+ else:
+ assert final["status"] == "inconclusive", final
+ assert diagnostics["assessed_mode_ids"] == ["mode-a"]
+
+
+def test_finite_scope_limitations_are_visible_in_coverage():
+ limit = "Only evaluated parameter points, not continuous uniqueness."
+ coverage = automatic._coverage({"search": {"coverage": "conus"}},
+ {"tiles_total": 1, "tiles_completed": 1, "data_scope_complete": True,
+ "finite_search_evidence": {"limitations": [limit]}}, {})
+ assert limit in coverage["limitations"]