feat(install): schema install --daemon templates (ADR-0027 post-refactor)#11
Merged
feat(install): schema install --daemon templates (ADR-0027 post-refactor)#11
Conversation
…stemd templates (ADR-0027 post-refactor)
ADR-0027's runbook cutover step 5 left the workstation-level unit as
"author by hand" until templates landed. This commit closes that gap with
two new templates and the matching `schema install --daemon` /
`schema uninstall --daemon` verbs. Per-project `--service` / `--config`
flow (ADR-0020) is preserved; the two flags are mutually exclusive via
clap `conflicts_with`.
Templates:
* `src/cli/templates/launchd-daemon.plist.template` — macOS LaunchAgent.
`Label = com.farchanjo.schema.daemon`,
`ProgramArguments = [{binary_path}, "daemon"]`, no `--config` flag, no
`{project_id}` slot. Carries `SoftResourceLimits.NumberOfFiles = 10240`
— the knob the four ADR-0026-era per-project daemons needed to dodge
kqueue fd exhaustion across N projects.
* `src/cli/templates/systemd-daemon.service.template` — Linux user unit.
`ExecStart = {binary_path} daemon`, `LimitNOFILE = 10240` for the same
reason.
Code:
* `src/cli/install.rs` — new `DaemonInstallInputs` (no config_path /
project_id fields), `render_macos_daemon_plist` /
`render_linux_daemon_unit` helpers, public constants
`DAEMON_LAUNCHD_LABEL` / `DAEMON_SYSTEMD_UNIT_NAME`. Three new unit
tests cover slot substitution + label constants + absence of `--config`
in the daemon variant.
* `src/main.rs` — `--daemon` flag added to `install` / `uninstall`
subcommands; new `--nice <N>` option (default 5, only consumed by the
daemon variant — per-project mode reads `[embedding].nice` from
schema.toml). Helpers `daemon_unit_path`, `write_daemon_unit_file`,
`daemon_unit_label`, `print_load_hint`, `print_unload_hint`,
`run_install_dispatch`, `run_uninstall_dispatch`,
`run_forget_dispatch` keep each `run_*` fn under the 30-line cognitive
budget after the install/uninstall flag matrix grew.
After this commit, ADR-0027 cutover step 5 is mechanical:
schema install --daemon
launchctl bootstrap gui/$(id -u) \
~/Library/LaunchAgents/com.farchanjo.schema.daemon.plist
ADR-0027 Evidence appended for the post-refactor templates entry.
Strict-lint gate: cargo clippy --all-features --all-targets --workspace
-- -D warnings exits 0. cargo fmt --all -- --check clean. cargo test
--all-features 97 passed (92 unit + 5 integration; +3 from the new
daemon-template render tests).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes the ADR-0027 cutover step 5 gap. New launchd / systemd templates that invoke
schema daemondirectly, plus matchingschema install --daemon/schema uninstall --daemonverbs.src/cli/templates/launchd-daemon.plist.template— macOS LaunchAgent withLabel = com.farchanjo.schema.daemon,SoftResourceLimits.NumberOfFiles = 10240(the knob the ADR-0026-era per-project daemons needed for fd exhaustion).src/cli/templates/systemd-daemon.service.template— Linux user unit withLimitNOFILE = 10240.DaemonInstallInputs+render_macos_daemon_plist/render_linux_daemon_unit+DAEMON_LAUNCHD_LABEL/DAEMON_SYSTEMD_UNIT_NAME.--service/--daemonmutually exclusive oninstall/uninstallvia clapconflicts_with.schema install --daemon+launchctl bootstrap.Test plan
cargo clippy --all-features --all-targets --workspace -- -D warningsexits 0cargo fmt --all -- --checkcleancargo test --all-features— 97 passed (92 unit + 5 integration; +3 daemon-template render tests)schema install --helpshows both--serviceand--daemon; conflicting flags rejected--service --config <path>) untouched in observable behaviourunsafelintjob green🤖 Generated with Claude Code