Skip to content

feat(roborev): add roborev code review daemon service - #1745

Merged
shunkakinoki merged 2 commits into
mainfrom
feat/roborev-service
May 10, 2026
Merged

feat(roborev): add roborev code review daemon service#1745
shunkakinoki merged 2 commits into
mainfrom
feat/roborev-service

Conversation

@shunkakinoki

@shunkakinoki shunkakinoki commented May 10, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add home-manager/services/roborev configuring roborev daemon run as a launchd agent on galactica (darwin) and a systemd user service on matic (linux).
  • Gated via inputs.host.isGalactica || inputs.host.isMatic; mirrors the dual-platform pattern used by home-manager/services/dolt and home-manager/services/qmd.
  • Activation script creates ~/.roborev with mode 0700 (matches paperclip activation pattern). Binary expected at ~/.local/bin/roborev (default curl install.sh target).

What roborev is

Local CLI for delegating code review to AI coding agents - background daemon + post-commit hook + TUI. Upstream: https://github.com/roborev-dev/roborev. Systemd unit replicated from packaging/systemd/roborev.service (Type=notify, restart-on-failure, RestartSec=5).

Test plan

  • nix flake check passes (darwin checks incl. eval-darwin-galactica)
  • make build + make switch on galactica
  • Confirm launchctl list | grep roborev shows the agent and /tmp/roborev.log populates
  • Eval nixosConfigurations.matic on a linux host (cannot run from darwin)

Summary by cubic

Adds the roborev code review daemon as a managed Home Manager service for galactica (launchd) and matic (systemd), auto-starting on login with restart. Also updates the Makefile to pass HOST/HOSTNAME into builds/switches and adds convenience restart targets.

  • New Features

    • Adds home-manager/services/roborev gated by host flags (launchd on Darwin, systemd user on Linux).
    • Creates ~/.roborev (0700); runs roborev daemon run with ROBOREV_DATA_DIR and PATH; expects ~/.local/bin/roborev.
    • Darwin logs to /tmp/roborev.log and /tmp/roborev.error.log; systemd uses Type=notify, Restart=on-failure, RestartSec=5.
    • Makefile injects HOST/HOSTNAME into all nix build/switch commands; adds launchctl-roborev and systemctl-roborev, wired into aggregate launchctl/systemctl.
  • Migration

    • Install ~/.local/bin/roborev.
    • Rebuild and switch; make nix-build/make nix-switch now pass HOST/HOSTNAME automatically.
    • Restart and verify: make launchctl-roborev (galactica) or make systemctl-roborev (matic); check via launchctl list | grep roborev or systemctl --user status roborev.

Written for commit 2cda980. Summary will update on new commits.

Configures launchd agent on galactica (darwin) and systemd user service
on matic (linux) to run `roborev daemon run`, gated on the host flags
from `lib/host.nix`. Mirrors the dolt/qmd dual-platform service
pattern. Binary path defaults to `~/.local/bin/roborev` (install.sh
target); data dir at `~/.roborev` is created via home activation.
@indent-zero

indent-zero Bot commented May 10, 2026

Copy link
Copy Markdown
Contributor
PR Summary

Adds a new roborev home-manager service (launchd agent on galactica / systemd user unit on matic, gated on lib/host.nix flags) along with the Makefile plumbing needed to actually exercise the host gating: nix-build and nix-switch now bake HOST/HOSTNAME into every nix invocation through sudo env, and dedicated launchctl-roborev / systemctl-roborev targets are wired into the existing aggregate service targets.

  • Adds home-manager/services/roborev/default.nix with enabled = isGalactica || isMatic, a home.activation.roborevSetup hook, a launchd agent (KeepAlive, RunAtLoad, env including ROBOREV_DATA_DIR, logs at /tmp/roborev.{log,error.log}), and a systemd user unit (Type=notify, Restart=on-failure, RestartSec=5).
  • Adds home-manager/services/roborev/activate.sh that idempotently mkdir -ps and chmod 700s the data directory.
  • Wires the new module into home-manager/services/default.nix alphabetically alongside the other services.
  • Updates Makefile to wrap every darwin-rebuild / nixos-rebuild / home-manager invocation in nix-build/nix-switch with $(SUDO) env HOST=... HOSTNAME=... ..., fixing a real bug where sudo was silently stripping HOST= from the child environment.
  • Adds launchctl-roborev (galactica-only) and systemctl-roborev (matic-only) Make targets and adds them to the launchctl / systemctl aggregate dependency lists.

Issues

3 potential issues found:

  • launchd and systemd restart semantics diverge: macOS uses KeepAlive = true (restart on any exit) while Linux uses Restart = "on-failure" (no restart on clean exit). After a graceful daemon stop, galactica respawns but matic stays stopped — the sibling dolt service uses Restart = "always" to keep parity. → Autofix
  • Type = "notify" requires roborev >= 0.50 (sd_notify support landed in that release). With an older binary at ~/.local/bin/roborev, systemd waits the full TimeoutStartSec for READY=1, marks the unit failed, then loops via Restart=on-failure+5s. Either pin/document a min version or fall back to Type = "simple". → Autofix
  • Systemd unit declares After = [ "network.target" ] but no matching Wants, while the closest sibling qmd declares both. Cosmetic for user units (network.target is mostly informational here) but worth noting for parity. → Autofix

CI Checks

shell-test is failing because the new home-manager/services/roborev/activate.sh was added to the repo but not appended to the covered_scripts list in spec/coverage_spec.sh:356-458. The shell-check "Alls Green" gate is a downstream failure of the same root cause.

Failing shell-test→ Autofix
  • spec/coverage_spec.sh:353 asserts that every non-spec *.sh file tracked by git appears in the hard-coded covered_scripts list. The new home-manager/services/roborev/activate.sh introduced in this PR isn't in that list, so the diff in the spec emits MISMATCH: Update coverage_spec.sh when adding new shell scripts and the suite fails (1459 examples, 1 failure).
Failing shell-check / Alls Green
  • Downstream gate: this job aggregates the result of the required jobs (shell-test is marked required to succeed). It will go green automatically once shell-test passes — no separate fix needed.

⚡ Autofix All

@mesa-dot-dev

mesa-dot-dev Bot commented May 10, 2026

Copy link
Copy Markdown

You do not have enough credits to review this pull request. Please purchase more credits to continue.

@coderabbitai

coderabbitai Bot commented May 10, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request adds a new Roborev service module to Home Manager. It conditionally enables the daemon on specific hosts, creates a data directory via activation, and provides OS-specific service wiring for macOS and Linux with proper environment variables and lifecycle management.

Changes

Roborev Service Module

Layer / File(s) Summary
Module Configuration & Enablement
home-manager/services/roborev/default.nix
Module structure with conditional enablement (inputs.host.isGalactica or isMatic), deriving binary and data directory paths from config.home.homeDirectory.
Activation & Data Setup
home-manager/services/roborev/activate.sh, home-manager/services/roborev/default.nix
Bash activation script creates the Roborev data directory with 700 permissions; home.activation.roborevSetup DAG entry runs after writeBoundary.
Platform-Specific Services
home-manager/services/roborev/default.nix
macOS launchd agent with KeepAlive and RunAtLoad enabled; Linux systemd user service with Type="notify" and restart-on-failure policy; both execute roborevBin daemon run with HOME, ROBOREV_DATA_DIR, and PATH environment variables.
Module Registration
home-manager/services/default.nix
Imports ./roborev module and includes roborev in the returned service list.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A daemon runs where once was none,
Cross Darwin, Linux—work is done,
With directories made and paths aligned,
A service strong, a service kind.
Roborev hops through systems bright! ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title 'feat(roborev): add roborev code review daemon service' accurately reflects the main change: adding a new roborev service module to Home Manager.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
Description check ✅ Passed The pull request description comprehensively explains the changes, including what roborev is, how it's configured for both platforms, the activation script details, and a clear test plan.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/roborev-service

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 and usage tips.

@mesa-dot-dev

mesa-dot-dev Bot commented May 10, 2026

Copy link
Copy Markdown

Mesa Description

TL;DR

Adds the roborev code review daemon as a managed Home Manager service, configuring it to run on login with auto-restart for both Darwin (galactica) and Linux (matic) hosts.

What changed?

  • home-manager/services/default.nix: Updated to include the new roborev service, defining its path and adding it to the list of available services within Home Manager.
  • home-manager/services/roborev/activate.sh: A new activation script that creates the ~/.roborev data directory and sets its permissions to 0700.
  • home-manager/services/roborev/default.nix: This new NixOS module defines the Home Manager service for roborev, enabling it conditionally based on inputs.host.isGalactica or inputs.host.isMatic. It configures the service to run roborev daemon run automatically using launchd on Darwin or systemd user services on Linux, and sets up its program arguments, environment variables (ROBOREV_DATA_DIR, PATH), and logging paths (e.g., /tmp/roborev.log on Darwin).

Description generated by Mesa. Update settings

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request adds the roborev service to Home Manager, including an activation script for directory initialization and service definitions for Darwin (launchd) and Linux (systemd). The review feedback suggests several improvements for robustness and idiomatic Nix code: utilizing config.home.profileDirectory instead of hardcoded paths in environment variables, relocating macOS log files from /tmp to a user-specific directory to avoid permission conflicts, and quoting the ExecStart path in the systemd service to handle potential spaces in file paths.

EnvironmentVariables = {
HOME = homeDir;
ROBOREV_DATA_DIR = dataDir;
PATH = "${homeDir}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin";

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.

high

The PATH for the Darwin launchd agent is missing the Nix profile directory. This will likely cause the daemon to fail if it depends on tools installed via Nix (such as git). Additionally, using config.home.profileDirectory is more idiomatic than hardcoding .nix-profile.

        PATH = "${homeDir}/.local/bin:${config.home.profileDirectory}/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin";

Comment on lines +35 to +36
StandardOutPath = "/tmp/roborev.log";
StandardErrorPath = "/tmp/roborev.error.log";

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.

medium

Using /tmp for log files in a launchd agent is discouraged. /tmp is a shared namespace on macOS, which can lead to permission conflicts between users and security risks (e.g., symlink attacks). Furthermore, /tmp is cleared on reboot. It is better to use a user-specific path like ~/Library/Logs/.

      StandardOutPath = "${homeDir}/Library/Logs/roborev.log";
      StandardErrorPath = "${homeDir}/Library/Logs/roborev.error.log";

};
Service = {
Type = "notify";
ExecStart = "${roborevBin} daemon run";

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.

medium

The ExecStart path should be quoted to handle cases where the home directory path might contain spaces. While uncommon, quoting is a best practice for robustness in systemd unit files.

      ExecStart = "\"${roborevBin}\" daemon run";

Environment = [
"HOME=${homeDir}"
"ROBOREV_DATA_DIR=${dataDir}"
"PATH=${homeDir}/.local/bin:${homeDir}/.nix-profile/bin:/usr/local/bin:/usr/bin:/bin"

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.

medium

Use config.home.profileDirectory instead of hardcoding ${homeDir}/.nix-profile for better maintainability and adherence to Home Manager idioms.

        "PATH=${homeDir}/.local/bin:${config.home.profileDirectory}/bin:/usr/local/bin:/usr/bin:/bin"

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

🧹 Nitpick comments (1)
home-manager/services/roborev/default.nix (1)

35-36: ⚡ Quick win

Consider persistent log locations.

The log files in /tmp/ will be cleared on reboot. For production use, consider using persistent locations like ~/Library/Logs/roborev.log on macOS or rely on system logging facilities.

🤖 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 `@home-manager/services/roborev/default.nix` around lines 35 - 36, The service
currently writes logs to ephemeral files via the StandardOutPath and
StandardErrorPath settings for the roborev service; change these to persistent
locations or switch to system logging: either set
StandardOutPath/StandardErrorPath to a durable directory (e.g., under the user
home or XDG state/logs) or replace them by configuring StandardOutput= and
StandardError= to "syslog" (or add a SyslogIdentifier) so logs go to the system
logger; update the roborev service definition accordingly and ensure the chosen
directory exists with correct permissions before enabling the service.
🤖 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.

Nitpick comments:
In `@home-manager/services/roborev/default.nix`:
- Around line 35-36: The service currently writes logs to ephemeral files via
the StandardOutPath and StandardErrorPath settings for the roborev service;
change these to persistent locations or switch to system logging: either set
StandardOutPath/StandardErrorPath to a durable directory (e.g., under the user
home or XDG state/logs) or replace them by configuring StandardOutput= and
StandardError= to "syslog" (or add a SyslogIdentifier) so logs go to the system
logger; update the roborev service definition accordingly and ensure the chosen
directory exists with correct permissions before enabling the service.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 9dd6d514-a247-4f99-8da7-dbcbae70a574

📥 Commits

Reviewing files that changed from the base of the PR and between 9b6e077 and 772d932.

📒 Files selected for processing (3)
  • home-manager/services/default.nix
  • home-manager/services/roborev/activate.sh
  • home-manager/services/roborev/default.nix

Service = {
Type = "notify";
ExecStart = "${roborevBin} daemon run";
Restart = "on-failure";

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.

Restart semantics diverge between platforms. On galactica, KeepAlive = true makes launchd respawn the agent on any exit (including clean exit 0). On matic, Restart = "on-failure" only respawns on non-zero exit / signal. So the same operator action — e.g. a graceful SIGTERM, a self-exit on idle, or a roborev daemon self-stop — leaves the daemon dead on matic but auto-restarted on galactica.

The sibling services this PR mirrors (dolt, qmd) both use Restart = "always" precisely to match KeepAlive=true. Suggest doing the same here unless there's a reason to want clean exits to stick on Linux only.

Suggested change
Restart = "on-failure";
Restart = "always";

After = [ "network.target" ];
};
Service = {
Type = "notify";

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.

Type = "notify" is gated on roborev >= 0.50. sd_notify readiness signaling was only added upstream in v0.50 (alongside the bundled systemd units). Nothing in the activation script or this module asserts the binary at ~/.local/bin/roborev is new enough.

Failure mode with an older binary on matic: systemd waits TimeoutStartSec (default 90s) for READY=1, marks the unit failed, then Restart=on-failure + RestartSec=5 retriggers the same 90s timeout in a loop. No symptom on galactica because launchd doesn't use sd_notify.

Options:

  • Drop to Type = "simple" (matches dolt/qmd pattern, works with any roborev version, you lose readiness signaling but the daemon is KeepAlive/Restart-managed anyway).
  • Keep Type = "notify" and pin the min version somewhere visible (README/install.sh) so a stale install isn't silently broken.

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

1 issue found across 3 files

Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="home-manager/services/roborev/default.nix">

<violation number="1" location="home-manager/services/roborev/default.nix:33">
P2: Include the Home Manager profile bin directory in the launchd PATH; otherwise the daemon may not find tools installed via Nix profile.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

EnvironmentVariables = {
HOME = homeDir;
ROBOREV_DATA_DIR = dataDir;
PATH = "${homeDir}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin";

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.

P2: Include the Home Manager profile bin directory in the launchd PATH; otherwise the daemon may not find tools installed via Nix profile.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At home-manager/services/roborev/default.nix, line 33:

<comment>Include the Home Manager profile bin directory in the launchd PATH; otherwise the daemon may not find tools installed via Nix profile.</comment>

<file context>
@@ -0,0 +1,61 @@
+      EnvironmentVariables = {
+        HOME = homeDir;
+        ROBOREV_DATA_DIR = dataDir;
+        PATH = "${homeDir}/.local/bin:/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin";
+      };
+      StandardOutPath = "/tmp/roborev.log";
</file context>

…v service targets

- prefix every nix invocation in nix-build/nix-switch with HOST=<host> HOSTNAME=<host> so lib/host.nix detects galactica/matic during flake eval
- use sudo env HOST= HOSTNAME= for darwin-rebuild and nixos-rebuild to bypass sudo env stripping
- add launchctl-roborev (gated on galactica) and systemctl-roborev (gated on matic) targets and wire them into the launchctl/systemctl aggregate targets
@shunkakinoki
shunkakinoki merged commit c2b6fcc into main May 10, 2026
31 of 32 checks passed
@shunkakinoki
shunkakinoki deleted the feat/roborev-service branch May 10, 2026 21:17
shunkakinoki added a commit that referenced this pull request May 11, 2026
… list (#1751)

Closes the shell-test CI failure caused by the roborev activate.sh not
being registered in coverage_spec.sh after #1745.
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