Filesystem watcher
Summary by CodeRabbit
-
New Features
- Introduced a new filesystem watcher tool for repositories, including a command-line interface with start, stop, and status commands.
- Added an asynchronous file status cache for fast tracking of modified, added, removed, and untracked files.
- Implemented an event processor to efficiently handle filesystem changes and update the status cache.
- Enabled inter-process communication via Unix sockets for client-server interactions.
- Provided a protocol for structured status and control messages between the CLI and watcher daemon.
-
Bug Fixes
- Not applicable.
-
Tests
- Added comprehensive unit, integration, and protocol serialization tests to ensure correct watcher behavior and communication.
[!IMPORTANT]
Review skipped
Draft detected.
Please check the settings in the CodeRabbit UI or the
.coderabbit.yamlfile in this repository. To trigger a single review, invoke the@coderabbitai reviewcommand.You can disable this status message by setting the
reviews.review_statustofalsein the CodeRabbit configuration file.
Walkthrough
A new Rust-based filesystem watcher daemon for Oxen repositories was introduced under src/watcher, including its own Cargo manifest, source modules, protocol definitions, IPC server, event processor, cache, CLI, error handling, and comprehensive tests (unit and integration). The workspace manifest was updated to register this new member.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Workspace Manifest Updateoxen-rust/Cargo.toml |
Added src/watcher to the workspace members list. |
Watcher Crate Manifestoxen-rust/src/watcher/Cargo.toml |
Introduced new Cargo.toml for the watcher package with dependencies, metadata, and binary/lib targets. |
Core Watcher Modulesoxen-rust/src/watcher/src/cache.rs,oxen-rust/src/watcher/src/cli.rs,oxen-rust/src/watcher/src/error.rs,oxen-rust/src/watcher/src/event_processor.rs,oxen-rust/src/watcher/src/ipc.rs,oxen-rust/src/watcher/src/lib.rs,oxen-rust/src/watcher/src/main.rs,oxen-rust/src/watcher/src/monitor.rs,oxen-rust/src/watcher/src/protocol.rs |
Implemented the watcher daemon: status cache, CLI parsing, error handling, event processing, IPC server, library root, application entrypoint, filesystem monitoring, and protocol definitions. |
Unit Tests for Watcher Componentsoxen-rust/src/watcher/src/cache_test.rs,oxen-rust/src/watcher/src/event_processor_test.rs,oxen-rust/src/watcher/src/protocol_test.rs |
Added comprehensive async unit tests for cache, event processor, and protocol serialization/deserialization. |
Integration Testsoxen-rust/src/watcher/tests/integration_test.rs |
Added async integration tests for watcher lifecycle, file detection, and prevention of multiple watcher instances. |
Sequence Diagram(s)
sequenceDiagram
participant CLI
participant IPC_Server
participant StatusCache
participant EventProcessor
participant FileSystem
CLI->>IPC_Server: Send WatcherRequest (e.g., Start, Status, Stop)
alt Start
IPC_Server->>StatusCache: Initialize cache
IPC_Server->>EventProcessor: Start event loop
EventProcessor->>FileSystem: Watch for changes
FileSystem-->>EventProcessor: Notify events
EventProcessor->>StatusCache: Update file statuses
IPC_Server-->>CLI: Watcher started (WatcherResponse)
else Status
IPC_Server->>StatusCache: Query status
StatusCache-->>IPC_Server: StatusResult
IPC_Server-->>CLI: WatcherResponse::Status
else Stop
IPC_Server-->>CLI: WatcherResponse::Ok
IPC_Server->>IPC_Server: Shutdown
end
Estimated code review effort
🎯 4 (Complex) | ⏱️ ~40 minutes
Poem
A watcher wakes in Oxen's den,
With ears alert for file and pen.
It caches, listens, logs with glee—
A rabbit's dream of IPC!
With tests that hop and code that shines,
This daemon guards your changing lines.
🐇✨
✨ Finishing touches
🧪 Generate unit tests
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
- [ ] Commit unit tests in branch
filesystem-watcher
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
@coderabbit review
✅ Actions performed
Review triggered.
Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.