fix(memory-core): use truncateUtf16Safe for diary context truncation#102524
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 4:45 AM ET / 08:45 UTC. Summary PR surface: Source +1, Tests +15. Total +16 across 2 files. Reproducibility: yes. source-reproducible: current main clamps diary context with 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 narrow SDK-facade truncation fix after the contributor adds redacted terminal output, logs, or another real behavior artifact showing the diary context surrogate-boundary case. Do we have a high-confidence way to reproduce the issue? Yes, source-reproducible: current main clamps diary context with raw Is this the best way to solve the issue? Yes for the code shape: the current PR head uses the existing AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against ecc2cffad8aa. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +1, Tests +15. Total +16 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 (1 earlier review cycle)
|
|
Maintainer review complete at exact head What changed during review:
Validation:
Known proof gaps: none for this bounded prompt-truncation fix. |
|
Merged via squash.
|
…penclaw#102524) * fix(memory-core): use truncateUtf16Safe for diary context truncation * test(memory-core): cover utf16 diary truncation * refactor(memory-core): use plugin sdk text runtime --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Dream-diary context was truncated with a raw UTF-16 code-unit slice. A boundary between an emoji's surrogate halves could pass malformed text into the dreaming narrative prompt.
Why This Change Was Made
The diary reader now uses the shared UTF-16-safe truncation helper through the supported plugin SDK text-runtime facade. The fix stays at the memory-core owner boundary and does not add a second truncation path.
User Impact
Long diary entries can contain emoji and other supplementary Unicode characters without producing an unpaired surrogate at the prompt boundary. ASCII and already-short entries are unchanged.
Evidence
readRecentDreamDiaryEntrieswith an emoji straddling the 20,000-code-unit boundary.node scripts/run-vitest.mjs extensions/memory-core/src/dreaming-narrative.test.ts— 59 passed.preserves complete Unicode code points at the diary context limit— 1 passed, 58 skipped.5ce7d36ee027passed after rerunning one transient artifact job with unavailable logs.🤖 Generated with Claude Code