Skip to content

Feature/snapshot for index#78

Merged
mors119 merged 2 commits into
FrilLab:mainfrom
mors119:feature/snapshot-for-index
Jun 17, 2026
Merged

Feature/snapshot for index#78
mors119 merged 2 commits into
FrilLab:mainfrom
mors119:feature/snapshot-for-index

Conversation

@mors119

@mors119 mors119 commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Summary

Add snapshot for index and Add repair engin for #47

Type of Change

  • feat
  • fix
  • docs
  • refactor
  • [x} test
  • chore

Required

  • cargo check passes
  • cargo fmt --all --check passes
  • cargo clippy --workspace --all-targets -- -D warnings passes
  • cargo test passes

Checklist

  • Code builds successfully
  • Tests pass
  • Documentation updated

Summary by CodeRabbit

  • New Features

    • Added workspace file move detection with confidence scoring.
    • Added automatic note reference repair when files are moved or renamed.
    • Added workspace change monitoring and snapshot tracking.
    • Added workspace scanning to identify all note files.
  • Refactor

    • Restructured caching and runtime components for improved state management.

@mors119 mors119 merged commit 63e28c9 into FrilLab:main Jun 17, 2026
2 of 3 checks passed
@mors119 mors119 deleted the feature/snapshot-for-index branch June 17, 2026 11:23
@coderabbitai

coderabbitai Bot commented Jun 17, 2026

Copy link
Copy Markdown

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: f2554c82-2b61-4569-be66-2fcccda6b115

📥 Commits

Reviewing files that changed from the base of the PR and between 2b0b070 and 0350ce9.

📒 Files selected for processing (22)
  • crates/frilvault-core/src/cache/vault_context.rs
  • crates/frilvault-core/src/lib.rs
  • crates/frilvault-core/src/runtime/cache_stats.rs
  • crates/frilvault-core/src/runtime/mod.rs
  • crates/frilvault-core/src/runtime/note_cache.rs
  • crates/frilvault-core/src/runtime/vault_context.rs
  • crates/frilvault-core/src/tests/helper.rs
  • crates/frilvault-core/src/tests/mod.rs
  • crates/frilvault-core/src/tests/repair_engin_test.rs
  • crates/frilvault-core/src/tests/workspace_index_repository_test.rs
  • crates/frilvault-core/src/workspace/diff.rs
  • crates/frilvault-core/src/workspace/entity/file_move.rs
  • crates/frilvault-core/src/workspace/entity/mod.rs
  • crates/frilvault-core/src/workspace/entity/repair_suggestion.rs
  • crates/frilvault-core/src/workspace/mod.rs
  • crates/frilvault-core/src/workspace/repair_engine.rs
  • crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs
  • crates/frilvault-core/src/workspace/service/workspace_service.rs
  • crates/frilvault-core/src/workspace/snapshot/mod.rs
  • crates/frilvault-core/src/workspace/snapshot/snapshot_manager.rs
  • crates/frilvault-core/src/workspace/snapshot/workspace_snapshot.rs
  • crates/frilvault-core/src/workspace/watcher.rs

📝 Walkthrough

Walkthrough

Removes the cache module from frilvault-core and replaces it with a runtime module containing a rebuilt VaultContext. Adds a workspace move-detection and auto-repair pipeline consisting of FileMove, IndexDiff, RepairSuggestion::from_moves, WorkspaceSnapshot, SnapshotManager, RepairEngine, and WorkspaceWatcher. Updates WorkspaceService to delegate file scanning and path resolution to VaultContext.

Changes

Workspace Auto-Repair Pipeline

Layer / File(s) Summary
VaultContext migration: cacheruntime module
crates/frilvault-core/src/lib.rs, crates/frilvault-core/src/runtime/vault_context.rs, crates/frilvault-core/src/runtime/note_cache.rs, crates/frilvault-core/src/cache/vault_context.rs
Removes the cache module and re-exports, introduces the runtime module. Rebuilds VaultContext with added methods: rebuild_index, list_all_note_files, scan_workspace_files (with recursive .vault-skipping walk), and resolve_note_path. Derives Clone on NoteCache.
FileMove entity, IndexDiff scoring, and RepairSuggestion conversion
crates/frilvault-core/src/workspace/entity/file_move.rs, crates/frilvault-core/src/workspace/entity/mod.rs, crates/frilvault-core/src/workspace/diff.rs, crates/frilvault-core/src/workspace/entity/repair_suggestion.rs, crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs, crates/frilvault-core/src/workspace/mod.rs
Adds FileMove struct. Adds IndexDiff::diff (similarity threshold ≥ 0.7) and exported similarity_score. Extends RepairSuggestion with from_moves (confidence threshold ≥ 0.5). Adds detect_moves and repair_suggestions to WorkspaceIndexRepository.
WorkspaceSnapshot and SnapshotManager
crates/frilvault-core/src/workspace/snapshot/workspace_snapshot.rs, crates/frilvault-core/src/workspace/snapshot/snapshot_manager.rs, crates/frilvault-core/src/workspace/snapshot/mod.rs
Adds WorkspaceSnapshot (serde wrapper around WorkspaceIndex) and SnapshotManager with new, update, and previous accessors for tracking prior index state.
RepairEngine: applying detected moves
crates/frilvault-core/src/workspace/repair_engine.rs
Adds RepairEngine holding a VaultContext with apply_moves that filters by confidence ≥ 1.0, renames files on disk, invalidates and reloads note cache entries, and returns the applied count.
WorkspaceWatcher orchestration and WorkspaceService delegation
crates/frilvault-core/src/workspace/watcher.rs, crates/frilvault-core/src/workspace/service/workspace_service.rs
Adds WorkspaceWatcher::on_change to rebuild index, detect moves against prior snapshot, apply repairs, and update snapshot. Refactors WorkspaceService::stats, repair_suggestions, and move_note_file to delegate to VaultContext methods, removing internal directory-walk helpers.
Tests
crates/frilvault-core/src/tests/helper.rs, crates/frilvault-core/src/tests/mod.rs, crates/frilvault-core/src/tests/repair_engin_test.rs, crates/frilvault-core/src/tests/workspace_index_repository_test.rs
Adds create_test_index_repository helper. Adds two RepairEngine tests (filesystem move verification and cache invalidation). Adds WorkspaceIndexRepository::detect_moves and IndexDiff::similarity_score tests with temporary workspace setup/teardown.

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant WorkspaceWatcher
  participant WorkspaceIndexRepository
  participant SnapshotManager
  participant RepairEngine
  participant VaultContext

  Caller->>WorkspaceWatcher: on_change()
  WorkspaceWatcher->>WorkspaceIndexRepository: rebuild_index()
  WorkspaceIndexRepository-->>WorkspaceWatcher: new_index
  WorkspaceWatcher->>SnapshotManager: previous()
  SnapshotManager-->>WorkspaceWatcher: Option<&WorkspaceIndex>
  alt previous snapshot exists
    WorkspaceWatcher->>WorkspaceIndexRepository: detect_moves(old_index, new_index)
    WorkspaceIndexRepository->>WorkspaceIndexRepository: IndexDiff::diff()
    WorkspaceIndexRepository-->>WorkspaceWatcher: Vec<FileMove>
    WorkspaceWatcher->>RepairEngine: apply_moves(moves)
    RepairEngine->>VaultContext: resolve_note_path(from)
    RepairEngine->>VaultContext: resolve_note_path(to)
    RepairEngine->>VaultContext: invalidate_notes(from)
    RepairEngine->>VaultContext: load_notes(to)
    RepairEngine-->>WorkspaceWatcher: usize applied
  end
  WorkspaceWatcher->>SnapshotManager: update(new_index)
  WorkspaceWatcher-->>Caller: FrilVaultResult<()>
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related PRs

  • FrilLab/frilvault#56: Implements the workspace indexing, health check, and repair system that this PR's FileMove, IndexDiff, RepairEngine, and WorkspaceIndexRepository move/repair helpers directly extend.

Poem

🐰 Hop hop! The cache has moved its den,
From cache to runtime, fresh and clean again.
A watcher now listens for files that stray,
Detects a rename, then shows them the way.
The engine repairs with a confident score—
No lost note left untracked anymore! 🗂️✨

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

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