Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions .github/workflows/promote-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,50 @@ jobs:
# `allow_not_next` drops the flag rather than adding a bypass: a rollback
# promotes an OLDER tag, which by definition is not what `next` serves.

# THE PROMOTE GUARD (foundations#132, #134, #159 item 4). Refuse to move
# `stable` unless the legacy bridge pin is LIVE in front of it.
#
# The guarantee this protects: every 1.0.0 and 1.0.1 install following
# `stable` reaches every later release with nothing but `wego update`, at any
# time, with no deadline and no reinstall. Those binaries trust only wego-ai's
# signing identity. The moment `stable` names a release signed under
# wego/cli's, they can no longer verify what `stable` points at — they refuse,
# fail-closed, and stay refusing. There is no later fix: a binary that cannot
# verify an update cannot be updated INTO one that can.
#
# So the pin has to already be answering before this pointer moves, and the
# only honest way to know that is to ASK api.wego.com the way an old binary
# asks it — with its user agent, for the object it actually fetches. A 1.0.x
# `wego update` sends `Bun/…` because the 1.0.x CLI never named itself; the
# pin keys on that prefix and nothing else. If the answer names the bridge
# prefix, an old binary is being served a release it can verify, and `stable`
# is free to move past it.
#
# **This refuses today, and that is correct.** The bridge does not exist until
# 3a publishes it and sets the two variables. It passes from the end of 3a on.
# There is deliberately no bypass input: a promote that needs to skip this is
# a promote that strands the 1.0.x install base, and `allow_not_next` does not
# reach it either — a rollback moves `stable` just as surely, so it needs the
# pin just as much.
#
# Production, not the promote's own store origin, on purpose: unlike the
# `--require-serving next` gate below — which must ask the store it is about
# to write — this one is about what INSTALLED BINARIES are being served, and
# `api.wego.com` is the host every one of them resolves through.
- name: Require the legacy bridge pin to be live
run: |
set -euo pipefail
loc=$(curl -sI -A 'Bun/1.3.14' \
'https://api.wego.com/install?dl=SHA256SUMS.txt&ring=stable' \
| grep -i '^location:' || true)
if printf '%s' "$loc" | grep -q '/cli/cli-v1.1.0/'; then
echo "ok: an old (Bun/) binary asking stable is served from the bridge prefix."
echo "$loc"
exit 0
fi
echo "::error::the legacy bridge pin is NOT live: a Bun/ user agent asking for stable is answered with '${loc:-no location header}', which does not name /cli/cli-v1.1.0/. Moving cli/stable now would strand every 1.0.0 and 1.0.1 install that follows it, permanently and unrecoverably. Publish the bridge and set CLI_LEGACY_BRIDGE_RING + CLI_LEGACY_BRIDGE_TAG on the production apps/api deploy first (wego/foundations#132)."
exit 1

# THE MOVE. A server-side copy of the frozen cli/<tag> blobs onto cli/stable.
# REQUIRE_PUBLISH: an absent token must FAIL here rather than exit 0 having
# promoted nothing - a "successful" promote that moved no pointer would read as
Expand Down
90 changes: 47 additions & 43 deletions .github/workflows/release-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -426,56 +426,57 @@ jobs:
# in ring-rules.ts) on the runner's own platform, which is what makes the
# predecessor capture and the self-update smoke executable here.

# SMOKE 3's predecessor, read from the IMMUTABLE `cli/<prev-tag>/` prefix.
# SMOKE 3's predecessor, read from `cli/next` — the RING THIS JOB ADVANCES —
# before the pointer moves.
#
# It used to be read from `cli/next` - the pointer THIS JOB advances a few steps
# later. That one choice cost five steps and an artifact: the read had to happen
# before the pointer moved, so a rerun could no longer see the old bytes, so the
# binary was uploaded as a run artifact, so a probe was needed to tell an
# attempt-1 miss from a real download failure, so a 404 needed a persisted
# sentinel to stay rerun-recoverable, so a separate gate had to read the
# resulting directory. Every one of those existed to work around reading a
# moving pointer.
# It was read from the immutable `cli/<prev-tag>/` prefix, which was the right
# answer while the tag namespace and the store namespace agreed. They no longer
# do. `prepare` derives `prev_tag` from this repository's git tags, and the
# release that `cli/next` currently points at was published by wego-ai under a
# DIFFERENT tag spelling: the 1.1.0 bytes live at `cli/cli-v1.1.0/`, not at
# `cli/v1.1.0/`. So the 1.2.0 run would compose a prefix that has never
# existed, take the 404 skip path below, and silently skip the only live test
# of hop 2 (foundations#133) — on the one release where hop 2 is the thing
# being proven. A skip is not a failure, so nothing would have flagged it.
#
# An immutable prefix does not move: any rerun reads the same bytes, in any
# order, with nothing persisted. `prepare` already knows the predecessor tag, and
# "no previous release" is now knowable UP FRONT instead of discovered as a 404.
# The ring does not have that problem: `cli/next` names whatever was last
# published to it, under whichever repository's tag spelling, which is also
# exactly what a consumer's `wego update` is following. That was the original
# fidelity argument for reading the ring, and it now costs nothing to honour —
# the five steps and the run artifact that reading a moving pointer used to
# require are not coming back, because this reads it ONCE, before the advance,
# in the same job that does the advancing.
#
# ONE FIDELITY TRADE, STATED. `cli/next` served what consumers actually run; the
# previous TAG may be a version no ring ever pointed at, because a release can
# fail after publishing its immutable objects but before advancing the pointer -
# v0.7.0 and v0.7.1 are both exactly that. This is acceptable because
# SMOKE 3 tests the PREDECESSOR's update code path, not which bytes a ring
# served: an unpublished-but-built binary exercises that path identically, and it
# was built by this same pipeline. If the smoke ever needs "what consumers really
# run", it needs the pointer read back, and the five steps come back with it.
# Rerun safety, which the immutable prefix used to provide: a rerun that gets
# this far has already advanced the pointer, so it captures the release it is
# re-releasing and the smoke becomes a same-version self-update. That is a
# weaker test, not a wrong one, and it is confined to reruns of an already
# published release.
#
# `VERSION` is read alongside the bytes so the summary can NAME the release
# being updated from. A skipped hop-2 test and a passing one must not look
# alike in the log.
- name: Capture the predecessor binary (for the update smoke)
id: prev_channel
if: steps.publish.outputs.store_origin != '' && needs.prepare.outputs.prev_tag != ''
if: steps.publish.outputs.store_origin != ''
env:
BASE: ${{ steps.publish.outputs.store_origin }}/cli/${{ needs.prepare.outputs.prev_tag }}
BASE: ${{ steps.publish.outputs.store_origin }}/cli/next
ASSET: wego-linux-x64
run: |
set -eu
dir="${RUNNER_TEMP}/prev-channel"
mkdir -p "$dir"
# Both the binary and its manifest: the fail-closed verify-then-execute in
# the next step checks one against the other before running anything.
# The binary, its manifest and the ring's version: the fail-closed
# verify-then-execute in the next step checks the first against the second
# before running anything, and the third names what is being updated FROM.
#
# A 404 is SKIP, not failure - and this is the one place that distinction
# decides whether a release can ship. A tag exists from the moment the
# release PR merges; its `cli/<tag>/` objects exist only if that release's
# job got as far as `--freeze`. So a release that failed EARLIER than the
# publish (a build break, a runner outage) leaves a tag in git with no
# prefix behind it - and that tag is the next release's predecessor. Under
# `curl -f` this step would then abort AFTER this job published its own
# immutable objects and BEFORE it advanced the pointer, identically on
# every re-run, and the only way out would be deleting a git tag. A missing
# predecessor is not evidence that self-update is broken, so it skips
# SMOKE 3 instead. Any OTHER status stays fatal: a 403 or a 500 says the
# store is misbehaving, which is not something to shrug at.
# A 404 is SKIP, not failure, and now means exactly one thing: the ring is
# EMPTY — no release has ever been published to `cli/next`. That is the
# first-release case, where there is by definition nothing to update from.
# Any OTHER status stays fatal: a 403 or a 500 says the store is
# misbehaving, which is not something to shrug at.
usable=1
for obj in "$ASSET" SHA256SUMS.txt; do
for obj in "$ASSET" SHA256SUMS.txt VERSION; do
code=$(curl -sSL --connect-timeout 15 --max-time 600 \
-w '%{http_code}' -o "$dir/$obj" "$BASE/$obj") \
|| { echo "::error::transport failure fetching $BASE/$obj (curl exit $?)." >&2; exit 1; }
Expand All @@ -489,9 +490,13 @@ jobs:
# Drop the partial directory so nothing downstream can mistake a 404
# body for a captured binary.
rm -rf "$dir"
echo "::notice::predecessor ${BASE##*/} has no published objects (404) - SMOKE 3 skipped. This release is unaffected."
echo "::notice::cli/next is empty (404) - SMOKE 3 skipped. This release is unaffected."
echo "SMOKE 3 skipped: cli/next is empty, nothing to update from." >> "$GITHUB_STEP_SUMMARY"
else
echo "Captured predecessor $BASE (verified before execution below)."
prev_version=$(tr -d '\r\n' < "$dir/VERSION")
echo "predecessor $prev_version from cli/next" >> "$GITHUB_STEP_SUMMARY"
echo "predecessor $prev_version from cli/next (verified before execution below)."
echo "prev_version=$prev_version" >> "$GITHUB_OUTPUT"
fi
echo "usable=$usable" >> "$GITHUB_OUTPUT"

Expand Down Expand Up @@ -533,10 +538,9 @@ jobs:
# downloads the binary and its SHA256SUMS.txt, and this step checks one against
# the other before anything is chmod'd or run. Separate from the capture so the
# verification is a step in its own right rather than a branch inside a download.
# Gated on `usable` as well as on the tag, because a predecessor that 404'd has
# no binary to verify.
# Gated on `usable`, because an empty `cli/next` leaves no binary to verify.
- name: Verify predecessor checksum
if: steps.publish.outputs.store_origin != '' && needs.prepare.outputs.prev_tag != '' && steps.prev_channel.outputs.usable == '1'
if: steps.publish.outputs.store_origin != '' && steps.prev_channel.outputs.usable == '1'
env:
DIR: ${{ runner.temp }}/prev-channel
ASSET: wego-linux-x64
Expand Down Expand Up @@ -662,7 +666,7 @@ jobs:
echo "resolver listening on 127.0.0.1:$PORT and redirecting into $STORE_ORIGIN"

- name: Smoke test real self-update (cli/next)
if: steps.publish.outputs.store_origin != '' && needs.prepare.outputs.prev_tag != '' && steps.prev_channel.outputs.usable == '1'
if: steps.publish.outputs.store_origin != '' && steps.prev_channel.outputs.usable == '1'
env:
OLD_BINARY: ${{ runner.temp }}/prev-channel/wego-linux-x64
VERSION: ${{ needs.prepare.outputs.version }}
Expand Down
120 changes: 119 additions & 1 deletion docs/runbook-cutover.md
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,9 @@ preview out of existence and #129's manual install ran on loopback.

**Keep**, deliberately:

- `cli/cli-v1.1.0/` in the production store — immutable, the last wego-ai build.
- `cli/cli-v1.1.0/` **and** `cli-sig/cli-v1.1.0/` in the production store — the
legacy bridge. **Never deleted by any lane, issue or cleanup.** See the
never-delete rule at the end of this file; it has no expiry date.
- `skill/next` and `skill/stable` — frozen, read by pre-relay binaries.
- wego-ai's `promote-cli.yml`, `publish-skill.yml`, repo-scope `BLOB_READ_WRITE_TOKEN`
and skills App secrets — the way back, until the 3c tail.
Expand Down Expand Up @@ -544,3 +546,119 @@ gh api repos/wego/wego-ai/compare/0e9f6bfe60864e6226decbebdd3e5b7535c7080e...mai
- wego-ai has no `release-cli.yml`, `edge-cli.yml` or `ci-cli.yml`; its `main` is
green and its open PRs are mergeable.
- The rehearsal blob store and the Phase 1 resolver are gone.

---

## 3c — prerequisites, and the two-hop test

3b moves `next` and `edge`. **`stable` moves in 3c**, and that is the move the
1.0.x install base cannot survive unaided. Everything in this section is the
preflight for that sitting (wego/foundations#134). Built in 3p
(wego/foundations#159); read here.

### Why `stable` is different

Every 1.0.0 and 1.0.1 install following `stable` must reach every later release
with nothing but `wego update` — at any time, with no deadline and no reinstall.
Those binaries trust only wego-ai's signing identity. The moment `stable` names a
release signed under wego/cli's, they cannot verify what `stable` points at: they
refuse, fail-closed, and keep refusing. **There is no later fix.** A binary that
cannot verify an update cannot be updated into one that can.

The mechanism is the **legacy bridge pin**: a frozen copy of 1.1.0 — the last
release those binaries can verify — at an immutable tag prefix, served to old
binaries only, while everyone else sees the live ring. Old binaries reach 1.1.0 by
`wego update`; the 1.1.0 they land on names itself `Wego-CLI/1.1.0`, is therefore
no longer pinned, and reaches 1.2.0 and everything after by `wego update` again.
Two hops, both automatic. That is what the test below proves.

### Prerequisite 1 — the pin is live (four curls)

All four must answer as shown before `stable` moves. The first is the pin; the
other three are its scope, and a pin that caught them would break the installer
script or freeze a ring that exists to move.

```bash
# 1. PINNED — an old binary asking stable is answered from the bridge
curl -sI -A 'Bun/1.3.14' 'https://api.wego.com/install?dl=SHA256SUMS.txt&ring=stable' | grep -i '^location:'
# must name /cli/cli-v1.1.0/

# 2. NOT PINNED — a binary that names itself
curl -sI -A 'Wego-CLI/1.1.0' 'https://api.wego.com/install?dl=SHA256SUMS.txt&ring=stable' | grep -i '^location:'
# must name /cli/stable/

# 3. NOT PINNED — another ring
curl -sI -A 'Bun/1.3.14' 'https://api.wego.com/install?dl=SHA256SUMS.txt&ring=next' | grep -i '^location:'
# must name /cli/next/

# 4. NOT PINNED — the installer script's own read (no agent)
curl -sI 'https://api.wego.com/install?dl=SHA256SUMS.txt&ring=stable' | grep -i '^location:'
# must name /cli/stable/
```

Curl 1 failing means the pin is not on, or the bridge prefix is empty. **Do not
continue**; setting the variables with no bridge behind them 404s every `stable`
1.0.x update check, which is the failure this whole apparatus exists to prevent.
The switch-on order and the two variables are in wego-ai's
`apps/api/docs/runtime-configuration.md`.

### Prerequisite 2 — the promote guard is on `main`

`promote-cli.yml` refuses to move `stable` unless curl 1 above passes. It asks
production the same question, with the same user agent, in the step immediately
before the pointer move, and it has no bypass input — `allow_not_next` does not
reach it either, because a rollback moves `stable` just as surely.

```bash
gh api repos/wego/cli/contents/.github/workflows/promote-cli.yml \
-H 'Accept: application/vnd.github.raw' | grep -q 'cli/cli-v1.1.0/' && echo "guard present"
```

It refuses today, correctly. It passes from the end of 3a on.

### The two-hop machine test

The one test that exercises the guarantee end to end, on a real machine, rather
than asserting it. Run it on the **kept 1.0.1 install** — the un-upgraded machine
following `stable`, named on wego/foundations#134 and deliberately not updated
since 3p. There is exactly one of these; do not use it for anything else first.

```bash
wego version # 1.0.1 — the starting point, and the reason this machine was kept

# HOP 1 — the pin hands an old binary the last release it can verify
wego update -y
wego version # must print 1.1.0

# HOP 2 — the binary now names itself, is no longer pinned, and follows the live ring
wego update -y
wego version # must print 1.2.0 (or whatever stable serves by then)
```

**Both hops must need no flag, no reinstall and no human step beyond `wego
update`.** That is the whole claim. If hop 1 prints "Already up to date", the pin
is catching a binary that names itself — check curl 2. If hop 2 prints "Already up
to date", the 1.1.0 it landed on does NOT carry the `Wego-CLI/` header
(wego-ai#1915) and is still being pinned to the bridge: that binary is stuck, and
`stable` must not move until a 1.1.0 that sends the header is what the bridge
serves.

### The never-delete rule

> **`cli/cli-v1.1.0/` and `cli-sig/cli-v1.1.0/` in the production store are never
> deleted — by any lane, any issue, any teardown, any cleanup, at any time.**

They are the bridge. Deleting either one strands every 1.0.0 and 1.0.1 install
that has not yet taken hop 1, permanently and unrecoverably — and those installs
are un-countable and un-contactable, so there is no point at which "everyone has
upgraded" becomes checkable. **The guarantee has no deadline, so the bridge has no
end date.**

This rule outranks every teardown list in this file and in wego/foundations#133,
#134 and their successors. A cleanup that proposes to reclaim the prefix is
wrong, not merely early.

`cli-sig/` is named explicitly because it is the easier one to miss: it is a
separate prefix from the downloads it vouches for, and a sweep written against
`cli/` alone would take the record while leaving the bytes — which fails the
update fail-closed, with no clue as to why.