Skip to content

fix(logging): use truncateUtf16Safe in diagnostic stability and session context#102570

Merged
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/utf16-diagnostic-logging
Jul 9, 2026
Merged

fix(logging): use truncateUtf16Safe in diagnostic stability and session context#102570
steipete merged 3 commits into
openclaw:mainfrom
lsr911:fix/utf16-diagnostic-logging

Conversation

@lsr911

@lsr911 lsr911 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Diagnostic stability bundles and session-context fields truncated arbitrary error text with raw UTF-16 slices. An emoji crossing either cutoff could leave an unpaired surrogate in logs or the generated stability bundle.

Why This Change Was Made

Use the repository's existing truncateUtf16Safe helper at both diagnostic-owner boundaries while preserving the current limits, quoting, and suffixes.

User Impact

Session diagnostics and failure bundles remain valid Unicode when long errors contain supplementary characters at a cutoff.

Evidence

  • Added session-field coverage at the 137-code-unit boundary.
  • Added generated stability-bundle coverage at the 500-code-unit boundary.
  • Focused diagnostics suites: 2 files, 16 tests passed.
  • Fresh autoreview: clean, no accepted/actionable findings (0.99).

Files Changed

File Change
src/logging/diagnostic-stability-bundle.ts Use UTF-16-safe truncation for persisted error messages.
src/logging/diagnostic-session-context.ts Use UTF-16-safe truncation for quoted log fields.
src/logging/diagnostic-stability-bundle.test.ts Add generated-bundle boundary proof.
src/logging/diagnostic-session-context.test.ts Add session-field boundary proof.

🤖 Generated with Claude Code

…on context

Replace naive .slice(0, N) with truncateUtf16Safe() in:
- diagnostic-stability-bundle.ts: error message sanitization
- diagnostic-session-context.ts: quoted field value truncation

Co-Authored-By: Claude <[email protected]>
@openclaw-barnacle openclaw-barnacle Bot added size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 9, 2026
@clawsweeper

clawsweeper Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 9, 2026, 5:09 AM ET / 09:09 UTC.

Summary
The branch replaces two diagnostic logging truncation calls with truncateUtf16Safe in stability bundle error messages and cron session context quoted fields.

PR surface: Source +2. Total +2 across 2 files.

Reproducibility: yes. from source inspection: a long error message or cron diagnostic field with an emoji crossing the truncation boundary can make current main return a dangling surrogate. I did not run a live reproduction.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
Result: blocked until real behavior proof is added.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P1] Add redacted real behavior proof showing a stability bundle or cron diagnostic log field remains valid Unicode across an emoji boundary.
  • [P1] Add focused regression coverage for both touched diagnostic truncation paths if the contributor can update the branch.

Proof guidance:

  • [P1] Needs real behavior proof before merge: No after-fix real behavior proof is present; a redacted terminal transcript, copied live output, or log/bundle excerpt showing an emoji-boundary diagnostic write would satisfy the gate, with private details redacted before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Risk before merge

  • [P1] No after-fix real behavior proof is present, so the contributor proof gate is still open for this external PR.
  • [P1] There is no focused regression coverage for the two exact diagnostic bundle/session-context surrogate-boundary cases touched by the patch.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow helper reuse after a redacted real log or bundle proof is added, ideally with focused surrogate-boundary regressions for both touched call sites.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Hold for contributor-side real behavior proof and normal maintainer validation; there is no narrow ClawSweeper repair task unless maintainers want tests added on the branch.

Security
Cleared: No concrete security or supply-chain concern found; the diff reuses an existing internal helper in logging and does not touch dependencies, lockfiles, workflows, permissions, or secrets.

Review details

Best possible solution:

Land the narrow helper reuse after a redacted real log or bundle proof is added, ideally with focused surrogate-boundary regressions for both touched call sites.

Do we have a high-confidence way to reproduce the issue?

Yes from source inspection: a long error message or cron diagnostic field with an emoji crossing the truncation boundary can make current main return a dangling surrogate. I did not run a live reproduction.

Is this the best way to solve the issue?

Mostly yes: reusing truncateUtf16Safe at the exact truncation sites is the right code shape, but the merge-ready version should include contributor real behavior proof and preferably focused regressions.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 3ac7729f4c5f.

Label changes

Label changes:

  • add P3: This is a low-blast-radius diagnostic logging Unicode correctness fix with no config, auth, storage, migration, or delivery change.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: No after-fix real behavior proof is present; a redacted terminal transcript, copied live output, or log/bundle excerpt showing an emoji-boundary diagnostic write would satisfy the gate, with private details redacted before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.

Label justifications:

  • P3: This is a low-blast-radius diagnostic logging Unicode correctness fix with no config, auth, storage, migration, or delivery change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: No after-fix real behavior proof is present; a redacted terminal transcript, copied live output, or log/bundle excerpt showing an emoji-boundary diagnostic write would satisfy the gate, with private details redacted before posting. After adding proof, update the PR body; ClawSweeper should re-review automatically. If it does not, the PR author or someone with repository write access can comment @clawsweeper re-review.
Evidence reviewed

PR surface:

Source +2. Total +2 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 2 4 2 +2
Tests 0 0 0 0
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 2 +2

What I checked:

Likely related people:

  • steipete: Blame for both affected diagnostic files points to merge commit 5c3c5c0 from feat(ui): redesign sessions page with overview tiles, kind avatars, and context meters #102523, and live PR metadata shows steipete merged adjacent UTF-16 truncation fixes. (role: introduced behavior and recent adjacent merger; confidence: high; commits: 5c3c5c0ee49a, 3ac7729f4c5f, 472e5167d38a; files: src/logging/diagnostic-session-context.ts, src/logging/diagnostic-stability-bundle.ts, packages/ai/src/providers/mistral.ts)
  • lsr911: Beyond this PR, lsr911 authored recently merged UTF-16-safe truncation fixes in adjacent OpenClaw code paths, including tool-policy audit and Mistral provider truncation. (role: adjacent UTF-16 truncation contributor; confidence: medium; commits: 472e5167d38a, 3ac7729f4c5f; files: src/agents/tool-policy-audit.ts, packages/ai/src/providers/mistral.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jul 9, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 9, 2026
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Land-ready at exact head 29ce8863b1cd994c7d4e6f05bdd1fab9efbaf9b7.

Maintainer review added exported session-formatter proof at the 137-code-unit boundary and generated stability-bundle proof at the 500-code-unit boundary. The focused suites passed (2 files, 16 tests), targeted oxfmt and git diff --check passed, fresh autoreview completed clean with no accepted/actionable findings (0.99), and the repository landing wrapper confirms exact-head hosted CI/Testbox gates passed.

Best-fix verdict: both diagnostic owners retain their established limits and suffixes while sharing the canonical UTF-16-safe boundary primitive; a new cross-diagnostics wrapper would add indirection without consolidating policy.

@steipete
steipete merged commit b8cca6a into openclaw:main Jul 9, 2026
105 of 106 checks passed
@steipete

steipete commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 10, 2026
…on context (openclaw#102570)

* fix(logging): use truncateUtf16Safe in diagnostic stability and session context

Replace naive .slice(0, N) with truncateUtf16Safe() in:
- diagnostic-stability-bundle.ts: error message sanitization
- diagnostic-session-context.ts: quoted field value truncation

Co-Authored-By: Claude <[email protected]>

* test(logging): cover diagnostic UTF-16 bounds

* style(logging): normalize diagnostic imports

---------

Co-authored-by: Claude <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants