feat: hub self-decided upgrade check via POST /api/upgrade - #73
Merged
Conversation
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.
Summary
POST /api/upgradelets a remote client TRIGGER the hub's staleness check;the restart decision is entirely the hub's own. It restarts onto the on-disk
code only when that code is NEWER than the running process:
package.jsonversion beats the version frozen at process start, ordist/**/*.jsmtime (floored to ms — APFS sub-ms fractions wouldotherwise beat a truncated
Date.now()) is later than process start, so arebuild without a version bump counts.
restarting: truethe hub replies, closes (~500ms), re-spawns itselffrom its own dist path (
bin/hub.tsrespawnSelf), and exits; bridgesre-register on their next heartbeat and EADDRINUSE keeps the respawn race
a machine singleton. A respawned process starts after the newest dist mtime,
so the check self-negates — no restart loops, and an OLDER disk version
never triggers.
(
onRestart, falling back toonIdleExitwhen unset).Test plan
tests/hub.test.ts: 401, version-bump restart, mtime(rebuild) restart, same-version no-op, older-version no-op, and safe
defaults on the real repo layout.
tsc --noEmit, eslint, prettier clean.docs/REMOTE-CLIENTS.md— new "Hub self-upgrade" section + endpoint row.Release 0.11.7.