Repository navigation
fix(memory): sanitize file-derived terminal search reports - #184396
Leon-SK668 wants to merge 1 commit into
Conversation
|
🦞👀 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 changesSanitize file-derived paths and snippets in human-readable memory search results while preserving raw JSON. Example: Run memory search saffronleaf against Markdown containing ESC erase, BEL, and C1 controls.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a concrete terminal-output defect still present on current main with a focused change and credible shipped-CLI evidence; no actionable defect was found. Priority: P2 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherLocal and Gateway-backed memory searches produce results for one CLI renderer, which emits either human-readable terminal text or raw JSON. flowchart TD
A[Memory files] --> B[Memory search owner]
B --> C[Local or Gateway result]
C --> D[Shared CLI renderer]
D --> E[Sanitized human report]
D --> F[Raw JSON]
Technical reviewBest possible solution: Keep sanitization in the existing shared renderer, preserving raw search results, JSON, and snippet line breaks. Do we have a high-confidence way to reproduce the issue? Current-main source exposes the control-bearing text to console output, and the contributor supplies before/after built-CLI evidence; this read-only review ran no target code. Is this the best way to solve the issue? The patch is the smallest complete repair: reuse the canonical sanitizer at human display egress without changing indexing, transport, stored content, or machine output. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 798570bc460f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +4, Tests +41. Total +45 across 2 files. Added test files: 1. View PR surface stats
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 Reviewed October 26, 2026, 4:45 AM ET / 08:45 UTC. |
…amilies (#186502) fix(cli): route remaining CLI reports through the terminal-text owner After #185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (#184454, #184379, #185374, #186449, #184396, #184788, #184813, #184394), @huwei-xydt (#185895, #185719), @wangmiao0668000666 (#175600, #175181, #175179), @SunnyShu0925 (#184747), @KrasimirKralev (#184597) and @arpe1618 (#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: #186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
|
Thanks @Leon-SK668. This is now fixed at the root in #186502 (3bcca4f), which routes the remaining CLI reports through the shared |
…amilies (openclaw#186502) fix(cli): route remaining CLI reports through the terminal-text owner After openclaw#185927 added one owner for escaping untrusted values in CLI output, contributors kept opening one PR per command to escape the next report. This moves the remaining human-readable reports in the plugins, secrets, sessions, memory and memory-wiki, workboard, backup, pairing, oc-path, config and setup commands onto `terminalText` / `displayPath`, and extends the owner to neutralize bidirectional control characters. JSON output, persisted identities, raw exports and the CLI's own colors are unchanged, and the trusted styling of `renderTable` is untouched. This absorbs the per-site fixes from @Leon-SK668 (openclaw#184454, openclaw#184379, openclaw#185374, openclaw#186449, openclaw#184396, openclaw#184788, openclaw#184813, openclaw#184394), @huwei-xydt (openclaw#185895, openclaw#185719), @wangmiao0668000666 (openclaw#175600, openclaw#175181, openclaw#175179), @SunnyShu0925 (openclaw#184747), @KrasimirKralev (openclaw#184597) and @arpe1618 (openclaw#150599), whose original commits are kept. Families no PR touched (update, Doctor, install-trust producers and others) are listed under "Not fixed here". Evidence: 85 built-CLI invocations per ref with crafted control and bidi characters in the reported values, captured as raw stdout bytes. Main printed the raw sequences; this change printed them neutralized, with identical normal colors and unchanged JSON. Details: openclaw#186502 (comment). Co-authored-by: 胡伟0668000622 <[email protected]> Co-authored-by: Claude Code <[email protected]> Co-authored-by: Leon-SK668 <[email protected]> Co-authored-by: wangmiao0668000666 <[email protected]> Co-authored-by: SunnyShu <0668000539@local> Co-authored-by: Krasimir Kralev <[email protected]> Co-authored-by: arpe1618 <[email protected]> Co-authored-by: Ayaan Zaidi <[email protected]>
What Problem This Solves
memory searchprints file-derived result paths and Markdown snippets directly into human terminal output. A normally indexed Markdown file can therefore introduce terminal-control sequences into a successful search report. Existing CLI tests strip VT characters before comparing ordinary output, which can conceal this boundary.Why This Change Was Made
Use the existing SDK
sanitizeTerminalTextin the one search renderer shared by local and attached-Gateway result owners. Sanitize the shortened display path before applying trusted theme styling. Sanitize snippets line by line so their intentional LF structure remains readable. The JSON branch returns before this human formatting.The canonical sanitizer and existing multiline-report pattern already solve this operation; no new helper, package, setting or API is necessary. The search operation, index, snippet projection, files, raw result objects and machine output retain their contracts. Warnings/errors and arbitrary argument echoes are outside this bounded successful-result change.
All-state symptom, renderer-symbol and owner-path searches, including public Leon/Alix footprints, found no equivalent viable fix. Existing
cli-search-outputPRs #180553, #124118 and #144833 address other behavior. Accepted file-derived location-report repair #183359 supplies a related presentation precedent.User Impact
Search results remain readable with ordinary Unicode and multiline snippets. File content no longer acts as terminal controls in the human report; TAB/CR are visible escape text. Raw JSON, source bytes, search ranking, indexing and result identities remain unchanged. No config/default, protocol, security permission, storage, migration or dependency change is introduced.
Evidence
Compiled RED is clean
18d2633de8abd677ae1852b48950701bce8ff302; exact GREEN is cleanea8af01c62356125180d343e2c892326edc976c5, parent mainf0d422a7cb485eb19ff9671aa3a588cb4cf3a46a. Relevant entry/search/render/runtime owners match between RED and parent. Fresh main95dff1e02bc59bc86dd6e75ff93d7ab2714daac9retains those owners and the publication contracts; native merge-tree verification is clean. Each recorder run checks clean source HEAD and matchingdist/build-info.json.commit.The same frozen recorder writes two ordinary Markdown files into a fresh isolated workspace, configures the documented FTS-only memory search (
provider: "none", vectors disabled), and uses five normal built CLI commands:The first Markdown file contains normal multiline text plus ESC erase, BEL and C1 erase controls (U+001B, U+0007 and U+009B). RED human output contains all three original controls. GREEN contains none and retains this captured snippet excerpt:
All five actual CLI commands exit 0 on both builds. The normal multiline
copperorchardcontrol is unchanged; absent JSON returnsresults: []. Controlled JSON still contains the exact original Markdown snippet and pathmemory/terminal-report.md, with source/snippet SHA2565ba1bce00572da394f2671ee9b8df488ee23744cb5b984837894f74bc193d772. No source file, config or index content is rewritten for presentation. A separate reader reopens both Markdown files/config and all ten saved process streams, verifies hashes, reparses real JSON and compares it to the actual source. It makes zero new OpenClaw calls.This uses the public index/search path and ordinary files, without internal database/result injection, Gateway, agent/model/embedding/API calls or production state. Dreaming, cron, catalog refresh and startup update checks are disabled only in the isolated fixture. Both runs retain the same 73-byte Node SQLite experimental warning on stderr; empty stderr is not claimed. An earlier plugins-disabled setup failure is retained as setup failure, not acceptance RED.
RED wall 63.86 s; GREEN wall 71.53 s. Frozen recorder SHA256
42fbe485049c41750303de91bbb4fa4843709bd29f1268e68d9af124f2ef483a; independent reader042849e3bda7a7802ff5da16a439fcb7e688a73f8a15f9a0f3ba7367b45023f0. RED receiptbb340b8d665c455a519dafb06d78f79ae4c2460aa49caf2639f2bfee26903c9c; GREEN receipt5d5c38ad34d5fe9a1756aa4382c5257816ed2ed4c82d02d8c61466c406ad6c75.Validation:
OPENCLAW_VITEST_RUNTIME=node node scripts/run-vitest.mjs extensions/memory-core/src/cli-search-output.test.ts extensions/memory-core/src/cli.test.ts --maxWorkers=1 --testNamePattern='search|file-derived' pnpm build sourcePerformance git diff --checkconfig/tsconfig/oxlint.source.jsonand full wrapper preparation: JSON diagnostics empty, two files, 293 rules, 77.893 s wall. Format/diff PASS. Exact-commit sourcePerformance build PASS, 296.55 s. An earlier broader lint attempt was interrupted, retained and excluded from PASS; no policy/limit was weakened.Not tested: an on-disk control-bearing filename (covered at the raw renderer boundary by regression tests), actual interactive TTY, attached-Gateway execution, all error/warning reports, cross-OS, packaged upgrades, broad suites or hosted PR CI. Both transport callers share the same changed renderer; the actual native proof exercises the local caller.
Agent Transcript
Implemented with Codex assistance. Actual task-scoped excerpt, with unrelated context, raw tools, credentials, private paths and reasoning omitted.
Authorized sanitized agent transcript
Assistant: “并行处理:我负责提交、构建和线上状态;一个子代理完成 memory 修复的规范检查,另两个分别复查剩余 Unicode 入口和已合入的终端报告族。”