Host apply¶
oupdate host --apply applies this host's Homebrew formula, cask and npm global updates, with the guards of the updater it replaces. Run --dry-run first: it runs every check and changes nothing on disk. It skips brew update and the HEAD fetch, upgrades, restarts, cleanup, the waiter and state writes, and it logs notices without sending them.
Quick start¶
- Write the
applyobject in$HOME/.config/oupdate/config.json(or pass--config FILE). Paths must be absolute; an unknown key is an error.${NAME}in any value (NAME is letters, digits and_, not starting with a digit) is read from the environment when the config is loaded, so a key or URL need not be written into the file; an unset or empty variable is an error that names it, and any other$text is kept as written.{date}inlogFileis the run's local date as YYYYMMDD, so each day gets its own file. Givebrewandnpmas absolute paths when launchd runs it: a LaunchDaemon's PATH has no Homebrew directory.claudeCodeis the absolute path of the native Claude Code binary (the install's.local/bin/claudein the user's home); leave it out on a host without one.notifyis a command that gets each notice as its last argument;[]means log-only by choice (see below).postUpgradeCheck(optional, off by default) maps a package name to an argv, e.g.{"git": ["git", "--version"]}: after the run, each package upgraded in it (brew or npm; a tap-qualified brew name matches on its last segment) gets its command run once, and a non-zero exit or a timeout is logged (post-upgrade check: <name> FAILED (rc=N)), notified, counted asFAILED: check:<name>in the brew line (so the run exits 1) and never aborts the run. A dry run runs no check.
{
"apply": {
"stateDir": "/var/lib/oupdate",
"logFile": "/var/log/oupdate/{date}.log",
"brew": "/opt/homebrew/bin/brew",
"npm": "/opt/homebrew/bin/npm",
"claudeCode": "/opt/example/bin/claude",
"typeBTaps": ["example/tool"],
"upstreamTaps": ["example/tool"],
"approvedTapsFile": "/etc/oupdate/approved-taps.tsv",
"pinRoots": ["/srv/repos"],
"caskExclude": ["some-huge-suite"],
"reviewer": { "type": "openai", "name": "local", "baseUrls": ["http://127.0.0.1:8080/v1"], "model": "your-model" },
"notify": ["/usr/local/bin/your-notifier"],
"labelRestart": { "org.example.quiet-daemon": ["/usr/local/sbin/restart-when-quiet", "--wait"], "org.example.manual": "skip" }
}
}
The openai reviewer also takes optional headers and expectHeaders. headers are sent on the request. expectHeaders names response headers a 2xx answer must carry: the name is compared case-insensitively and the value exactly. A mismatch discards that answer (<base>: answer <header> <got>, expected <want>, or missing when the header is absent) and the next base is tried. It is not retried. To refuse an answer a model proxy served from its cloud fallback, set "expectHeaders": {"x-served-by": "local"} (the header your proxy sets).
oupdate host --apply --dry-runprints the run and a dry-run summary. Read the tier split, the holds and the notices it would have sent. It writesdry-run-<log file name>beside the log, never the dated log itself, and its header and summary are named so that nothing reading a log takes a dry run for a run.oupdate host --applyis the live run. The exit code is 1 when anything failed.- Schedule it with launchd or cron. See Schedule it.
Every line goes to the log file and stdout as it is made. A run stopped by SIGTERM or SIGINT (or SIGHUP, when started from a terminal), or one that crashes, ends with an === ABORTED: ... line: the commands it was running are stopped (SIGTERM, then SIGKILL), nothing new starts (no command, no reviewer command, no idle waiter, no delayed restart), nothing more is logged, no done notice is sent, and the exit code is the signal's (143, 130, 129). A dry run or a Gatekeeper one-off stopped that way ends with === STOPPED: ... instead, in its own log file. Without a terminal (launchd, nohup), SIGHUP is left alone, so nohup keeps a logout from stopping the run. A finished run ends with the summary block the host shadow report already reads, then a done notice:
=== <host> summary ===
brew: upgraded: ...; casks upgraded: ...; PINNED: ...; STUCK: ...
npm: upgraded: ...; claude-code: 2.1.309
mas: not checked — the App Store phase is not in oupdate
mas reads "not checked" on every run by design: the App Store phase is not in oUpdate, and the words are not ones a status reader counts as trouble. claude-code is the version after the update, FAILED (rc=<rc>, on <version>) or FAILED (timeout, on <version>) when the update failed (unknown when --version fails too), not configured without claudeCode, and dry-run in a dry run. A claudeCode path that is not executable is skipped with no claude-code part.
Schedule it¶
oupdate host --launchd-plist prints a LaunchDaemon plist that runs oupdate host --apply every day at one time. It writes nothing; you install it as root.
oupdate host --launchd-plist --label org.example.oupdate-apply --user USER --at 03:30 \
[--config FILE] [--bun PATH] [--app DIR] [--home DIR] [--stdout FILE] [--path DIR]... > org.example.oupdate-apply.plist
- The label takes letters, digits,
.and-only; it becomes the plist's file name. - The job runs as
--userwith groupstaff, at--at(HH:MM, 00:00 to 23:59), and not at load. It has no KeepAlive and no AbandonProcessGroup: the idle waiter detaches itself. - It runs
<bun> <app>/src/cli.ts host --apply, plus--config FILEwhen given.--bundefaults to thebunfound on PATH, as found (not resolved), and--appto this tree. Every path must be absolute. A bun in a temp dir (/tmp,/private/tmp,/var/folders) or in abun-node-directory (the node shimbun run --bunputs first on PATH) is refused, given or found: it is gone at reboot or the next upgrade. A found bun under your home is refused when--useris someone else, who may not be able to reach it; pass--bunthen. A bun inside a HomebrewCellarkeg is refused, given or found: the first run that upgrades bun ends withbrew cleanup, which deletes that keg, and launchd then cannot start the job. Use the stable link, e.g./opt/homebrew/bin/bun. HOMEis--home. It can be left out only when--useris the user running the command.PATHis bun's directory, then the directories of the config's absolutebrewandnpm, then each--path DIR, then/usr/bin:/bin:/usr/sbin:/sbin. Homebrew's own directory is not on it unless the config puts it there, so givebrewandnpmas absolute paths in the config: a barebrew(the default) is not found under launchd. npm is a#!/usr/bin/env nodescript, sonodemust be on that PATH: Homebrew's npm and node share a directory, which the config'snpmadds. Without--config, or with a barenpmin it, pass--pathwith node's directory.- With
--config, the config is read even when--stdoutis given, for the brew and npm directories. To skip it, leave out--configand give those directories with--path; the job then reads the default config. - launchd's stdout and stderr go to
--stdout. It defaults tolaunchd-oupdate.logbeside the config'sapply.logFile. A name that starts with2is refused, because a log reader takes the newest2*.logas the run log.
Pick the time the old updater ran. launchd does not create the stdout file's directory, so make it first, owned by the job's user. Then, as root, disable the old job and install the new one:
mkdir -p /var/log/oupdate && chown USER:staff /var/log/oupdate
cp org.example.oupdate-apply.plist /Library/LaunchDaemons/org.example.oupdate-apply.plist
chown root:wheel /Library/LaunchDaemons/org.example.oupdate-apply.plist
chmod 644 /Library/LaunchDaemons/org.example.oupdate-apply.plist
plutil -lint /Library/LaunchDaemons/org.example.oupdate-apply.plist
launchctl disable system/org.example.old-updater
launchctl bootout system/org.example.old-updater
launchctl bootstrap system /Library/LaunchDaemons/org.example.oupdate-apply.plist
launchctl print system/org.example.oupdate-apply
These steps assume the old job is a LaunchDaemon (system/). If it is a LaunchAgent, use gui/<uid>/<old label> for its disable, bootout and enable, and launchctl bootstrap gui/<uid> <its plist> in the revert.
disable keeps the old job off across reboots; its plist stays where it is, for the revert. To install a changed plist later, run launchctl bootout system/org.example.oupdate-apply before the copy: bootstrapping a label that is already loaded fails with 5: Input/output error.
To revert, as root:
launchctl bootout system/org.example.oupdate-apply
rm /Library/LaunchDaemons/org.example.oupdate-apply.plist
launchctl enable system/org.example.old-updater
launchctl bootstrap system /Library/LaunchDaemons/org.example.old-updater.plist
What it does¶
- Waiter report. A deferred service's waiter recovers a drain a dead waiter left behind, then shows its last outcome.
- brew. Sync the taps, then list outdated formulae (HEAD installs included) and casks (auto-updating ones included). Then:
- Drop the excluded casks, and hold pinned tools: a
brew pin, or a name in a repo'spins.jsonone level underpinRoots. - Split the rest by tap:
- Type A: the official taps. A deterministic version policy holds a major increase of a sensitive package.
- Type B:
typeBTapsplus this host's rows in the approved-taps file. Each package gets its own review before it installs. - Upstream taps (
upstreamTaps, off by default; the tap must also be Type B): for a tap that IS the project's source repo, with a source-built formula, every release changes hundreds of non-formula files, so the "support files changed" FLAG could never pass. For a listed tap the review instead reads only the supply-chain surface of the release diff (the receipt's tap revision to the tap HEAD): the formula, install and build scripts,setup.py/pyproject.toml/Makefile/CMakeLists.txt, package manifests and lockfiles,.github/workflows,packaging/,scripts/, plist and shell files, and any newly executable file or symlink. Other source files are counted, not read. Before the reviewer runs, a deterministic scan of the lines the release adds to that surface FLAGs a fetch piped into a shell, an encoded payload, a new curl/wget/git clone or network call in a build step (CI workflows excepted), a dependency from a url, VCS or another index, a new npm install hook, and any added or changed binary that is not an image, font or PDF. The reviewer then reads the formula plus that surface with extra indicators for new network steps, dependency sources and hooks, and a FLAG holds the package. The formula gates (url origin, artifact kind, new off-tap dependency, formula loading other files) and the tap-unchanged and off-tap-dependency re-checks beforebrew upgradestill apply. No receipt revision, an unreadable diff or a HEAD install still holds the package. A tap not listed behaves exactly as before. - App bundles (
appBundles, off by default): a macOS.appinstalled outside brew and published as a signed, notarized disk image on the project's GitHub release ({"name", "app": "/Applications/X.app", "repo": "owner/name", "asset": "<regex matching exactly one release asset>", "restart": ["/abs/waiter", ...]}). Only a stablevX.Y.Zrelease newer than the installed bundle counts. The asset needs a published sha256 digest and a download url on the project's own release path; the release's supply-chain surface (the tag-to-tag diff, read as for an upstream tap) must have no deterministic finding and the reviewer must APPROVE it. The downloaded image must match the digest, and the new bundle must have the installed bundle's id, Team ID and the release's version, passcodesign --verify --deep --strictand be accepted by Gatekeeper as notarized Developer ID code of that team. Then the old bundle is renamed<app>.bak-oupdate-<version>(kept; never overwritten) and the new one moved in;restart, if set, is started detached with the backup path appended. A dry run reviews and verifies nothing past the review and installs nothing. - Unknown taps: an advisory review only. One notice asks for the tap's approval; nothing installs.
- Upgrade what passed, one package at a time. Relink, then restart each upgraded service, except a deferred one: that goes to its idle waiter.
- Deferred casks. One at a time, with Gatekeeper around each upgrade: snapshot before, then release and check after.
- Stale keg and linkage. Restart services still running from a deleted keg, and report broken library links. Every stale process is looked at, not one per package. This oUpdate run and the processes that started it are never restarted; they move to the new keg with the next run. A process launchd started (parent pid 1) is looked up in launchd by its pid:
launchctl print systemfor a daemon (restarted withsudo -n launchctl kickstart -k system/<label>), thenlaunchctl print gui/<uid>for your own agent (restarted ingui/<uid>/). So a job whose label never names the package, such as an agent running a Homebrewbun, is still found. Only when launchd has no row for such a pid is the label taken from a plist name, once per package: the label must be the package or process name, or end in.and it (sh.brew.<pkg>,homebrew.mxcl.<pkg>), never a name that merely contains it. Such a label is restarted only whenlaunchctl printshows it running exactly that pid and the pid's executable is a file of the stale keg; otherwise the pid is reported as an orphan, never restarted. The restart helper is used only for such a name-matched label, since it restarts a package's own service. More than one label for a pid, an unmatched label or an ambiguous plist match is named for you, never guessed. A process launchd did not start (a shell'sbun, say) is never restarted, not by its pid and not by a plist name: if its direct parent is a launchd job's own process (say a plist whose shell does notexec), the package is named for an operator as<pkg>(child of <label>), noticed and counted toward stuck, and never restarted through that chain; when that job was already restarted or handed to its owner this run, the child carries that outcome instead. Any other process (an interactive one, or one deeper under a job, such as a shell in a session under a daemon) is left alone and not counted on the re-scan; a job further up its chain is only logged. A label is restarted once per run; every package stale under it is accounted for by that one outcome.labelRestartoverrides the restart of a label, matched literally, on either path:"skip"leaves it to the job's owner (the STALE KEG note says so),"kickstart"restarts it as usual, and a command (its first entry an absolute path) is started detached with the label as its last argument and not waited for; the note readsSTALE KEG: <pkg> handed to <command> (<label>)until a run finds the package gone (a re-scan that already finds it gone says onlyrestarted onto new keg). The samelabelRestartapplies when step 2 restarts the service of a package it just upgraded, before the restart helper and kickstart, for a label whose plist exists. An owner command is started at most once per run: a label step 2 handed over is not handed again by this step. Write owner commands to be single-instance anyway (take a lock, exit when another one runs).staleKegUnlistedsays what this step does with a label not inlabelRestart:"kickstart"(the default) restarts it as above;"report"makeslabelRestartan allow list, so such a label is never restarted (no helper, no kickstart), its packages read<pkg>(reported only, not on the restart list)in the STALE KEG note and count toward stuck. List a label as"kickstart"to restart it then; a"kickstart"label found only by plist name goes through the restart helper by package when the helper lists that package. Report mode does not cover deferred services: they still go to their idle waiter. Step 2 obeys it too: in report mode a label with a plist that is not inlabelRestartis not restarted there (no helper, no kickstart) and reads<pkg>(reported only, not on the restart list)in the restarted list. A failed or timed-out launchctl query (print gui/<uid>fails with no GUI session) is logged and falls back to the plist name. The log says which way each label was found. A dry run runs these queries and only says what it would kickstart, hand over, leave or report. A deferred service on a deleted keg is handed to its idle waiter unless its--holderprobe answers 0, the waiter's sign that one is already running. Any other answer hands off; a timed-out probe is named in the note. Your waiter must take its own exclusive lock and exit when another one is live. During a stop, nothing is handed off.
staleOwners restarts long-running launchd jobs that are still on a deleted keg, one at a time, when each is idle. Each entry is {"match": <label glob, * and ?>, "probe"?: argv, "health"?: url, "restart"?: "kickstart" | {"bootstrap": <absolute plist path>}, "healthWithinSec"?: n} and takes precedence over labelRestart and staleKegUnlisted. A matched label is queued, never restarted inline: the run starts oupdate host --stale-owners-waiter --config <file> detached, and the waiter works the queue under a kernel lock (flock on <stateDir>/owner-restarts/lock). For each job it waits until idle (the probe exits 0, or by default the pid holds no established TCP connection for 60 s; still busy after 2 h reads held: busy), re-reads the pid just before restarting, restarts it (launchctl kickstart -k, or bootout then bootstrap of the plist; sudo -n in the system domain), then checks health: a new running pid within healthWithinSec (default 60), the health URL answering 200 when set, and no deleted keg mapped by that pid. A failure stops the queue, writes FAILED: <label> ... rollback: <command> and marks the label so it is not tried again until you remove it from <stateDir>/owner-restarts/failed; a waiter killed mid-restart counts as failed. Results are reported by the next run. A label found only by a plist name is queued only when launchd runs the stale pid under it. Processes from a run job of a job runner (jobRunners: command names, so a stale <runner> run … --job <id> process is named with its job id) and orphans with no launchd job are reported with their pids, never restarted. The STALE KEG note counts every outcome per package, and anything not cleared keeps it.
releaseChecks (optional, off by default) gates a formula's release on a quality check run on the host. Each entry is {"formula": <name, bare or tap-qualified>, "command": argv, "retries"?: n (default 1), "timeoutSec"?: n (default 900), "before"?: argv, "after"?: argv, "runAs"?: <user>}. For a listed formula the upgrade keeps the previous keg (no install cleanup in a run with release checks; the cleanup step skips the formula until its check decides; a process still on the previous keg counts as stale). before runs right before the upgrade. After the upgrade and its owner restart (a staleOwners job on the previous keg is restarted inline, the same way the waiter does it, never queued), command runs with GATE_VERSION=<the installed version>: exit 0 is PASS, exit 1 FAIL (rerun up to retries more times), any other exit or a timeout means the check could not run: no verdict, the new version stays and a notice says so. FAIL on every attempt rolls back: brew uninstall of the new keg (brew resolves the linked keg) and brew link of the one left (brew link always links the latest keg, so it cannot pick the older one while both are installed); a formula trusted before is trusted again. Then the owner restarts, the release is held (<stateDir>/release-checks/holds/<formula>.json; later runs log HELD by release check and skip that version, a newer one is tried) and the check runs again on the restored version. after runs when the check passed, could not run, or the restored version passed; after any other confirmed fail (restored version failing, previous keg missing, rollback or owner restart failing) it is not run and a loud notice says so. When the run stops before any verdict (an upgrade or before failure, an owner restart that failed, an error), after still runs once before did. A formula not upgraded this run runs neither. owners (optional) names launchd labels, matched literally, whose restart the check always needs, whether or not the stale-keg scan found them (system domain when /Library/LaunchDaemons/<label>.plist exists, else the user's LaunchAgents, else system); one not running or not found is a restart failure. runAs runs before, command and after as /usr/bin/sudo -n -u <user> -H --preserve-env=GATE_VERSION -- <argv>. An upgrade whose check has not decided is recorded in <stateDir>/release-checks/pending/, so a run that dies leaves it to the next. A dry run logs what it would run and runs none of it. Versions are read from the opt link (a keg-only formula has no linked keg; its rollback is brew link --force then brew unlink); a version that cannot be read is a no-verdict end, notified. While a gated formula is outdated (or held), a planned upgrade whose brew deps include it waits for a later run, so brew never pulls the gated release in unchecked; unreadable dependencies wait too. A signal after before still runs after (forced past the stop, before oUpdate exits); the pending record is removed only once after ran and the check is over. An owner gone before its restart is a restart failure, never a pass. A failed inline owner restart is appended to <stateDir>/owner-restarts/failed, as the waiter's are, so neither loses the other's entry. The pending record is a written state machine (upgraded, owner restarted, verdict, rolled back, restored owner restarted, restored verdict, after ran): every step is written before the next starts, and a later run resumes from the last one; while a record is unfinished its formula is not upgraded again. The dependency guard covers every planned upgrade: a gated formula on another outdated gated one, and casks (brew deps --cask). A release check's owner is restarted inline even if an earlier restart of it failed, and a formula whose own service label matches staleOwners always needs that restart. The inline restarts, check and re-check hold the waiter's lock (waited for up to 10 min, else the check waits for a later run), the label's queued waiter job is removed, and a waiter for other owners queued meanwhile starts after the release checks.
5. Stuck. Count what is still pending, run after run. Pinned and excluded packages never count.
6. npm globals. One review of the batch, with literal attack indicators forced to FLAG. An install hook (preinstall, install, postinstall, prepare) that is new or changed since the installed version also FLAGs, even when it only runs a local file, because the file it runs is not read here. For the same reason any preinstall, install or postinstall hook FLAGs even when unchanged, since the file it runs can change under the same hook string; an unchanged prepare does not, because npm does not run it for a registry install. Then upgrade each package by name.
7. Claude Code (native). In the npm phase, after npm: <claudeCode> update (its output indented in the log), then <claudeCode> --version for the version the summary reports. The native build updates itself in place; with its background updater off, this call is the only update path. A dry run logs DRY RUN - would run: claude update and runs neither command; during a stop neither starts. A timed-out update is also a FAILED — timeout:claude-update entry on the npm line.
Fail closed: a failed query is a FAILED entry in the summary, never "nothing to update". An unreadable state file is reported and kept. With no reviewer configured, everything that needs a review is held. A command that runs past timeoutMs is killed with its whole process group. It becomes a FAILED entry: the package, for an upgrade, else timeout:<command>. The run goes on to the next step, and what the stopped step already upgraded is still reported, relinked, restarted and cleaned up. With no notify key, notices are only logged, and the brew line ends with notify: not configured. "notify": [] makes the run log-only by choice: notices are still logged as [notify] ..., nothing is sent, and the brew line has no such note.
Gatekeeper one-offs, with no review and no upgrade:
- oupdate host --gatekeeper-approve CASK releases a cask nobody ever approved. The same three gates apply: one Team ID, the pinned team, and notarization.
- oupdate host --gatekeeper-revert CASK puts back every quarantine value a release removed.
A HEAD install and a source-built Type B package (except for an upstreamTaps tap, which gets the surface review above) are held or reported, never skipped.
The Gatekeeper one-offs exit 1 when nothing was released or restored. They log to gatekeeper-<log file name>, never the dated log.