Repository navigation
Refresh each host's agent package from main on an hourly job - #6
Merged
Merged
Conversation
Every machine pins its package independently, so a skill fix merged to main only reaches a host when someone re-runs bootstrap-agent there. A theme deleted on main stayed in use for a week that way. bin/refresh-agent compares the installed .release-revision against the tip of main and, when they differ, re-runs bootstrap-agent from the package being replaced, so the installer updates on the same tick. It reads url and tokenRef from the existing host config and never writes it. A matching pin prints one line and exits zero. A missing config, a missing package, a non-sha revision, and an unreachable GitHub each exit nonzero naming the failing step, because this runs unattended. --install --job-id writes the hourly LaunchAgent through the hub reporter and refuses to overwrite a plist it did not write. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Two hourly runs, or one racing a manual bootstrap-agent, would both clear install-agent's guards and then race the agent-current relink. mini-host.py takes the same non-blocking flock around activate; a second runner now exits naming the lock step instead of interleaving. The documented and suggested job ids also have to follow the registry's <host>.launchd.<label> convention, and a wrong example in the one document telling operators how to run this is how the next drift starts. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
This is the root cause of the stale-template bug. Every machine pins its own agent package, so a skill fix merged to main only reaches a host when someone re-runs
bootstrap-agentthere by hand. A theme that main had already deleted stayed in use for a week that way, across three machines, and every plan generated in that window used it.What it does
bin/refresh-agentcompares the installed.release-revisionagainst the tip of main and, when they differ, re-runsbootstrap-agentfrom the package being replaced, so the installer picks up its own fixes on the same tick. It readsurlandtokenReffrom the existing host config and never writes that file. A matching pin prints one line and exits zero.It runs unattended, so there is no recovery path and no default that papers over a broken host. A missing config, a missing package, a non-sha revision, and an unreachable GitHub each exit nonzero naming the failing step.
--install --job-idschedules it hourly as a user LaunchAgent whoseProgramArgumentsgo through the hub reporter, so an unattended failure surfaces as a failed run rather than silence. The job id differs per host, hence an explicit argument. It refuses to overwrite a plist at that label it did not write.The scheduled command deliberately points at the stable
agent-currentlink rather than a resolved path, which would bakepackages/<sha>into the plist and strand the job at the first upgrade.Review notes
The second commit is mine on top of the implementation. It adds the non-blocking flock, because two hourly runs, or one racing a manual
bootstrap-agent, would both clearinstall-agent's guards and then race theagent-currentrelink.mini-host.pyguardsactivatethe same way. It also corrects the job id examples to the registry's<host>.launchd.<label>convention.Known gaps, deliberately not addressed here
Nothing checks that main is green. The Mini's own deploy path runs typecheck and both suites inside
activatebefore flippingcurrent, butbootstrap-agentverifies nothing, so a bad merge would propagate to every agent host within the hour. Gating on the commit's check-runs status would close it. It is a real hole, and it turns this from tracking main into tracking a release channel, which is a separate decision.Nothing prunes
packages/<sha>, so an hourly refresh against an active repo accumulates one package directory per merged commit.Verification
Self-check passes under the Mini's Python 3.9.6 and under 3.14. 14 Python deploy regressions, up from 8. 68 bun tests, 193 assertions. Clean typecheck. The live resolve path was also exercised read-only against the real GitHub API and returned exactly
git rev-parse origin/main, so it is proven rather than inferred. The mutating path was never run and no LaunchAgent was installed.🤖 Generated with Claude Code