8000 feat(osx): run the Mac's fleet account as a self-hosted CI runner that yields to its owner by inkatze · Pull Request #238 · inkatze/dotfiles · GitHub
[go: up one dir, main page]

Skip to content

feat(osx): run the Mac's fleet account as a self-hosted CI runner that yields to its owner - #238

Merged
inkatze merged 14 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-6bd70f89
Nov 12, 2026
Merged

inkatze merged 14 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-6bd70f89

Conversation

@inkatze
@inkatze inkatze commented Nov 11, 2026 •
Copy link
Copy Markdown
Owner

The Mac's fleet account can now act as a self-hosted GitHub Actions runner for inkatze/dotfiles, inkatze/planwright and any repository listed in the machine-local file ~/.config/dotfiles/runner-repos (private names stay out of this repo). dotfiles' own lint job uses it for pushes to main.

Runner role (roles/osx/tasks/offload-runner.yml)

  • One runner and one crontab-started gate per repository, each in ~/actions-runners/<owner>-<repo>, labels self-hosted, macOS, mac-fleet. Runs niced (Nice 10, background, low-priority I/O). No sudo, no Homebrew, nothing in the owner's account; the offload guard test now covers the new task file.
  • The release is pinned in role defaults with its published sha256; the download is verified.
  • Registration token: fetched at run time from the fleet account's gh login (POST /repos/<owner>/<repo>/actions/runners/registration-token), held in a no_log task and handed to config.sh through its environment only; never written to disk or logs. A directory that already has a .runner file is left alone. The fleet gh login needs admin on each repository and the repo scope.
  • How it yields (runner-gate.sh, started by runner-start.sh): the fleet account only logs in over ssh, so it has no launchd user domain. Two crontab lines per runner (@reboot and every 5 minutes) call runner-start.sh, which starts the gate detached and niced and does nothing if that gate already runs. The gate runs the listener in --once mode, only while keyboard/mouse idle time is at least 300 s (osx_runner_idle_seconds) and the one-minute load average is under 6 (osx_runner_load_max). Whichever account owns the console does not matter: a Mac left logged in and untouched serves jobs. Otherwise, with no job started, the listener is stopped and the runner shows offline. A job already running is never interrupted: it finishes niced, and nothing new starts afterwards. A job assigned in the instant the owner returns can be dropped by GitHub as a lost runner and needs a re-run.

Workflow (.github/workflows/test.yml, separate commit)

  • Only lint can use the Mac, and only for a push to main of inkatze/dotfiles. test stays on macos-latest on purpose: it runs the roles for real against $HOME (symlinks, defaults, Homebrew, sudo), which the fleet account must never take. The brew install coreutils step runs on hosted runners only.
  • Fork PRs stay off the Mac, and so does every pull request: runs-on selects the Mac only when the repository is inkatze/dotfiles and the event is a push (the workflow's push trigger is main only). Fork PRs and forks' own pushes get macos-latest. The workflow has no pull_request_target or workflow_run trigger and must never route either to the self-hosted label.
  • Runner unavailable: pull requests never wait for the Mac. A main push whose lint job is queued while the Mac yields or is offline waits (no automatic fallback; timeout-minutes: 30 bounds only the run). That gates no merge. Tried instead of a token: routing pull requests to the Mac (rejected, since a queued PR job cannot fall back), and a queued-timeout rerun on hosted runners (needs an API token to see runner status; not done).
  • dotfiles ci: cut macOS runner slots and bound every CI step with a timeout #237 (CI time limits and runner cuts) is open and also edits .github/workflows/test.yml; whichever lands second forward-merges main. The test.yml change here is its own small commit.

Open before ready

Nothing open from the Mac exercise: the crontab starter was exercised as the fleet account over ssh (scratch copy under ~, a stub run.sh that sleeps, a stub ioreg on PATH reading a file, load 5.10 before starting; nothing under ~/actions-runners, no runner registered, no crontab line added since cron itself was confirmed earlier).

  • runner-start.sh <dir> (RUNNER_POLL_SECONDS=2, RUNNER_LOAD_MAX=100, idle reading 400 s) printed starter-exit=0, and ps showed bash .../runner-gate.sh .../runner.
  • After that ssh session had ended (a second one, 8 s later): the same gate pid was still running (pid file and ps agree), ~/.cache held dotfiles-runner-runner.{err,out,pid}, both logs empty, and stub.log read 22:18:20 stub run.sh started --once.
  • Simulated active reading (idle file set to 0): 8 s later the stub's sleep was gone and the gate still ran. Back to 400 s idle: 8 s later a new stub was running and stub.log gained 22:20:19 stub run.sh started --once.
  • Caveat: ps printed NI 20 for the gate (started under taskpolicy -b plus nice -n 10); a plain nice -n 10 process printed NI 15 on that Mac, so the exact nice value was not confirmed, only that the gate is not at the default priority.
  • Cleanup and final check, run over ssh after killing the gate and stub and removing the pid file, lock dir, logs, scratch directory and the crontab snapshot. The crontab was empty before and diff against the snapshot printed crontab-unchanged:
CHECK
(no runner-gate / runner-start / stub process lines)
(no dotfiles-runner files in ~/.cache)
zsh:4: no matches found: /Users/fleet/pr238-exercise*
crontab:
END
  • Bot review: cubic refused to start (free monthly review limit reached, resumes 2 December 2026), so this PR uses PR-Agent: it reviewed the current head with no findings and its check passed.

Operator items

  • Run the playbook on the Mac as the fleet account; first run gh auth refresh --scopes repo over ssh, and the fleet login needs admin on each repository.
  • Confirm "Require approval for all outside collaborators" (fork PR workflow approval) on the public repositories.
  • One runner serves one job at a time, so concurrent main-push lint jobs queue serially.

Convergence: polish applied one comment rewrap; one Gemini panel pass on this run (three findings validated and declined: the push trigger is main-only, and two are pre-existing and outside this diff), nothing applied.

Step records

Steps at pre-implementation (run 000004)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on db86d378ec7e.

  • Warning: empty list; fired after the gate change was already committed (specless unit, work began before the run was opened)

Steps at pre-ci (run 000004)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on db86d378ec7e.

  • Warning: empty list; fired after the gate change was already committed (specless unit, work began before the run was opened)

Steps at convergence (run 000004)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill polish in-session inline db86d37 to 9c89a35 2026-11-11T23:26:40Z 2026-11-11T23:30:37Z applied (degraded: isolated step hosted in-session; inline review, one comment rewrap applied; end taken from the fix commit's time)
2 panel-review skill panel-review in-session inline 9c89a35 2026-11-11T23:42:47Z 2026-11-11T23:48:51Z passed (degraded: isolated step hosted in-session; gemini pass 1 on this run, three findings validated and declined (push trigger is main-only; two pre-existing, out of this diff), nothing applied)

Ended on 9c89a3532ee8.

Steps at pre-pr (run 000004)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on 9c89a3532ee8.

Steps at pre-implementation (run 000005)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on cd56e01b0d85.

  • Warning: empty list; fired after the change was already committed (specless unit, work began before the run was opened)

Steps at pre-ci (run 000005)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on cd56e01b0d85.

  • Warning: empty list; fired after the change was already committed (specless unit, work began before the run was opened)

Steps at convergence (run 000005)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill polish in-session inline cd56e01 to 1e52d6b 2026-11-12T03:27:28Z 2026-11-12T03:31:17Z applied (degraded: isolated step hosted in-session; this was an inline review of the diff, not the polish loop; one fix applied (stale start lock cleared); end taken from the fix commit's time)
2 panel-review skill panel-review in-session inline 1e52d6b to ec0369d 2026-11-12T03:35:31Z 2026-11-12T04:06:08Z applied (degraded: isolated step hosted in-session; two gemini passes on this run: pass 1 applied three fixes (create ~/.local/bin, fail on an unusable cache dir, poll the start test; two more commits fixed a test bug it introduced) and declined the rest as pre-existing or out of the diff; pass 2 surfaced only declined or gold-plating items, nothing to apply)

Ended on ec0369d7014c.

Steps at pre-pr (run 000005)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
none

Ended on ec0369d7014c.

Steps at post-pr (run 000005)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill bot-review in-session inline ec0369d 2026-11-12T06:43:04Z 2026-11-12T06:55:20Z passed (degraded: isolated step hosted in-session; bot-review --nested --reviewer pr_agent after cubic quota refusal) cubic refused: "cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 40,041 of the 40,000 allowed lines of code this month. Reviews resume on 2 December 2026." Switched to PR-Agent: it reviewed head ec0369d (run 43168395071.1, no findings, gating check PR-Agent SUCCESS); drain found 0 findings, nothing to reply to, ledger empty.

Ended on ec0369d7014c.


Summary by cubic

Turns the Mac's fleet account into a self-hosted GitHub Actions runner that only takes jobs while the Mac is idle, so the owner is never squeezed out. One runner per repository (inkatze/dotfiles, inkatze/planwright, plus all owner/repo lines in ~/.config/dotfiles/runner-repos), each in ~/actions-runners/<owner>-<repo> with labels self-hosted, macOS, mac-fleet, running niced with no sudo, no Homebrew, and nothing in the owner's account.

Runner gate

  • runner-gate.sh starts the listener only while keyboard and mouse idle time is at least 300 s (osx_runner_idle_seconds) and the one-minute load average is under 6 (osx_runner_load_max), whoever owns the console.
  • A job already running is never interrupted; it finishes niced and nothing new starts, while otherwise the listener is stopped and the runner shows offline.
  • The fleet account only logs in over ssh, so it has no launchd user domain and no sudo: runner-start.sh, called from the account's crontab at boot and every osx_runner_recheck_minutes, keeps the gate running and does nothing when it already runs, outliving any ssh session.
  • Registration tokens come from the fleet gh login at run time, live only in a no_log task's memory and the registering command's environment, and are never written to disk or logs; a directory that already has a .runner file is left alone.
  • The runner release is pinned in the role defaults with its published sha256.

Workflow routing

  • Only lint uses the Mac, and only for pushes to main of inkatze/dotfiles; pull requests and fork pushes stay on macos-latest, with no pull_request_target or workflow_run trigger.
  • test stays on hosted runners on purpose: it runs the roles for real against $HOME (symlinks, defaults, Homebrew, sudo), which the fleet account must never take.
  • A main push whose lint job queues while the Mac yields waits with no fallback (timeout-minutes: 30 bounds the run, not the wait), and PRs never wait on the Mac.

Not yet exercised on the Mac: the idle and console checks and the ioreg PATH lookup were not run there because the Mac was busy; two defects found in review (missing log directory, ioreg off the path) are fixed in code only. To adopt: run the playbook as the fleet account after gh auth refresh --scopes repo, and the login needs admin on each repository.

Written for commit ec0369d. Summary will update on new commits.

View guided diff Turn on auto-fix

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions
Copy link
Copy Markdown

PR-Agent run 43168395071.1 on ec0369d: success

@inkatze
inkatze commented Nov 12, 2026
Copy link
Copy Markdown
Owner Author

@cubic-dev-ai review this PR

@cubic-dev-ai
cubic-dev-ai Bot commented Nov 12, 2026
Copy link
Copy Markdown

@cubic-dev-ai review this PR

@inkatze cubic can't start this review because your workspace has reached its free monthly review limit. cubic has reviewed 40,041 of the 40,000 allowed lines of code this month. Reviews resume on 2 December 2026 (in 21 days). Paid plans include much higher monthly review limits. Upgrade now to resume reviews.

To help optimise your usage, you can tune cubic to get the most out of your usage limits:

Learn more →

@inkatze
inkatze marked this pull request as ready for review November 12, 2026 07:53
@inkatze
inkatze merged commit 488246d into main Nov 12, 2026
14 checks passed
@inkatze
inkatze deleted the planwright/flight/mc-dotfiles-ad-hoc-6bd70f89 branch November 12, 2026 15:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0