Fix inclusive bounds handling in Position encoding #70
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fix inclusive bounds handling in Position encoding
Summary
Fixed a critical bug in the aggregate component where the
inclusive
argument for bounds was not being respected. The issue was in the Position encoding system insrc/client/positions.ts
where the Position type had an incorrect structure that wasn't properly encoding inclusive/exclusive boundary behavior.Key Changes:
Position
type from[Key, string | null | never[], "" | null | never[]]
to[Key, string | null | never[]]
boundToPosition
function to correctly encode inclusive/exclusive behavior using the ID field withBEFORE_ALL_IDS
(null) andAFTER_ALL_IDS
([]) markersRoot Cause: The previous Position encoding used a third element to encode inclusive/exclusive behavior, but the comparison logic in the B-tree wasn't properly interpreting these markers, causing all bounds to be treated as inclusive.
Fix: Moved the inclusive/exclusive encoding into the ID field (second element) where the existing comparison logic already handles null vs [] ordering correctly.
Review & Testing Checklist for Human
Testing Plan
Diagram
Notes