Repository navigation
Conversation
Registry::watch_directory and unwatch_directory now make a relative directory absolute once, lexically, so journal files under it are registered and notify events for it are applied. Absolute input is used unchanged. Completes SOW-0173 and tracks the pre-existing unwatch exact-key mismatch as SOW-0174.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | 51 |
| Duplication | 4 |
AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Pull Request Overview
An empty watch-directory input can resolve to the process working directory, causing unintended scanning and watching; this should be fixed before merging.
Coverage is also missing for relative-watch remove/rename notifications and preservation of absolute inputs. The registry implementation is a complexity hotspot, so these scenarios are particularly useful to validate.
About this PR
- Add automated tests for relative-watch remove and rename notifications, and for preserving absolute directory behavior.
Test suggestions
- Register existing journal files from a relative directory
- Apply a create notification for a relative watch
- Apply remove and rename notifications for a relative watch
- Unwatch using the same relative directory and remove its files
- Verify absolute directory input remains unchanged
- Reject an empty directory
Prompt proposal for missing tests
Consider implementing these tests if applicable:
1. Apply remove and rename notifications for a relative watch
2. Verify absolute directory input remains unchanged
Make this review better
TIP Add a ticket key to the branch or title so the reviewer can check the PR against it. Or tell us which ticket tracker you use here.
TIP How was this review? Give us feedback
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Architecture diagram
sequenceDiagram
participant Caller as External Caller
participant Reg as Registry
participant Abs as absolute_directory
participant Repo as Repository
participant Watch as notify Watcher
participant FS as Filesystem
Note over Caller,FS: Directory Watch and File Registration
Caller->>Reg: watch_directory(path)
Reg->>Abs: resolve path lexically
Abs-->>Reg: absolute path or error
alt Invalid path (empty, non-UTF-8)
Reg-->>Caller: RegistryError::Io
else Valid path
Reg->>Repo: scan_journal_files(abs_path)
Repo->>FS: walk directory
FS-->>Repo: journal files
Repo->>Repo: register files with abs keys
Reg->>Watch: add watch on abs path
Watch-->>Reg: watch established
Reg-->>Caller: Ok
end
Note over Watch,FS: Notify Event (create/remove/rename)
FS->>Watch: file system change
Watch-->>Reg: event with abs path
Reg->>Repo: process_event(abs_path)
Repo->>Repo: add/remove file entry
Repo-->>Reg: updated
Reg-->>Watch: event handled
Note over Caller,Reg: Unwatch
Caller->>Reg: unwatch_directory(path)
Reg->>Abs: resolve path lexically
Abs-->>Reg: absolute path
Reg->>Watch: remove watch
Watch-->>Reg: watch removed
Reg->>Repo: remove files by abs key
Repo-->>Reg: files removed
Reg-->>Caller: Ok
Note over Reg,Repo: SOW-0174 (pre-existing, tracked):<br/>trailing slash or machine-id dir<br/>leaves files registered
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
The relative watch test now applies create, rename and remove notify events, matching the SOW's acceptance criterion, and runs on Unix only because Windows temp directories can sit on another drive.
…stry-relative-dir # Conflicts: # .agents/sow/pending/SOW-0173-20261104-rust-registry-relative-directory.md
…stry-relative-dir
…stry-relative-dir
Summary
Registry::watch_directoryandunwatch_directorymake a relative directory absolute once, lexically (std::path::absolute), so journal files under it are registered and notify events for it are applied. Before, every file was skipped and the call returnedOkwith zero files.Stacked on #23 (SOW-0172).
Validation
cargo test --workspace: 685 passed, 0 failed.cargo clippy -p systemd-journal-sdk-registry --all-targets: no warnings in changed lines..agents/sow/audit.sh: clean.Summary by cubic
Registry::watch_directoryandunwatch_directorynow resolve a relative directory once, lexically, so journal files under it are registered and notify events for it are applied. Previously every file was skipped and the call returnedOkwith zero files; absolute input is used unchanged and an empty directory is now refused with an error.notifywatcher: relative watch, create, rename and remove events, unwatch. It fails without the fix.Written for commit 7ffd9f7. Summary will update on new commits.