Skip to content

SOW-0173: Rust Registry resolves relative watch directories - #24

Open
ktsaou wants to merge 7 commits into
sow-0172/rust-log-relative-dirfrom
sow-0173/rust-registry-relative-dir
Open

ktsaou wants to merge 7 commits into
sow-0172/rust-log-relative-dirfrom
sow-0173/rust-registry-relative-dir

Conversation

@ktsaou

@ktsaou ktsaou commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Registry::watch_directory and unwatch_directory make 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 returned Ok with zero files.
  • Absolute input is used unchanged, so existing callers see identical keys and paths.
  • New integration test drives the real notify watcher: relative watch, create event, unwatch. It fails without the fix.
  • SOW-0174 tracks a pre-existing issue found while validating: unwatch leaves files registered when the watch string has a trailing slash or names a machine-id directory directly.

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_directory and unwatch_directory now 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 returned Ok with zero files; absolute input is used unchanged and an empty directory is now refused with an error.

  • Adds a Unix-only integration test that drives the real notify watcher: relative watch, create, rename and remove events, unwatch. It fails without the fix.
  • Validation: 685 workspace tests pass, clippy clean on changed lines, rustfmt and SOW audit clean.
  • Tracks a pre-existing issue as SOW-0174: unwatch leaves files registered when the watch string has a trailing slash or names a machine-id directory directly.

Written for commit 7ffd9f7. Summary will update on new commits.

View guided diff Turn on auto-fix

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

coderabbitai Bot commented Nov 5, 2026 •

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 74d449fc-4e7b-4d49-963b-3d754354e91c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@CLAassistant

CLAassistant commented Nov 5, 2026 •

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@codacy-production

codacy-production Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

🟢 Metrics 51 complexity · 4 duplication

Metric Results
Complexity 51
Duplication 4

View in Codacy

AI Reviewer: first review requested successfully. AI can make mistakes. Always validate suggestions.

Run reviewer

TIP This summary will be updated as you push new changes.

@codacy-production codacy-production Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

⚠️ Resolve issues before merging

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

@cubic-dev-ai cubic-dev-ai 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.

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
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread .agents/sow/SOW-status.md Resolved
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

This branch has not been deployed

No deployments
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.

2 participants