Skip to content

Index: every write declares what it changed and refreshes it - #1286

Merged
vmillet-dev merged 1 commit into
dev/0.18.0from
index/declared-writes
Nov 3, 2026
Merged

vmillet-dev merged 1 commit into
dev/0.18.0from
index/declared-writes

Conversation

@vmillet-dev

@vmillet-dev vmillet-dev commented Nov 2, 2026 •

Copy link
Copy Markdown
Owner

Closes #1151

Phase 1, step 5 of docs/egui-migration-plan.md (§ 3.5 rule 2, Annex C, R4).

  • index::Changed { notes, attachments, folders, globals, rebuild } and Engine::write(|db| …): the closure answers its value and what it changed; write then refreshes the index — the named notes read again (notes::store::live, dropped when no longer live), the attachment counts, the folder chips or the global values reloaded. A refresh that fails empties the index rather than leaving it stale. No service function refreshes the index itself.
  • Every write that touches what the index holds declares it (Annex C):
    • one note or a batch, by its ids: create, update, duplicate (+ attachments), convert, restore a revision, field values, trash and restore, move and its undo, file into a folder and its undo, tag / untag / remove a tag / restore tags, pin, priority and its undo, purge (+ attachments);
    • attachments: attach a file or an image, delete; empty the trash;
    • folders: create, rename, recolour, move and its undo;
    • globals: the global {{field}} values;
    • Changed::everything() — emptied, rebuilt by the next read: rename or drop tags corpus-wide, delete a folder or a space, import, the first launch's samples.
      Writes that touch nothing the index holds (space names and pins, board geometry, HTTP) keep lock.
  • The check: Engine::index_matches_library (hidden) compares the index with one built from the database now; an index not started on the open library passes, since the next read builds it.

Tests: tests/commands/index.rs checks the index right after each write of every family above (a later write re-reading the same note would hide a miss — verified by breaking set_pinned's declaration: the test fails). Local: fmt, clippy (-D warnings), cargo test --workspace (1 608 tests) green.

🤖 Generated with Claude Code

@vmillet-dev vmillet-dev added the change Behaviour change to something that already existed label Nov 2, 2026
@vmillet-dev
vmillet-dev force-pushed the index/declared-writes branch 3 times, most recently from b6a9442 to a891c78 Compare November 3, 2026 03:36
Engine::write runs the write, then reads again the notes, counts, folders or globals it names;
corpus-wide writes empty the index for the next read to build.
@vmillet-dev
vmillet-dev force-pushed the index/declared-writes branch from a891c78 to 7d66740 Compare November 3, 2026 04:17
@vmillet-dev
vmillet-dev merged commit 7e7002d into dev/0.18.0 Nov 3, 2026
18 checks passed
@vmillet-dev
vmillet-dev deleted the index/declared-writes branch November 3, 2026 04:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

change Behaviour change to something that already existed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant