Repository navigation
Conversation
Ref: BUG-311-knowledge-ontology-source-page-splits-surrogate-pair (local finding)
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR routes Knowledge ontology source pagination through the existing Unicode-safe text-window helper. Example: Read ontology.yaml with maxChars=256 when 😀 spans UTF-16 offsets 255–256.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this PR fixes a current-main Unicode pagination defect with a small, coherent change; no actionable findings remain, and CI is still pending. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherKnowledge's authorized ontology inspection receives a source path and pagination limits, reads the enumerated source, and returns bounded text with its continuation offset. flowchart LR
A[Gateway session action] --> B[Knowledge service]
B --> C[Authorized storage operation]
C --> D[Ontology inspection]
D --> E[Shared text window]
E --> F[Source text and continuation]
Technical reviewBest possible solution: Use the existing textWindow owner for source text and continuation offsets, as this PR does. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically splits an emoji crossing the requested boundary, and the supplied built-Gateway before/after trace confirms the failure and repair; no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete repair: reuse the existing Unicode-safe window and its continuation, retaining source authorization and extending the existing integration regression. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3f6417465d89. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +4, Tests -5, Docs +2. Total +1 across 3 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 5, 2026, 9:28 AM ET / 14:28 UTC (Revision 3). |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Built Linux Gateway before/after proofPreserved @SunnyShu0925's fix. Frozen main Used the shipped The normal Knowledge tool provisions the owner's store through a real The source places 😀 across the first 256-unit boundary, followed by repeated 🦞 comments. Paging uses only the returned Every page's total/totalChars matches the full source length; page lengths stay <=256, offsets advance by exactly the returned text length, and the sixth page ends pagination. Main only reconstructs if consumers retain the lone UTF-16 halves until joining; encoding pages separately corrupts them. Candidate preserves each complete character and reconstructs exactly in both cases. Controls, checked in all four runs and compared exactly across parsed responses (no normalization): authorized source inventory, totals, full default-window read, Setup captures are retained transparently: HTTP tools intentionally lack a memory audience, so provisioning moved to the normal owner chat turn; the fixture selected direct tool schemas and sufficient context; its authored file was placed in the authorized private partition; expected Gateway error envelopes are captured rather than treated as CLI transport successes. None of those setup failures is counted as product reproduction. The completed four-run receipt above is from invocation Local evidence: Focused checks: 21 tests passed across |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Exact-head CI failure classificationHead
This is a scoped stager reproduction, not a full shard rerun. Local Docker is linux-arm64 whereas hosted CI is linux-x64; the matching failure is in the same unmodified staging owner, pin and shell stager, before any linted product file executes.
|
|
Maintainer override: the reds are inherited. core-3 shows the same max-lines diagnostics (transcript.test.ts:1078 and session-entry-read.worker.ts:728) on hourly main run 42035744729. core-5's pinned Bun staging failure reproduces identically on main and the candidate. The hosted Knowledge lint this PR touches passed. Receipt: #193433 (comment) |
|
Landed in 6d49ef1. Thanks @SunnyShu0925. Knowledge source pages no longer split emoji across page boundaries. |
…penclaw#193433) fix(knowledge): page authorized sources on Unicode-safe boundaries Knowledge source pages were cut with a bare UTF-16 slice, so emoji and other surrogate pairs could be split across pages, corrupting each page's text, and the next offset could be wrong. Pages now use the existing Unicode-safe text window, so pages concatenate losslessly and the next offset is correct. A misaligned offset gets the existing refusal. Source authorization, inventory, totals and budgets are unchanged. Evidence: built Gateway `plugins.sessionAction` pagination, twice per ref. Main split two pages and corrupted per-page UTF-8; with this change every character is kept, the next offset is 255, and the pages reconstruct the source exactly. Inventory, totals, budgets and unauthorized-source controls match. Details: openclaw#193433 (comment). Thanks @SunnyShu0925. Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
Ontology source pagination uses bare UTF-16 slices. When an emoji crosses a page boundary, one page ends with its high surrogate and the next starts with its low surrogate. JSON can retain the separate halves, but consumers encoding each page to UTF-8 get replacement characters instead of the authored source. The returned first continuation is also inside the character.
Fix
Preserve @SunnyShu0925's fix: route the authorized source read through the existing
textWindowowner, just like other bounded text surfaces. Return that owner's text and nextOffset. SourcePath authorization, source inventory, totalChars, schema, and budgets are unchanged; explicit offsets inside a pair receive the existing refusal. No new validation owner, schema, configuration, auth, retry guidance, or model-facing text.Consolidate the existing source-view regression's repeated options while retaining per-page UTF-8 round-trip, exact full concatenation, misaligned-offset refusal, source authorization, and diagnostics assertions. Clarify the existing source-offset documentation.
Evidence
Built Linux Gateway proof and focused checks: secretless
node:24.22.1, main twice/candidate twice, independently built runtimes and shippedopenclaw.mjsentry point. Normalplugins.sessionActionpagination returns six pages and terminates in every run. Main: first nextOffset 256, two split-character pages, UTF-8-per-page concatenation corrupts the source. Candidate: first nextOffset 255, zero split-character pages, lossless concatenation. Misaligned offset refused; authorized inventory, totals, default/full read, maxChars=512, unauthorized path and invalid-budget controls are exactly unchanged across all four runs.Real owner chat/tool execution provisions the store via a faithful local OpenAI-compatible fixture; all source inspection goes through the built Gateway. Separate task-owned profiles/config/state/DB/workspaces/ports, verified resolved paths. No live credentials, no fault injection, no model-quality claim.
21 focused tests, typed lint, focused test typecheck and formatter passed. Final regression copied to frozen main fails exactly the per-page UTF-8 assertion; seven other tests pass.
Whole-PR deltas: production +8/-4 (12 gross, net +4); tests +5/-10 (net -5); docs +5/-3. No allocation file or shared ceiling change. The existing shared window owner eliminates the last bare source-page slice; no new machinery.
Merge risk
Low: only selected source text windows change at surrogate boundaries. ASCII/full-window controls and source authorization remain unchanged. Reverting restores split pages, not a data migration: no stored source bytes, registry state, schema, auth, inventory, or protocol is modified. No downgrade or recovery action is required.