From ba352c87998999371dc3aedfbc3da7b71a1da81d Mon Sep 17 00:00:00 2001 From: r3dbars Date: Sun, 10 May 2026 00:44:19 -0500 Subject: [PATCH] Lock runtime diagnostics context keys --- Tests/RuntimeDiagnosticsStoreTests.swift | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Tests/RuntimeDiagnosticsStoreTests.swift b/Tests/RuntimeDiagnosticsStoreTests.swift index 639c5c43..1e1c03f0 100644 --- a/Tests/RuntimeDiagnosticsStoreTests.swift +++ b/Tests/RuntimeDiagnosticsStoreTests.swift @@ -29,6 +29,25 @@ func testRuntimeDiagnosticsStore() { assertEqual(context["session_duration_bucket"], "1_4m", "context should bucket previous session duration") assertEqual(context["session_kind"], "dictation", "context should keep coarse session kind") assertEqual(context["session_stage"], "recording", "context should keep coarse session stage") + assertEqual( + Set(context.keys), + [ + "app_version", + "build_version", + "heartbeat_age_bucket", + "last_event", + "os_major", + "session_active", + "session_duration_bucket", + "session_kind", + "session_stage", + ], + "unclean shutdown context should stay limited to previous-session runtime keys" + ) + assertNil(context["previous_clean_shutdown"], "unclean shutdown context should not include current-session-only clean state") + assertNil(context["launch_id"], "launch IDs should not leak into unclean shutdown context") + assertNil(context["started_at"], "raw start timestamps should not leak into unclean shutdown context") + assertNil(context["updated_at"], "raw heartbeat timestamps should not leak into unclean shutdown context") } runSuite("RuntimeDiagnosticsStore builds current Sentry runtime context") {