fix(active-memory): use truncateUtf16Safe for log value truncation#102551
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 6:05 AM ET / 10:05 UTC. Summary PR surface: Source 0, Tests +2. Total +2 across 2 files. Reproducibility: yes. Current main uses raw UTF-16 code-unit slicing for active-memory log values, and a session key with an emoji high surrogate at the 300-code-unit boundary would leave a dangling surrogate before the ellipsis; I did not run a live active-memory process in this read-only review. Review metrics: none identified. 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: Land this narrow log-value helper substitution after redacted real-behavior proof is added; keep the separate search-query truncation discussion on a better-proven related PR. Do we have a high-confidence way to reproduce the issue? Yes. Current main uses raw UTF-16 code-unit slicing for active-memory log values, and a session key with an emoji high surrogate at the 300-code-unit boundary would leave a dangling surrogate before the ellipsis; I did not run a live active-memory process in this read-only review. Is this the best way to solve the issue? Yes. Reusing the existing UTF-16-safe helper at the local log truncation point, plus the new hook-level regression, is the narrow maintainable fix for log values; the broader search-query slice should remain separate. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 4be6fa7413af. Label changesLabel justifications:
Evidence reviewedPR surface: Source 0, Tests +2. Total +2 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)
|
|
Land-ready verification at exact head
No docs, config, recall, cache, API, or dependency changes. Ready to merge. |
|
Merged via squash.
|
…penclaw#102551) * fix(active-memory): use truncateUtf16Safe for log value truncation * fix(active-memory): use truncateUtf16Safe for log value truncation * test(active-memory): cover UTF-16-safe log limits --------- Co-authored-by: Peter Steinberger <[email protected]>
What Problem This Solves
Active Memory sanitizes session identifiers, model references, and failure messages into bounded single-line log values. The existing 300-code-unit cap used
slice, so an astral character crossing the boundary could leave malformed UTF-16 in those logs.Why This Change Was Made
Replace the final fixed-width slice with the existing shared
truncateUtf16Safeutility. New local logic is unnecessary: the utility preserves the established cap while dropping only a high surrogate that would otherwise be split.The follow-up regression improves the existing public hook-level log-limit test. It supplies a real session key with an emoji straddling the 300-code-unit boundary and verifies the complete session field plus the absence of unpaired surrogates in the emitted start log.
User Impact
Active Memory diagnostics remain single-line and bounded, but no longer contain malformed Unicode at the length limit. No config, recall, cache, or API behavior changes.
Evidence
node ../../node_modules/vitest/vitest.mjs run --config test/vitest/vitest.extension-active-memory.config.ts extensions/active-memory/index.test.ts -t 'caps active-memory log field lengths'— 1 passed, 156 skipped.oxfmtcompleted for the changed test.git diff --checkpassed.toSingleLineLogValueconsumer benefits from the same canonical boundary.94fb898bd4d1aca94648d717687973bc745ec0ac.Risk
Low. One internal log renderer now uses the shared truncation invariant; text not splitting a surrogate pair is unchanged.
AI-assisted
This PR was generated with Claude Code and improved/reviewed by a maintainer agent.