From 86fcb79ef0e96ba4deeebed4531d3f58d91703d6 Mon Sep 17 00:00:00 2001 From: kavemang <66108693+kavemang@users.noreply.github.com> Date: Sun, 11 Oct 2026 00:14:25 -0500 Subject: [PATCH] test(protocol): verify bundled schema decoder wiring Refs #2708 --- .../Sources/WhoopProtocol/WhoopProtocol.swift | 10 --------- .../Tests/WhoopProtocolTests/SmokeTests.swift | 21 ++++++++++++++++--- Tools/parity_ledger_baseline.json | 2 +- Tools/parity_twin_map.json | 8 +++---- 4 files changed, 23 insertions(+), 18 deletions(-) delete mode 100644 Packages/WhoopProtocol/Sources/WhoopProtocol/WhoopProtocol.swift diff --git a/Packages/WhoopProtocol/Sources/WhoopProtocol/WhoopProtocol.swift b/Packages/WhoopProtocol/Sources/WhoopProtocol/WhoopProtocol.swift deleted file mode 100644 index b9f3cc8b55..0000000000 --- a/Packages/WhoopProtocol/Sources/WhoopProtocol/WhoopProtocol.swift +++ /dev/null @@ -1,10 +0,0 @@ -import Foundation - -/// OpenWhoop protocol library — schema-driven WHOOP 4.0 frame decoder. -/// Implemented across Framing.swift / Values.swift / Schema.swift / Interpreter.swift (Phase B). -public enum WhoopProtocolInfo { - /// URL of the bundled canonical decode schema (a resource of this package target). - public static func schemaResourceURL() -> URL? { - Bundle.module.url(forResource: "whoop_protocol", withExtension: "json") - } -} diff --git a/Packages/WhoopProtocol/Tests/WhoopProtocolTests/SmokeTests.swift b/Packages/WhoopProtocol/Tests/WhoopProtocolTests/SmokeTests.swift index dba6be84c7..a0f735540b 100644 --- a/Packages/WhoopProtocol/Tests/WhoopProtocolTests/SmokeTests.swift +++ b/Packages/WhoopProtocol/Tests/WhoopProtocolTests/SmokeTests.swift @@ -2,8 +2,23 @@ import XCTest @testable import WhoopProtocol final class SmokeTests: XCTestCase { - func testSchemaResourceBundled() { - XCTAssertNotNil(WhoopProtocolInfo.schemaResourceURL(), - "whoop_protocol.json must be bundled in the WhoopProtocol target") + func testBundledSchemaLoadsAndWiresEveryPacketDecoder() throws { + // Exercise the loader used by parseFrame, including its post-hook registration. A resource URL + // alone cannot detect a schema that loads but silently skips a packet's dynamic fields. + let schema = loadSchema() + XCTAssertFalse(schema.envelope.isEmpty) + XCTAssertEqual(Set(schema.packets.keys), [ + "REALTIME_DATA", "REALTIME_RAW_DATA", "HISTORICAL_DATA", "EVENT", + "COMMAND_RESPONSE", "METADATA", "CONSOLE_LOGS", + ]) + + for (name, packet) in schema.packets { + XCTAssertEqual(schema.packet(forType: packet.type), packet, name) + for alias in packet.aliases { + XCTAssertEqual(schema.packet(forType: alias), packet, "\(name) alias \(alias)") + } + let hookName = try XCTUnwrap(packet.post, "\(name) needs its dynamic-field decoder") + XCTAssertNotNil(postHooks[hookName], "\(name) references an unregistered hook: \(hookName)") + } } } diff --git a/Tools/parity_ledger_baseline.json b/Tools/parity_ledger_baseline.json index 361e74c26a..9fbbdc2a3a 100644 --- a/Tools/parity_ledger_baseline.json +++ b/Tools/parity_ledger_baseline.json @@ -17,7 +17,7 @@ {"rule": "test-only-callsite", "scope": "Packages/OuraProtocol", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/OuraProtocol; no wildcard matching.", "count": 5, "identities_sha256": "ff6404cd4d27782334dd844223be3ec86bb3260bef7f7e29c658fb6ad6e7938e"}, {"rule": "test-only-callsite", "scope": "Packages/StrandAnalytics", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/StrandAnalytics; no wildcard matching.", "count": 44, "identities_sha256": "fff777acbc66e7dad92bd0a6c8b7644e5c7ab6ddc0a7106dfecc49319da6127b"}, {"rule": "test-only-callsite", "scope": "Packages/StrandImport", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/StrandImport; no wildcard matching.", "count": 14, "identities_sha256": "1acdc71178e0a555f000c42980345e8c38495f9e3806a866f31b260865d3ac98"}, - {"rule": "test-only-callsite", "scope": "Packages/WhoopProtocol", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/WhoopProtocol; no wildcard matching.", "count": 30, "identities_sha256": "a9dc115534e8710217db9cd39bcceaa1419741737bfd3b733007dc0215cd5af2"}, + {"rule": "test-only-callsite", "scope": "Packages/WhoopProtocol", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/WhoopProtocol; no wildcard matching.", "count": 29, "identities_sha256": "a13306c37eb1a9272b8666d09700d5120fb5fe0e629f3aaaeef649357f7f8b45"}, {"rule": "test-only-callsite", "scope": "Packages/WhoopStore", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope Packages/WhoopStore; no wildcard matching.", "count": 37, "identities_sha256": "2a62c1ece1c541b662dd407f0668d9a02782bb4d21f9bb181518272ff12f0e40"}, {"rule": "test-only-callsite", "scope": "android/analytics", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope android/analytics; no wildcard matching.", "count": 65, "identities_sha256": "fda58e5bb0fe07a9fa773d8e5f8961d483e8b177f1529b6e9dc3ac26df7c31cf"}, {"rule": "test-only-callsite", "scope": "android/data", "reason": "Exact declaration is reached only from tests in the conservative lexical call graph; dynamic, callback and external entry points are intentionally not inferred.", "provenance": "Exact identities emitted by parity_ledger rule test-only-callsite for current upstream scope android/data; no wildcard matching.", "count": 13, "identities_sha256": "6abaae19303cadccbe259d7db320850e269433472b28c84a1bfce7d32d54ce5f"}, diff --git a/Tools/parity_twin_map.json b/Tools/parity_twin_map.json index 6d97b4e14d..767e162915 100644 --- a/Tools/parity_twin_map.json +++ b/Tools/parity_twin_map.json @@ -18,16 +18,16 @@ ] }, "authority": { - "files": {"count": 510, "sha256": "b1c73338e79009d984d1313d8b3166e52672712c68074f5fee190c503e299b18"}, - "functions": {"count": 4538, "sha256": "f62a1ca0dfb2122fdca87a2f455ec0ca4435903c24069ae13bc4e75c0c3f32c0"}, + "files": {"count": 509, "sha256": "0a0b02d39eb26ad0635933ad6fca51fb4c33db98178410bfe6676ab9d0fdcaee"}, + "functions": {"count": 4537, "sha256": "a10084c830d9b91c0f02bb308fa7ac0f1466c7537de3303669e0f4fbeffdf6f2"}, "properties": {"count": 488, "sha256": "77d60fe0f6218252233b9e60da8bf5135968e49be3c6d2027d0973ea20ddf792"}, "constants": {"count": 2001, "sha256": "a9c1f36d2acc614dd747fd6cc0b3ea48079b81517afda5591d219f9591e353c3"}, "file_pairs": {"count": 81, "sha256": "3c94824ccff843da495a212a973d89ce61e536b6795dbee2d0e496a7e7a498f0"}, "function_pairs": {"count": 226, "sha256": "7c7f2298ad7921101241f39d86ecab774d21eadeb89d52d4d5db0397878905f2"}, "property_pairs": {"count": 163, "sha256": "b7d4a29086beec661993370657c0bcdae86f79b221fdc0043206161df5e1117f"}, "constant_pairs": {"count": 702, "sha256": "e3de4c1b84b8500c5700292648bf23dc680e5e14cde055c36c5d1ef4ecc39dc2"}, - "unpaired_files": {"count": 370, "sha256": "441451c8f68b68e1dc3d3556c28952b4bdac243de9d6f909d3c18d6ac9732a1e"}, - "unpaired_functions": {"count": 4099, "sha256": "3ee3e74d901e17225e294c309c1b00a7a5b178bb3164bff43eaaa5309d574169"}, + "unpaired_files": {"count": 369, "sha256": "3462a2a8135bfd793dc6493f10fb72b4fae9028ad9ec47c8dec84b9f5a4dc01a"}, + "unpaired_functions": {"count": 4098, "sha256": "a7c3215172bf4d1cd33b8df390684d4d65fc1109f8ee52b3d344b04d231f08fd"}, "unpaired_properties": {"count": 162, "sha256": "dabff97ba9bce0aebdc8ef84b9c4f107ce574020e8b0455d8f9214082948246b"}, "unpaired_constants": {"count": 597, "sha256": "578c607cc05b1cd1f867c206c9fab70237ac40707cd49d4e0c5cc66b400184c7"} }