Repository navigation
fix(notice): ignore a cached answer written by a different binary - #35
sunny-wego wants to merge 1 commit into
Conversation
Reported from the field on 1.2.4, on every command:
$ wego version
1.2.4
Your wego channel now serves 1.2.3 (you have 1.2.4). Run `wego update -y`.
$ wego update
Already up to date (1.2.4, ring stable).
$ cat ~/.config/wego/.update-check
1.2.3
The ring was correct throughout - the 1.2.4 promote finished green and `update`
agreed. The lie was local: `.update-check` still held the answer read while
`cli/stable` served 1.2.3, and the throttle governs the network READ rather than
the message, so the notice reported that answer for the whole window without
re-fetching.
WHY THE EXISTING FIX COULD NOT COVER IT. #33 deletes the file after a
swap, from `update.ts` - which runs in the binary PERFORMING the swap. The swap
here was performed by 1.2.3, which predates that code. A write-side fix only ever
covers users whose PREVIOUS binary already had it, which is the same shape as the
1.2.0 user-agent bug.
AND IT NEVER COVERS A REINSTALL AT ALL. `curl … | sh` replaces the binary and
writes only `install.json` (`apps/api` `renderInstallScript` - checked, there is
no other write). `update.ts` does not run, so nothing on that path clears the
cache. That matters because reinstalling is the ONLY recovery for a stranded
1.2.0 install, and a 1.2.0 binary is pinned to the legacy bridge, so its notice
cached 1.1.0 - reinstall it onto 1.2.4 and it says "your channel now serves
1.1.0" forever. The recovery path was the worst-affected one.
So the check moves to the READER, which does not care how the binary changed.
`.update-check` becomes two lines - the channel's answer, then the version that
wrote it - and a cache whose stamp is not the running version is ignored.
Both directions of the format change were measured, not assumed:
old build reads two lines `looksLikeVersion("1.2.4\n1.2.3")` is false, so it
goes silent rather than reporting a mangled string
new build reads one line no stamp -> "not mine" -> ignored, which is the
right answer for every file in the field today
SUPPRESSED FOR REPORTING, REMEMBERED FOR THROTTLING. Falling through to a fresh
fetch would be one command more correct and would re-fetch on EVERY command for a
whole window whenever that fetch fails - the per-invocation network call the
unclaimable path already exists to avoid. Honouring the throttle costs at most one
window of silence, and a missed notice is the right failure here: the bug being
fixed is a notice that was confidently wrong. It self-heals at the next window,
when the normal path fetches and stamps.
The delete-on-swap from #33 stays. The two are complementary - deletion saves a
read on the common path, the stamp covers every path deletion cannot reach.
Verified: three tests fail against shipped 1.2.4 and pass here, including the
field report reproduced exactly. Two more are guards - a cache that IS this
binary's own must still report, and the pre-stamp file must read back with no
writer. `bun test` 1486 pass / 1 fail (the known root-permissions
`skill.test.ts` case, which fails on a clean tree too); typecheck clean; lint at
the 8-warning / 1-info baseline.
```release-note
`wego` no longer reports a stale release-channel version after an update or a
reinstall, which could wrongly claim the channel had been rolled back.
```
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
|
Closing without merging. The approach is superseded by a simpler one: stop caching the answer at all. Why
Everything this PR added — the two-line format, Guarding a cache whose other comparison input can change underneath it is a losing position, and today made that concrete: three defects in one afternoon, all in this area, each one a fix for the previous fix. What replaces itThe file becomes a pure timestamp. Nothing is stored, so nothing can go stale, and the bug class is deleted rather than defended against. The behaviour change, stated plainly: you are told about a new version once per window rather than on every command inside it. That persistence is a real thing being given up — the original comment called it out as deliberate, "a stale install keeps being told, for free". "For free" was the false economy: free in network terms, expensive in correctness terms. The diagnosis in this PR still stands and is worth keeping in the record — a cache written by one binary and read by another describes a comparison that no longer holds, and Superseded by the follow-up PR. Generated by Claude Code |
`.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
Candidate for v1.2.5. Fixes a false notice reported from the field on 1.2.4, and closes the gap that #33 structurally could not.
The report
The ring was correct throughout — the 1.2.4 promote finished green and
updateagreed. The lie was local..update-checkstill held the answer read whilecli/stableserved 1.2.3, and the throttle governs the network read, not the message, so the notice reported that answer for the whole window without re-fetching.Why #33 could not fix this
#33 deletes the file after a swap, from
update.ts— which runs in the binary performing the swap. The swap here was performed by 1.2.3, which predates that code.A write-side fix only ever covers users whose previous binary already had it. Same shape as the 1.2.0 user-agent bug: the fixer has to be the old version.
And it never covers a reinstall at all
curl … | shreplaces the binary and writes onlyinstall.json— I checkedrenderInstallScript, there is no other write.update.tsdoesn't run, so nothing on that path clears the cache.That matters more than it first looks. Reinstalling is the only recovery for a stranded 1.2.0 install, and a 1.2.0 binary is pinned to the legacy bridge, so its notice cached
1.1.0. Reinstall it onto 1.2.4 and it says "your channel now serves 1.1.0" indefinitely. The recovery path was the worst-affected one.The fix: move the check to the reader
.update-checkbecomes two lines — the channel's answer, then the version that wrote it — and a cache whose stamp isn't the running version is ignored. The reader doesn't care how the binary changed, so it covers update, reinstall and manual copy alike.Both directions of the format change were measured, not assumed:
looksLikeVersion("1.2.4\n1.2.3")→false→ silent, not a mangled versionSo it degrades to a missed notice, never a false one, and every stale cache self-heals on first run.
Suppressed for reporting, remembered for throttling
Deliberate, and the alternative is worse. Falling through to a fresh fetch would be one command more correct — and would re-fetch on every command for a whole window whenever that fetch fails, which is the per-invocation network call the
skipped-unclaimablepath already exists to avoid.Honouring the throttle costs at most one window of silence. A missed notice is the right failure here: the bug being fixed is a notice that was confidently wrong. It self-heals at the next window, when the normal path fetches and stamps.
#33's delete-on-swap stays. The two are complementary — deletion saves a read on the common path, the stamp covers every path deletion cannot reach.
Tests
Three fail against shipped 1.2.4, including the field report reproduced exactly:
Two are guards, labelled as such: a cache that is this binary's own must still report (or the change would silence every legitimate throttled notice), and a pre-stamp file must read back with
writtenByundefined.The shared
stored()fixture now stamps with the version under test by default, so the existing throttle and network tests keep measuring throttling rather than accidentally measuring staleness.bun testskill.test.tscase, which fails on a clean tree too)bun run typecheckbun run lintFor anyone already seeing it
rm ~/.config/wego/.update-checkclears it now. Otherwise it expires with the window, and this release prevents it recurring.Refs #33.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
Generated by Claude Code