Skip to content

fix(reindex): skip logical collections in incremental walk and orphan deletion - #628

Draft
kokorolx wants to merge 1 commit into
masterfrom
fix/reindex-logical-collection-dataloss
Draft

kokorolx wants to merge 1 commit into
masterfrom
fix/reindex-logical-collection-dataloss

Conversation

@kokorolx

Copy link
Copy Markdown
Collaborator

Summary

  • memory and sessions are DB-backed collections whose documents carry synthetic (summary://...) or empty source_path, never real files. Incremental reindex previously walked their nominal filesystem roots as if they held real files — if either root existed and contained even one file, the orphan-deletion pass would delete every indexed document in that collection.
  • Adds isLogicalCollection() to skip memory/sessions in the reindex walk and orphan-deletion loop, and drops them from the watcher-attach list at init time (matching daemon-startup behavior, which already skips a nonexistent path).
  • POST /api/v1/init now validates root_path (rejects nonexistent/non-directory/unreadable paths with 400) instead of registering a permanently-empty collection.
  • POST /api/v1/collections and the rename endpoint now reject memory/sessions as a collection name, closing a name-collision gap found during review: a disk-backed collection created or renamed to one of those reserved names would otherwise be silently skipped by future incremental reindex.

Status

This is a WIP snapshot of Group 1+2 from openspec/changes/fix-install-ux-regressions/tasks.md. Groups 3-8 (CLI init flag parsing, usage-parity test, skill command table, service-install recommendation, npm postinstall diagnostic, CI) are not yet implemented.

Test plan

  • go build ./...
  • go test -race -short ./... — full suite passes
  • New regression tests: logical-collection skip, missing-root no-warning, force-wipe still targets sessions, root-path validation (nonexistent/file/unreadable/relative), reserved-name rejection on add + rename
  • /simplify pass (4 reviewers: reuse/simplification/efficiency/altitude) applied
  • Independent code-review pass (correctness) applied — found and fixed the reserved-name collision gap above

… deletion

memory and sessions are DB-backed collections whose documents carry
synthetic (summary://...) or empty source_path, never real files.
Reindex previously walked their nominal filesystem roots as if they
held real files; if either root existed and contained even one file,
the orphan-deletion pass would delete every indexed document in that
collection. Also validates root_path at POST /api/v1/init so an
unreadable path is rejected instead of registered as a
permanently-empty collection.
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.

1 participant