Skip to content

fix(cron): keep bounded diagnostics UTF-16 safe#102624

Merged
steipete merged 2 commits into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-cron-diag
Jul 9, 2026
Merged

fix(cron): keep bounded diagnostics UTF-16 safe#102624
steipete merged 2 commits into
openclaw:mainfrom
lzyyzznl:fix/truncateUtf16Safe-cron-diag

Conversation

@lzyyzznl

@lzyyzznl lzyyzznl commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Cron run diagnostics bounded entry messages and summaries with raw UTF-16 code-unit slicing. A limit that landed between the halves of an emoji or another supplementary character could persist and display a lone surrogate.

Why This Change Was Made

Both bounded diagnostic surfaces now use the shared truncateUtf16Safe primitive before appending their existing ellipsis. This preserves the current caps, redaction, truncation metadata, and short-text behavior without adding another code path.

User Impact

Long cron diagnostic entries and summaries remain valid Unicode in run logs and operator-facing control surfaces. Existing bounds and ASCII behavior are unchanged.

Evidence

  • Focused src/cron/run-diagnostics.test.ts suite passed.
  • Exact regression assertions cover the 1,000-unit entry cap and 2,000-unit summary cap with an emoji on each split boundary.
  • Focused oxfmt and oxlint passed; git diff --check passed.
  • Fresh branch autoreview found no accepted or actionable findings (0.99 confidence).

@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, 8:03 AM ET / 12:03 UTC.

Summary
The PR imports truncateUtf16Safe for cron diagnostic entry-message and summary prefix caps and adds a regression test for those two UTF-16 boundary cases.

PR surface: Source +1, Tests +23. Total +24 across 2 files.

Reproducibility: yes. source-reproducible: the unchanged exec path raw-slices the retained tail before normalization, and a read-only probe showed the retained string can start with low surrogate 0xde00. I did not run a live cron job in this read-only review.

Review metrics: none identified.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🦪 silver shellfish
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:

  • Make exec-tail truncation UTF-16-safe and cover the aggregated exec boundary in src/cron/run-diagnostics.test.ts.
  • [P1] Add redacted real behavior proof, such as terminal output or logs from a cron diagnostic path showing valid Unicode after the fix.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Missing: the PR body lists focused tests/lint/autoreview only, with no live cron run, terminal transcript, copied output, redacted log, or linked artifact showing after-fix diagnostic truncation; updating the PR body with proof should trigger re-review, or a maintainer can comment @clawsweeper re-review. 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] Failed exec diagnostics can still contain malformed UTF-16 when aggregated is tailed at the 2,000-code-unit boundary before normalization.
  • [P1] The PR body and discussion still provide tests/CI only, not redacted real cron diagnostic output showing after-fix behavior.

Maintainer options:

  1. Decide the mitigation before merge
    Make the exec tail use a UTF-16-safe suffix slice too, keep the new entry/summary boundary coverage, add an exec aggregated boundary test, and require redacted runtime proof before merge.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • [P1] Contributor-side code revision and real behavior proof are required before merge; ClawSweeper should not open an automated repair lane while the external proof gate is missing.

Security
Cleared: No concrete security or supply-chain concern found; the diff reuses an existing internal helper and adds tests without touching dependencies, lockfiles, workflows, permissions, or secrets.

Review findings

  • [P2] Clamp the exec tail before normalizing diagnostics — src/cron/run-diagnostics.ts:105
Review details

Best possible solution:

Make the exec tail use a UTF-16-safe suffix slice too, keep the new entry/summary boundary coverage, add an exec aggregated boundary test, and require redacted runtime proof before merge.

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

Yes, source-reproducible: the unchanged exec path raw-slices the retained tail before normalization, and a read-only probe showed the retained string can start with low surrogate 0xde00. I did not run a live cron job in this read-only review.

Is this the best way to solve the issue?

No. truncateUtf16Safe is the right helper for entry and summary prefix caps, but the best fix also uses a UTF-16-safe suffix slice for tailText and proves the exec aggregated boundary.

Full review comments:

  • [P2] Clamp the exec tail before normalizing diagnostics — src/cron/run-diagnostics.ts:105
    This is the same blocker from the prior ClawSweeper cycle. The new clamps only protect prefix truncation after diagnostics are normalized, but failed exec details still call tailText(aggregated, EXEC_DIAGNOSTIC_TAIL_CHARS), where tailText uses raw value.slice(value.length - maxChars). If an emoji crosses that 2,000-code-unit tail boundary, the retained string starts with a lone low surrogate and the summary path returns it unchanged; make the tail slice UTF-16-safe and add an exec aggregated boundary test.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.9

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is a narrow cron diagnostic Unicode correctness fix with low blast radius and no config, auth, storage, migration, provider, or delivery behavior change.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Missing: the PR body lists focused tests/lint/autoreview only, with no live cron run, terminal transcript, copied output, redacted log, or linked artifact showing after-fix diagnostic truncation; updating the PR body with proof should trigger re-review, or a maintainer can comment @clawsweeper re-review. 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 +1, Tests +23. Total +24 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 2 +1
Tests 1 23 0 +23
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 26 2 +24

Acceptance criteria:

  • [P1] pnpm test src/cron/run-diagnostics.test.ts after adding exec-tail coverage.
  • [P1] Attach redacted terminal output, copied live output, or logs from a cron diagnostic path showing valid Unicode after the fix.

What I checked:

  • PR diff changes only prefix clamps: The PR replaces the entry-message and summary prefix .slice(0, limit) calls with truncateUtf16Safe and adds a test for those two boundaries, but it does not change the exec-tail helper. (src/cron/run-diagnostics.ts:105, 90358d973703)
  • Current exec tail remains raw-sliced: tailText still keeps the final diagnostic text with value.slice(value.length - maxChars), so the retained text can start inside a surrogate pair. (src/cron/run-diagnostics.ts:89, c9b3358d43f7)
  • Exec details use the tail before normalization: Failed exec details feed tailText(aggregated, EXEC_DIAGNOSTIC_TAIL_CHARS) into cron diagnostics before summary and entry normalization run. (src/cron/run-diagnostics.ts:298, c9b3358d43f7)
  • UTF-16 helper contract checked: truncateUtf16Safe delegates to sliceUtf16Safe(input, 0, limit), which protects the end boundary of a prefix slice but does not repair a string that already begins with a dangling low surrogate. (packages/normalization-core/src/utf16-slice.ts:44, c9b3358d43f7)
  • Read-only source probe reproduced the remaining boundary: A Node probe matching the current helper logic showed a 2,002-code-unit string with an emoji crossing the 2,000-code-unit tail boundary produces a raw tail starting with low surrogate 0xde00, and prefix truncation preserves that leading low surrogate.
  • Previous ClawSweeper finding remains unresolved: The existing review comment already identified the exec-tail blocker; the current head added entry/summary tests but left the production tail path unchanged and still has no runtime proof attachment. (90358d973703)

Likely related people:

  • steipete: Path history shows recent cron diagnostics commits by this person, and the current PR also contains their added regression-test commit. (role: recent cron diagnostics contributor and adjacent reviewer; confidence: high; commits: c8a953af9371, 875c9fd96dd8, 90358d973703; files: src/cron/run-diagnostics.ts, src/cron/run-diagnostics.test.ts)
  • kevinslin: GitHub path history ties the original cron run diagnostics/status surface to commit 89db1e5440f5537790bcc8f5a5fbdddad0eaac46. (role: feature introducer; confidence: high; commits: 89db1e5440f5; files: src/cron/run-diagnostics.ts, src/cron/run-diagnostics.test.ts)
  • LiLan0125: Recent cron diagnostics work in the same module added the web_search provider warning path and tests. (role: recent adjacent contributor; confidence: medium; commits: 685b95b607bb; files: src/cron/run-diagnostics.ts, src/cron/run-diagnostics.test.ts)
  • lsr911: Related merged UTF-16-safe truncation PRs used the same helper pattern on nearby diagnostic/logging surfaces, which is useful context for consistency. (role: adjacent UTF-16 truncation contributor; confidence: medium; commits: 472e5167d38a, 32de66616303; files: src/agents/tool-policy-audit.ts, extensions/codex/src/app-server/event-projector.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.
Review history (2 earlier review cycles)
  • reviewed 2026-07-09T09:49:58.070Z sha bcb72bc :: needs real behavior proof before merge. :: [P2] Clamp the exec tail before normalizing diagnostics
  • reviewed 2026-07-09T10:24:33.779Z sha bcb72bc :: needs real behavior proof before merge. :: [P2] Clamp the exec tail before normalizing diagnostics

@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 changed the title fix(cron): use truncateUtf16Safe for diagnostic entry and summary truncation fix(cron): keep bounded diagnostics UTF-16 safe Jul 9, 2026
@steipete
steipete merged commit f786efd into openclaw:main Jul 9, 2026
103 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
* fix(cron): use truncateUtf16Safe for diagnostic entry and summary truncation

* test(cron): cover UTF-16 diagnostic boundaries

---------

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