Skip to content

fix(openclaw): preserve mutation content whitespace - #345

Merged
loveRhythm1990 merged 1 commit into
matrixorigin:mainfrom
MatrixAdventurer:fix/openclaw-mutation-whitespace-20261020
Oct 20, 2026
Merged

loveRhythm1990 merged 1 commit into
matrixorigin:mainfrom
MatrixAdventurer:fix/openclaw-mutation-whitespace-20261020

Conversation

@MatrixAdventurer

@MatrixAdventurer MatrixAdventurer commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

由 LW 授权的 ChatGPT Business 智能体提交。

What type of PR is this?

  • fix (bug fix)
  • test (regression coverage)

Which issue(s) this PR fixes

New narrowly scoped OpenClaw content-fidelity defect. Searches for whitespace/indentation/cache found no matching issue or existing fix PR; no automatic issue closure.

What this PR does / why we need it

The HTTP adapter returns stored/corrected server content in a text envelope, but the client trims that envelope and then consumes arbitrary whitespace after the colon. For example, the server response content " return value\n" becomes "return value" in the returned record and cache. A subsequent cache hit therefore differs from a fresh GET. This loses significant indentation/newlines in code and formatted text; it does not change the stored database record.

  • Extract text without trimming first; preserve it for memory_store and memory_correct, retaining existing trimming for other tools.
  • Consume only the formatter's single separator space, not content whitespace.
  • Preserve the authoritative response content, not the caller's input (the server can redact content).
  • No API request, storage, authorization, retry, dependency, or gate changes.

Scope

2 files, +82/-6, based on main ed63438362280c5a1bb4c802c641236929a7f821.
Head 5022a6c6f2c44ae9c78bbb282d1f7bb853aaa1f3; tree 821ec62832ed5ed170f8dae8585b16187e2a865e exactly matches the locally tested tree.
Own fork: MatrixAdventurer:fix/openclaw-mutation-whitespace-20261020. No upstream dev branch exists, so target is main.

Verification

Node 24.19.0 / Vitest 4.1.11, working directory plugins/openclaw:

  • Identical new regression file on unchanged baseline: 12 failed / 3 passed.
  • Fixed regression: 15 passed across store, correction by ID and correction by query; indentation, tabs, Unicode, CRLF/trailing whitespace and plain-text controls.
  • npm ci, full npm test: 203 passed / 12 files.
  • npm run test:pack: passed, including bundle build, package validation and all 6 packed files.
  • git diff --check: passed.
  • Independent review agent: Approve, independently repeated baseline red (byte-identical test), full green and packaging checks.

Tests use native fetch against real loopback HTTP fixtures and the real client/adapter. They verify request semantics, returned content, actual cache hits and fresh-client GET consistency. This is not a live Memoria/MatrixOne integration test.

Remaining gates / limitations

  • Upstream CI passed for head 5022a6c6f2c44ae9c78bbb282d1f7bb853aaa1f3: OpenClaw tests and packaging, Rust Check & Clippy, Unit Tests and MatrixOne DB Tests, and PR title check. No local Rust/database integration test is claimed.
  • Extra npx tsc --noEmit still reports 42 pre-existing optional-host-peer diagnostics (openclaw/plugin-sdk absent and downstream type errors), with identical baseline/fixed output; no new diagnostics or weakened gate.
  • No force-push, merge, deployment or package publication.

Keep authoritative response indentation and trailing whitespace in stored
and corrected records and their cache entries. Preserve trimming for other
tools and consume only the mutation formatter's delimiter space.

Cover store and both correction paths with native HTTP regressions.

由 LW 授权的 ChatGPT Business 智能体提交。
@loveRhythm1990

Copy link
Copy Markdown
Collaborator

LGTM on 5022a6c6f2c44ae9c78bbb282d1f7bb853aaa1f3.

The reported defect is real: trimming the mutation response and consuming arbitrary whitespace after the separator removes meaningful indentation and trailing whitespace from returned/cached content, while the stored record remains unchanged. Preserving the raw mutation text and consuming only the formatter's separator correctly fixes this. I checked the HTTP adapter and Rust MCP formatters; both emit that single separator space. Other tools retain their previous trimming behavior.

The tests exercise store, correction by ID, and correction by query through real loopback HTTP fixtures, checking request semantics, server-provided content, cache hits, and fresh GET consistency. Locally, all 203 OpenClaw tests and package build/verification passed. With the baseline client and the same regression tests, 12 failed and 3 passed, confirming the original bug. Current CI is green, including the MatrixOne DB tests and explicit restore/cleanup regression steps; no local database integration run is claimed.

Coverage: 2/2 changed files reviewed (100%), 0 skipped. No actionable issues found.

@loveRhythm1990
loveRhythm1990 merged commit 0695ad6 into matrixorigin:main Oct 20, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants