Skip to content

Commit 20a3e50

Browse files
authored
fix(update): loud appcast publishing + unified channel precedence (#1026)
The v0.60.0 release exposed a silent failure chain: the repository-dispatch that tells mcpproxy.app to serve the fresh Sparkle feeds 401'd on an expired MARKETING_SITE_DISPATCH_TOKEN under continue-on-error, so the site kept serving the 0.59.0 feed. Sparkle told users they were up to date while the tray menu line and doctor (GitHub API) offered v0.60.0 — and every stale window makes updates look sequential, since the single-item feed then offers exactly N-1. CI: - release.yml / prerelease.yml: drop continue-on-error from the publish-appcast dispatch steps. They run after all release assets (feeds included) are uploaded, so a red job blocks nothing — it is the recovery signal. - Add a 'Verify live feeds are fresh' step to both sparkle-appcast jobs: poll mcpproxy.app until the live bytes sha256-match the just-generated feeds (one shared 15-min deadline), mirroring the site's own verify but on the side of the broken link that actually failed. Go (divergence found while auditing the surfaces): - mcpproxy update now applies the same build-version-authoritative channel precedence as the daemon's checker (exported as updatecheck.IncludePrereleasesForBuild): a stable build never resolves against the prerelease list, even with a stale 'channel: rc' config or env opt-in, and go-install builds promote their module version first (updatecheck.PromoteGoInstallVersion) exactly like the checker. - Fix the stale 'every 4 hours' doc comment on VersionInfo.
1 parent 770b58e commit 20a3e50

7 files changed

Lines changed: 190 additions & 33 deletions

File tree

‎.github/workflows/prerelease.yml‎

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1200,14 +1200,48 @@ jobs:
12001200
path: appcast-out/*
12011201
if-no-files-found: ignore
12021202

1203-
# Same site hand-off as release.yml, beta channel. Non-blocking; the
1204-
# site workflow is manually re-runnable (workflow_dispatch).
1203+
# Same site hand-off as release.yml, beta channel. MUST fail loudly (see
1204+
# the matching comment in release.yml): the mcpproxy.app beta feed is the
1205+
# ONLY stable URL for the rc channel — GitHub's releases/latest/download
1206+
# never resolves to a prerelease — so a silently lost dispatch strands
1207+
# every beta user on the previous RC. All release assets are uploaded
1208+
# before this step; a red job blocks nothing. Backfill by re-running this
1209+
# job, or via the site's publish-appcast workflow_dispatch.
12051210
- name: Publish beta feeds to mcpproxy.app
12061211
if: steps.appcast.outputs.generated == 'true'
1207-
continue-on-error: true
12081212
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
12091213
with:
12101214
token: ${{ secrets.MARKETING_SITE_DISPATCH_TOKEN }}
12111215
repository: smart-mcp-proxy/mcpproxy.app-website
12121216
event-type: publish-appcast
12131217
client-payload: '{"version": "${{ github.ref_name }}", "channel": "beta"}'
1218+
1219+
# End-to-end freshness check, mirroring release.yml's: poll until the
1220+
# live site serves the exact bytes this job generated, on one 15-min
1221+
# deadline shared across the feeds.
1222+
- name: Verify live feeds are fresh
1223+
if: steps.appcast.outputs.generated == 'true'
1224+
run: |
1225+
set -euo pipefail
1226+
DEADLINE=$(( $(date +%s) + 15 * 60 ))
1227+
FAILED=0
1228+
for f in appcast-out/*.xml; do
1229+
NAME=$(basename "$f")
1230+
WANT=$(shasum -a 256 "$f" | cut -d' ' -f1)
1231+
OK=""
1232+
# Check-first: every feed gets at least one probe even after an
1233+
# earlier feed has exhausted the shared deadline.
1234+
while :; do
1235+
GOT=$(curl -fsSL "https://mcpproxy.app/${NAME}" 2>/dev/null | shasum -a 256 | cut -d' ' -f1 || true)
1236+
if [ "$GOT" = "$WANT" ]; then OK=yes; break; fi
1237+
if [ "$(date +%s)" -ge "$DEADLINE" ]; then break; fi
1238+
sleep 15
1239+
done
1240+
if [ -n "$OK" ]; then
1241+
echo "✅ https://mcpproxy.app/${NAME} serves the ${GITHUB_REF_NAME} feed"
1242+
else
1243+
echo "::error::https://mcpproxy.app/${NAME} still does not serve the ${GITHUB_REF_NAME} feed after 15 minutes — beta users will be offered a stale version"
1244+
FAILED=1
1245+
fi
1246+
done
1247+
exit "$FAILED"

‎.github/workflows/release.yml‎

Lines changed: 52 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,14 +1572,13 @@ jobs:
15721572
# native/macos/MCPProxy/MCPProxy/Services/SparkleFeedURL.swift, and the file
15731573
# names below are the other half of that contract.
15741574
#
1575-
# TODO(maintainer decision #1 in docs/research/auto-updater-issue-957-2026-08-07.html):
1576-
# the shipped Info.plist points at https://mcpproxy.app/appcast.xml, which the
1577-
# WEBSITE repo would have to serve — this repository cannot publish there. Until
1578-
# that is wired, the feeds are (a) attached to the release and (b) exported as a
1579-
# workflow artifact (`sparkle-appcast`) for the website repo to consume. The
1580-
# GitHub-hosted stable URL
1575+
# The shipped Info.plist points at https://mcpproxy.app/appcast.xml (decision
1576+
# #1 in docs/research/auto-updater-issue-957-2026-08-07.html). This job feeds
1577+
# the site via a repository-dispatch below; the feeds are also (a) attached to
1578+
# the release and (b) exported as a workflow artifact (`sparkle-appcast`) as
1579+
# backfill sources. The GitHub-hosted stable URL
15811580
# https://github.com/OWNER/REPO/releases/latest/download/appcast-<arch>.xml
1582-
# works today as an interim SUFeedURL for the STABLE channel only (it resolves to
1581+
# works as an alternative SUFeedURL for the STABLE channel only (it resolves to
15831582
# the newest non-prerelease release); set repository variable SPARKLE_FEED_URL to
15841583
# use it. It does NOT serve the beta channel — see prerelease.yml.
15851584
sparkle-appcast:
@@ -1697,11 +1696,16 @@ jobs:
16971696
# Tell mcpproxy.app to serve the freshly uploaded feeds (they are public
16981697
# release assets by now — the site's publish-appcast workflow downloads
16991698
# them from the release, so no artifact plumbing crosses repos).
1700-
# Non-blocking: the feeds stay downloadable from the release either way,
1701-
# and the site workflow can be re-run by hand (workflow_dispatch).
1699+
# This step MUST fail loudly: on v0.60.0 an expired
1700+
# MARKETING_SITE_DISPATCH_TOKEN made this dispatch 401 under
1701+
# continue-on-error, the site kept serving the 0.59.0 feed, and Sparkle
1702+
# told users they were up to date while doctor/tray offered v0.60.0.
1703+
# Failing here blocks nothing — every release asset (feeds included) is
1704+
# uploaded by earlier steps; a red job is the recovery signal. Backfill by
1705+
# re-running this job, or by hand via the site's publish-appcast
1706+
# workflow_dispatch.
17021707
- name: Publish feeds to mcpproxy.app
17031708
if: steps.appcast.outputs.generated == 'true'
1704-
continue-on-error: true
17051709
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
17061710
with:
17071711
token: ${{ secrets.MARKETING_SITE_DISPATCH_TOKEN }}
@@ -1713,14 +1717,51 @@ jobs:
17131717
# (see the channel-policy comment above).
17141718
- name: Publish stable item to the beta feeds
17151719
if: steps.appcast.outputs.generated == 'true'
1716-
continue-on-error: true
17171720
uses: peter-evans/repository-dispatch@28959ce8df70de7be546dd1250a005dd32156697 # v4.0.1
17181721
with:
17191722
token: ${{ secrets.MARKETING_SITE_DISPATCH_TOKEN }}
17201723
repository: smart-mcp-proxy/mcpproxy.app-website
17211724
event-type: publish-appcast
17221725
client-payload: '{"version": "${{ github.ref_name }}", "channel": "beta"}'
17231726

1727+
# End-to-end freshness check: the dispatch above only queues the site's
1728+
# publish-appcast workflow — a failed site run, a queued run replaced by
1729+
# its sibling in the site's concurrency group, or a stale Cloudflare
1730+
# Pages deploy would still leave the live feed behind. Poll until the
1731+
# LIVE bytes match what this job generated (the site's own verify step
1732+
# does the same from its side, but it never runs if the dispatch is
1733+
# lost). One 15-min deadline SHARED across all feeds: dispatch → site
1734+
# workflow queue → commit → Pages deploy is ~3-5 min per channel, and a
1735+
# shared budget keeps a total site outage from holding this macOS runner
1736+
# for 15 min per file. The beta copies are byte-identical to the stable
1737+
# feeds (cp above), so this loop verifies both dispatches.
1738+
- name: Verify live feeds are fresh
1739+
if: steps.appcast.outputs.generated == 'true'
1740+
run: |
1741+
set -euo pipefail
1742+
DEADLINE=$(( $(date +%s) + 15 * 60 ))
1743+
FAILED=0
1744+
for f in appcast-out/*.xml; do
1745+
NAME=$(basename "$f")
1746+
WANT=$(shasum -a 256 "$f" | cut -d' ' -f1)
1747+
OK=""
1748+
# Check-first: every feed gets at least one probe even after an
1749+
# earlier feed has exhausted the shared deadline.
1750+
while :; do
1751+
GOT=$(curl -fsSL "https://mcpproxy.app/${NAME}" 2>/dev/null | shasum -a 256 | cut -d' ' -f1 || true)
1752+
if [ "$GOT" = "$WANT" ]; then OK=yes; break; fi
1753+
if [ "$(date +%s)" -ge "$DEADLINE" ]; then break; fi
1754+
sleep 15
1755+
done
1756+
if [ -n "$OK" ]; then
1757+
echo "✅ https://mcpproxy.app/${NAME} serves the ${GITHUB_REF_NAME} feed"
1758+
else
1759+
echo "::error::https://mcpproxy.app/${NAME} still does not serve the ${GITHUB_REF_NAME} feed after 15 minutes — Sparkle users will be offered a stale version"
1760+
FAILED=1
1761+
fi
1762+
done
1763+
exit "$FAILED"
1764+
17241765
provenance:
17251766
needs: [release]
17261767
permissions:
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package main
2+
3+
import (
4+
"testing"
5+
)
6+
7+
// prereleasePreference must apply the same build-version-authoritative rule as
8+
// the daemon's Checker.IncludePrereleases (Spec 079 FR-014 / FR-023): a stable
9+
// build never resolves against the prerelease list, whatever a stale
10+
// `channel: rc` config says, and an RC build always does.
11+
func TestPrereleasePreference_BuildIdentityAuthoritative(t *testing.T) {
12+
// Pin the env opt-in off so ambient shell exports (an RC dogfooder's
13+
// MCPPROXY_ALLOW_PRERELEASE_UPDATES=true) can't flip the negative cases.
14+
t.Setenv("MCPPROXY_ALLOW_PRERELEASE_UPDATES", "")
15+
16+
t.Run("stable build ignores stale rc config", func(t *testing.T) {
17+
if prereleasePreferenceFor("v0.60.0", true) {
18+
t.Fatal("stable build must never offer prereleases, even with channel: rc config")
19+
}
20+
})
21+
22+
t.Run("stable build ignores env opt-in", func(t *testing.T) {
23+
t.Setenv("MCPPROXY_ALLOW_PRERELEASE_UPDATES", "true")
24+
if prereleasePreferenceFor("v0.60.0", false) {
25+
t.Fatal("stable build must never offer prereleases, even with env opt-in")
26+
}
27+
})
28+
29+
t.Run("rc build always tracks prereleases", func(t *testing.T) {
30+
if !prereleasePreferenceFor("v0.61.0-rc.1", false) {
31+
t.Fatal("rc build must track the rc channel regardless of config")
32+
}
33+
})
34+
35+
t.Run("dev build honors config opt-in", func(t *testing.T) {
36+
if !prereleasePreferenceFor("development", true) {
37+
t.Fatal("unstamped build with channel: rc must opt in")
38+
}
39+
})
40+
41+
t.Run("dev build honors env opt-in", func(t *testing.T) {
42+
t.Setenv("MCPPROXY_ALLOW_PRERELEASE_UPDATES", "true")
43+
if !prereleasePreferenceFor("development", false) {
44+
t.Fatal("unstamped build with env opt-in must opt in")
45+
}
46+
})
47+
48+
t.Run("dev build defaults to stable", func(t *testing.T) {
49+
if prereleasePreferenceFor("development", false) {
50+
t.Fatal("unstamped build without any opt-in must stay on stable")
51+
}
52+
})
53+
}

‎cmd/mcpproxy/update_cmd.go‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,10 @@ Examples:
176176
func newUpdateRunner(out, errOut io.Writer, flags updateFlags) (*updateRunner, error) {
177177
version := httpapi.GetBuildVersion()
178178
channel := updatecheck.DetectChannel(version)
179+
// go-install builds carry the non-semver ldflags default; promote to the
180+
// module version exactly like the daemon's checker does, so the channel
181+
// precedence below classifies the build identically (FR-023).
182+
version = updatecheck.PromoteGoInstallVersion(version, channel)
179183

180184
execPath, err := resolvedExecutablePath()
181185
if err != nil {
@@ -191,7 +195,7 @@ func newUpdateRunner(out, errOut io.Writer, flags updateFlags) (*updateRunner, e
191195
currentVersion: version,
192196
channel: channel,
193197
execPath: execPath,
194-
includePrereleases: prereleasePreference(),
198+
includePrereleases: prereleasePreference(version),
195199
flags: flags,
196200
releases: &githubReleaseSource{client: client},
197201
httpClient: &http.Client{Timeout: downloadTimeout},
@@ -202,17 +206,21 @@ func newUpdateRunner(out, errOut io.Writer, flags updateFlags) (*updateRunner, e
202206
}
203207

204208
// prereleasePreference mirrors the checker's precedence (Spec 079 FR-014):
209+
// the released build's own identity is authoritative, then
205210
// MCPPROXY_ALLOW_PRERELEASE_UPDATES wins over update_check.channel, so
206211
// `mcpproxy update` offers exactly what the daemon's nudge offered (FR-023).
207-
func prereleasePreference() bool {
208-
if os.Getenv(updatecheck.EnvAllowPrereleaseUpdates) == "true" {
209-
return true
212+
func prereleasePreference(buildVersion string) bool {
213+
cfgPrerelease := false
214+
if cfg, err := loadCLIConfig(configFile); err == nil && cfg != nil {
215+
cfgPrerelease = cfg.UpdateCheck.IncludePrereleases()
210216
}
211-
cfg, err := loadCLIConfig(configFile)
212-
if err != nil || cfg == nil {
213-
return false
214-
}
215-
return cfg.UpdateCheck.IncludePrereleases()
217+
return prereleasePreferenceFor(buildVersion, cfgPrerelease)
218+
}
219+
220+
// prereleasePreferenceFor is the config-independent core of
221+
// prereleasePreference, split out for tests.
222+
func prereleasePreferenceFor(buildVersion string, cfgPrerelease bool) bool {
223+
return updatecheck.IncludePrereleasesForBuild(buildVersion, cfgPrerelease)
216224
}
217225

218226
// resolvedExecutablePath returns the symlink-resolved path of the running

‎internal/updatecheck/channel.go‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,18 @@ func (d *channelDetector) resolvedExecPath() string {
269269
// checks. For every other channel, or when build info is unusable, the
270270
// original version is returned unchanged.
271271
func promoteGoInstallVersion(version, channel string, readBuildInfo func() (*debug.BuildInfo, bool)) string {
272+
return promoteGoInstallVersionImpl(version, channel, readBuildInfo)
273+
}
274+
275+
// PromoteGoInstallVersion is the production-wired form of
276+
// promoteGoInstallVersion, shared with `mcpproxy update` so the CLI resolves
277+
// the same build identity (and therefore the same channel precedence) as the
278+
// daemon's checker (Spec 079 FR-023).
279+
func PromoteGoInstallVersion(version, channel string) string {
280+
return promoteGoInstallVersionImpl(version, channel, debug.ReadBuildInfo)
281+
}
282+
283+
func promoteGoInstallVersionImpl(version, channel string, readBuildInfo func() (*debug.BuildInfo, bool)) string {
272284
if channel != ChannelGoInstall {
273285
return version
274286
}

‎internal/updatecheck/checker.go‎

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -209,12 +209,22 @@ func (c *Checker) enabledLocked() bool {
209209
// MCPPROXY_ALLOW_PRERELEASE_UPDATES=true wins over the config channel
210210
// (Spec 079 FR-014 precedence: env > config); otherwise channel=rc opts in.
211211
func (c *Checker) IncludePrereleases() bool {
212-
// The running build's own version is authoritative (issue: a stable user
213-
// must never be offered an RC; an RC user may be offered stable or the next
214-
// RC). This deliberately overrides the config/env opt-in for RELEASED
215-
// builds, so a stale `channel: rc` config left over from a
216-
// previously-installed RC cannot resurrect RC offers on a stable build.
217-
switch versionChannelKind(c.version) {
212+
c.mu.RLock()
213+
cfgPrerelease := c.cfgPrerelease
214+
c.mu.RUnlock()
215+
return IncludePrereleasesForBuild(c.version, cfgPrerelease)
216+
}
217+
218+
// IncludePrereleasesForBuild applies the full channel precedence for a build
219+
// version. The running build's own version is authoritative (issue: a stable
220+
// user must never be offered an RC; an RC user may be offered stable or the
221+
// next RC). This deliberately overrides the config/env opt-in for RELEASED
222+
// builds, so a stale `channel: rc` config left over from a
223+
// previously-installed RC cannot resurrect RC offers on a stable build.
224+
// Shared by the daemon's Checker and `mcpproxy update` so both resolve the
225+
// same channel (Spec 079 FR-023).
226+
func IncludePrereleasesForBuild(buildVersion string, cfgPrerelease bool) bool {
227+
switch versionChannelKind(buildVersion) {
218228
case buildChannelStable:
219229
// A stable build never tracks prereleases, whatever the config/env say.
220230
return false
@@ -232,9 +242,7 @@ func (c *Checker) IncludePrereleases() bool {
232242
if os.Getenv(EnvAllowPrereleaseUpdates) == "true" {
233243
return true
234244
}
235-
c.mu.RLock()
236-
defer c.mu.RUnlock()
237-
return c.cfgPrerelease
245+
return cfgPrerelease
238246
}
239247
}
240248

‎internal/updatecheck/types.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ package updatecheck
44
import "time"
55

66
// VersionInfo represents the current version and update availability.
7-
// This is stored in-memory only and refreshed on startup + every 4 hours.
7+
// This is stored in-memory only and refreshed on startup + every
8+
// DefaultCheckInterval (24h; stretched by backoff after failed checks).
89
type VersionInfo struct {
910
// CurrentVersion is the version of the running MCPProxy instance.
1011
// Format: semver with "v" prefix (e.g., "v1.2.3") or "development"

0 commit comments

Comments
 (0)