Skip to content

fix(markdown): preserve index when vault inventory is unsafe - #496

Merged
EyJunge1 merged 1 commit into
tickernelz:mainfrom
Phototonic:fix/markdown-reconcile-safety-495
Nov 6, 2026
Merged

EyJunge1 merged 1 commit into
tickernelz:mainfrom
Phototonic:fix/markdown-reconcile-safety-495

Conversation

@Phototonic

Copy link
Copy Markdown
Contributor

Summary

Closes #495.

Removing the Markdown vault while the service is running currently produces an empty inventory and can permanently delete every indexed memory. This change skips inferred deletion when the vault has no Markdown files or when scanning, reading, parsing, or processing a file fails, and logs the reason. Readable files can still be indexed during an incomplete scan.

Watcher-triggered deletions use the same safeguards and only remove the requested path. Full reconciliation reads each file once so its indexed content and deletion identity come from the same snapshot. The README and its five translations document the behavior.

Tradeoff: deliberately deleting the final Markdown file preserves its indexed memory. Delete that memory explicitly through the tool or Web UI when removal is intentional. A healthy, nonempty vault still permits permanent deletion of missing memories; these safeguards cannot detect an incomplete sync that looks like a complete, nonempty vault and do not replace backups. The existing delete-before-insert behavior for replacement writes is unchanged.

Test plan

  • Exercised the change locally with isolated storage and configuration.
  • Added 20 deletion-safety regression scenarios; the complete Markdown suite passes all 35 tests.
  • Tested real Linux watcher events with synthetic notes: ordinary deletion, empty-vault preservation, vault rename, restoration, and explicit reindexing.
  • Checked missing/empty-vault reconciliation and startup against a consistent disposable database copy, verifying unchanged memory rows, metadata, and shard counts.
  • Noted the empty-vault tradeoff and remaining limitations above.

Checklist

  • Branch is based on current main.
  • bun test --timeout 30000: 1,182 passed, 4 platform-specific skips, 0 failed across 157 files (Bun 1.3.14, Linux).
  • bun run typecheck passes (via bun run check).
  • bun run check passes (formatting, lint and TypeScript).
  • bun run build passes.
  • Docs / README updated.

@EyJunge1
EyJunge1 merged commit a9e49dd into tickernelz:main Nov 6, 2026
9 checks passed
@EyJunge1 EyJunge1 mentioned this pull request Nov 6, 2026
3 tasks done
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.

markdown 后端:vault 目录被清空或不存在时,对账会把库里全部记忆硬删除,没有任何保护

2 participants