Skip to content

[WIP, AIT-287] Implement new rules for discarding buffered object operations#112

Closed
lawrence-forooghian wants to merge 4 commits intomainfrom
AIT-287-new-rules-for-discarding-buffered-events
Closed

[WIP, AIT-287] Implement new rules for discarding buffered object operations#112
lawrence-forooghian wants to merge 4 commits intomainfrom
AIT-287-new-rules-for-discarding-buffered-events

Conversation

@lawrence-forooghian
Copy link
Collaborator

@lawrence-forooghian lawrence-forooghian commented Jan 21, 2026

Implements ably/specification@997584f. Integration tests ported from ably/ably-js@9b2224d.

@coderabbitai
Copy link

coderabbitai bot commented Jan 21, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: e1b7753e-bc37-422e-ace8-ee0d2502418b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch AIT-287-new-rules-for-discarding-buffered-events

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 14:49 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 11de235 to 5e0c796 Compare January 21, 2026 17:06
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 17:08 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 5e0c796 to 45e17cd Compare January 21, 2026 17:15
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 17:16 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 45e17cd to 18a9f76 Compare January 21, 2026 17:47
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 17:48 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch 2 times, most recently from a9c8eef to 83643ca Compare January 21, 2026 17:56
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 17:57 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 83643ca to 6125bf0 Compare January 21, 2026 18:34
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 18:35 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 6125bf0 to 4942c24 Compare January 21, 2026 19:15
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 19:17 Inactive
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 4942c24 to b8a86e8 Compare January 21, 2026 20:31
@github-actions github-actions bot temporarily deployed to staging/pull/112/AblyLiveObjects January 21, 2026 20:33 Inactive
@lawrence-forooghian lawrence-forooghian changed the title [AIT-287] Implement new rules for discarding buffered object operations [WIP, AIT-287] Implement new rules for discarding buffered object operations Feb 26, 2026
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from b8a86e8 to 4049153 Compare February 26, 2026 20:30
lawrence-forooghian and others added 4 commits March 3, 2026 22:23
Instead of waiting for the server to echo back an operation before
applying it locally, operations are now applied immediately upon
receiving the ACK from Realtime.

Implements the behaviours from spec commit 56a0bba and ports the
corresponding integration tests from ably-js commit 6b1c2de, plus the
test fix in ably-js commit f9fbe8e (from [1]).

[1] ably/ably-js#2175

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port of ably-js commit b329fd2. Verifies that when an ATTACHED message
is received without the HAS_OBJECTS flag, the SDK clears all local
LiveObjects state (root map should have no keys).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Per spec commit 997584f, buffered object operations must now be
cleared on every ATTACHED message (new RTO4d), rather than when a
new OBJECT_SYNC sequence starts (old RTO5a2b) or in the
no-HAS_OBJECTS path specifically (old RTO4b5).

The key insight is that on ATTACHED, either:
- HAS_OBJECTS is set, meaning the subsequent sync sequence includes
  all operations up to the attach point, making previously buffered
  operations redundant
- HAS_OBJECTS is not set, meaning the client performs an implicit
  sync and clears local state anyway

Production changes:
- nosync_onChannelAttached: replace `if` with `switch` to clear
  buffer on every ATTACHED (RTO4d), even when already SYNCING
- nosync_handleObjectSyncProtocolMessage: stop clearing buffer on
  new sync sequence (RTO5a2b replaced by RTO4d)

Test changes:
- doesNotModifyStateWhenHasObjectsIsTrue: renamed, now asserts
  buffer is cleared (RTO4d) whilst pool and sync sequence remain
  unchanged
- newSequenceIdDiscardsInFlightSync: removed RTO5a2b annotation
  and buffered ops assertion, now only covers RTO5a2a

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Port four test cases from ably-js commit 9b2224d that verify the
updated buffered object operations clearing behaviour:

1. bufferedObjectOperationsAreDiscardedOnAttached — starts a sync
   sequence, injects an operation, receives ATTACHED, injects
   another operation, completes sync, verifies only the
   post-ATTACHED operation was applied

2. bufferedObjectOperationsAreDiscardedWhenAlreadySyncingChannel-
   ReceivesAttached — already SYNCING, injects an operation,
   receives another ATTACHED, injects another operation, completes
   sync, verifies only the post-ATTACHED operation was applied

3. bufferedObjectOperationsAreNotDiscardedOnNewObjectSyncSequence
   — starts a sync, injects an operation, starts a new sync with
   a different sequence ID, injects another operation, completes
   the second sync, verifies BOTH operations were applied (buffer
   was NOT cleared by the new sequence)

4. operationsAreBufferedDuringResyncWithoutPrecedingAttached —
   completes a sync, then receives OBJECT_SYNC without a preceding
   ATTACHED, verifies operations are buffered during the resync
   and applied upon completion

Also adds a testsOnly_bufferedObjectOperationsCount accessor to
support direct assertions on buffer state in these tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@lawrence-forooghian lawrence-forooghian force-pushed the AIT-287-new-rules-for-discarding-buffered-events branch from 4049153 to f736ce8 Compare March 5, 2026 16:34
@lawrence-forooghian lawrence-forooghian removed the request for review from ttypic March 5, 2026 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant