carlos / platform Public

system update: the request names the tag the operator confirmed

Fix round 1 (Astra P2-7). Without --version the CLI resolved latest.txt
to show the tag in its prompt, but left the version out of the request,
and the console resolved the feed again: the CLI could confirm v3 while
the console promoted v2, which the resolved-latest floor accepts.

The request now always names the confirmed tag; a resolved one rides
with "latest": true. The console promotes exactly that tag and, for
"latest", still runs the resolved-latest floor (resolvedSystemLatestAllowed)
on it, as for a tag it resolves itself. A typed --version is unchanged.
A console older than the field refuses the body (the door is strict);
--version works against it. Failing when the CLI cannot reach the feed
stays, per the ruling: confirming a tag needs the tag.

Tests: TestSystemUpdateSendsTheConfirmedLatest (failed before: no
version in the request) and
TestConfirmedLatestPromotesTheConfirmedTagAndKeepsTheFloor (failed
before: the door refused the field).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
claude agent, operated by paul@keymail.dev pushed by paul@keymail.dev f35f25f62dab1b5f6fadfc675bf37ae77ae2d3d2 parent 4272d2f
4 files changed, +90 −16
  • internal/console/apisystemupdate.go +8 −1
  • internal/console/apisystemupdate_latest_test.go +36 −0
  • system.go +19 −15
  • system_fleetfloor_test.go +27 −0
diff --git a/internal/console/apisystemupdate.go b/internal/console/apisystemupdate.go
index 9710d6efd..7c844960b 100644
--- a/internal/console/apisystemupdate.go
+++ b/internal/console/apisystemupdate.go
@@ -425,6 +425,13 @@ type systemUpdateRequest struct {
// --allow-below-fleet-forward-floor`: the fleet forward floor's override
// (fleetfloor.go), part of the request's identity too.
AllowBelowFleetForwardFloor bool `json:"allow_below_fleet_forward_floor"`
+ // Latest says Version is the latest public release the CLI resolved
+ // from latest.txt and the operator confirmed, not a release they typed
+ // (hunt H6-M3, fix round 1). The job promotes exactly Version, never a
+ // second resolution of the feed, and holds it to the resolved-latest
+ // floor (resolvedSystemLatestAllowed) as it does a tag it resolves
+ // itself. Without Version it means nothing.
+ Latest bool `json:"latest"`
}
// handleAPISystemUpdate starts the promote and answers with a job id. The
@@ -603,7 +610,7 @@ func (s *Server) runSystemUpdate(ctx context.Context, id string, job *systemJob,
if !publicrelease.TagRe.MatchString(tag) {
return fmt.Errorf("%q is not a release tag; use --file for a local build", tag)
}
- if in.Version == "" {
+ if in.Version == "" || in.Latest {
if err := s.resolvedSystemLatestAllowed(ctx, in.Component, in.Channel, tag); err != nil {
return err
}
diff --git a/internal/console/apisystemupdate_latest_test.go b/internal/console/apisystemupdate_latest_test.go
index 0cda0fca5..3e5895581 100644
--- a/internal/console/apisystemupdate_latest_test.go
+++ b/internal/console/apisystemupdate_latest_test.go
@@ -42,3 +42,39 @@ func TestResolvedLatestFloorLeavesTypedVersionsAlone(t *testing.T) {
t.Fatalf("refusal = %q", e)
}
}
+
+// The CLI resolves latest.txt itself and the operator confirms that tag
+// (hunt H6-M3, Astra P2-7): the request carries the confirmed tag with
+// "latest": true. The console promotes exactly that tag, never a second
+// resolution of the feed, and still holds it to the resolved-latest floor:
+// a confirmed latest below the release the channel serves is refused as a
+// typed --version would not be.
+func TestConfirmedLatestPromotesTheConfirmedTagAndKeepsTheFloor(t *testing.T) {
+ fx := newConsoleFixture(t)
+ feed := newHuntFeed(t, fx)
+ feed.publish("v0.30.0", map[string][]byte{"carlos-linux-arm64": []byte("ELF v0.30.0 arm64")})
+ feed.publish("v0.30.1", map[string][]byte{"carlos-linux-arm64": []byte("ELF v0.30.1 arm64")})
+ feed.publish("v0.30.2", map[string][]byte{"carlos-linux-arm64": []byte("ELF v0.30.2 arm64")})
+ seedBox(t, fx, "ie", "linux-arm64", "stable", "v0.30.0")
+ owner := cliToken(t, fx, "paul@keymail.dev", "code-hunt-m3c")
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "stable", "version": "v0.30.0", "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("setup: %v", job)
+ }
+ // The operator confirmed v0.30.1; the feed has moved on since.
+ feed.setLatest("v0.30.2")
+ if job := huntUpdate(t, fx, owner, map[string]any{"channel": "stable", "version": "v0.30.1", "latest": true, "spread": "0s"}); job["error"] != "" {
+ t.Fatalf("the confirmed latest: %v", job)
+ }
+ p, _, err := release.GetSystemPointer(context.Background(), fx.rel, fx.pub, "router", "stable")
+ if err != nil || p.Current.Version != "v0.30.1" {
+ t.Fatalf("pointer = %+v, %v; want the confirmed v0.30.1", p, err)
+ }
+ // A confirmed latest below the channel's release is refused.
+ job := huntUpdate(t, fx, owner, map[string]any{"channel": "stable", "version": "v0.30.0", "latest": true, "spread": "0s"})
+ if e, _ := job["error"].(string); !strings.Contains(e, "v0.30.0, below the v0.30.1") {
+ t.Fatalf("a confirmed latest below the channel = %q, want the resolved-latest refusal", e)
+ }
+ if p, _, _ := release.GetSystemPointer(context.Background(), fx.rel, fx.pub, "router", "stable"); p.Current.Version != "v0.30.1" {
+ t.Fatalf("the refused latest moved the pointer to %s", p.Current.Version)
+ }
+}
diff --git a/system.go b/system.go
index 0ece70be6..75e7f7b56 100644
--- a/system.go
+++ b/system.go
@@ -393,11 +393,10 @@ func runSystemUpdate(args []string) {
}
}
// Without --version the tag comes from the feed's latest.txt, resolved
- // HERE too so the prompt names it: an unsigned pointer the operator
- // never sees is one they cannot judge (hunt H6-M3). The console still
- // resolves it itself, and refuses one below the channel's current
- // release, so a feed that changes its mind in between cannot move the
- // channel back.
+ // HERE so the prompt names it: an unsigned pointer the operator never
+ // sees is one they cannot judge (hunt H6-M3). The request carries the
+ // confirmed tag, and the console refuses it if it is below the channel's
+ // current release.
target, err := systemUpdateTarget(*version, func() (string, error) { return fetchLatest(10 * time.Second) })
if err != nil {
log.Fatalf("carlos system update: %v", err)
@@ -434,8 +433,15 @@ func runSystemUpdate(args []string) {
if *allowBelowFleetForwardFloor {
in["allow_below_fleet_forward_floor"] = true
}
- if target.typed {
- in["version"] = target.tag
+ // The tag the operator just confirmed is the tag promoted: a resolved
+ // one rides with "latest": true, so the console promotes exactly it
+ // (never a second resolution of the feed) and still holds it to the
+ // resolved-latest floor (hunt H6-M3, fix round 1). A console older
+ // than the field refuses the request as a body it does not understand;
+ // --version works there.
+ in["version"] = target.tag
+ if !target.typed {
+ in["latest"] = true
}
if *file != "" {
handle, err := sess.uploadSystemBinary(ctx, *file, *version, *platform)
@@ -474,14 +480,12 @@ func runSystemUpdate(args []string) {
// systemUpdateTarget is what `carlos system update` is about to promote:
// the tag, how the prompt names it, and whether the operator typed it. A
-// typed --version is itself, and is what the request names. An empty one is
-// resolved through resolve (the feed's latest.txt) so the prompt can say
-// "v0.30.1 (the latest public release)" instead of a phrase the operator
-// cannot check; the request still leaves the version out, since the console
-// resolves and judges the latest release itself, and an older console does
-// not know a field that says "resolved". A feed that cannot be reached is an
-// error, not a fallback to a blind promote: the operator can name the
-// release with --version.
+// typed --version is itself. An empty one is resolved through resolve (the
+// feed's latest.txt) so the prompt can say "v0.30.1 (the latest public
+// release)" instead of a phrase the operator cannot check; the request
+// names that tag with "latest": true, so what is promoted is what was
+// confirmed. A feed that cannot be reached is an error, not a fallback to a
+// blind promote: the operator can name the release with --version.
type systemTarget struct {
tag string
what string
diff --git a/system_fleetfloor_test.go b/system_fleetfloor_test.go
index a3c22ca41..b83a443f1 100644
--- a/system_fleetfloor_test.go
+++ b/system_fleetfloor_test.go
@@ -2,6 +2,7 @@ package main
import (
"encoding/json"
+ "io"
"net/http"
"net/http/httptest"
"path/filepath"
@@ -83,3 +84,29 @@ func TestSystemUpdateSendsTheFleetFloorOverride(t *testing.T) {
}
}
}
+
+// Without --version the CLI resolves latest.txt, the operator confirms that
+// tag, and the request names it with "latest": true, so the console
+// promotes exactly the confirmed release and still judges it as a resolved
+// latest (hunt H6-M3, Astra P2-7). A typed --version sends no "latest".
+func TestSystemUpdateSendsTheConfirmedLatest(t *testing.T) {
+ bodies := systemFloorCLIFixture(t)
+ captureStdout(t)
+ feed := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { io.WriteString(w, "v0.31.0\n") }))
+ t.Cleanup(feed.Close)
+ old := updateLatestURL
+ updateLatestURL = feed.URL
+ t.Cleanup(func() { updateLatestURL = old })
+ runSystemUpdate([]string{"--channel", "canary", "--yes"})
+ runSystemUpdate([]string{"--channel", "canary", "--version", "v0.30.0", "--yes"})
+ got := bodies["update"]
+ if len(got) != 2 {
+ t.Fatalf("%d requests, want 2", len(got))
+ }
+ if got[0]["version"] != "v0.31.0" || got[0]["latest"] != true {
+ t.Errorf("resolved latest sent %v, want version v0.31.0 and latest true", got[0])
+ }
+ if _, ok := got[1]["latest"]; ok || got[1]["version"] != "v0.30.0" {
+ t.Errorf("typed --version sent %v, want version v0.30.0 and no latest", got[1])
+ }
+}