Repository navigation
fix(update): classify verification failures, and drop the notice cache after a swap - #33
Merged
Merged
Conversation
…e after a swap Three defects, one root: `update` treated every verification failure as the same thing, when they need three different answers. 1. A MID-PROMOTE WINDOW REPORTED ITSELF AS PERMANENT. `upload-release-blob.ts` copies the signed record and the manifest as two adjacent writes, so a reader landing between them sees one new and one old, and a cache can straddle the pair for its whole 60s TTL. The publisher's own comment calls the cost of that window "a moment of 'try again'". `update` returned EXIT.PERMANENT for it, which tells every wrapper, retry loop and CI job to stop retrying a condition that clears in seconds. EXIT.RETRYABLE has existed in the taxonomy all along and is what `rate_limited` already uses; this is the same shape of condition. A lie told to a machine is worse than a confusing sentence told to a person, because the person can wait and try again. 2. THE REINSTALL HINT WENT OUT ON FOUR CLASSES THAT REINSTALLING DOES NOT FIX. Added in 1.2.3 for the #29 case, where the ring serves a record this binary's trust set can never accept and only a different build can take it. It landed on every non-network refusal, including the promote window above - so the advice most likely to be seen during a routine promote was "reinstall", for a condition that resolves itself. The test I shipped with it used a PAYLOAD mismatch, which is the promote window, not an identity rejection. It asserted the right string against the wrong scenario and so could not catch this. `verifySignedManifest` now returns a `kind` alongside the reason, in the three classes a consumer acts on differently: identity genuine record, signer this binary does not accept. Permanent, and the ONLY class reinstalling fixes. inconsistent record and manifest disagree, or the record could not be read. The promote window. Self-resolving -> RETRYABLE. invalid not a Fulcio record at all (no pinned root, chain, time). Permanent, and reinstalling changes nothing, so it gets the reason and no advice rather than advice that would not work. When the two are indistinguishable, `inconsistent` wins: the install is refused in every class, so over-classifying as self-resolving costs a wasted retry while over-classifying as permanent costs recovery. 3. `.update-check` SURVIVED AN UPDATE, AND 1.2.3 MADE THAT VISIBLE. The file records the version the channel last advertised; the throttle governs the network READ, not the message, so inside the window the notice reports from it without re-fetching. Nothing ever invalidated it after a swap. Invisible while the notice only fired forward - the stale value equalled what we had just become, and equal is silent. 1.2.3 made the notice fire on any difference, so a cached value that has fallen BEHIND now speaks, in the present tense, and is wrong. Reported from the field within minutes: Your wego channel now serves 1.1.0 (you have 1.2.3) read from a cache written while `cli/stable` still served 1.1.0, hours earlier. DELETED rather than rewritten, because `update` compares checksums and never learns the version string the ring advertises: it knows the file is wrong, not what is right. Best-effort, after the swap is durable - a cache file must never turn a completed update into a failed one. Verified. Five tests fail against the shipped 1.2.3 behaviour and pass here: the promote window's exit code, the cache deletion, and the three classifications. Two more are guards rather than evidence, and say so - the identity case must NOT carry the mid-update wording, and a no-op update must NOT delete the cache. `bun test` 1481 pass / 1 fail (the known root-permissions `skill.test.ts` case, which fails on a clean tree too); typecheck clean; lint back at the 8-warning / 1-info baseline (a pristine main measures the same). ```release-note `wego update` now tells a mid-promote release channel apart from a genuine dead end: it reports the first as retryable and only suggests reinstalling for the one case reinstalling fixes, and it no longer reports a stale version after updating. ``` Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
sunny-wego
requested review from
chuyeowego and
yeouchien-wego
as code owners
September 14, 2026 13:50
sunny-wego
pushed a commit
that referenced
this pull request
Sep 14, 2026
`.update-check` did two jobs and only one was load-bearing:
mtime when we last asked -> throttles the network read. The real point.
content what the channel said -> lets the notice repeat on every command
inside the window.
Everything that has gone wrong in this area today was the second job.
A stored answer is HALF of a comparison. The other half - the running version -
changes on every update and every reinstall, and this file can observe neither.
Defending that position cost three defects in one afternoon: the reinstall-hint
misfire, the delete-on-swap that only helps when the PREVIOUS binary already had
it (#33), and the two-line `writtenBy` stamp meant to cover what deletion
structurally cannot (#35, now closed). Each was a fix for the one before it.
So the cache goes. The file is a timestamp; its content is never written and
never read. Nothing is stored, so nothing can go stale, and the bug class is
deleted rather than guarded.
WHAT CHANGES FOR A USER. The notice fires ONCE per window - on the command that
crosses it - instead of on every command inside it. That persistence was
deliberate ("a stale install keeps being told, for free"), and "for free" was the
false economy: free in network terms, expensive in correctness terms. Being told
once a day is a reminder; being told fifty times a day is noise. The narrow loss
is a message missed because its one invocation had stderr discarded.
REMOVED: `writeLatest` and its atomic write-then-rename, `UpdateCheckState.latest`,
the `known` plumbing, `update.ts`'s delete-on-swap and its `updateCheckPath` dep,
and `readChannelVersion`'s three-way return - `""` on a 404 versus `null` on
everything else existed only to decide what could overwrite storage, so a
distinction that no longer changes behaviour is gone too.
`cached` is renamed `throttled`, because nothing is cached and a reader should
not have to discover that.
TESTS: about ten disappear because the behaviour they pinned does not exist -
round-tripping the answer, clearing it on a 404, keeping it on a 5xx, not
corrupting it with a garbage body, not truncating it on claim, still nagging when
the write fails. Four of those collapse into one case asserting the single rule
that replaced them: every way of not knowing is silence. One is added, pinning
the file's emptiness as the design rather than an oversight, so reintroducing a
write means deleting a test that says why not to.
Net 299 deletions against 108 insertions.
VERIFIED ON A REAL BINARY, not only in units - a 1.2.5 build against a loopback
channel serving 1.9.9:
run 1 A new wego is available: 1.2.5 -> 1.9.9. Run `wego update -y`.
run 2 (silent)
run 3 (silent)
requests made: 1 .update-check: 0 bytes
`bun test` 1472 pass / 1 fail (the known root-permissions `skill.test.ts` case,
which fails on a clean tree too); typecheck clean; lint at 7 warnings / 1 info,
one BELOW the 8-warning baseline on main.
```release-note
`wego` now mentions a new release once a day rather than on every command, and no
longer reports a version it read before the binary changed underneath it.
```
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Candidate for v1.2.4. Three defects with one root:
updatetreated every verification failure as the same thing, when they need three different answers. Two of the three were introduced by me in 1.2.3.1. A mid-promote window reported itself as permanent
upload-release-blob.tscopies the signed record and the manifest as two adjacent writes, so a reader landing between them sees one new and one old — and a cache can straddle the pair for its whole 60s TTL. The publisher's own comment names the cost:updatereturnedEXIT.PERMANENTfor it. That tells every wrapper, retry loop and CI job to stop retrying a condition that clears in seconds.EXIT.RETRYABLEhas been in the taxonomy all along and is whatrate_limitedalready uses.A lie told to a machine is worse than a confusing sentence told to a person: the person can wait and try again.
This one predates today and is the most consequential of the three.
2. The reinstall hint went out on four classes that reinstalling does not fix
Added in 1.2.3 for the #29 case, where the ring serves a record this binary's trust set can never accept and only a different build can take it. It landed on every non-network refusal — including the promote window above, so the advice most likely to be seen during a routine promote was "reinstall", for a condition that resolves itself.
The test I shipped with it used a payload mismatch, which is the promote window, not an identity rejection. It asserted the right string against the wrong scenario, so it could not catch this. That test is rewritten here against a record re-issued to an untrusted leaf, which is the real case.
The classification
verifySignedManifestnow returns akindalongside the reason:identityPERMANENTinconsistentRETRYABLEinvalidPERMANENTWhen two are indistinguishable,
inconsistentwins. The install is refused in every class, so over-classifying as self-resolving costs a wasted retry, while over-classifying as permanent costs recovery. That asymmetry is why an unreadable bundle is filed asinconsistentrather thaninvalid.3.
.update-checksurvived an update, and 1.2.3 made that visibleThe file records the version the channel last advertised, and the throttle governs the network read, not the message — so inside the window the notice reports from it without re-fetching. Nothing ever invalidated it after a swap.
Invisible while the notice only fired forward: the stale value equalled what you had just become, and equal is silent.
fae4882made the notice fire on any difference, so a cached value that has fallen behind now speaks, in the present tense, and is wrong. Reported from the field within minutes of 1.2.3:read from a cache written hours earlier, while
cli/stablestill served 1.1.0 after the morning rollback.Deleted rather than rewritten, because
updatecompares checksums and never learns the version string the ring advertises — it knows the file is wrong, not what is right. Best-effort and after the swap is durable: a cache file must never turn a completed update into a failed one.Tests
Five fail against shipped 1.2.3 and pass here:
Two are guards, not evidence, and are labelled as such in the source: the identity case must not carry the mid-update wording, and a no-op update must not delete the cache. Both pass either way; they exist to stop a later change collapsing the distinction.
bun testskill.test.tscase, which fails on a clean tree too)bun run typecheckbun run lintmain, which reports the sameScope note
apps/apiin wego-ai has its own copy ofrelease-signingand is untouched. Its?sums=route reads onlyok/reason, so the added field is inert there even after the eventual sync.Refs #29, #31.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
Generated by Claude Code