Skip to content

refactor(core): Remove unused wrapper. Switch from yaml format to json#85

Merged
mors119 merged 3 commits into
FrilLab:mainfrom
mors119:refactor/switch-to-json
Jun 23, 2026
Merged

refactor(core): Remove unused wrapper. Switch from yaml format to json#85
mors119 merged 3 commits into
FrilLab:mainfrom
mors119:refactor/switch-to-json

Conversation

@mors119

@mors119 mors119 commented Jun 23, 2026

Copy link
Copy Markdown
Collaborator

Summary

Remove unused wrapper. Switch from yaml format to json format

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

Release Notes

  • Refactor

    • Migrated storage format from YAML to JSON for all notes and workspace metadata files.
  • Documentation

    • Updated architecture and implementation documentation to reflect the new JSON-based persistence model.

@coderabbitai

coderabbitai Bot commented Jun 23, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@mors119, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 53 minutes and 35 seconds. Learn how PR review limits work.

To continue reviewing without waiting, enable usage-based billing in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan refill rate.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, the refill rate gradually slows as usage increases. The highest same-day bursts are limited more strictly.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 65dfef8e-8f4d-4b19-8c6a-bd49374b154e

📥 Commits

Reviewing files that changed from the base of the PR and between 11a43ef and 9df3858.

📒 Files selected for processing (6)
  • crates/frilvault-core/src/note/entity/note_file.rs
  • crates/frilvault-core/src/runtime/vault_context.rs
  • crates/frilvault-core/src/storage/mod.rs
  • crates/frilvault-core/src/storage/note_file_record.rs
  • crates/frilvault-core/src/storage/repository.rs
  • crates/frilvault-core/src/workspace/path/path_resolver.rs
📝 Walkthrough

Walkthrough

The PR migrates the entire storage and serialization layer from YAML (serde_yml) to JSON (serde_json). The serde_yml dependency is replaced by serde_json, file extension and workspace filename constants change to .json, the YamlParser/NoteParser trait stack is replaced by a standalone JsonParser, YamlNoteRepository is renamed to NoteRepository, workspace repositories adopt serde_json, scattered anchor modules are consolidated into a single anchor.rs, and all tests and documentation are updated accordingly.

Changes

YAML → JSON Storage Migration

Layer / File(s) Summary
Dependency, constants, and error type
crates/frilvault-core/Cargo.toml, crates/frilvault-core/src/constants.rs, crates/frilvault-core/src/error/errors.rs
Swaps serde_yml for serde_json = "1.0.150", sets NOTE_FILE_EXTENSION to "json" and WORKSPACE_FILE_NAME to "workspace.json", and replaces FrilVaultError::Yaml(serde_yml::Error) with FrilVaultError::JSON(serde_json::Error).
Note entity anchor consolidation
crates/frilvault-core/src/note/entity/anchor.rs, crates/frilvault-core/src/note/entity/mod.rs
Removes four separate anchor modules (line_anchor, note_anchor, symbol_anchor, symbol_kind) and re-exports, replaces them with a single anchor.rs defining NoteAnchor, LineAnchor, SymbolAnchor, and SymbolKind. Updates mod.rs to re-export only anchor, note, and note_file.
NoteParser trait removal and JsonParser addition
crates/frilvault-core/src/parser/json_parser.rs, crates/frilvault-core/src/parser/mod.rs
Removes the NoteParser trait (note_parser.rs) and YamlParser (yaml_parser.rs); adds JsonParser with serialize/deserialize methods via serde_json; rewires parser/mod.rs to expose only json_parser.
NoteRepository replacing YamlNoteRepository
crates/frilvault-core/src/storage/repository.rs, crates/frilvault-core/src/storage/mod.rs
Renames YamlNoteRepository to NoteRepository backed by JsonParser; save_by_source_file now serializes JSON. Updates storage/mod.rs to declare and re-export repository instead of yaml_repository.
Workspace repositories, path resolver, and VaultContext wiring
crates/frilvault-core/src/workspace/path/path_resolver.rs, crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs, crates/frilvault-core/src/workspace/repository/workspace_repository.rs, crates/frilvault-core/src/runtime/vault_context.rs, crates/frilvault-core/src/app/frilvault.rs
Switches WorkspaceIndexRepository load/save/rebuild and WorkspaceRepository save to serde_json; updates PathResolver::workspace_index_path to workspace.json; changes VaultContext field and constructor from YamlNoteRepository to NoteRepository; updates FrilVault::build_context accordingly.
Test suite migration to JSON
crates/frilvault-core/src/tests/helper.rs, crates/frilvault-core/src/tests/mod.rs, crates/frilvault-core/src/tests/parser_test.rs, crates/frilvault-core/src/tests/repository_test.rs, crates/frilvault-core/src/tests/note_resolver_test.rs, crates/frilvault-core/src/tests/note_service_test.rs
Replaces create_test_yaml_repository with create_test_repository; renames test modules from yaml_* to parser_test/repository_test; adds JsonParser serialize/deserialize unit tests; updates .yml.json path assertions; renames test functions to JSON-specific names.
Documentation updates
README.md, docs/ARCHITECTURE.md, docs/CURRENT_STATE.md, docs/ROADMAP.md
Updates all YAML references to JSON, renames workspace.yml to workspace.json, and replaces YamlNoteRepository with NoteRepository across README and all doc files.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • FrilLab/frilvault#38: This PR directly replaces the YamlParser/YamlNoteRepository/serde_yml infrastructure introduced in #38 with the JSON equivalents.
  • FrilLab/frilvault#78: That PR created VaultContext around YamlNoteRepository; this PR changes the same field and constructor to use NoteRepository.
  • FrilLab/frilvault#57: Both PRs modify crates/frilvault-core/src/note/entity/mod.rs and the anchor module layout, with this PR consolidating what #57 split into multiple files.

Poem

🐇 Hop, hop, away with the YAML today,
JSON curly braces are here to stay!
workspace.json gleams in the vault,
No more serde_yml — it's not our fault.
The parser hops light, the repo renames right,
All tests turn green in the JSON moonlight! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 33.33% 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 captures the main changes: removing an unused wrapper (NoteParser trait and associated implementations) and switching storage format from YAML to JSON.
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.

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

Actionable comments posted: 2

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs (1)

23-33: 🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Prevent silent index reset when migrating existing workspaces.

Line 27 returns a default index when workspace.json is absent, and Line 58 persists that default. For users upgrading from YAML-only index files, this silently drops prior index state instead of migrating/failing explicitly.

Also applies to: 51-59

🤖 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/workspace/repository/workspace_index_repository.rs`
around lines 23 - 33, When the load method detects that the workspace index file
does not exist at line 27, instead of returning a default WorkspaceIndex, check
for legacy YAML index files in the workspace directory. Implement migration
logic to convert the existing YAML format to the new JSON format, or fail
explicitly with a clear error message indicating the migration issue, rather
than silently returning a default index that would drop prior workspace state.
🤖 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.

Inline comments:
In `@crates/frilvault-core/src/constants.rs`:
- Line 2: The change to NOTE_FILE_EXTENSION breaks backward compatibility with
existing vaults using YAML files. Keep both the JSON extension constant and add
a legacy YAML extension constant in the constants.rs file, then update the file
loading logic throughout the codebase to first attempt reading from the JSON
file path, fall back to reading from the YAML file path if JSON is not found,
and automatically rewrite the loaded data back to JSON format to migrate the
vault forward. This ensures existing YAML vaults remain discoverable and
functional while new data is stored in JSON.

In `@crates/frilvault-core/src/storage/repository.rs`:
- Around line 56-58: The current implementation only writes to JSON format
without handling the migration of existing legacy .yml note files, causing them
to become inaccessible after upgrade. Before the write operation in the
serialize and fs::write calls, implement a migration or fallback mechanism that
detects existing .yml files and converts them to the new JSON format.
Alternatively, ensure the read path checks for and loads from existing .yml
files if the corresponding .json file doesn't exist, preserving backward
compatibility during the transition period before fully switching to JSON-only
storage.

---

Outside diff comments:
In
`@crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs`:
- Around line 23-33: When the load method detects that the workspace index file
does not exist at line 27, instead of returning a default WorkspaceIndex, check
for legacy YAML index files in the workspace directory. Implement migration
logic to convert the existing YAML format to the new JSON format, or fail
explicitly with a clear error message indicating the migration issue, rather
than silently returning a default index that would drop prior workspace state.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 7eca1424-b209-4c6e-a0f6-744eb7e126f2

📥 Commits

Reviewing files that changed from the base of the PR and between 29679b4 and 11a43ef.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (31)
  • README.md
  • crates/frilvault-core/Cargo.toml
  • crates/frilvault-core/src/app/frilvault.rs
  • crates/frilvault-core/src/constants.rs
  • crates/frilvault-core/src/error/errors.rs
  • crates/frilvault-core/src/note/entity/anchor.rs
  • crates/frilvault-core/src/note/entity/line_anchor.rs
  • crates/frilvault-core/src/note/entity/mod.rs
  • crates/frilvault-core/src/note/entity/note_anchor.rs
  • crates/frilvault-core/src/note/entity/symbol_anchor.rs
  • crates/frilvault-core/src/note/entity/symbol_kind.rs
  • crates/frilvault-core/src/parser/json_parser.rs
  • crates/frilvault-core/src/parser/mod.rs
  • crates/frilvault-core/src/parser/note_parser.rs
  • crates/frilvault-core/src/parser/yaml_parser.rs
  • crates/frilvault-core/src/runtime/vault_context.rs
  • crates/frilvault-core/src/storage/mod.rs
  • crates/frilvault-core/src/storage/repository.rs
  • crates/frilvault-core/src/tests/helper.rs
  • crates/frilvault-core/src/tests/mod.rs
  • crates/frilvault-core/src/tests/note_resolver_test.rs
  • crates/frilvault-core/src/tests/note_service_test.rs
  • crates/frilvault-core/src/tests/parser_test.rs
  • crates/frilvault-core/src/tests/repository_test.rs
  • crates/frilvault-core/src/tests/yaml_parser_test.rs
  • crates/frilvault-core/src/workspace/path/path_resolver.rs
  • crates/frilvault-core/src/workspace/repository/workspace_index_repository.rs
  • crates/frilvault-core/src/workspace/repository/workspace_repository.rs
  • docs/ARCHITECTURE.md
  • docs/CURRENT_STATE.md
  • docs/ROADMAP.md
💤 Files with no reviewable changes (7)
  • crates/frilvault-core/src/tests/yaml_parser_test.rs
  • crates/frilvault-core/src/note/entity/line_anchor.rs
  • crates/frilvault-core/src/note/entity/symbol_kind.rs
  • crates/frilvault-core/src/parser/yaml_parser.rs
  • crates/frilvault-core/src/parser/note_parser.rs
  • crates/frilvault-core/src/note/entity/symbol_anchor.rs
  • crates/frilvault-core/src/note/entity/note_anchor.rs

@@ -1,7 +1,7 @@
pub const VAULT_DIR_NAME: &str = ".vault";
pub const NOTE_FILE_EXTENSION: &str = "yml";
pub const NOTE_FILE_EXTENSION: &str = "json";

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Add a backward-compatible read path for legacy YAML vault data.

Changing both constants to JSON-only makes existing *.yml notes and workspace.yml undiscoverable unless migration/fallback is guaranteed. That is a persisted storage contract break for existing vaults.

Minimal compatibility bridge
 pub const NOTE_FILE_EXTENSION: &str = "json";
+pub const LEGACY_NOTE_FILE_EXTENSION: &str = "yml";
 ...
 pub const WORKSPACE_FILE_NAME: &str = "workspace.json";
+pub const LEGACY_WORKSPACE_FILE_NAME: &str = "workspace.yml";

Then load-path logic should: try JSON first, fallback to legacy YAML once, then rewrite JSON.

Also applies to: 7-7

🤖 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/constants.rs` at line 2, The change to
NOTE_FILE_EXTENSION breaks backward compatibility with existing vaults using
YAML files. Keep both the JSON extension constant and add a legacy YAML
extension constant in the constants.rs file, then update the file loading logic
throughout the codebase to first attempt reading from the JSON file path, fall
back to reading from the YAML file path if JSON is not found, and automatically
rewrite the loaded data back to JSON format to migrate the vault forward. This
ensures existing YAML vaults remain discoverable and functional while new data
is stored in JSON.

Comment on lines +56 to +58
let json = self.parser.serialize(note_file)?;

fs::write(note_path, yaml)?;
fs::write(note_path, json)?;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🗄️ Data Integrity & Integration | 🟠 Major | 🏗️ Heavy lift

Add a legacy-note migration/fallback path before fully switching writes to JSON.

On Line 56 and Line 58, writes are JSON-only. Combined with JSON path resolution/loading, existing .yml note files become unreadable after upgrade (reads resolve missing .json and fall back to empty/default), which effectively hides previously persisted notes.

🤖 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/storage/repository.rs` around lines 56 - 58, The
current implementation only writes to JSON format without handling the migration
of existing legacy .yml note files, causing them to become inaccessible after
upgrade. Before the write operation in the serialize and fs::write calls,
implement a migration or fallback mechanism that detects existing .yml files and
converts them to the new JSON format. Alternatively, ensure the read path checks
for and loads from existing .yml files if the corresponding .json file doesn't
exist, preserving backward compatibility during the transition period before
fully switching to JSON-only storage.

@mors119 mors119 merged commit 53db17d into FrilLab:main Jun 23, 2026
3 checks passed
@mors119 mors119 deleted the refactor/switch-to-json branch June 23, 2026 23:47
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