Skip to content

fix(update): classify verification failures, and drop the notice cache after a swap - #33

Merged
sunny-wego merged 1 commit into
mainfrom
claude/foundations-issues-audit-7ug0hz
Sep 14, 2026
Merged

sunny-wego merged 1 commit into
mainfrom
claude/foundations-issues-audit-7ug0hz

Conversation

@sunny-wego

Copy link
Copy Markdown
Collaborator

Candidate for v1.2.4. Three defects with one root: update treated 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.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 names the cost:

"both fail closed, so the cost is a moment of 'try again', never an unverified install."

update returned EXIT.PERMANENT for it. That tells every wrapper, retry loop and CI job to stop retrying a condition that clears in seconds. EXIT.RETRYABLE has been in the taxonomy all along and is what rate_limited already 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

verifySignedManifest now returns a kind alongside the reason:

kind meaning exit advice
identity genuine record, signer this binary does not accept PERMANENT reinstall — the only class it fixes
inconsistent record and manifest disagree, or the record could not be read RETRYABLE channel may be mid-update, try shortly
invalid not a Fulcio record at all (no pinned root, chain, time) PERMANENT none — reinstalling changes nothing

When 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. That asymmetry is why an unreadable bundle is filed as inconsistent rather than invalid.

3. .update-check survived an update, and 1.2.3 made that visible

The 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. fae4882 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 of 1.2.3:

Your wego channel now serves 1.1.0 (you have 1.2.3)

read from a cache written hours earlier, while cli/stable still served 1.1.0 after the morning rollback.

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 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:

(fail) update > refuses a record that does not vouch for the manifest served with it
(fail) update > drops the new-version cache after replacing the binary
(fail) the class a refusal is filed under > files a record over OTHER bytes as inconsistent - the promote window
(fail) the class a refusal is filed under > files an unreadable record as inconsistent, not invalid
(fail) the class a refusal is filed under > files a wrong signing identity as identity - the only reinstallable class

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.

Check Result
bun test 1481 pass, 1 fail (the known root-permissions skill.test.ts case, which fails on a clean tree too)
bun run typecheck clean
bun run lint 8 warnings / 1 info — measured against a pristine main, which reports the same

Scope note

apps/api in wego-ai has its own copy of release-signing and is untouched. Its ?sums= route reads only ok/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

…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
sunny-wego merged commit afeee54 into main Sep 14, 2026
1 check passed
@sunny-wego
sunny-wego deleted the claude/foundations-issues-audit-7ug0hz branch September 14, 2026 13:52
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
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.

2 participants