diff --git a/backend/apps/service/client.py b/backend/apps/service/client.py index 951a79b9..fc537fde 100644 --- a/backend/apps/service/client.py +++ b/backend/apps/service/client.py @@ -400,6 +400,8 @@ def submit_diagnostic(diagnostic: dict) -> None: # is deliberately capturing, so only the sink-less case is blocked. if os.environ.get("PYTEST_CURRENT_TEST") and test_sink is None: return + # The build that wrote an envelope is the first thing a field read needs, and it used to be inferred from which fields were present. + diagnostic.setdefault("app_version", APP_VERSION) try: from backend.apps.service.ring_buffer import snapshot diagnostic["recent_log"] = snapshot() diff --git a/backend/tests/test_service.py b/backend/tests/test_service.py index bc9085fb..b7dc4f91 100644 --- a/backend/tests/test_service.py +++ b/backend/tests/test_service.py @@ -214,6 +214,16 @@ def test_legacy_submit_diagnostic(sink): assert len(sink) == 1 +def test_every_diagnostic_carries_the_app_version(sink): + # Alex's -11 crashes (2026-09-04) had to be dated to a build by which envelope FIELDS they carried; the version rides every envelope now. + from backend.apps.service.client import submit_diagnostic + from backend.apps.service.version import APP_VERSION + submit_diagnostic({"kind": "model_error"}) + _, body = sink[0] + assert body["d"]["diagnostic"]["app_version"] == APP_VERSION + assert APP_VERSION and APP_VERSION != "unknown" + + # --- spool ------------------------------------------------------------------- def test_buffer_enqueue_and_drain(tmp_path):