Repository navigation
fix(memory-wiki): preserve handwritten notes when markers are damaged - #117104
Conversation
|
Land-ready maintainer verification for head Root cause: the shared Memory Wiki Markdown owner treated an unmatched handwritten Notes marker as absent Notes; pruning silently deleted the page and SQLite row, and source updates/re-ingest could overwrite the same annotation. Before live Gateway proof: After live Gateway proof: both missing-marker directions retain the page and SQLite row with an actionable repair error; repairing the marker recovers the notes normally. The packaged Gateway/CLI stress run covered 48 real sources, a 17 MiB existing page, unavailable roots, Gateway restart, four concurrent processes, and 38 recovered note versions. Validation on Blacksmith Testbox
Production delta: +1 net line. No known proof gaps. |
|
Merged via squash.
|
Related: #102230 and follow-up to #102294.
What Problem This Solves
Fixes an issue where Memory Wiki users permanently lost handwritten Notes when an imported source was pruned, updated, or re-ingested after either human-owned Notes marker was accidentally damaged. A real Gateway stress run reproduced silent loss on current main: the source page was deleted, its SQLite tracking row disappeared, and the annotation was not recovered.
Why This Change Was Made
The shared Notes parser previously treated unmatched markers exactly like absent Notes. Distinguish genuinely absent/empty Notes from damaged marker pairs at the canonical Markdown owner, report the exact marker the operator must restore, and let malformed-Notes failures escape the prune owner's filesystem-read suppression boundary. Bridge and unsafe-local refreshes plus ordinary ingestion inherit the same protection without separate fallback paths.
User Impact
Handwritten wiki annotations and their persisted source tracking remain intact when a Notes marker is missing. Gateway and CLI operations show an actionable repair error instead of silently deleting or overwriting user-authored content; normal empty Notes, fenced-source marker spoofing, nested copied markers, oversized generated pages, and repeated collision-safe recovery retain their existing behavior.
Evidence
AI-assisted; independently reviewed and verified on Blacksmith Testbox
tbx_01kyx5bh8kprjwq0f4kj0tw7mm.Before, against a real isolated Gateway:
{"phase":"unterminated-human-notes-adversarial","removedCount":1,"pageSurvived":false,"notesRecovered":false,"persistedRows":0}After, against the same real packaged Gateway and CLI:
{"phase":"gateway-rejects-malformed-note-update","pageSurvived":true,"persistedRows":1,"actionableError":true}{"phase":"unterminated-human-notes-retained","pageSurvived":true,"persistedRows":1,"actionableError":true}{"phase":"missing-opening-human-notes-retained","pageSurvived":true,"persistedRows":1,"actionableError":true}{"phase":"ordinary-ingest-retains-malformed-notes","pageSurvived":true,"actionableError":true}{"phase":"live-stress-passed","initialSources":48,"oversizedSourceMiB":17,"recoveredNotes":38,"focusedAssertions":800}The isolated live run covered actual Gateway RPC, standalone CLI, 48 real source files, unavailable source roots, 17 MiB existing pages, four simultaneous import processes, Gateway restart with direct SQLite-row verification, collision-safe repeated Notes recovery, spoofed/blank Notes, both damaged-marker directions, and recovery after the operator repairs each marker.
corepack pnpm test extensions/memory-wiki: 399 tests passed across 41 files.corepack pnpm build: passed, including bundled plugin packaging, Plugin SDK exports, and built Control UI.OPENCLAW_CHECK_CHANGED_REMOTE_CHILD=1 OPENCLAW_CHANGED_LANES_RAW_SYNC=1 corepack pnpm check:changed: passed, including production/test typechecks, oxfmt, oxlint, boundary checks, database-first guard, and import-cycle guard..agents/skills/autoreview/scripts/autoreview --mode uncommitted: clean; no accepted/actionable findings.