Description
Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment on this issue.
Written-by: FlyBot Lead
Claimed-by: FlyBot Lead
Claim-Id: 8688939b73f049e0ae99bac3a88b4082
Branch: dev/2-memory-bounds-code-points
Base: a989587
At: 2026-11-01T07:38:33Z
Implementation: FlyBot (ours) — PR follows within 24h. Do not pick up without a pickup-ok comment.
Written-by: FlyBot Lead
What happens
Four bounds in core/src/host/memory.js still cut with String.prototype.slice, which counts UTF-16 units. A cut that lands inside a surrogate pair leaves half an emoji in the stored or returned value, so a memory news line, a recall query, a saved summary or an ask prompt can carry a lone surrogate — rendered as �, and a lone surrogate is what JSON.stringify then writes out.
Live main a989587f:
| site | bound | what it bounds |
|---|---|---|
core/src/host/memory.js:569 |
NEWS_TEXT_MAX = 160 |
the news line the memory digest reads (noteNews) |
core/src/host/memory.js:909 |
120 | recall's query, before the terms are split |
core/src/host/memory.js:1042 |
SUMMARY_TEXT_MAX = 8_000 |
the summary text the model returned, stored in summaries |
core/src/host/memory.js:1084 |
ASK_TEXT_MAX = 2_000 |
the ask prompt body |
core/src/host/memory.js:1147 already does it right — that clip uses the shared cut() plus codePointStart for the tail (#1918) — so the pattern is in the same file.
Reproduction (node, the live-main expressions)
'a'.repeat(159) + '😀'→slice(0,160)= 160 units,isWellFormed() === false, tail"aaa\ud83d"'a'.repeat(119) + '😀'→slice(0,120)= 120 units, not well formed'a'.repeat(7999) + '😀'→slice(0,8000)= 8000 units, not well formed'a'.repeat(1999) + '😀'→slice(0,2000)= 2000 units, not well formed
The same four inputs through cut(text, N).text give 159 / 119 / 7999 / 1999 units and are all well formed — the emoji is dropped whole, never halved.
Expected
All four values stay well formed, and each bound still holds (length <= N). Use the shared cut() from core/src/shared/text-boundary.js; a slice after trim() is still wrong at the bound.
Scope
- the four sites above.
- tests in
core/test/memory.test.js: one case per site, red first on live main, each able to fail alone (mutate one site and only its case goes red). core/src/host/memory.jshas a full-file mirror underpatches/ds-bot/files/src/host/memory.js; runnode scripts/ds-bot-patches.mjs generateand commit what it writes — never hand-edit the mirror, and a secondgeneratemust be a no-op.- no
core/client.jschange. - changelog fragment.
Dedup
Searched open and closed issues: no open issue covers these four. #1918 fixed the memory-review prompt clip in the same file (:1146–:1147) and #1916/#1917 swept other host modules; none lists these lines. Today's #2005 covers the Project panels (project-assistant.js, project-board.js, project-team.js) and does not touch memory.js, so the two can land independently.
Activity
HugoXK commentedon Nov 1, 2026
Correction to this issue's Scope line, which I wrote: it says
patches/ds-bot/files/src/host/memory.jsis a whole-file mirror that has to change. That is wrong —memory.jsis an upstream file,patches/ds-bot/files/holds 293 files andmemory.jsis not one of them (re-verified on PR #2014's tip). The correct carrier ispatches/ds-bot/0001-core-fixes.patch, which is exactly what PR #2014 regenerated.Nothing in the PR changes because of this; the note is here so a later reader does not demand a mirror that does not exist.
Written-by: FlyBot Lead
HugoXK commentedon Nov 1, 2026
Release
Written-by: FlyBot Lead
Released: 8688939b73f049e0ae99bac3a88b4082
Reason: merged as #2014 at 49e4eaf
At: 2026-11-01T10:24:21Z