[AI] fix(memory): use truncateUtf16Safe for dreaming snippet truncation#101946
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 12:37 AM ET / 04:37 UTC. Summary PR surface: Source +7, Tests +67. Total +74 across 2 files. Reproducibility: yes. source-reproducible: current main and v2026.6.11 use raw Review metrics: none identified. Stored data model Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Proof guidance:
Risk before merge
Maintainer options:
Next step before merge
Security Review detailsBest possible solution: Merge the SDK-facade truncation fix after a real workspace dreaming run proves daily snippets and session corpus output stay valid Unicode. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main and v2026.6.11 use raw Is this the best way to solve the issue? Yes for the code change: reusing the existing Plugin SDK AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against e2a4973edf3b. Label changesLabel justifications:
Evidence reviewedPR surface: Source +7, Tests +67. Total +74 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics. How this review workflow works
Review history (19 earlier review cycles; latest 8 shown)
|
Replace .slice(0, N) with truncateUtf16Safe() at 5 call sites in dreaming-phases.ts so complex emoji and surrogate pairs near the truncation boundary are not split into lone surrogates. truncateUtf16Safe is the standard SDK helper, already used in session-cost-usage, cron, exec-approval, and node-host modules for the same purpose.
668ce1e to
9ae8803
Compare
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
@clawsweeper re-review |
|
@clawsweeper re-review |
…rrogate-proof test Replace direct @openclaw/normalization-core/utf16-slice import with openclaw/plugin-sdk/memory-core-host-engine-foundation SDK facade, matching manager-search.ts in the same extension. Add surrogate-proof.test.ts that runs a full dreaming ingestion sweep with emoji at the 280-char boundary and verifies zero lone surrogates.
… assert session corpus file
|
@clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Land-ready review complete for exact head Maintainer review kept all five useful memory-core fixes and replaced 280 lines of standalone proof scaffolding with exact cases in the existing dreaming production harness. Coverage now isolates daily headings, daily items, joined daily chunks, normalized session snippets, and rendered session lines. Proof:
Known proof gaps: none for this bounded owner path. |
|
Merged via squash.
|
…on (openclaw#101946) * [AI] fix(memory): use truncateUtf16Safe for dreaming snippet truncation Replace .slice(0, N) with truncateUtf16Safe() at 5 call sites in dreaming-phases.ts so complex emoji and surrogate pairs near the truncation boundary are not split into lone surrogates. truncateUtf16Safe is the standard SDK helper, already used in session-cost-usage, cron, exec-approval, and node-host modules for the same purpose. * [AI] fix(memory): use SDK facade import for truncateUtf16Safe, add surrogate-proof test Replace direct @openclaw/normalization-core/utf16-slice import with openclaw/plugin-sdk/memory-core-host-engine-foundation SDK facade, matching manager-search.ts in the same extension. Add surrogate-proof.test.ts that runs a full dreaming ingestion sweep with emoji at the 280-char boundary and verifies zero lone surrogates. * [AI] fix(memory-proof): use relative imports in surrogate-proof test * [AI] fix(memory-proof): place emoji at post-prefix 280-char boundary, assert session corpus file * [AI] fix(memory-proof): avoid unnecessary String callback in oxlint * [AI] fix(memory-proof): add curly braces per eslint curly rule * [AI] feat(proof): add standalone dreaming surrogate truncation proof script * [AI] chore(proof): remove unused SQLite-dependent proof script * [AI] fix(proof): correct emoji boundary placement for all 5 call sites * [AI] fix(proof): add curly braces per eslint curly rule in proof script * [AI] fix(proof): session emoji at actual corpus 280-char boundary * test: streamline memory dreaming UTF-16 coverage --------- Co-authored-by: hailory <[email protected]> Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Memory-core dreaming truncated daily-note and session-corpus snippets with raw UTF-16 code-unit slices. A limit through an emoji or another supplementary Unicode character could persist a lone surrogate in staged memory or corpus output.
Why This Change Was Made
truncateUtf16SafePlugin SDK surface at all five dreaming-owned truncation boundaries.User Impact
Dreaming ingestion keeps valid Unicode when a configured snippet cap lands inside a surrogate pair. Ordinary text and existing limits are unchanged.
Evidence
env CI=true corepack pnpm test extensions/memory-core/src/dreaming-phases.test.tsgit diff --checkAI-assisted: Yes