AIS-5214: Clamp ending overlap in add/remove fold - #3
Merged
Conversation
beginningOverlap and endingOverlap were computed independently, so a
repeated boundary char (' ' vs ' ') counted toward both and
getNonOverlap over-trimmed, dropping a char from the change list's
original or modified projection.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DZPwQoG2HtFHPnTDvsncrR
Constructing trackers in the it.each table ran them at file load, so a throw would fail the whole file instead of one case. Also swap the emoji repro for ASCII: surrogate pairs play no part in the bug. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DZPwQoG2HtFHPnTDvsncrR
saghen
approved these changes
Sep 17, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
concatChanges(src/helpers.ts), which could drop a character from the change list.beginningOverlapandendingOverlapwere computed independently. When the boundary character repeats (' 'vs' '), the same character counted toward both, sogetNonOverlaptrimmed it twice.endingOverlapis now clamped tominLength - beginningOverlapwhere it is computed. The trailing common-suffix push already applied this clamp; the trim did not.tests/index.test.ts. Each pins the exactgetChanges()output and runsassertValidTracker.Repro (before this change)
' 0'.remove(2,3).add(2,'😊 ').remove(0,5)[' ', [1,'0']]' 0'' 0''aa'.add(0,'aaa').remove(3,5)['aa']'aa''aaa''aab'.add(0,'ab').remove(2,5)['ab']'ab''aab'Impact
getChangeChunks(). Chunk lengths are derived from the change list, so index mapping on those rehydrated trackers can be skewed.Test plan
npm test: 180/180 passnpm run fuzz: 5000 iterations passnpm run buildsucceedsFollow-up
v1.4.3after merge.ai-platformtts-service/pkg/stringtracker): apply the same clamp, add the 3 cases as fixtures, regenerate the golden oracle, and bump@speechifyinc/string-trackerin audio-server.🤖 Generated with Claude Code
https://claude.ai/code/session_01DZPwQoG2HtFHPnTDvsncrR