8000 Refuse fork jobs on the Mac's self-hosted runners and run several instances per repository by inkatze · Pull Request #258 · inkatze/dotfiles · GitHub
[go: up one dir, main page]

Skip to content

Refuse fork jobs on the Mac's self-hosted runners and run several instances per repository - #258

Merged
inkatze merged 5 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-78f5c048
Nov 14, 2026
Merged

inkatze merged 5 commits into
mainfrom
planwright/flight/mc-dotfiles-ad-hoc-78f5c048

Conversation

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

Merge before #250: both touch scripts/runner-start-test.sh; #250 syncs onto main after this lands.

What

The Mac's self-hosted runners now refuse any job that is not the repository's own code, stay awake, and run several instances per repository with a per-instance environment.

  • Fail-closed job-started hook. runner-job-started-hook.sh refuses unless GITHUB_REP 8000 OSITORY is the runner's own repository and the event is push, or pull_request whose head repository (read with /usr/bin/jq) is that same repository. The play installs one copy per runner instance beside a .repo file naming its repository, writes ACTIONS_RUNNER_HOOK_JOB_STARTED into the runner's .env, and fails if it cannot (it also stops early when /usr/bin/jq is missing). No gate is scheduled before the hook is in place.
  • Several instances per repository. osx_runner_instances (planwright: 4). An instance's directory and name follow the live runners (offload-mac-ci, -2, ...); both labels mac-fleet and offload-mac-ci are registered. Chosen: adopt existing registrations (a directory with .runner is never re-registered), not deregister and re-register, so no offline duplicates appear on GitHub and no removal tokens are needed. The stopgap's hand-set @reboot lines are removed by the play (cron's own name matching cannot adopt them) and replaced by the gate's.
  • Order. config.sh rewrites .path and may rewrite .env, so the hook line, the per-instance NPM_CONFIG_PREFIX (~/.npm-global-<n>), PLANWRIGHT_TEST_JOBS (half the cores, at least 1) and the .path prefix (the npm prefix's bin and a pinned node's bin) are written after registration and before any gate starts. When any of them changed, the runner's idle listener is stopped so its gate starts a fresh one; a listener serving a job finishes first (--once).
  • Awake. runner-start.sh starts each gate under /usr/bin/caffeinate -i, for the gate's whole life. Yielding to the Mac's owner is unchanged: niced runs, and the listener stops while the Mac is in use.
  • Node. Pinned in the role and put on the runners' PATH, rather than writing the account's global mise config, so that config stays untouched and the pin sits beside the runners it serves.
  • Spotlight. Fresh runners register with --work _work.noindex; an existing instance's _work moves to _work.noindex behind a _work symlink (runner-workdir.sh), skipped while a job runs and caught up by the next play run.

Tests: scripts/runner-hook-test.sh (new, wired into CI) covers push, same-repository pull request, fork pull request, other events, and a missing or unreadable payload or repository file. scripts/runner-start-test.sh pins caffeinate, the work-directory move, the idle-listener refresh, the instance and label wiring, the per-instance npm prefix, the core split and the task order.

Operator steps (admin)

After this merges. Checked 2026-11-14: ssh mac reaches the fleet account (zsh), whose ~/dev/dotfiles is a clean main checkout with ansible-playbook, mise and jq on its PATH, and this repository's gh login has admin.

  1. Rerun the playbook on the Mac (no sudo; runs as the fleet account):

    ssh mac 'cd ~/dev/dotfiles && git pull --ff-only origin main && ./scripts/playbook.sh'
  2. Set the fork-approval policy (currently first_time_contributors):

    gh api -X PUT repos/inkatze/dotfiles/actions/permissions/fork-pr-contributor-approval -f approval_policy=all_external_contributors

Then check the hook once, as docs/offload-host.md describes: a pull request from a branch passes with the hook in its log, and the hook refuses when run by hand with a fork's event file.

Step records

Steps at pre-implementation (run 000001)

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

Ended on 7aaac4bb5830.

  • Warning: fired after the implementation edits were drafted in the working tree, before any commit; completed at the base head

Steps at pre-ci (run 000001)

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

Ended on 845622b93597.

Steps at convergence (run 000001)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 polish skill polish in-session stream-json 845622b to f147aa2 2026-11-14T05:50:23Z 2026-11-14T06:23:13Z applied (degraded: isolated session not spawnable by this worker; ran in-session) polish --nested, 2 passes, inline lens walk (small narrow diff), declared. Pass 1: 2 findings applied (a9ee55b: play requires /usr/bin/jq before installing the hook; stale stop-a-runner instructions corrected). Pass 2: 0 new dispositions, converged. Requirement deltas from mission control (f147aa2, PLANWRIGHT_TEST_JOBS) were built between passes. No Needs-sign-off or human-judgment items. Audit file not written: the worktree's .claude is off limits.
2 panel-review skill panel-review in-session stream-json f147aa2 to 480fc88 2026-11-14T06:29:56Z 2026-11-14T07:38:52Z applied (degraded: isolated session not spawnable by this worker; ran in-session) panel-review --nested, backend gemini (consent on file for this repository), 2 discovery passes. Pass 1: 2 documentation findings applied (0b0e144). Pass 2 on 480fc88: 4 findings, all declined: trailing-slash dir (the play never passes one), _work and _work.noindex both existing (needs manual intervention, narrow), its missing test, and unescaped dir in pgrep patterns (matches the gate's existing pattern). No forks; converged.

Ended on 480fc88f6657.

Steps at pre-pr (run 000001)

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

Ended on 480fc88f6657.

Steps at post-pr (run 000002)

# Step Kind Target Hosting Backend Session Head Start End Outcome Excerpt Output
1 bot-review skill bot-review in-session stream-json 480fc88 2026-11-14T08:51:22Z 2026-11-14T09:05:22Z passed (degraded: isolated session not spawnable by this worker; ran in-session; start time estimated after the step) bot-review --nested --reviewer pr_agent, 1 iteration. PR-Agent reviewed head 480fc88 (run 43574867063.1, status success): 0 inline findings, 0 description-level findings, 0 unresolved threads; converged, nothing to apply. Cubic refused on quota (2026-11-14T08:15:21Z), so PR-Agent is the bot review.

Ended on 480fc88f6657.

Post-PR: cubic was triggered first (@cubic-dev-ai review this PR, 2026-11-14T08:15:17Z, head 480fc88). Its reply was a quota refusal: "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." PR-Agent's review is therefore this PR's bot review; its run on this head (run 43574867063.1) succeeded and its drain (/bot-review --nested --reviewer pr_agent) found nothing to reply to or resolve.


Summary by cubic

Makes the Mac's self-hosted runners fail closed against fork jobs, run several instances per repository, and stay awake so idle sleep no longer drops them offline.

  • A job-started hook refuses any job that is not the runner's own repository's push or same-repository pull request; it is installed per instance before any gate starts, and the play stops if /usr/bin/jq is missing.
  • planwright gets four instances (adopted from the stopgap, never re-registered) with per-instance directories, names, and labels.
  • Each instance gets its own npm prefix, a pinned node on the job PATH, and PLANWRIGHT_TEST_JOBS set to half the Mac's cores.
  • Gates run under caffeinate -i for their whole life; yielding to the Mac's owner is unchanged.
  • Runner work directories move to _work.noindex so Spotlight stops indexing checkouts.
  • .env and .path are written after registration and before gates; a changed runner's idle listener is restarted so it reads the new environment.

After merge (operator)

  • While no job runs, stop each stopgap listener (pkill -f 'actions-runners/inkatze-planwright.*Runner.Listener' as the fleet account), then rerun the playbook on the Mac.
  • Set the fork-approval policy with gh api -X PUT repos/inkatze/dotfiles/actions/permissions/fork-pr-contributor-approval -f approval_policy=all_external_contributors (needs admin).

Written for commit 480fc88. Summary will update on new commits.

View guided diff Turn on auto-fix

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

@cubic-dev-ai review this PR

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

@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 19 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 →

@github-actions
Copy link
Copy Markdown

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

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

@github-actions
Copy link
Copy Markdown

PR-Agent run 43574867063.1 on 480fc88: success

@inkatze
inkatze marked this pull request as ready for review November 14, 2026 09:19
@inkatze
inkatze merged commit 2c0031e into main Nov 14, 2026
14 checks passed
@inkatze
inkatze deleted the planwright/flight/mc-dotfiles-ad-hoc-78f5c048 branch November 14, 2026 15:31
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