[AIT-454] Implement MAP_CLEAR operation#122
[AIT-454] Implement MAP_CLEAR operation#122lawrence-forooghian wants to merge 2 commits intointegration/protocol-v6from
MAP_CLEAR operation#122Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThis pull request adds support for a MAP_CLEAR operation to the Live Objects protocol, introducing a Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
📝 Coding Plan
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
15f8798 to
826195e
Compare
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (3)
Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift (1)
504-512: Move the access modifier to the extension declaration.Line 504 adds a new non-test Swift extension without an explicit ACL on the extension itself, and the members then repeat
internal.♻️ Suggested cleanup
-extension WireMapClear: WireObjectCodable { - internal init(wireObject _: [String: WireValue]) throws(ARTErrorInfo) { +internal extension WireMapClear: WireObjectCodable { + init(wireObject _: [String: WireValue]) throws(ARTErrorInfo) { // No fields to decode } - internal var toWireObject: [String: WireValue] { + var toWireObject: [String: WireValue] { [:] } }As per coding guidelines,
**/*.swift: Specify an explicit access control level (SwiftLint explicit_acl) for all declarations in Swift code (tests are exempt)andWhen extending a type, put the access level on the extension declaration rather than on each member (tests are exempt)`.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift` around lines 504 - 512, The extension for WireMapClear declares members with the internal ACL; move the access control to the extension itself by declaring the extension as internal (e.g. internal extension WireMapClear: WireObjectCodable) and remove the redundant internal modifiers from the initializer init(wireObject _: [String: WireValue]) throws(ARTErrorInfo) and the computed property toWireObject so the extension-level ACL applies to both members.Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift (1)
535-544: Consider surfacingclearTimeserialin the higher-level map factories too.
objectsMap(...)now understands the new field, butmapObjectState(...)/mapObjectMessage(...)still can't build a cleared map directly, so tests already have to drop down toobjectState(map:).🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift` around lines 535 - 544, Add a clearTimeserial parameter to the higher-level map factories so tests can build cleared maps without calling objectState(map:); update mapObjectState(...) and mapObjectMessage(...) signatures to accept clearTimeserial: String? (default nil) and pass it through when creating the underlying ObjectsMap via objectsMap(semantics:entries:clearTimeserial:) or when calling objectState(map:), and update any internal calls to preserve the new argument so existing callers remain backwards-compatible.Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift (1)
167-202: Cover the new wire opcode with a round-trip test.These assertions only prove that
mapClearcan be decoded when the field is present. Because the fixture still usesaction: 0, they won't catch a broken MAP_CLEAR raw value or an omitted"mapClear": [:]on encode.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift` around lines 167 - 202, Add a round-trip test that constructs a WireObjectOperation with the MAP_CLEAR opcode (use the enum case .mapClear or its raw value instead of action: 0) and a "mapClear": [:] field, then encode it to the wire dictionary and decode it back asserting action == .known(.mapClear), objectId matches, and mapClear is present; place this alongside or as a new test (e.g., in WireObjectMessageTests/WireObjectOperation tests) so encode+decode will catch any broken MAP_CLEAR raw value or omitted mapClear on encode.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swift`:
- Around line 470-471: When zeroing the map, also clear the persisted RTLM25
serial: set clearTimeserial = nil inside the map-reset paths so stale serials
aren’t retained. Update the resetData(userCallbackQueue:) implementation and
resetDataToZeroValued() (and any other zero-root code path that currently resets
map contents) to explicitly assign clearTimeserial = nil immediately after the
map/state is cleared so subsequent MAP_SET/MAP_REMOVE/MAP_CLEAR operations use a
fresh serial.
---
Nitpick comments:
In `@Sources/AblyLiveObjects/Protocol/WireObjectMessage.swift`:
- Around line 504-512: The extension for WireMapClear declares members with the
internal ACL; move the access control to the extension itself by declaring the
extension as internal (e.g. internal extension WireMapClear: WireObjectCodable)
and remove the redundant internal modifiers from the initializer init(wireObject
_: [String: WireValue]) throws(ARTErrorInfo) and the computed property
toWireObject so the extension-level ACL applies to both members.
In `@Tests/AblyLiveObjectsTests/Helpers/TestFactories.swift`:
- Around line 535-544: Add a clearTimeserial parameter to the higher-level map
factories so tests can build cleared maps without calling objectState(map:);
update mapObjectState(...) and mapObjectMessage(...) signatures to accept
clearTimeserial: String? (default nil) and pass it through when creating the
underlying ObjectsMap via objectsMap(semantics:entries:clearTimeserial:) or when
calling objectState(map:), and update any internal calls to preserve the new
argument so existing callers remain backwards-compatible.
In `@Tests/AblyLiveObjectsTests/WireObjectMessageTests.swift`:
- Around line 167-202: Add a round-trip test that constructs a
WireObjectOperation with the MAP_CLEAR opcode (use the enum case .mapClear or
its raw value instead of action: 0) and a "mapClear": [:] field, then encode it
to the wire dictionary and decode it back asserting action == .known(.mapClear),
objectId matches, and mapClear is present; place this alongside or as a new test
(e.g., in WireObjectMessageTests/WireObjectOperation tests) so encode+decode
will catch any broken MAP_CLEAR raw value or omitted mapClear on encode.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: e50b0da5-1be4-4c6f-954e-15a37b1eda23
📒 Files selected for processing (8)
Sources/AblyLiveObjects/Internal/InternalDefaultLiveMap.swiftSources/AblyLiveObjects/Internal/InternalDefaultRealtimeObjects.swiftSources/AblyLiveObjects/Protocol/ObjectMessage.swiftSources/AblyLiveObjects/Protocol/WireObjectMessage.swiftTests/AblyLiveObjectsTests/Helpers/TestFactories.swiftTests/AblyLiveObjectsTests/InternalDefaultLiveMapTests.swiftTests/AblyLiveObjectsTests/InternalDefaultRealtimeObjectsTests.swiftTests/AblyLiveObjectsTests/WireObjectMessageTests.swift
826195e to
02b4ec1
Compare
02b4ec1 to
f7bc82d
Compare
456fcad to
6d0df37
Compare
6d0df37 to
a4cc108
Compare
a4cc108 to
2c20981
Compare
2c20981 to
21ff573
Compare
21ff573 to
88e3fa9
Compare
88e3fa9 to
ff67818
Compare
Make everything go via a single method that implements the RTLM4 definition.
Per spec commit a9f839b. Integration tests ported from JS commit d2ddac6. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ff67818 to
99fe9ba
Compare
Implements the
MAP_CLEARoperation as specified in ably/specification#432. Integration tests ported from ably/ably-js#2176.Summary by CodeRabbit
New Features
Tests