@@ -114,7 +114,7 @@ struct WatchApprovalTransportSourceGuardTests {
114114 " WatchGatewayID.key(snapshot.gatewayStableID) == WatchGatewayID.key(token.gatewayStableID) " ) )
115115 }
116116
117- @ Test func `watch applies retry reset only to its exact active attempt` ( ) throws {
117+ @ Test func `retry reset matches the exact active attempt` ( ) throws {
118118 let storeSource = try Self . readWatchSource ( " WatchInboxStore.swift " )
119119 let promptConsume = try Self . extract (
120120 storeSource ,
@@ -125,23 +125,11 @@ struct WatchApprovalTransportSourceGuardTests {
125125 from : " private func upsertExecApproval( " ,
126126 to : " private static func snapshotCanReplace( " )
127127
128- let guardedUpsert = try #require ( promptConsume . range ( of : " guard self.upsertExecApproval( " ) )
129- let notificationOwnerCheck = try #require ( promptConsume . range ( of : " guard let approvalOwnerKey " ) )
130- #expect ( guardedUpsert . lowerBound < notificationOwnerCheck . lowerBound )
131- let upsertAdmission = promptConsume [ guardedUpsert . lowerBound ..< notificationOwnerCheck . lowerBound ]
132- #expect ( upsertAdmission . contains ( " else { return } " ) )
133- #expect ( upsert . contains ( " resetResolutionAttemptID: String? = nil) -> Bool " ) )
134- #expect ( upsert . components ( separatedBy : " return false " ) . count >= 3 )
135- #expect ( upsert . contains ( " return true " ) )
136- #expect ( promptConsume . contains (
137- " resetResolutionAttemptID: message.resetResolutionAttemptId " ) )
138- #expect ( upsert . contains ( " let activeResolutionAttemptID = " ) )
128+ #expect ( promptConsume . contains ( " resetResolutionAttemptID: message.resetResolutionAttemptId " ) )
129+ #expect ( upsert . contains ( " resetResolutionAttemptID: String? = nil " ) )
139130 #expect ( upsert . contains (
140131 " WatchOpaqueUTF8Key(resetResolutionAttemptID) == WatchOpaqueUTF8Key(activeResolutionAttemptID) " ) )
141132 #expect ( upsert . contains ( " activeResolutionAttemptID = resetResolvingState ? nil " ) )
142- #expect ( ! storeSource . contains ( " appliedResetDeliveryIDs " ) )
143- #expect ( ! storeSource . contains ( " deliveryId " ) )
144- #expect ( ! storeSource . contains ( " resetResolvingState: Bool? " ) )
145133 }
146134
147135 @ Test func `watch rejects partial or missing approval snapshot arrays` ( ) throws {
@@ -290,80 +278,35 @@ struct WatchApprovalTransportSourceGuardTests {
290278 #expect ( detailScroll . contains ( " self.content " ) )
291279 }
292280
293- @ Test func `watch notification identity frames dotted components ` ( ) throws {
281+ @ Test func `notification identity keeps dotted owners distinct ` ( ) throws {
294282 let storeSource = try Self . readWatchSource ( " WatchInboxStore.swift " )
295- let messagesSource = try Self . readWatchSource ( " WatchInboxMessages.swift " )
296- let identifierSource = try Self . readIOSServiceSource ( " ExactOpaqueIdentifier.swift " )
297- let promptConsume = try Self . extract (
298- storeSource ,
299- from : " func consume( \n execApprovalPrompt " ,
300- to : " func consume( \n execApprovalSnapshot " )
301- let rawLeft = " a.b " + " . " + " c "
302- let rawRight = " a " + " . " + " b.c "
303- #expect ( rawLeft == rawRight )
304-
305- let framedLeft = ExactOpaqueIdentifierKey ( " a.b " ) . notificationComponent + " . "
283+ let left = ExactOpaqueIdentifierKey ( " a.b " ) . notificationComponent + " . "
306284 + ExactOpaqueIdentifierKey ( " c " ) . notificationComponent
307- let framedRight = ExactOpaqueIdentifierKey ( " a " ) . notificationComponent + " . "
285+ let right = ExactOpaqueIdentifierKey ( " a " ) . notificationComponent + " . "
308286 + ExactOpaqueIdentifierKey ( " b.c " ) . notificationComponent
309- #expect ( framedLeft != framedRight )
310- #expect ( messagesSource . contains ( " typealias WatchOpaqueUTF8Key = ExactOpaqueIdentifierKey " ) )
311- #expect ( identifierSource . contains ( " 0x2D, 0x5F, 0x7E " ) )
312- #expect ( ! identifierSource . contains ( " 0x2D, 0x2E, 0x5F, 0x7E " ) )
313- #expect ( ! storeSource . contains ( " 0x2D, 0x2E, 0x5F, 0x7E " ) )
287+
288+ #expect ( left != right )
314289 #expect ( storeSource . contains ( " gatewayKey.notificationComponent). \\ (approvalKey.notificationComponent " ) )
315- #expect ( storeSource . contains ( " legacyExecApprovalNotificationIdentifier " ) )
316- #expect ( storeSource . contains ( " hasLiveLegacyNotificationCollision " ) )
290+ #expect ( storeSource . contains ( " !self.hasLiveLegacyNotificationCollision( " ) )
317291 #expect ( storeSource . contains ( " recordKey != excludedKey " ) )
318- let legacyCleanup = try #require (
319- promptConsume . range ( of : " if let legacyNotificationIdentifier " ) )
320- let notificationSchedule = try #require (
321- promptConsume . range ( of : " await self.postLocalNotification( " ) )
322- #expect ( legacyCleanup . lowerBound < notificationSchedule . lowerBound )
323- #expect ( promptConsume . contains ( " !self.hasLiveLegacyNotificationCollision( " ) )
324- #expect ( promptConsume . contains (
325- " self.removeLocalNotifications(identifiers: [legacyNotificationIdentifier]) " ) )
326292 }
327293
328- @ Test func `watch snapshot acknowledgment advances only after store acceptance` ( ) throws {
294+ @ Test func `snapshot acknowledgment follows store acceptance` ( ) throws {
329295 let storeSource = try Self . readWatchSource ( " WatchInboxStore.swift " )
330296 let receiverSource = try Self . readWatchSource ( " WatchConnectivityReceiver.swift " )
331297 let snapshotConsume = try Self . extract (
332298 storeSource ,
333299 from : " func consume( \n execApprovalSnapshot " ,
334300 to : " func consume(appSnapshot " )
335- let replay = try Self . extract (
336- storeSource ,
337- from : " func replayDeferredGatewayPayloads() " ,
338- to : " private func clearMessagePrompt() " )
339- let correlation = try #require ( snapshotConsume . range ( of : " let hasCanonicalRequestCorrelation " ) )
340- let ownerValidation = try #require ( snapshotConsume . range ( of : " let allApprovalOwnersMatch " ) )
341- let existingRecords = try #require ( snapshotConsume . range ( of : " let existingRecords = self.execApprovals " ) )
342301
343302 #expect ( snapshotConsume . contains ( " transport: String) -> Bool " ) )
344- #expect ( snapshotConsume . components ( separatedBy : " return false " ) . count >= 4 )
303+ #expect ( snapshotConsume . contains ( " guard allApprovalOwnersMatch else { return false } " ) )
345304 #expect ( snapshotConsume . contains ( " self.persistState() \n return true " ) )
346305 #expect ( receiverSource . contains (
347306 " if self.store.consume(execApprovalSnapshot: execApprovalSnapshot, transport: transport) " ) )
348307 #expect ( receiverSource . contains (
349308 " if self.store.consume(execApprovalSnapshot: snapshot, transport: transport) " ) )
350- #expect ( replay . contains (
351- " func replayDeferredGatewayPayloads() -> [WatchExecApprovalSnapshotMessage] " ) )
352- #expect ( replay . contains (
353- " var appliedExecApprovalSnapshots: [WatchExecApprovalSnapshotMessage] = [] " ) )
354- #expect ( replay . contains ( " if self.consume(execApprovalSnapshot: message, transport: transport) " ) )
355- #expect ( replay . contains ( " appliedExecApprovalSnapshots.append(message) " ) )
356- #expect ( replay . contains ( " return appliedExecApprovalSnapshots " ) )
357- #expect ( receiverSource . components (
358- separatedBy : " for snapshot in self.store.replayDeferredGatewayPayloads() " ) . count == 3 )
359- #expect ( receiverSource . components (
360- separatedBy : " self.recordAcceptedExecApprovalSnapshot(snapshot) " ) . count >= 3 )
361- #expect ( ! receiverSource . contains ( " execApprovalSnapshotRevision " ) )
362- #expect ( correlation . lowerBound < ownerValidation . lowerBound )
363- #expect ( ownerValidation . lowerBound < existingRecords . lowerBound )
364- #expect ( snapshotConsume . contains ( " guard allApprovalOwnersMatch else { return false } " ) )
365- #expect ( snapshotConsume . contains (
366- " Self.gatewayIDsMatch(approval.gatewayStableID, snapshotGatewayID) " ) )
309+ #expect ( receiverSource . contains ( " if self.consume(execApprovalSnapshot: message, transport: transport) " ) )
367310 }
368311
369312 private static func readWatchSource ( _ filename : String ) throws -> String {
@@ -375,15 +318,6 @@ struct WatchApprovalTransportSourceGuardTests {
375318 return try String ( contentsOf : url , encoding : . utf8 )
376319 }
377320
378- private static func readIOSServiceSource ( _ filename : String ) throws -> String {
379- let url = URL ( fileURLWithPath : #filePath )
380- . deletingLastPathComponent ( )
381- . deletingLastPathComponent ( )
382- . appendingPathComponent ( " Sources/Services " )
383- . appendingPathComponent ( filename )
384- return try String ( contentsOf : url , encoding : . utf8 )
385- }
386-
387321 private static func extract ( _ source : String , from start : String , to end : String ) throws -> String {
388322 let startRange = try #require ( source . range ( of : start ) )
389323 let tail = source [ startRange . lowerBound ... ]
0 commit comments