Skip to content

refactor(core): introduce FrilVault facade#82

Merged
mors119 merged 1 commit into
FrilLab:mainfrom
mors119:refactor/frilvault
Jun 20, 2026
Merged

refactor(core): introduce FrilVault facade#82
mors119 merged 1 commit into
FrilLab:mainfrom
mors119:refactor/frilvault

Conversation

@mors119

@mors119 mors119 commented Jun 20, 2026

Copy link
Copy Markdown
Collaborator

Summary

refactor(core): introduce FrilVault facade

  • add FrilVault::open as a core entry point
  • centralize service bootstrap inside frilvault-core
  • prepare CLI and Node bridge to stop assembling internal repositories

Type of Change

  • feat
  • fix
  • docs
  • refactor
  • 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

  • Refactor

    • Restructured workspace initialization and configuration management to ensure consistent and reliable command execution across different directory contexts.
    • Updated internal architecture to provide explicit workspace context for all operations.
  • Tests

    • Added integration tests validating workspace operations and core functionality.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The PR introduces a FrilVault struct in frilvault-core with an open(workspace_root) constructor and converts the existing create_note_service and create_workspace_service free functions into instance methods. All seven CLI command execute functions are updated to call FrilVault::open(current_dir) and create services from the resulting workspace handle. Two integration tests are added to verify the new construction paths.

Changes

FrilVault Facade Refactor

Layer / File(s) Summary
FrilVault struct and service factory methods
crates/frilvault-core/src/app/frilvault.rs, crates/frilvault-core/src/app/mod.rs, crates/frilvault-core/src/lib.rs
Adds FrilVault struct with workspace_root: PathBuf, open() constructor, and create_note_service/create_workspace_service instance methods that replace the removed free functions. The frilvault submodule is made private while its contents remain re-exported. Module declaration order in lib.rs is adjusted.
CLI commands updated to use FrilVault::open
apps/frilvault-cli/src/command/add.rs, apps/frilvault-cli/src/command/delete.rs, apps/frilvault-cli/src/command/doctor.rs, apps/frilvault-cli/src/command/list.rs, apps/frilvault-cli/src/command/repair.rs, apps/frilvault-cli/src/command/search.rs, apps/frilvault-cli/src/command/stats.rs, apps/frilvault-cli/src/command/update.rs
All seven CLI command execute functions replace direct service-constructor free-function calls with FrilVault::open(std::env::current_dir()?) followed by the appropriate create_*_service(&workspace) instance call. Imports are updated in each file to reference FrilVault instead of the removed free functions.
Integration tests for FrilVault::open
crates/frilvault-core/src/tests/frilvault_app_test.rs, crates/frilvault-core/src/tests/mod.rs
Adds two tests: one creates a temp workspace and verifies that a note can be added and listed through the note service; the other verifies that a fresh workspace reports file_count of 0 through the workspace service.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • FrilLab/frilvault#40: Introduced the create_note_service() free-function call sites in the same CLI command files that this PR replaces with FrilVault::open(...).create_note_service(...).
  • FrilLab/frilvault#81: Directly introduces the FrilVault facade that this PR builds on to migrate CLI commands away from free-function service constructors.
  • FrilLab/frilvault#57: Updated the same doctor/repair/stats command wiring to use WorkspaceService, which this PR further migrates to the FrilVault::open construction path.

Poem

🐇 Hop, hop — no more loose functions scattered about,
A FrilVault::open bundles the workspace throughout!
Each command now bows to a struct, neat and bright,
create_note_service blooms in the workspace's light.
The rabbit cheers: one entry, all paths aligned right! 🌿

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 15.38% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: introducing a FrilVault facade to the core module as the primary entry point.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
crates/frilvault-core/src/app/frilvault.rs (1)

22-47: ⚡ Quick win

Extract shared workspace bootstrap into a private helper.

create_note_service and create_workspace_service repeat the same resolver/workspace/index setup. Centralizing that setup will reduce drift risk when bootstrap behavior changes.

♻️ Proposed refactor
 impl FrilVault {
+    fn bootstrap_workspace(&self) -> FrilVaultResult<(PathResolver, WorkspaceIndexRepository)> {
+        let resolver = PathResolver::new(&self.workspace_root);
+
+        let workspace_repository = WorkspaceRepository::new(resolver.clone());
+        workspace_repository.create_if_missing()?;
+
+        let index_repository = WorkspaceIndexRepository::new(resolver.clone());
+        index_repository.create_if_missing()?;
+
+        Ok((resolver, index_repository))
+    }
+
     pub fn create_note_service(&self) -> FrilVaultResult<NoteService> {
-        let resolver = PathResolver::new(&self.workspace_root);
-
-        let workspace_repository = WorkspaceRepository::new(resolver.clone());
-        workspace_repository.create_if_missing()?;
-
-        let index_repository = WorkspaceIndexRepository::new(resolver.clone());
-        index_repository.create_if_missing()?;
+        let (resolver, index_repository) = self.bootstrap_workspace()?;
 
         let note_repository = YamlNoteRepository::new(resolver.clone());
         let vault_context = VaultContext::new(note_repository, index_repository);
 
         Ok(NoteService::new(vault_context))
     }
 
     pub fn create_workspace_service(&self) -> FrilVaultResult<WorkspaceService> {
-        let resolver = PathResolver::new(&self.workspace_root);
-
-        let workspace_repository = WorkspaceRepository::new(resolver.clone());
-        workspace_repository.create_if_missing()?;
-
-        let index_repository = WorkspaceIndexRepository::new(resolver.clone());
-        index_repository.create_if_missing()?;
+        let (resolver, index_repository) = self.bootstrap_workspace()?;
 
         let note_repository = YamlNoteRepository::new(resolver);
         let vault_context = VaultContext::new(note_repository, index_repository.clone());
 
         Ok(WorkspaceService::new(vault_context, index_repository))
     }
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/frilvault-core/src/app/frilvault.rs` around lines 22 - 47, The methods
create_note_service and create_workspace_service contain duplicated code for
workspace bootstrap setup (creating PathResolver, WorkspaceRepository, and
WorkspaceIndexRepository instances with their create_if_missing calls). Extract
this common setup logic into a private helper method that returns the
initialized repositories and resolver, then call this helper from both
create_note_service and create_workspace_service to eliminate duplication and
reduce maintenance burden.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@crates/frilvault-core/src/app/frilvault.rs`:
- Around line 22-47: The methods create_note_service and
create_workspace_service contain duplicated code for workspace bootstrap setup
(creating PathResolver, WorkspaceRepository, and WorkspaceIndexRepository
instances with their create_if_missing calls). Extract this common setup logic
into a private helper method that returns the initialized repositories and
resolver, then call this helper from both create_note_service and
create_workspace_service to eliminate duplication and reduce maintenance burden.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: e8ad59c6-d474-4e5d-acdc-369359022501

📥 Commits

Reviewing files that changed from the base of the PR and between a8bafdc and 9f04839.

📒 Files selected for processing (13)
  • apps/frilvault-cli/src/command/add.rs
  • apps/frilvault-cli/src/command/delete.rs
  • apps/frilvault-cli/src/command/doctor.rs
  • apps/frilvault-cli/src/command/list.rs
  • apps/frilvault-cli/src/command/repair.rs
  • apps/frilvault-cli/src/command/search.rs
  • apps/frilvault-cli/src/command/stats.rs
  • apps/frilvault-cli/src/command/update.rs
  • crates/frilvault-core/src/app/frilvault.rs
  • crates/frilvault-core/src/app/mod.rs
  • crates/frilvault-core/src/lib.rs
  • crates/frilvault-core/src/tests/frilvault_app_test.rs
  • crates/frilvault-core/src/tests/mod.rs

@mors119 mors119 merged commit 0404ec9 into FrilLab:main Jun 20, 2026
3 checks passed
@mors119 mors119 deleted the refactor/frilvault branch June 20, 2026 08:42
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