fix(mobile/ios): reject events below composite cursor

Co-authored-by: npub1tquskdu6yc4h8l7xxtceculxw600grekeq0xg2ukqfrwl7vrzg3quz3gmp <58390b379a262b73ffc632f19c73e6769ef40f36c81e642b960246eff9831222@buzz.block.builderlab.xyz>
Signed-off-by: npub1tquskdu6yc4h8l7xxtceculxw600grekeq0xg2ukqfrwl7vrzg3quz3gmp <58390b379a262b73ffc632f19c73e6769ef40f36c81e642b960246eff9831222@buzz.block.builderlab.xyz>
Co-authored-by: Cursor <noreply@cursor.com>
Ai-assisted: true
This commit is contained in:
npub1tquskdu6yc4h8l7xxtceculxw600grekeq0xg2ukqfrwl7vrzg3quz3gmp
2026-07-27 20:20:31 -07:00
co-authored by Cursor
parent 1598cf0f06
commit b20d3114cb
3 changed files with 21 additions and 1 deletions
+1
View File
@@ -9,6 +9,7 @@
.tags*
**/.vagrant/
**/DerivedData/
BuzzPushKit/Package.resolved
Icon?
**/Pods/
**/.symlinks/
@@ -112,7 +112,7 @@ public struct PushConsumptionState: Codable, Equatable, Sendable {
) -> Bool {
let originState = state(for: origin)
return position.createdAt <= now + allowedFutureSkew
&& position.createdAt >= (originState.cursor?.createdAt ?? position.createdAt)
&& position >= (originState.cursor ?? position)
&& !originState.contains(eventID: position.id)
}
@@ -44,6 +44,25 @@ final class PushConsumptionStateTests: XCTestCase {
XCTAssertEqual(state.state(for: "origin").delivered.count, 64)
}
func testEvictedDeliveredEventBelowCompositeCursorIsNeverSelectedAgain() {
var state = PushConsumptionState()
for index in 0..<70 {
state.consume(
PushEventPosition(createdAt: 1_000, id: String(format: "%064x", index)),
for: "origin"
)
}
let evicted = PushEventPosition(createdAt: 1_000, id: String(format: "%064x", 0))
let sameSecondSuccessor = PushEventPosition(
createdAt: 1_000,
id: String(format: "%064x", 70)
)
XCTAssertFalse(state.hasConsumed(eventID: evicted.id, for: "origin"))
XCTAssertFalse(state.canSelect(evicted, for: "origin", now: 2_000))
XCTAssertTrue(state.canSelect(sameSecondSuccessor, for: "origin", now: 2_000))
}
func testEventOlderThanCompositeCursorIsNotSelected() {
var state = PushConsumptionState()
state.consume(PushEventPosition(createdAt: 2_000, id: "newer"), for: "origin")