Skip to content

feat: hub self-decided upgrade check via POST /api/upgrade - #73

Merged
william0wang merged 1 commit into
mainfrom
feat/hub-self-upgrade
Aug 23, 2026
Merged

feat: hub self-decided upgrade check via POST /api/upgrade#73
william0wang merged 1 commit into
mainfrom
feat/hub-self-upgrade

Conversation

@william0wang

Copy link
Copy Markdown
Owner

Summary

  • POST /api/upgrade lets 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:
    • on-disk package.json version beats the version frozen at process start, or
    • any dist/**/*.js mtime (floored to ms — APFS sub-ms fractions would
      otherwise beat a truncated Date.now()) is later than process start, so a
      rebuild without a version bump counts.
  • On restarting: true the hub replies, closes (~500ms), re-spawns itself
    from its own dist path (bin/hub.ts respawnSelf), and exits; bridges
    re-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.
  • The existing newer-bridge handshake now uses the same restart path
    (onRestart, falling back to onIdleExit when unset).

Test plan

  • 6 new cases in 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.
  • Full suite 696/696, tsc --noEmit, eslint, prettier clean.
  • docs/REMOTE-CLIENTS.md — new "Hub self-upgrade" section + endpoint row.

Release 0.11.7.

@william0wang
william0wang merged commit 6b613a4 into main Aug 23, 2026
1 check passed
@william0wang
william0wang deleted the feat/hub-self-upgrade branch August 23, 2026 06:21
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