Repository navigation
fix: surrogate-pair-safe text excerpts — #1615 fingerprint line + family ratchet - #1626
Merged
Merged
Conversation
…ting UTF-16 pairs (#1615) summaryFingerprintLine sliced on raw code units; a cut landing inside a surrogate pair left a lone half that JSON.stringify emits as an unpaired escape, so strict upstreams reject the whole request body. The receipt rides every turn once in history, upgrading the deterministic failure of #816/#828 into permanent session death. - src/text-safe.ts: shared safePrefix/safeSuffix/scrubLoneSurrogates (decompress-shared.ts now reuses it instead of its local copy) - stream.ts fingerprint + compress-loop-responses/loop-core log head/tail + server.ts secret mask: all string excerpts go through the clamp - family gate test: raw .slice(-N) on strings is ratcheted out of src/ (allowlist: array receivers + text-safe itself) Fixes #1615
Contributor
📦 Built Package ArtifactBranch: Option A — Install this exact build (recommended)npm install -g billion-context@0.0.1569-pr.1626.bf3be41This exact version is immutable and reproducible. The rolling Option B — Download artifact
tar xzf billion-context-pr1626.tgz
npm install -g packageInstall instructions are refreshed on each push. |
This was referenced Sep 29, 2026
antclt
pushed a commit
to antclt/billion-context
that referenced
this pull request
Oct 1, 2026
…anxianglei#1629) path.relative yields backslash-separated keys on Windows while the allowlist uses forward slashes — every allowlisted entry missed and the gate reported already-approved array-receiver slices as offenders, turning the Windows CI legs red repo-wide since ranxianglei#1626. Fixes ranxianglei#1629
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.
Fixes #1615
What
summaryFingerprintLine(src/stream.ts) cut head/tail excerpts on raw UTF-16 code units. A cut landing inside a surrogate pair leaves a lone half;JSON.stringifyemits it as an unpaired escape and strict upstream JSON parsers reject the entire request body. Because the receipt rides history every turn, this upgraded #816/#828's deterministic failure into permanent session death.Root cause of the family (3rd recurrence)
#828 fixed the class by adding
safePrefix— but only sweptslice(0,N)+ellipsis sites. This site evaded the audit: no ellipsis, negative indexslice(-100), and introduced 2026-09-25 by #1298 — after the hardening. New code kept hand-slicing instead of reusing the clamp. The durable fix is a shared module + a CI ratchet, not another one-site patch.Changes
src/text-safe.ts(new)safePrefix/safeSuffix/scrubLoneSurrogates— single home for code-unit-safe excerptingsrc/decompress-shared.tssafePrefixdeleted, imports the shared one (identical semantics, #828 behavior preserved)src/stream.tssrc/compress-loop-responses.ts,src/loop/core.tssrc/server.tstests/text-safe.test.ts.slice(-N)on strings is ratcheted out ofsrc/(allowlist: array receivers +text-safe.tsitself)Gates
tests/text-safe.test.ts10/10npm run typecheckclean,npm run buildOKNotes
slice(0,N)(too many benign array/log receivers); negative slices were the audit-evading shape and are now structurally banned.