Skip to content

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

Expose operator chunk controls for real pipeline consistency checks (#10)

Cinna Davis6911036f8bb1
diff --git a/docs/PRODUCT.md b/docs/PRODUCT.md
index 28993e7..1767b4c 100644
--- a/docs/PRODUCT.md
+++ b/docs/PRODUCT.md
@@ -108,6 +108,16 @@ aircraft. Grid finalists undergo jointly constrained position/clock refinement;
`refine_finalists` (default 5) limits physical sensitivity refinement. Unassessed
retained approaches prevent an affirmative confidence decision.
+For reproducible chunk-boundary checks, an operator may set
+`"discovery": {"chunk_s": 120.0, "overlap_s": 60.0}` in this private configuration.
+These are the only discovery overrides supported by the product adapter. The
+existing detector validates the overlap and chunk constraints; spectral bands,
+acceptance thresholds and other scientific settings keep their defaults. The
+actual settings and analyzed chunks are saved in `discovery/discovery.json`, and
+the operator configuration hash is retained in provenance. This configuration is
+not an upload-request field. A chunk-size comparison must rerun detection and the
+pipeline; it cannot reuse final candidates as if discovery had run again.
+
The automatic path always uses one shared clock inside the supplied start window
and robust ridge loss. Its default association path considers every proposed
independent group; harmonics count once and unsupported acoustic proposals remain
diff --git a/src/aircraft_geoloc/automatic.py b/src/aircraft_geoloc/automatic.py
index 80b9d04..476e346 100644
--- a/src/aircraft_geoloc/automatic.py
+++ b/src/aircraft_geoloc/automatic.py
@@ -52,9 +52,16 @@ def analyze(request, output_dir, config=None, progress=lambda *args, **kwargs: N
try:
from .intake import AudioIntakeError, intake_recording
- from .discovery import discover_events
+ from .discovery import DiscoverySettings, discover_events
except ImportError as exc:
return finish("failed", "component_unavailable", f"Automatic audio components are not installed: {exc}")
+ discovery_options = config.get("discovery", {})
+ if not isinstance(discovery_options, dict) or discovery_options.keys() - {"chunk_s", "overlap_s"}:
+ return finish("failed", "invalid_configuration", "Operator discovery settings support only chunk_s and overlap_s.")
+ try:
+ discovery_settings = DiscoverySettings(**discovery_options)
+ except (TypeError, ValueError) as exc:
+ return finish("failed", "invalid_configuration", f"Invalid operator discovery settings: {exc}")
progress("intake", 0.05)
try:
recording = intake_recording(request["audio_path"], output / "intake", time_window=request.get("time_window"))
@@ -62,7 +69,7 @@ def analyze(request, output_dir, config=None, progress=lambda *args, **kwargs: N
return finish("failed", exc.code, str(exc))
state["recording"] = recording.metadata
progress("discovery", 0.15, recording=recording.metadata)
- events = [validate_event(event) for event in discover_events(recording, output_dir=output / "discovery")]
+ events = [validate_event(event) for event in discover_events(recording, output_dir=output / "discovery", settings=discovery_settings)]
state["events"] = events
provenance["discovered_events"] = len(events)
if recording.time_status == "needs_input":
diff --git a/tests/test_automatic.py b/tests/test_automatic.py
index fa4f9f9..f2eb73e 100644
--- a/tests/test_automatic.py
+++ b/tests/test_automatic.py
@@ -28,8 +28,8 @@ def encoded_mp3(tmp_path, *, moving=False):
return target.read_bytes()
-def submit_and_wait(tmp_path, payload, *, time_window=None):
- manager = JobManager(tmp_path / "jobs")
+def submit_and_wait(tmp_path, payload, *, time_window=None, config=None):
+ manager = JobManager(tmp_path / "jobs", config)
server = JobServer(("127.0.0.1", 0), manager)
thread = threading.Thread(target=server.serve_forever, daemon=True)
thread.start()
@@ -79,16 +79,24 @@ def test_stationary_mp3_returns_no_events_without_search(tmp_path):
assert not (directory / "search").exists()
-def test_moving_tone_mp3_discovers_events_then_reports_missing_data(tmp_path):
[email protected]("discovery", [None, {"chunk_s": 24., "overlap_s": 16.}])
+def test_moving_tone_mp3_discovers_events_then_reports_missing_data(tmp_path, discovery):
pytest.importorskip("aircraft_geoloc.data_access")
pytest.importorskip("aircraft_geoloc.matching")
pytest.importorskip("aircraft_geoloc.tiled_search")
payload = encoded_mp3(tmp_path, moving=True)
- final, directory = submit_and_wait(tmp_path, payload, time_window=WINDOW)
+ config = {"discovery": discovery} if discovery is not None else {}
+ final, directory = submit_and_wait(tmp_path, payload, time_window=WINDOW, config=config)
assert final["status"] == "inconclusive" and final["reason_code"] == "data_unavailable", final
assert len(final["events"]) >= 1
assert list((directory / "discovery").glob("event-*.png"))
assert final["coverage"]["data_status"] == "unavailable"
+ from dataclasses import asdict
+ from aircraft_geoloc.discovery import DiscoverySettings
+ receipt = json.loads((directory/"discovery/discovery.json").read_text())
+ assert receipt["settings"] == asdict(DiscoverySettings(**(discovery or {})))
+ assert len(receipt["chunks"]) > 1 if discovery else len(receipt["chunks"]) == 1
+ assert json.loads((directory/"operator.json").read_text()) == config
def test_corrupt_upload_returns_predictable_decode_failure(tmp_path):
@@ -204,3 +212,16 @@ def test_an_explicit_event_cap_is_incomplete_work_not_missing_flight_data():
assert coverage["search_complete"] is False
assert coverage["data_status"] == "available"
assert any("limit 3" in message for message in coverage["limitations"])
+
+
[email protected]("options", [None, {"min_frequency_hz": 400.}, {"chunk_s": "bad"},
+ {"chunk_s": 24., "overlap_s": 24.}])
+def test_invalid_operator_discovery_configuration_is_explicit(tmp_path, options):
+ from aircraft_geoloc.automatic import analyze
+ source = tmp_path/"unused.mp3"
+ source.write_bytes(b"configuration must fail before decode")
+ final = analyze({"schema_version": 1, "audio_path": str(source)}, tmp_path/"output",
+ {"discovery": options})
+ assert final["status"] == "failed"
+ assert final["reason_code"] == "invalid_configuration"
+ assert not (tmp_path/"output/intake").exists()
diff --git a/tests/test_service.py b/tests/test_service.py
index a34d92b..dcc6e9e 100644
--- a/tests/test_service.py
+++ b/tests/test_service.py
@@ -78,7 +78,8 @@ def test_terminal_result_survives_restart_and_interrupted_job_is_explicit(tmp_pa
def test_request_validation_upload_limits_and_paths(tmp_path, monkeypatch):
with running_server(tmp_path, monkeypatch) as (manager, url):
- for metadata in ({"schema_version": 1, "events": []}, {"schema_version": 1, "audio_path": "/etc/passwd"}):
+ for metadata in ({"schema_version": 1, "events": []}, {"schema_version": 1, "audio_path": "/etc/passwd"},
+ {"schema_version": 1, "discovery": {"chunk_s": 24., "overlap_s": 16.}}):
with pytest.raises(urllib.error.HTTPError) as error:
request(url + "/api/jobs", b"x", metadata)
assert error.value.code == 400