Skip to content

Implement daemon core scaffolding#12

Merged
leynos merged 6 commits intomainfrom
codex/implement-comenqd-daemon-core-features
Jul 27, 2025
Merged

Implement daemon core scaffolding#12
leynos merged 6 commits intomainfrom
codex/implement-comenqd-daemon-core-features

Conversation

@leynos
Copy link
Copy Markdown
Owner

@leynos leynos commented Jul 27, 2025

Summary

  • initialize structured logging for comenqd
  • create the queue directory on startup
  • spawn daemon tasks from main
  • add unit test for queue creation
  • document daemon core decisions
  • mark roadmap items done

Testing

  • make fmt
  • make lint
  • make test

https://chatgpt.com/codex/tasks/task_e_6885798eb22c83229346cb5503416d88

Summary by Sourcery

Implement core scaffolding for the comenqd daemon by introducing structured logging, ensuring queue directory initialization on startup, adding test coverage for the queue setup, and updating documentation to reflect these changes.

New Features:

  • Add a logging module that initializes structured JSON logging via tracing_subscriber

Enhancements:

  • Create the queue directory on daemon startup and emit an informational log
  • Refactor main.rs to use the new logging::init function instead of direct tracing_subscriber initialization

Documentation:

  • Mark roadmap items for logging, queue initialization, and task spawning as completed
  • Update design documentation to include logging setup and queue directory creation
  • Reformat AGENTS.md for consistent line wrapping

Tests:

  • Add an asynchronous unit test verifying that run() creates the queue directory

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented Jul 27, 2025

Reviewer's Guide

This PR scaffolds the comenqd daemon by centralizing structured logging, ensuring the queue directory is created at startup (with logging), adding a unit test for directory creation, and updating documentation and roadmap items accordingly.

Sequence diagram for daemon startup with structured logging and queue directory creation

sequenceDiagram
    actor System
    participant Main as main()
    participant Logging as logging::init()
    participant Config as Config::load()
    participant Daemon as daemon::run()
    participant FS as fs::create_dir_all()
    participant Tracing as tracing::info

    System->>Main: Start process
    Main->>Logging: Initialize structured logging
    Logging-->>Main: Logging ready
    Main->>Config: Load configuration
    Config-->>Main: Config object
    Main->>Tracing: Log daemon started
    Main->>Daemon: run(config)
    Daemon->>FS: Create queue directory
    FS-->>Daemon: Directory created
    Daemon->>Tracing: Log queue directory prepared
    Daemon-->>Main: Daemon tasks spawned
Loading

Class diagram for logging initialization and daemon run changes

classDiagram
    class logging {
        +init()
    }
    class daemon {
        +run(config: Config) : Result
    }
    class Config {
        +github_token: String
        +socket_path: PathBuf
        +queue_path: PathBuf
        +cooldown_period_seconds: u64
        +load() : Result<Config>
    }
    logging <.. daemon : uses
    Config <.. daemon : uses
    daemon : +run() creates queue dir
    daemon : +run() logs queue dir
    main o-- logging : calls
    main o-- Config : loads
    main o-- daemon : runs
Loading

File-Level Changes

Change Details Files
Introduce a dedicated logging module for structured tracing
  • Add logging.rs to initialize a global JSON-formatted tracing subscriber
  • Replace direct tracing_subscriber::fmt::init() in main.rs with logging::init()
crates/comenqd/src/logging.rs
crates/comenqd/src/main.rs
Ensure queue directory is created before daemon tasks run
  • Invoke fs::create_dir_all for config.queue_path at the start of run
  • Emit a tracing info log after preparing the queue directory
crates/comenqd/src/daemon.rs
Add unit test for queue directory creation
  • Implement a Tokio test that spawns run and asserts the queue path exists
  • Use tempdir to isolate filesystem interactions
crates/comenqd/src/daemon.rs
Update project documentation and mark roadmap items as done
  • Correct formatting and line wrapping in AGENTS.md
  • Mark structured logging, queue initialization, and task spawning as completed in docs/roadmap.md
  • Document logging initialization and queue directory logic in docs/comenq-design.md
AGENTS.md
docs/roadmap.md
docs/comenq-design.md

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 27, 2025

Summary by CodeRabbit

  • New Features

    • Introduced structured logging with JSON output and dynamic log level configuration.
    • Ensured the queue directory is created asynchronously at daemon startup.
  • Bug Fixes

    • Improved clarity and consistency in documentation and guidelines.
  • Documentation

    • Expanded details on daemon initialisation, logging, and queue directory creation.
    • Updated roadmap to reflect completed tasks related to logging and queue management.
  • Tests

    • Added tests for asynchronous directory creation and logging initialisation.

Walkthrough

Update the daemon to ensure the queue directory is created before startup, introduce a centralised logging module with structured JSON output, and revise the main function to use this logging initialisation. Enhance documentation to clarify the daemon’s startup sequence and mark relevant roadmap items as completed. Apply minor formatting adjustments to AGENTS.md.

Changes

File(s) Change Summary
AGENTS.md Reformatted lines and adjusted line wrapping for improved readability; no content changes.
crates/comenqd/src/{daemon.rs,main.rs} Added async queue directory creation before daemon runs; refactored main to use new logging module.
crates/comenqd/src/logging.rs Added logging module with init() for structured JSON logging; included minimal test.
docs/{comenq-design.md,roadmap.md} Expanded daemon startup description and marked key roadmap tasks as completed.

Sequence Diagram(s)

sequenceDiagram
    participant Main
    participant Logging
    participant Daemon
    participant FileSystem

    Main->>Logging: init()
    Logging-->>Main: Logging initialised (JSON, RUST_LOG)
    Main->>Daemon: run(config)
    Daemon->>FileSystem: create_dir_all(config.queue_path)
    FileSystem-->>Daemon: Directory ensured
    Daemon->>Daemon: Spawn UDS listener & queue worker
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related PRs

Poem

Logs now structured, queues prepared with care,
The daemon awakens, its duties laid bare.
Docs and roadmap checked, all tasks in a row,
With JSON logs shining, let the messages flow!

🚀✨

✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch codex/implement-comenqd-daemon-core-features

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey @leynos - I've reviewed your changes and found some issues that need to be addressed.

Blocking issues:

  • Use of #[allow(dead_code)] is forbidden; please use a narrowly scoped #[expect(lint, reason = "...")] if absolutely necessary. (link)

General comments:

  • In run, replace the blocking std::fs::create_dir_all call with tokio::fs::create_dir_all (or wrap it in spawn_blocking) to avoid blocking the async runtime.
  • Extract the queue directory creation into a separate helper so you can test it directly instead of spawning the full daemon and relying on tokio::time::sleep.
  • Remove the now-unnecessary #[allow(dead_code)] on logging::init since it’s actually used in main.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In `run`, replace the blocking `std::fs::create_dir_all` call with `tokio::fs::create_dir_all` (or wrap it in `spawn_blocking`) to avoid blocking the async runtime.
- Extract the queue directory creation into a separate helper so you can test it directly instead of spawning the full daemon and relying on `tokio::time::sleep`.
- Remove the now-unnecessary `#[allow(dead_code)]` on `logging::init` since it’s actually used in `main`.

## Individual Comments

### Comment 1
<location> `AGENTS.md:31` </location>
<code_context>
+  examples demonstrating the usage and outcome of the function. Test
+  documentation should omit examples where the example serves only to reiterate
+  the test logic.
+- **Keep file size managable.** No single code file may be longer than 400
+  lines.
   Long switch statements or dispatch tables should be broken up by feature and
-  constituents colocated with targets. Large blocks of test data should be moved
</code_context>

<issue_to_address>
Typo: 'managable' should be 'manageable'.

Please update the spelling to 'manageable'.
</issue_to_address>

<suggested_fix>
<<<<<<< SEARCH
- **Keep file size managable.** No single code file may be longer than 400
  lines.
=======
- **Keep file size manageable.** No single code file may be longer than 400
  lines.
>>>>>>> REPLACE

</suggested_fix>

### Comment 2
<location> `crates/comenqd/src/logging.rs:10` </location>
<code_context>
+use tracing_subscriber::{EnvFilter, fmt};
+
+/// Initialize the global tracing subscriber.
+#[allow(dead_code)]
+pub fn init() {
+    fmt()
</code_context>

<issue_to_address>
Use of `#[allow(dead_code)]` is forbidden; please use a narrowly scoped `#[expect(lint, reason = "...")]` if absolutely necessary.

The review instructions explicitly forbid the use of `#[allow]`. If this lint must be suppressed, please use `#[expect(dead_code, reason = "...")]` with a clear justification, and scope it as narrowly as possible.
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment thread AGENTS.md Outdated
Comment thread crates/comenqd/src/logging.rs Outdated
@leynos
Copy link
Copy Markdown
Owner Author

leynos commented Jul 27, 2025

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 27, 2025

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (2)
AGENTS.md (1)

31-31: Fix the persistent typo: "managable" should be "manageable".

This typo was flagged in previous reviews but remains uncorrected.

-- **Keep file size managable.** No single code file may be longer than 400
+- **Keep file size manageable.** No single code file may be longer than 400
crates/comenqd/src/logging.rs (1)

10-10: Remove forbidden #[allow(dead_code)] attribute.

Use #[expect(dead_code, reason = "...")] with proper justification if lint suppression is absolutely necessary.

-#[allow(dead_code)]
+#[expect(dead_code, reason = "Used by main.rs - FIXME: remove when integration complete")]
📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 89d688e and 414b725.

⛔ Files ignored due to path filters (1)
  • Cargo.lock is excluded by !**/*.lock
📒 Files selected for processing (6)
  • AGENTS.md (4 hunks)
  • crates/comenqd/src/daemon.rs (2 hunks)
  • crates/comenqd/src/logging.rs (1 hunks)
  • crates/comenqd/src/main.rs (1 hunks)
  • docs/comenq-design.md (1 hunks)
  • docs/roadmap.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • AGENTS.md
  • docs/comenq-design.md
  • docs/roadmap.md
**/*.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • crates/comenqd/src/main.rs
  • crates/comenqd/src/logging.rs
  • crates/comenqd/src/daemon.rs
🧠 Learnings (1)
AGENTS.md (1)

Learnt from: CR
PR: leynos/wireframe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-21T13:10:04.795Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of 'license' which is to be left unchanged for community consistency).

🧬 Code Graph Analysis (1)
crates/comenqd/src/main.rs (1)
crates/comenqd/src/logging.rs (1)
  • init (11-16)
🪛 LanguageTool
AGENTS.md

[locale-violation] ~47-~47: LICENSE must be spelled with a “c” when used as a noun in British English. Use “licence”.
Context: ...grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged ...

(LICENCE_LICENSE_NOUN_SINGULAR)


[uncategorized] ~161-~161: Possible missing comma found.
Context: ...(>=) version requirements is strictly forbidden as they introduce unacceptable risk a...

(AI_HYDRA_LEO_MISSING_COMMA)

docs/comenq-design.md

[style] ~1016-~1016: Would you like to use the Oxford spelling “initialized”? The spelling ‘initialised’ is also correct.
Context: ... described above. Structured logging is initialised using tracing_subscriber with JSON ou...

(OXFORD_SPELLING_Z_NOT_S)

🔇 Additional comments (14)
AGENTS.md (6)

12-13: Line wrapping improvement looks good.

The rewrapping maintains readability whilst adhering to the 80-column limit.


34-35: Formatting improvement approved.

The line wrapping enhances readability without altering the content.


47-48: Formatting change approved.

The line rewrapping improves consistency. Note that the static analysis hint about "LICENSE" vs "LICENCE" is a false positive here, as this explicitly documents an exception for the filename convention.


158-159: Line wrapping improvement looks good.

The rewrapping maintains clarity whilst adhering to formatting standards.


161-162: Formatting improvement approved.

The line rewrapping enhances readability. The static analysis hint about a missing comma is a false positive - the sentence structure is grammatically correct.


169-170: Line wrapping improvement looks good.

The rewrapping maintains readability within the column limits.

crates/comenqd/src/logging.rs (2)

1-6: Module documentation follows guidelines correctly.

The //! doc comment properly explains the module's purpose and utility as required.


7-7: Import statement is appropriate.

The imports align with the module's functionality requirements.

crates/comenqd/src/main.rs (2)

7-7: Module declaration is appropriate.

The logging module import enables centralised logging initialisation.


16-16: Centralised logging initialisation is an improvement.

Moving logging setup to a dedicated module enhances maintainability and follows good separation of concerns.

docs/roadmap.md (3)

37-38: Task completion accurately reflects implementation.

The structured logging setup using tracing and tracing-subscriber has been properly implemented.


40-41: Queue initialisation task completion is accurate.

The implementation ensures the yaque persistent queue directory is created at startup.


43-44: Main function structuring task completion is correct.

The daemon's main function now properly spawns the required long-running Tokio tasks.

docs/comenq-design.md (1)

1016-1019: Documentation accurately reflects implementation.

The updates correctly describe the daemon's startup sequence, structured logging with JSON output, and queue directory creation. The British English spelling "initialised" is correct per the en-GB-oxendict guidelines - ignore the static analysis suggestion for Oxford spelling.

Comment thread crates/comenqd/src/daemon.rs Outdated
Comment thread crates/comenqd/src/daemon.rs
Comment thread crates/comenqd/src/logging.rs
@github-actions
Copy link
Copy Markdown

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jul 27, 2025

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

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

♻️ Duplicate comments (1)
crates/comenqd/src/logging.rs (1)

21-24: Enhance test coverage to verify logging configuration.

The test merely calls init() without verifying that the tracing subscriber is configured correctly. Expand the test to capture log output or verify that log events are emitted.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 414b725 and eb7a88f.

📒 Files selected for processing (4)
  • AGENTS.md (4 hunks)
  • crates/comenqd/src/daemon.rs (3 hunks)
  • crates/comenqd/src/logging.rs (1 hunks)
  • docs/comenq-design.md (1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • AGENTS.md
  • docs/comenq-design.md
**/*.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • crates/comenqd/src/logging.rs
  • crates/comenqd/src/daemon.rs
🧠 Learnings (1)
AGENTS.md (1)

Learnt from: CR
PR: leynos/wireframe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-21T13:10:04.795Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of 'license' which is to be left unchanged for community consistency).

🪛 LanguageTool
AGENTS.md

[locale-violation] ~46-~46: LICENSE must be spelled with a “c” when used as a noun in British English. Use “licence”.
Context: ...grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged ...

(LICENCE_LICENSE_NOUN_SINGULAR)


[uncategorized] ~160-~160: Possible missing comma found.
Context: ...(>=) version requirements is strictly forbidden as they introduce unacceptable risk a...

(AI_HYDRA_LEO_MISSING_COMMA)

docs/comenq-design.md

[style] ~1016-~1016: Would you like to use the Oxford spelling “initialized”? The spelling ‘initialised’ is also correct.
Context: ... described above. Structured logging is initialised using tracing_subscriber with JSON ou...

(OXFORD_SPELLING_Z_NOT_S)

🔇 Additional comments (6)
crates/comenqd/src/logging.rs (2)

1-6: Module documentation follows guidelines correctly.

The module documentation properly uses //! syntax and clearly explains the module's purpose and utility, adhering to the coding guidelines.


9-15: Logging initialization implementation is correct.

The init() function properly sets up structured JSON logging with environment-based filtering. The implementation is concise and follows the single responsibility principle.

crates/comenqd/src/daemon.rs (3)

10-10: Import aliasing correctly distinguishes sync and async filesystem operations.

The aliasing of std::fs to stdfs and addition of tokio::fs import clearly separates synchronous and asynchronous filesystem operations, improving code clarity.

Also applies to: 15-15


35-38: Asynchronous queue directory creation is correctly implemented.

The ensure_queue_dir function properly uses tokio::fs::create_dir_all for asynchronous directory creation, avoiding blocking the async executor.


42-43: Queue directory initialization integrated correctly into daemon startup.

The run function now ensures the queue directory exists before proceeding with daemon tasks, with appropriate logging. This addresses the core requirement for queue initialization.

docs/comenq-design.md (1)

1016-1019: Documentation accurately reflects the implemented daemon initialization.

The updated text correctly describes the structured logging initialization using tracing_subscriber with JSON output and the asynchronous queue directory creation, aligning with the implemented functionality.

Comment thread AGENTS.md Outdated
Comment thread AGENTS.md Outdated
Comment thread crates/comenqd/src/daemon.rs Outdated
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb7a88f and c3b3678.

📒 Files selected for processing (2)
  • crates/comenqd/src/daemon.rs (3 hunks)
  • crates/comenqd/src/logging.rs (1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rs

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.rs: Clippy warnings MUST be disallowed.
Fix any warnings emitted during tests in the code itself rather than silencing them.
Where a function is too long, extract meaningfully named helper functions adhering to separation of concerns and CQRS.
Where a function has too many parameters, group related parameters in meaningfully named structs.
Where a function is returning a large error consider using Arc to reduce the amount of data returned.
Write unit and behavioural tests for new functionality. Run both before and after making any change.
Every module must begin with a module level (//!) comment explaining the module's purpose and utility.
Document public APIs using Rustdoc comments (///) so documentation can be generated with cargo doc.
Prefer immutable data and avoid unnecessary mut bindings.
Handle errors with the Result type instead of panicking where feasible.
Avoid unsafe code unless absolutely necessary and document any usage clearly.
Place function attributes after doc comments.
Do not use return in single-line functions.
Use predicate functions for conditional criteria with more than two branches.
Lints must not be silenced except as a last resort.
Lint rule suppressions must be tightly scoped and include a clear reason.
Prefer expect over allow.
Prefer .expect() over .unwrap().
Use concat!() to combine long string literals rather than escaping newlines with a backslash.
Prefer semantic error enums. Derive std::error::Error (via the thiserror crate) for any condition the caller might inspect, retry, or map to an HTTP status.
Use an opaque error only at the app boundary. Use eyre::Report for human-readable logs; these should not be exposed in public APIs.
Never export the opaque type from a library. Convert to domain enums at API boundaries, and to eyre only in the main main() entrypoint or top-level async task.

Files:

  • crates/comenqd/src/daemon.rs
  • crates/comenqd/src/logging.rs

⚙️ CodeRabbit Configuration File

**/*.rs: * Seek to keep the cyclomatic complexity of functions no more than 12.

  • Adhere to single responsibility and CQRS

  • Place function attributes after doc comments.

  • Do not use return in single-line functions.

  • Move conditionals with >2 branches into a predicate function.

  • Avoid unsafe unless absolutely necessary.

  • Every module must begin with a //! doc comment that explains the module's purpose and utility.

  • Comments and docs must follow en-GB-oxendict (-ize / -our) spelling and grammar

  • Lints must not be silenced except as a last resort.

    • #[allow] is forbidden.
    • Only narrowly scoped #[expect(lint, reason = "...")] is allowed.
    • No lint groups, no blanket or file-wide suppression.
    • Include FIXME: with link if a fix is expected.
  • Use rstest fixtures for shared setup and to avoid repetition between tests.

  • Replace duplicated tests with #[rstest(...)] parameterised cases.

  • Prefer mockall for mocks/stubs.

  • Prefer .expect() over .unwrap()

  • Ensure that any API or behavioural changes are reflected in the documentation in docs/

  • Ensure that any completed roadmap steps are recorded in the appropriate roadmap in docs/

  • Files must not exceed 400 lines in length

    • Large modules must be decomposed
    • Long match statements or dispatch tables should be decomposed by domain and collocated with targets
    • Large blocks of inline data (e.g., test fixtures, constants or templates) must be moved to external files and inlined at compile-time or loaded at run-time.

Files:

  • crates/comenqd/src/daemon.rs
  • crates/comenqd/src/logging.rs
🔇 Additional comments (10)
crates/comenqd/src/daemon.rs (5)

10-10: Import aliasing is well-executed.

The aliasing of std::fs as stdfs to differentiate from tokio::fs improves code clarity and prevents confusion between synchronous and asynchronous filesystem operations.

Also applies to: 15-15


35-38: Function implementation is correct and addresses previous feedback.

The asynchronous ensure_queue_dir function properly uses tokio::fs::create_dir_all instead of the synchronous version, addressing the previous review concern about blocking the async executor.


42-43: Queue directory preparation is properly integrated.

The call to ensure_queue_dir followed by the logging statement provides clear visibility into the daemon's startup sequence.


114-120: Test implementation follows coding guidelines.

The test correctly uses .expect() instead of .unwrap() and provides descriptive error messages, addressing previous feedback about coding guideline adherence.


122-151: Test robustness significantly improved.

The test addresses all previous concerns:

  • Uses .expect() instead of .unwrap()
  • Verifies directory doesn't exist initially
  • Implements proper timeout logic instead of fixed sleep
  • Provides clear failure messaging

The timeout-based approach with Instant and elapsed time checking is much more robust than the previous fixed delay.

crates/comenqd/src/logging.rs (5)

1-6: Module documentation meets requirements.

The module-level doc comment clearly explains the module's purpose and utility, adhering to the coding guidelines.


10-13: Public API design is appropriate.

The init() function provides a simple interface for default logging setup while delegating to the more flexible init_with_writer() function.


15-25: Logging configuration is well-structured.

The function properly configures JSON output with environment-based filtering and accepts custom writers for testing flexibility.


33-61: Custom writer implementation is solid.

The BufMakeWriter and BufWriter implementations provide a clean way to capture logging output for testing without external dependencies.


63-72: Test coverage addresses previous feedback.

The test successfully verifies that logging initialisation works correctly by capturing actual log output, addressing the previous suggestion to enhance test coverage beyond just calling the init function.

Comment thread crates/comenqd/src/daemon.rs Outdated
Comment thread crates/comenqd/src/logging.rs Outdated
leynos and others added 3 commits July 27, 2025 03:14
@leynos leynos merged commit 0be4b4c into main Jul 27, 2025
1 check was pending
@leynos leynos deleted the codex/implement-comenqd-daemon-core-features branch July 27, 2025 12:52
Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 142a106 and c18c2df.

📒 Files selected for processing (1)
  • AGENTS.md (4 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
**/*.md

📄 CodeRabbit Inference Engine (AGENTS.md)

**/*.md: Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged for community consistency.)
Validate Markdown files using make markdownlint.
Run make fmt after any documentation changes to format all Markdown files and fix table markup.
Validate Mermaid diagrams in Markdown files by running make nixie.
Markdown paragraphs and bullet points must be wrapped at 80 columns.
Code blocks must be wrapped at 120 columns.
Tables and headings must not be wrapped.
Use dashes (-) for list bullets.
Use GitHub-flavoured Markdown footnotes ([^1]) for references and footnotes.

Files:

  • AGENTS.md

⚙️ CodeRabbit Configuration File

**/*.md: * Avoid 2nd person or 1st person pronouns ("I", "you", "we")

  • Use en-GB-oxendict (-ize / -our) spelling and grammar
  • Paragraphs and bullets must be wrapped to 80 columns, except where a long URL would prevent this (in which case, silence MD013 for that line)
  • Code blocks should be wrapped to 120 columns.
  • Headings must not be wrapped.
  • Documents must start with a level 1 heading
  • Headings must correctly increase or decrease by no more than one level at a time
  • Use GitHub-flavoured Markdown style for footnotes and endnotes.
  • Numbered footnotes must be numbered by order of appearance in the document.

Files:

  • AGENTS.md
🧠 Learnings (1)
AGENTS.md (9)

Learnt from: CR
PR: leynos/lille#0
File: AGENTS.md:0-0
Timestamp: 2025-07-27T12:14:14.240Z
Learning: Applies to **/*.md : Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged for community consistency.)

Learnt from: CR
PR: leynos/comenq#0
File: AGENTS.md:0-0
Timestamp: 2025-07-27T00:57:05.353Z
Learning: Applies to **/*.md : Documentation must use en-GB-oxendict spelling and grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged for community consistency.)

Learnt from: CR
PR: leynos/wireframe#0
File: AGENTS.md:0-0
Timestamp: 2025-07-21T13:10:04.795Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of 'license' which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/netsuke#0
File: AGENTS.md:0-0
Timestamp: 2025-07-20T02:48:05.151Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of 'license' which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/ddlint#0
File: AGENTS.md:0-0
Timestamp: 2025-07-18T18:35:14.639Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/mdtablefix#0
File: AGENTS.md:0-0
Timestamp: 2025-07-20T03:26:36.990Z
Learning: Applies to docs/**/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/rstest-bdd#0
File: AGENTS.md:0-0
Timestamp: 2025-07-22T06:27:02.647Z
Learning: Applies to **/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/ortho-config#0
File: AGENTS.md:0-0
Timestamp: 2025-07-20T21:31:16.982Z
Learning: Applies to **/*.md : Documentation must use en-GB-oxendict spelling and grammar (with the exception of "license" which is to be left unchanged for community consistency).

Learnt from: CR
PR: leynos/vk#0
File: AGENTS.md:0-0
Timestamp: 2025-07-27T00:37:06.651Z
Learning: Applies to **/*.md : Documentation must use en-GB-oxendict spelling and grammar, except for the naming of the "LICENSE" file.

🪛 LanguageTool
AGENTS.md

[locale-violation] ~46-~46: LICENSE must be spelled with a “c” when used as a noun in British English. Use “licence”.
Context: ...grammar. (EXCEPTION: the naming of the "LICENSE" file, which is to be left unchanged ...

(LICENCE_LICENSE_NOUN_SINGULAR)

🔇 Additional comments (7)
AGENTS.md (7)

12-13: Resolve earlier dangling “or” issue

Text now reads smoothly and meets the earlier nitpick.


19-19: Boolean naming advice is concise and correct
Guidance is clear and aligns with internal conventions.


28-31: Example-related wording tightened

Sentence structure is improved and stays within the 80-column rule.


46-47: Spelling exception paragraph is accurate

The explicit “LICENSE” exception deliberately overrides the British-English rule; keep as is.


157-158: Caret-range rationale reads well

No issues spotted; content satisfies style and length constraints.


160-161: Inequality wording fixed and within 80 columns

Section now meets grammar and wrapping rules.


168-169: Complete the list with missing phrase

Insert the missing “or map” to restore parallel structure.

-  `thiserror` crate) for any condition the caller might inspect, retry,
-  to an HTTP status.
+  `thiserror` crate) for any condition the caller might inspect, retry, or map
+  to an HTTP status.

Likely an incorrect or invalid review comment.

Comment thread AGENTS.md
Comment on lines +32 to +34
lines. Long switch statements or dispatch tables should be broken up by
feature and constituents colocated with targets. Large blocks of test data
should be moved to external data files.
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.

🧹 Nitpick (assertive)

Rephrase long-switch guidance for readability
Add a comma and a clarifying phrase to avoid the slightly awkward “feature and constituents colocated with targets”.

-  feature and constituents colocated with targets. Large blocks of test data
+  feature, with their constituents colocated alongside their targets. Large
+  blocks of test data
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
lines. Long switch statements or dispatch tables should be broken up by
feature and constituents colocated with targets. Large blocks of test data
should be moved to external data files.
lines. Long switch statements or dispatch tables should be broken up by
feature, with their constituents colocated alongside their targets. Large
blocks of test data should be moved to external data files.
🤖 Prompt for AI Agents
In AGENTS.md around lines 32 to 34, rephrase the guidance on long switch
statements for better readability by adding a comma after "feature" and
including a clarifying phrase to make the meaning of "constituents colocated
with targets" clearer and less awkward. Adjust the sentence structure to improve
flow and comprehension.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant