Skip to content

refactor: [SDK-4911] rebuild OperationRepo unmatched delta queue on flush - #1693

Merged
nan-li merged 2 commits into
mainfrom
nan/fix-flush-delta-queue-iteration
Jul 31, 2026
Merged

refactor: [SDK-4911] rebuild OperationRepo unmatched delta queue on flush#1693
nan-li merged 2 commits into
mainfrom
nan/fix-flush-delta-queue-iteration

Conversation

@nan-li

@nan-li nan-li commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Refactors OSOperationRepo.flushDeltaQueue to rebuild deltaQueue as the list of unmatched deltas instead of removing matched entries while iterating.
  • Same keep-until-executor-available semantics; clearer than for-in + remove(at:) on the same array (Swift Array value semantics make the old loop safe, not undefined behavior).

Test plan

  • OSOperationRepoFlushTests: matched deltas dispatch and clear the repo queue; unmatched stay queued in order.
  • Deterministic interleaved matched/unmatched case asserts dispatched deltas and retained queue order.
  • Existing UserConcurrencyTests.testOperationRepoFlushingConcurrency still relevant (Full plan); it does not assert this routing behavior.

Rebuilding the unmatched list avoids for-in + remove(at:) on the same
array, which could crash or skip deltas.

Co-Authored-By: Cursor <cursoragent@cursor.com>
@nan-li
nan-li force-pushed the nan/fix-flush-delta-queue-iteration branch from 13d214f to 29ce8ad Compare July 27, 2026 15:46
@nan-li nan-li changed the title fix: stop mutating OperationRepo deltaQueue during flush fix: [SDK-4911] stop mutating OperationRepo deltaQueue during flush Jul 27, 2026
@nan-li
nan-li requested a review from a team July 27, 2026 15:47

@fadi-george fadi-george left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add tests?

@nan-li

nan-li commented Jul 30, 2026

Copy link
Copy Markdown
Contributor Author

Added tests

@nan-li nan-li changed the title fix: [SDK-4911] stop mutating OperationRepo deltaQueue during flush refactor: [SDK-4911] rebuild OperationRepo unmatched delta queue on flush Jul 30, 2026
Co-Authored-By: Cursor <cursoragent@cursor.com>
@nan-li
nan-li force-pushed the nan/fix-flush-delta-queue-iteration branch from 130805d to e2eb189 Compare July 30, 2026 16:32
@nan-li
nan-li merged commit 6a37a52 into main Jul 31, 2026
2 of 3 checks passed
@nan-li
nan-li deleted the nan/fix-flush-delta-queue-iteration branch July 31, 2026 06:52
@github-actions github-actions Bot mentioned this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants