Skip to content

fix(memory-wiki): reject blank or non-UTF-8 wiki apply --body-file - #168045

Merged
obviyus merged 3 commits into
openclaw:mainfrom
nocodet888-arch:fix/wiki-apply-body-file-utf8
Oct 22, 2026
Merged

obviyus merged 3 commits into
openclaw:mainfrom
nocodet888-arch:fix/wiki-apply-body-file-utf8

Conversation

@nocodet888-arch

@nocodet888-arch nocodet888-arch commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

wiki apply synthesis --body-file reads input with lossy UTF-8 decoding and accepts whitespace-only files. Applying a blank file can silently erase an existing generated summary; malformed bytes can permanently replace the text with U+FFFD characters.

Changes

Validate file bytes with Node's UTF-8 validator before decoding, and reject blank decoded text before mutation. Keep direct --body handling and valid UTF-8 file updates unchanged. Document the file-body requirement in the CLI reference.

Thanks to @nocodet888-arch for the data-loss repair and regression; their commit is retained. The regression now uses the current CLI test helper after integration with main.

Evidence

Built main 759015dc1664d02dcb4f3f9f3c98dfdf43492d5c and candidate independently in isolated Node 24.22.1 Linux Docker. Enabled the shipped memory-wiki plugin, initialized the vault with wiki init, and created the original synthesis through wiki apply synthesis Good --source-id src.manual --body "Real summary v1". No internal wiki state was seeded.

Independent byte reads of the actual vault page show:

Input file Main Candidate
Whitespace only, twice Reports success and removes the original summary Exits 1; original page bytes unchanged both times
Latin-1 Café bytes Reports success and writes U+FFFD, losing the original Exits 1; original page bytes unchanged
Valid UTF-8 Café 🌱 — valid UTF-8 summary Updates successfully, preserving Unicode Same successful Unicode update

Direct-body seeding succeeds before every case on both arms. The focused wiki CLI suite passes all 30 tests; changed-file formatting and lint pass.

Simplification: one existing body resolver owns both refusals, using Node's byte validator; no new mutation path, state, SDK, or configuration. Whole PR production delta +16/-1; tests +47/-0. Necessary growth covers two distinct data-loss inputs and actionable errors.

Merge danger: reverting the code is a two-way door, but cannot recover text already corrupted by older builds. Blast radius is file-backed synthesis application; valid UTF-8 and direct bodies retain their behavior.

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Reject blank or malformed UTF-8 synthesis body files before Memory Wiki changes the vault.

Example: Run openclaw wiki apply synthesis Good --source-id src.manual --body-file blank-body.txt, where the file contains only spaces and newlines.

  • Before: The command reports success and removes the existing Real summary v1 summary.
  • After: The command exits with an actionable error and preserves the original page bytes.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused data-loss repair with shipped-CLI preservation evidence, a meaningful regression, and no open findings; broad exact-head CI remains in progress.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The PR records independently built base and candidate CLI runs in isolated Linux Docker through plugin enablement, wiki initialization, synthesis creation, and file-backed updates; repeated blank input and malformed UTF-8 exit 1 with unchanged vault bytes, while valid Unicode updates succeed, with exact-head collaborator confirmation.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Applying a blank or incorrectly encoded body file can silently destroy an existing generated summary.
Reason: Rejecting these inputs restores the existing nonempty summary expectation and prevents irreversible text damage without adding configuration or changing valid updates.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it fixes a concrete data-loss path still present on current main, and the reviewed diff has no actionable defects.

Priority: P2
Reviewed head: 334f3b70f162f98714b2cffc2d6b53eab2bac3b0

Before merge

None.

Findings

None.

Agent review details

How this fits together

The memory-wiki plugin registers the wiki CLI, resolves summary text from arguments or a local file, then passes valid content to the existing vault mutation and compilation owners.

flowchart LR
  A[Wiki apply synthesis] --> B[Existing body resolver]
  C[Body file bytes] --> B
  B --> D[UTF-8 and nonblank checks]
  D --> E[Actionable CLI error]
  D --> F[Existing vault mutation]
  F --> G[Synthesis page and compiled indexes]
Loading

Technical review

Best possible solution:

Land the existing body-resolver validation with its preservation regression and documented UTF-8 requirement after the normal CI gates pass.

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

Current-main source exposes both destructive inputs, and the supplied base/candidate shipped-CLI comparison records their outcomes; this read-only review ran no target code.

Is this the best way to solve the issue?

This is the smallest complete fix: validate external file bytes in the existing CLI resolver before any mutation, preserve valid input, and reuse the shared error renderer.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 99baae10742c.

Provenance checked

  • Synthesis body-file decoding changes intended behavior with a stated reason (afb89b4: The original wiki apply CLI added file-backed summary input; restoration commit 5716d83 retained its direct UTF-8 read, with no documented requirement to accept blank or malformed input.)
  • Plugin CLI failure reporting keeps the original intent (fix(cli): plugin commands hide their failure reason #168850: The shared plugin binding makes action failures visible while retaining root-owned exit codes and JSON envelopes.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit 5716d83 adds extensions/memory-wiki/src/cli.ts:156 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 5716d83336fd; files: extensions/memory-wiki/src/cli.ts)
  • Peter Steinberger: Raw commit 27e1bc9 adds extensions/memory-wiki/src/cli.ts:755 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 27e1bc92c282; files: extensions/memory-wiki/src/cli.ts)

PR surface

Source +15, Tests +47, Docs +4. Total +66 across 3 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 16 1 +15
Tests 1 47 0 +47
Docs 1 4 0 +4
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 67 1 +66

Review metrics

Metric Value Why it matters
Production versus regression code Production +16/-1; tests +47/-0 The growth stays in the existing resolver and CLI suite, covering two distinct destructive inputs without new state or abstractions.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: A specific optional wiki CLI operation can erase or corrupt an existing summary, with a focused repair and limited blast radius.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • proof: sufficient: Contributor real behavior proof is sufficient.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (4 earlier review cycles)
  • reviewed 2026-10-10T00:35:38.944Z sha aef06b000f2c47477e03a4087483f9f339b9f22f :: needs changes before merge. :: [P2] [P2] Show the body-file rejection reason and recovery step
  • reviewed 2026-10-10T05:17:23.987Z sha 244b78e9516476c204f39920f33372448bff0c5d :: needs maintainer review before merge. :: none
  • reviewed 2026-10-17T09:14:00.194Z sha a2dff5602b1751d03084b5d21bfb8ef625349dc6 :: needs changes before merge. :: [P1] [P1] Reuse the shared plugin CLI failure renderer
  • reviewed 2026-10-18T03:42:48.789Z sha c30276d :: needs maintainer review before merge. :: none

Reviewed October 22, 2026, 4:13 PM ET / 20:13 UTC (Revision 5).

@nocodet888-arch
nocodet888-arch force-pushed the fix/wiki-apply-body-file-utf8 branch from aef06b0 to 244b78e Compare October 10, 2026 05:12
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

Addressed ClawSweeper P2: body-file rejection now prints the specific reason + recovery step via the wiki CLI user-facing parse-exit path (no more generic "The CLI command failed."). Packaged CLI RED/GREEN + vault readback refreshed on this head.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 10, 2026
@nocodet888-arch
nocodet888-arch force-pushed the fix/wiki-apply-body-file-utf8 branch from 244b78e to 6730e9e Compare October 15, 2026 10:40
@nocodet888-arch
nocodet888-arch force-pushed the fix/wiki-apply-body-file-utf8 branch from 6730e9e to a2dff56 Compare October 17, 2026 09:07
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Lint-only amend on the same single commit: resolveWikiApplyBody now return failWikiCli(...) so oxlint consistent-return is satisfied (CI check-lint-core-1 was red on the prior head). Behavior and proof unchanged.

@clawsweeper

clawsweeper Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 17, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 17, 2026
@nocodet888-arch
nocodet888-arch force-pushed the fix/wiki-apply-body-file-utf8 branch from a2dff56 to c30276d Compare October 18, 2026 03:37
@nocodet888-arch

Copy link
Copy Markdown
Contributor Author

Addressed ClawSweeper P1 (shared plugin CLI failure renderer): removed the local failWikiCli helper (console.error + throw) that printed the rejection twice after #168850. resolveWikiApplyBody now throws ordinary errors carrying the existing recovery messages (Save the file as UTF-8, then retry. / Supply nonempty UTF-8 text (or use --body), then retry.), retaining the byte-valid UTF-8 and blank checks, so toPluginCommandFailure renders the failure once. Rebased onto current main; still a single commit.

Local check: oxlint extensions/memory-wiki/src/cli.ts extensions/memory-wiki/src/cli.test.ts passes. Full Vitest for extensions/memory-wiki/src/cli.test.ts could not complete on this box (compiled subprocess OOM, exit 137, before tests ran) — CI to confirm.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 18, 2026
@obviyus

obviyus commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@obviyus

obviyus commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Exact head 334f3b7: 30 focused wiki CLI tests pass; changed-file formatting/lint pass. Built shipped CLI proof in Evidence independently reads actual vault bytes after blank input twice, malformed UTF-8, and valid Unicode updates. A supporting bounded gpt-5-mini smoke through the shipped agent returned CLI_LIVE_OK; the isolated credential was removed afterward.

@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Oct 22, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 22, 2026
@obviyus
obviyus merged commit 3f962c1 into openclaw:main Oct 22, 2026
98 of 99 checks passed
@obviyus

obviyus commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Landed in 3f962c1. Thanks @nocodet888-arch. wiki apply synthesis no longer wipes or corrupts summaries from bad body files.

@obviyus

obviyus commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

Merged—thank you @nocodet888-arch for preventing blank-file and invalid-UTF-8 synthesis data loss. Built CLI proof confirmed exact byte preservation on both refusal paths and successful valid Unicode updates.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 23, 2026
…penclaw#168045)

fix(wiki): refuse blank or malformed --body-file input for synthesis

`openclaw wiki apply synthesis --body-file` accepted a blank file and wiped the existing summary, and it rewrote malformed (non-UTF-8) bytes as U+FFFD replacement characters for good. Both are now rejected before anything is written, and the existing summary stays unchanged.

Evidence: built CLI with a summary created through the CLI. On main a blank body file wiped it and a Latin-1 file was saved with U+FFFD (twice each); with this change both are refused and the vault bytes are unchanged (twice each). Valid UTF-8 (Café, emoji) and an inline body still work. Production +16/-1, CLI docs updated.

Thanks @nocodet888-arch.

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

Labels

docs Improvements or additions to documentation extensions: memory-wiki P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants