Skip to content

fix(selfupdate): save the update channel on first boot - #1899

Merged
frahlg merged 1 commit into
masterfrom
g1-fix-store-update-channel
Oct 27, 2026
Merged

frahlg merged 1 commit into
masterfrom
g1-fix-store-update-channel

Conversation

@frahlg

@frahlg frahlg commented Oct 27, 2026

Copy link
Copy Markdown
Member

Item G1-fix of the stable plan.

Problem

Core picks the update channel from update.channel in state.db. Only SetChannel and the old edge migration write that key. A box installed with install.sh --tag v0.X.Y-beta.N never stores one, so Core infers the channel from the running version (selfupdate.go:228, inferChannel at :874).

The beta channel offers promoted stables on purpose. So:

  1. A box runs v0.158.0-beta.3 with no stored channel. It infers beta and is offered v0.158.0.
  2. It installs v0.158.0 and restarts. inferChannel("v0.158.0") returns stable.
  3. v0.159.0-beta.1 publishes. The box reports update_available=false and never sees another beta.

Every validation site installed by tag would leave beta at the first stable promotion. The plan's gate G7 needs this fix in a beta that those sites run first, so each saves beta while it still runs a beta build.

Change

In New, when no channel is stored and the running version is a beta or stable tag, save the inferred channel. Dev builds (Version = "dev") save nothing. SetChannel, the edge migration and a stored channel all behave as before.

The plan also says to store the channel when an update is accepted. I left that out: an update runs on a release build, which has already saved its channel at boot, so a second write would change nothing.

Tests

  • TestNew_BetaBoxStaysOnBetaAfterStablePromotion: the audit's repro (caa-69), renamed. It fails on master with channel flipped to "stable" only because the version string changed and passes here.
  • TestNew_DevBuildSavesNoChannel: new.
  • cd go && go test -race -count=1 ./internal/selfupdate/... ./internal/api/... ./internal/ftwcli/...: ok.
  • go test -race -count=1 ./cmd/ftw/ -run 'Native|Fleet|Update|Version': ok.
  • go vet ./... and go build ./...: clean.

Risk

Low. It touches only the selfupdate KV, not control or dispatch. One change in behaviour: a box that stores stable and is later pinned to a beta tag (for example to test a hotfix) stays on stable afterwards. Today it would flip to beta. The owner can still change the channel with ftw update --channel beta.

🤖 Generated with Claude Code

A box installed from a beta tag stored no channel, so Core inferred it
from the running version. After the box installed the promoted stable,
the version had no beta suffix and the box moved to the stable channel
without being asked. Save the inferred channel the first time a release
build boots with none stored. Dev builds save nothing; SetChannel and
the edge migration are unchanged.

Item G1-fix of the stable plan.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T13:37:57.755391Z 4743c1a PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@frahlg
frahlg merged commit 4e22b10 into master Oct 27, 2026
22 checks passed
@frahlg
frahlg deleted the g1-fix-store-update-channel branch November 11, 2026 09:22
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