Skip to content

feat(swm-macos-runner): one-slot Tart macOS runner (plan part 1) - #288

Merged
twistedmelonman merged 16 commits into
mainfrom
claude/feat-swm-macos-runner-c124fda4
Nov 18, 2026
Merged

twistedmelonman merged 16 commits into
mainfrom
claude/feat-swm-macos-runner-c124fda4

Conversation

@smartwatermelon-agent

Copy link
Copy Markdown
Contributor

Plan part 1, Tasks 0–7: the code for the smartwatermelon macOS CI runner on MIMOLETTE. Each job runs in its own Tart VM, and there is one slot. Task 8, the live proof on MIMOLETTE, is not done yet. It needs sudo and a fork PR from Andrew.

What this adds under scripts/swm-macos-runner/:

  • A fork-guard job-started hook. It runs in the guest and fails closed.
  • A local image build from the pinned base.
  • A one-slot supervisor, run as a gui launchd job. It alerts via ntfy with the prefix macOS runner:. It refuses a VM that is not on the Tart subnet.
  • An installer, a LaunchAgent and the runbook docs/runbooks/swm-macos-runner.md.
  • An updater that runs every 600 s. It waits while a JIT config is handed over, and the supervisor holds the next pass for a pending update.

Changes to scripts/nos-runner/:

  • github-app.sh reads any Keychain key item. NOS defaults are unchanged.
  • The pf guard loads the Tart LAN-block anchors (v4 and v6) every 60 s.

The new pf rules go live only after Andrew reruns install-pf.sh with sudo in Task 8. The live NOS updater installs the github-app.sh change within 600 s of the merge.

Two possible gaps have no code fix yet: VM IPv6 to global LAN addresses, and workflow env: reaching the hook. Plan Task 8 Step 3 now has a probe for each, with the action to take if it fails.

Tests: bash scripts/swm-macos-runner/tests/run-tests.sh gives 0 FAIL. The first red run of every new test ran in a throwaway Linux container on MIMOLETTE. Each task had a spec and quality review, and the final review of the whole branch had one fix wave and a re-review.

Advances #252

Claude Code Bot added 16 commits November 17, 2026 17:36
The live checks on MIMOLETTE passed: both rule files load before the VM
bridge exists, IPv4 and IPv6 LAN traffic is blocked, and df on the
external disk does not hang under launchd. An IPv6 DNS pass rule did not
match, so the build blocks all IPv6 LAN traffic and DNS uses the IPv4
resolver. Also fix the Undo hold value and the Tart version.
app_jwt reads GH_APP_KEY_SERVICE and GH_APP_KEY_ACCOUNT, defaulting to the
NOS runner item, so the smartwatermelon macOS runner can reuse the helper.
The guest runs this hook before any workflow step and denies every
event that does not provably come from a branch of the same repository
in an allowed owner. Tests use crafted payloads, and a control run
against an allow-all hook must fail exactly 16 deny cases, so the cases
are proven able to fail. CI runs the suite in tests.yml.
Add com.apple/swm-tart (v4) and swm-tart-v6 (bridge101) next to the NOS
anchors, each set with its own ok files so one set failing never clears
the other. The plist now runs the guard every 60 s.
One check_v4_anchor helper serves both sets, and the main ruleset is read
and checked once, failing both sets as before.
config.sh holds the pinned base, runner version and limits; SWM_IMAGE
hashes guest/ plus the base digest. build-image.sh clones the base, installs
the runner, hook and run-job.sh, renames to SWM_IMAGE, then deletes old
swm-macos-runner-* images. Every tart call is bounded.
A failed stop left tart run up and the plain wait hung, so swm-build-tmp
was never deleted. wait_run polls for SWM_STOP_LIMIT_S, then kills the
run pid through KILL_BIN. A run that outlives a good stop now fails.
supervisor.sh run|once|test-alert keeps one mimolette-macos VM per job.
Each pass sweeps leftover mimolette-macos-* VMs and the recorded runner,
checks pf, disk and the image (builds it when missing), then clones,
boots and waits for the IP, the guest agent and the IPv6 ok file. Only
then does it mint the token and the JIT config, which goes to tart exec
on a pipe, never argv or a file. Alerts go out once per change of KIND;
after 3 fails the loop backs off. A SIGTERM ends the running tart call
and tears the slot down.

wait_run moves from build-image.sh into lib.sh so both scripts share it.
lib.sh gains abort_bounded and notify_ok; config.sh gains the supervisor
waits, the swm-runner App IDs and the ok-file paths.
…art-hung

The commit review found two gaps. A SIGTERM during the clone, ip or
readiness wait waited out the tart call (up to 600 s, past launchd's
ExitTimeOut); now everything from the clone to the end of the job is
abortable. And a readiness exec that timed out while the guest booted
marked the pass tart-hung and alerted at once; it now counts as a
start failure.
Reset fails and send recovered after the job exec returns 0, not at the JIT
handoff. A failed job now counts like a start failure (3 fails: one alert,
backoff). A SWM_JOB_MAX_S time-out is neutral: an idle runner hits it every 6 h.
Adds install.sh (libexec copy, plist render, bootout then bootstrap), the
LaunchAgent plist (ExitTimeOut 300), its tests and the runbook. Notes the
shared ntfy topic and the 60 s pf guard in the NOS runbook.
Add update.sh and its LaunchAgent (every 600 s): pull the clone, and when the
runner code or github-app.sh has a new commit and the slot file says job=0,
run install.sh. install.sh now installs and loads the updater too, and skips
reloading it when the updater itself runs it.
… subnet

The pf rules cover only 192.168.65.0/24. The supervisor now keeps the
tart ip output and, for any other address, logs it, tears the VM down and
counts a pf fail instead of handing over the JIT config.
…plist

The hang drill sets SWM_CLONE_LIMIT_S in the env file, but install.sh
rendered only NTFY_TOPIC, so the drill changed nothing. Lines matching
SWM_<NAME>_S=<digits> now go into the supervisor plist environment.
Any other SWM_ line, or a repeated knob, is refused before anything is
installed.
An idle JIT runner holds job=1 for up to 6 h, so the updater almost
never saw job=0 and a merged fix could wait a day. The updater now
writes update-pending when it holds a version back and clears it after
a good install or when nothing is new. The supervisor, at the start of
a pass with job=0 and before the clone, waits for that file to go
(SWM_UPDATE_WAIT_S, 900 s; SIGTERM ends the wait). The runbook now says
job=1 means the runner may be idle or busy.
The final review found two unverified gaps: whether a job VM can reach
global IPv6 addresses, and whether workflow env reaches the job-started
hook. Task 8 Step 3 now probes both and says what to do if either fails.
@twistedmelonman
twistedmelonman merged commit e674f10 into main Nov 18, 2026
6 checks passed
@twistedmelonman
twistedmelonman deleted the claude/feat-swm-macos-runner-c124fda4 branch November 18, 2026 20:09
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