Skip to content

fix(memory-wiki): prevent source ingest content loss during concurrent vault writes - #104209

Merged
steipete merged 5 commits into
openclaw:mainfrom
masatohoshino:fix/memory-wiki-ingest-mutation-serialization
Jul 18, 2026
Merged

steipete merged 5 commits into
openclaw:mainfrom
masatohoshino:fix/memory-wiki-ingest-mutation-serialization

Conversation

@masatohoshino

@masatohoshino masatohoshino commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Related: #103408

What Problem This Solves

Memory Wiki source ingest read, merged, and rewrote a source page outside the established per-vault mutation transaction. A concurrent locked mutation could therefore write stale page state after ingest, silently discarding content even though ingest reported success.

Why This Change Was Made

ingestMemoryWikiSource now uses the same reentrant withMemoryWikiVaultMutation boundary as apply, compile, and source sync. The lock covers vault initialization, existence/read decisions, page write, log append, and compile. Nested compile re-enters the same-vault lease; unrelated vaults remain parallel.

Maintainer follow-up replaced the original 50 ms timing assertion with deterministic queue-boundary proof. The test observes the real KeyedAsyncQueue.enqueue call: fixed code reaches the outer ingest queue before filesystem work, while unfixed code first reaches the queue from nested compile after the page write, making the same page-absence assertion fail deterministically.

User Impact

Concurrent same-process source ingest and Memory Wiki mutations no longer lose ingested content through stale write-back. Single-caller behavior and public APIs remain unchanged.

Evidence

  • node scripts/run-vitest.mjs extensions/memory-wiki/src/ingest.test.ts extensions/memory-wiki/src/mutation-coordinator.test.ts extensions/memory-wiki/src/source-sync.test.ts — 3 files, 18 tests passed.
  • node scripts/check-changed.mjs -- extensions/memory-wiki/src/ingest.ts extensions/memory-wiki/src/ingest.test.ts — delegated extension/test typechecks, lint, formatting, boundaries, and guards passed on Testbox tbx_01kxs9d6x4f62xbtgdbfkpsyty: https://github.com/openclaw/openclaw/actions/runs/29622791656
  • .agents/skills/autoreview/scripts/autoreview --mode uncommitted --stream-engine-output — clean after each maintainer edit; final confidence 0.99.
  • git diff --check — passed.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P1 High-priority user-facing bug, regression, or broken workflow. labels Jul 11, 2026
@clawsweeper

clawsweeper Bot commented Jul 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge. Reviewed July 17, 2026, 8:40 PM ET / July 18, 2026, 00:40 UTC.

Summary
Wraps Memory Wiki source ingest in the existing vault mutation coordinator and adds a deterministic concurrency regression test.

PR surface: Source +15, Tests +63. Total +78 across 2 files.

Reproducibility: yes. in source: the added test constructs a held same-vault mutation and concurrent ingest with a deterministic queue-boundary observation, although this review did not run it on the current head.

Review metrics: none identified.

Stored data model
Persistent data-model change detected: serialized state: extensions/memory-wiki/src/ingest.test.ts, unknown-data-model-change: extensions/memory-wiki/src/ingest.test.ts, vector/embedding metadata: extensions/memory-wiki/src/ingest.test.ts, vector/embedding metadata: extensions/memory-wiki/src/ingest.ts. Confirm migration or upgrade compatibility proof before merge.

Merge readiness
Overall: 🧂 unranked krab
Proof: 🧂 unranked krab
Patch quality: 🐚 platinum hermit
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:

  • [P1] Add a redacted terminal transcript, runtime log, or recording that runs concurrent source ingest and a competing same-vault mutation on this head and shows the ingested page remains present.
  • After updating the PR body with proof, request an exact-head ClawSweeper re-review if one is not triggered automatically.

Proof guidance:

  • [P1] Needs real behavior proof before merge: Focused tests and static checks are useful supplemental evidence, but the current head has no redacted live concurrent-ingest run, runtime transcript, recording, or log showing the repaired behavior; add such evidence and update the PR body for re-review.

Next step before merge

  • [P1] The remaining action is contributor-supplied real behavior proof followed by normal exact-head maintainer review, not a safe automated repair.

Security
Cleared: The two-file diff adds no dependency, workflow, permission, secret, package-resolution, or external-code-execution surface.

Review details

Best possible solution:

Retain the coordinator-based implementation, add redacted after-fix runtime evidence that concurrently performs source ingest and a competing same-vault mutation, then complete exact-head maintainer review.

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

Yes, in source: the added test constructs a held same-vault mutation and concurrent ingest with a deterministic queue-boundary observation, although this review did not run it on the current head.

Is this the best way to solve the issue?

Yes: reusing the existing reentrant per-vault coordinator is the narrowest maintainable fix because ingest performs the same vault read-modify-write-plus-compile sequence as the already serialized mutators.

AGENTS.md: found and applied where relevant.

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

Label changes

Label changes:

  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🧂 unranked krab, so this older rating label is no longer current.

Label justifications:

  • P1: The patch targets silent loss of ingested Memory Wiki content during concurrent same-vault writes, which is an urgent data-integrity regression in an active workflow.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Focused tests and static checks are useful supplemental evidence, but the current head has no redacted live concurrent-ingest run, runtime transcript, recording, or log showing the repaired behavior; add such evidence and update the PR body for re-review.
Evidence reviewed

PR surface:

Source +15, Tests +63. Total +78 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 16 1 +15
Tests 1 64 1 +63
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 80 2 +78

What I checked:

  • Changed mutation boundary: The proposed wrapper serializes the full ingest read-modify-write and compile span through the established per-vault coordinator, matching the stated invariant that same-vault mutators must not interleave. (extensions/memory-wiki/src/ingest.ts:146, da416bf7c541)
  • Deterministic regression coverage: The added test holds a vault mutation, starts ingest, observes the real queue boundary, and verifies the source page is not written before the held mutation releases; this is stronger than the earlier timing-based assertion. (extensions/memory-wiki/src/ingest.test.ts:77, da416bf7c541)
  • Established coordinator provenance: The related merged change introduced the same reentrant per-vault coordinator for apply and compile, so this PR is a focused extension of the existing ownership boundary rather than a parallel locking design. (extensions/memory-wiki/src/mutation-coordinator.ts, d6f07f36db62)
  • Current proof state: The PR body reports focused tests, changed-surface checks, and autoreview, but contains no redacted live ingest run, runtime log, terminal transcript, recording, or linked artifact showing the after-fix concurrent user path on the current head. (da416bf7c541)

Likely related people:

  • steipete: Introduced and merged the existing vault-transaction coordinator, then authored the deterministic queue-boundary follow-up commits on this branch. (role: feature owner and recent area contributor; confidence: high; commits: d6f07f36db62, 8a0fc8c1b2a2, da416bf7c541; files: extensions/memory-wiki/src/mutation-coordinator.ts, extensions/memory-wiki/src/ingest.test.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-11T06:05:28.341Z sha f0c411e87f79390ab97a717564bf40ded2c53764 :: needs maintainer review before merge. :: none
  • reviewed 2026-07-18T00:28:19.564Z sha cc9f13cd2da995d204bba244afbe8164173e3d95 :: needs real behavior proof before merge. :: none

@steipete steipete self-assigned this Jul 17, 2026
@steipete
steipete force-pushed the fix/memory-wiki-ingest-mutation-serialization branch from f0c411e to cc9f13c Compare July 18, 2026 00:24
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jul 18, 2026
@steipete
steipete force-pushed the fix/memory-wiki-ingest-mutation-serialization branch from cc9f13c to 1d9a6ec Compare July 18, 2026 00:37
@steipete
steipete force-pushed the fix/memory-wiki-ingest-mutation-serialization branch from 1d9a6ec to da416bf Compare July 18, 2026 00:39
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jul 18, 2026
@steipete

Copy link
Copy Markdown
Contributor

Maintainer pass complete for head da416bf7c541cf76edc9f1240f41994b8d29ab9d.

Ready for prepare and merge.

@steipete
steipete merged commit cc0a977 into openclaw:main Jul 18, 2026
92 of 94 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 18, 2026
…t vault writes (openclaw#104209)

* fix(memory-wiki): serialize source ingest with vault mutations

* test(memory-wiki): make ingest lock proof deterministic

* test(memory-wiki): type queue spy receiver

* test(memory-wiki): keep queue spy lint-safe

* style(memory-wiki): format ingest lock proof

---------

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

extensions: memory-wiki P1 High-priority user-facing bug, regression, or broken workflow. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: S 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