Skip to content

Make ctrlrelay portable across machines#121

Merged
oscarvalenzuelab merged 5 commits intomainfrom
feat/portable-config
May 4, 2026
Merged

Make ctrlrelay portable across machines#121
oscarvalenzuelab merged 5 commits intomainfrom
feat/portable-config

Conversation

@oscarvalenzuelab
Copy link
Copy Markdown
Collaborator

Summary

Adds three portability primitives so a single orchestrator.yaml can run unmodified across machines:

  1. node_id defaults to socket.gethostname() when missing, null, or blank. Heartbeats and session logs still get a meaningful per-node label without forcing every operator to hand-edit the file.

  2. paths.repo_root + paths.owner_aliases let repos[].local_path be derived as ${repo_root}/${owner_aliases.get(owner, owner)}/${repo} instead of being hand-written for every entry. Per-repo local_path still wins as override. Without repo_root, the legacy behaviour (per-repo local_path required) is preserved.

  3. ctrlrelay install launchd|systemd renders bridge + poller unit files from in-package templates and writes them to the conventional locations (~/Library/LaunchAgents / ~/.config/systemd/user). Substitutes ${USER}, ${HOME}, ${CTRLRELAY_BIN}, ${WORKDIR}, ${LABEL_PREFIX}, ${POLLER_INTERVAL}, and (when exported) ${CTRLRELAY_TELEGRAM_TOKEN}. Refuses to clobber existing files unless --force. Replaces the docs/operations.md copy-paste-and-edit-/Users/$ME flow.

The example orchestrator.yaml.example and docs/{configuration,getting-started,operations}.md are updated to surface the new conventions; the live config/orchestrator.yaml is gitignored as operator state but on the contributor's machine it collapses from 69 explicit local_path entries to 20.

Test plan

  • 477 unit tests pass (pytest -q)
  • 33 new tests cover node_id default, repo_root derivation, owner_aliases mapping, override precedence, missing-repo_root error path, template rendering, filename conventions, env-var token passthrough, write-refusal-on-overwrite, and CLI dry-run
  • ruff check clean
  • Templates ship in the wheel (unzip -l confirms templates/launchd/*.plist.template and templates/systemd/*.service.template)
  • ctrlrelay install launchd --dry-run smoke-tested locally

…hs.repo_root

Two portability changes that let a single orchestrator.yaml run
unmodified on multiple machines.

node_id falls back to socket.gethostname() when missing, null, or
blank — heartbeats and session logs still get a meaningful per-node
label without forcing every operator to edit the file.

paths.repo_root + paths.owner_aliases let RepoConfig.local_path be
derived as ${repo_root}/${owner_aliases.get(owner, owner)}/${repo}.
Per-repo local_path still wins as an override for repos that don't
follow the convention. Without repo_root, the legacy behaviour
(local_path required per repo) is preserved.
Update the example file so new operators see node_id-defaults-to-hostname
and paths.repo_root + owner_aliases as the recommended path. Pairs with
the previous commit that introduced the schema. The live operator
orchestrator.yaml is gitignored — re-run with the new schema locally
(this machine's copy collapsed from 69 explicit local_paths to 20).
New 'ctrlrelay install launchd|systemd' command renders bridge and
poller service unit files from in-package templates, substituting
USER, HOME, CTRLRELAY_BIN, WORKDIR, LABEL_PREFIX, POLLER_INTERVAL,
and (when set) CTRLRELAY_TELEGRAM_TOKEN. Writes to the conventional
locations (~/Library/LaunchAgents on macOS, ~/.config/systemd/user on
Linux) and refuses to clobber existing files unless --force.

This replaces the docs.operations.md copy-paste flow where every
operator had to hand-edit /Users/$ME/... strings — a tax on portability
and a common source of broken plists. Templates live under
src/ctrlrelay/templates/{launchd,systemd}/ and ship in the wheel.

Unresolved template variables (typically CTRLRELAY_TELEGRAM_TOKEN
when the env var isn't exported at install time) are surfaced as a
warning rather than silently emitting a literal ${TOKEN} into the
plist.
configuration.md: node_id is now optional (defaults to hostname);
paths gets repo_root + owner_aliases keys; repos[].local_path is
conditional on whether repo_root is set.

getting-started.md: drop node_id from the required-edit list and from
the minimal config snippet (hostname picks it up automatically).

operations.md: lead each platform section with 'ctrlrelay install
launchd|systemd' as the recommended path; keep the full inline
templates as a hand-write fallback. Drops the redundant repeat blocks
that duplicated the install steps.
@oscarvalenzuelab oscarvalenzuelab merged commit 8f1ab16 into main May 4, 2026
4 checks passed
@oscarvalenzuelab oscarvalenzuelab deleted the feat/portable-config branch May 4, 2026 04:08
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