Skip to content

Run model-sync and deriver as systemd --user timers on Linux - #2815

Open
Heretic-tripto wants to merge 2 commits into
danielmiessler:mainfrom
Heretic-tripto:linux-systemd-modelsync-deriver
Open

Heretic-tripto wants to merge 2 commits into
danielmiessler:mainfrom
Heretic-tripto:linux-systemd-modelsync-deriver

Conversation

@Heretic-tripto

Copy link
Copy Markdown

Problem

Two nightly jobs only run on macOS:

  • InstallModelSync.ts calls launchctl unconditionally, so on Linux the
    install fails with Executable not found in $PATH: "launchctl". In a
    Services.ts install run this fails the core-services leg of the update.
  • manage-deriver.sh on Linux prints macOS only. Skipping and exits 0, so
    Services reports the deriver as installed while nothing is scheduled.

Change

  • InstallModelSync.ts: Linux branch on lib/SystemdUser, same shape as
    InstallHealthSync. Schedule matches the plist (daily 05:10). macOS path
    unchanged.
  • InstallDeriverSystemd.ts (new): systemd --user timer for the deriver,
    daily 03:00, same command as the launchd plist.
  • manage-deriver.sh: install|uninstall|status delegate to the systemd
    installer on non-Darwin hosts. macOS path unchanged.

Testing

  • Arch Linux (Omarchy), systemd --user: InstallModelSync.ts and
    manage-deriver.sh install both report active · enabled, with the next
    run at the scheduled time. The model-sync first run completed.
  • bash -n on the script and bun build --no-bundle parse on both TS files.
  • Not exercised: --uninstall on Linux, and anything on macOS.

🤖 Generated with Claude Code

Both nightly jobs were macOS-only. On Linux InstallModelSync.ts failed at
launchctl, and manage-deriver.sh exited 0 with "macOS only. Skipping", so
Services reported the deriver as installed when nothing was scheduled.

- InstallModelSync.ts: add a Linux branch on lib/SystemdUser (same shape as
  InstallHealthSync). Schedule matches the plist: daily 05:10.
- InstallDeriverSystemd.ts (new): systemd --user timer for the deriver,
  daily 03:00, same command as the launchd plist.
- manage-deriver.sh: delegate install/uninstall/status to the systemd
  installer on non-Darwin hosts. macOS path unchanged.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNVp6Ee6Tan1v5P3HENTHB

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

Code Review: Multi-Axis Evaluation

Thank you @Heretic-tripto for expanding Linux support! Providing first-class systemd --user unit and timer automation for the nightly deriver and model-sync brings much-needed parity with the macOS launchd automation.


1. Architecture & Systemd User Standards

  • Leveraging Shared Infrastructure: Utilizing lib/SystemdUser (which is already proven in InstallHealthSync.ts) ensures systemd unit and timer definitions adhere to standard XDG user directories (~/.config/systemd/user/) with clean calendar schedules (OnCalendar format).
  • Schedule Parity: Matching the macOS launchd schedules (03:00 for the nightly deriver and 05:10 for model-sync) maintains synchronization consistency across heterogeneous operating systems.
  • Immediate First Sync: In InstallModelSync.ts, triggering an initial sync immediately following installation:
    const first = await sh([bunPath, lifeosPath("TOOLS", "ModelSync.ts"), "--sync"]);
    gives the user immediate feedback and seeds initial model pricing data without requiring them to wait for the next scheduled timer event.

2. Portability Consideration

  • Claude Directory Path in Shell Wrapper:
    • In manage-deriver.sh:
      exec "$BUN_PATH" "$HOME/.claude/LIFEOS/TOOLS/InstallDeriverSystemd.ts" "$1"
      hardcodes $HOME/.claude.
    • In contrast, the TypeScript tool itself uses getClaudeDir() from Paths.ts, which respects custom installation roots (such as CLAUDE_HOME or symlinked workspaces).
    • Recommendation: Consider checking ${CLAUDE_HOME:-$HOME/.claude} in manage-deriver.sh to ensure consistency for users utilizing custom directory locations.

3. Error Handling & Bun Resolution

  • Explicit validation via await systemd.which("bun") and throwing early with actionable guidance ("bun not found in PATH - install bun first") provides clean operational debugging if the daemon environment lacks user binary paths.

Summary: Well-structured Linux timer integration that mirrors macOS launchd behavior cleanly. LGTM!

The shell wrapper hardcoded $HOME/.claude. The TypeScript resolver reads
CLAUDE_PLUGIN_ROOT, CLAUDE_CONFIG_DIR and LIFEOS_SKILLS_DIR, so the two
could point at different roots. Resolving the installer from the script's
own location follows whatever root the install lives in, without copying
the resolver into bash.

Co-Authored-By: Claude Haiku 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01CNVp6Ee6Tan1v5P3HENTHB
@Heretic-tripto

Copy link
Copy Markdown
Author

Thanks for the review. Applied the portability point in a follow-up commit.

The suggested ${CLAUDE_HOME:-$HOME/.claude} would not match the resolver: Paths.ts reads CLAUDE_PLUGIN_ROOT, CLAUDE_CONFIG_DIR and LIFEOS_SKILLS_DIR, and has no CLAUDE_HOME. Copying that order into bash would duplicate it in two places. Instead, manage-deriver.sh now resolves InstallDeriverSystemd.ts relative to its own location, so the shell and TypeScript follow the same install root.

Checked: bash -n passes, the resolved path exists, and status reads the active timer.

🤖 Generated with Claude Code

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