Skip to content

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

Verify baseline bytes in isolated chunk replays

Cinna Davise89d1237b736
diff --git a/scripts/run_real_metamorphic.py b/scripts/run_real_metamorphic.py
index 508db22..aa1a1b9 100644
--- a/scripts/run_real_metamorphic.py
+++ b/scripts/run_real_metamorphic.py
@@ -795,6 +795,12 @@ def run(plan_path, output, *, selected_case=None):
try:
canonical, reference = make_canonical(plan["source"]["path"], output, plan["protocol"])
write_json(output / "canonical.json", identity(canonical))
+ baseline_input = None
+ if selected_case and selected_case.startswith("chunks_"):
+ baseline = next(case for case in plan["cases"] if case["id"] == "baseline")
+ baseline_dir = output / "baseline-encoding"
+ baseline_dir.mkdir()
+ baseline_input = identity(encode(canonical, baseline_dir, baseline["encoding"], plan["protocol"]))
for case, row in zip(plan["cases"], state["cases"]):
if selected_case and case["id"] != selected_case:
row["state"] = "not_selected"
@@ -819,8 +825,11 @@ def run(plan_path, output, *, selected_case=None):
and (native["channels"] != 2 or native["identical_channel_max_difference"] == 0.0))}
except Exception as exc:
row["usability"] = {"passed": False, "error": f"{type(exc).__name__}: {exc}"}
- baseline_input = state["cases"][0].get("encoded_input")
- if case["id"].startswith("chunks_") and baseline_input:
+ if case["id"] == "baseline":
+ baseline_input = row["encoded_input"]
+ if case["id"].startswith("chunks_"):
+ if baseline_input is None:
+ raise ValueError("Chunk input cannot be verified without the baseline encoding")
same_input = row["encoded_input"]["sha256"] == baseline_input["sha256"]
row["usability"]["chunk_input_matches_baseline"] = same_input
row["usability"]["passed"] = bool(row["usability"]["passed"] and same_input)
diff --git a/tests/test_real_metamorphic_runner.py b/tests/test_real_metamorphic_runner.py
index d87d7c2..e24c5fa 100644
--- a/tests/test_real_metamorphic_runner.py
+++ b/tests/test_real_metamorphic_runner.py
@@ -93,3 +93,25 @@ def test_actual_recorded_clip_encoding_and_padding_contract(tmp_path):
assert metrics["identical_channel_max_difference"] == 0
assert metrics["first_packet"]
# Transform contracts are not full-pipeline or one-hour matrix evidence.
+
+
[email protected]("case_id", ["chunks_60_30", "chunks_180_60"])
+def test_chunk_only_replay_compares_actual_baseline(tmp_path, case_id):
+ audio = os.environ.get("DOPPLERGEIST_REAL_METAMORPHIC_AUDIO")
+ request = os.environ.get("DOPPLERGEIST_REAL_METAMORPHIC_REQUEST")
+ operator = os.environ.get("DOPPLERGEIST_REAL_METAMORPHIC_OPERATOR")
+ if not all((audio, request, operator)):
+ pytest.skip("Set real recording, request and offline operator paths")
+ plan = runner.prepare(audio, json.loads(Path(request).read_text()),
+ json.loads(Path(operator).read_text()), tmp_path / "plan",
+ source_note="Real recorded input for chunk replay control",
+ scope_note="Offline single-arm software check, not a localization test",
+ job_max_runtime_s=15, http_timeout_s=40)
+ output = tmp_path / "run"
+ runner.run(plan, output, selected_case=case_id)
+ state = json.loads((output / "state.json").read_text())
+ row = next(item for item in state["cases"] if item["id"] == case_id)
+ assert state["state"] == "finished" and row["state"] == "finished"
+ assert row["usability"]["chunk_input_matches_baseline"] is True
+ baseline = next((output / "baseline-encoding").glob("*.mp3"))
+ assert runner.identity(baseline)["sha256"] == row["encoded_input"]["sha256"]