Repository navigation
refactor(notice): stop caching the channel's answer; keep only the stamp - #36
Merged
Merged
Conversation
`.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
The comment said a zero-byte append "leaves an already-stored answer intact, so claiming the window can never lose the version we are about to nag about". There is no stored answer to lose - `claimWindow` is now the only writer and the file is empty by design. Left as it was, it would read as evidence that something IS stored, which is exactly the kind of stale rationale that sends the next reader looking for a mechanism that no longer exists. Comment only. 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.5. Supersedes #35, which is closed. Deletes the bug class instead of guarding it.
299 deletions, 108 insertions.
The observation
.update-checkdid two jobs, and only one was load-bearing:Everything that went wrong 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, each a fix for the one before it:
writtenBystamp, meant to cover what deletion structurally cannotThe change
The file becomes a timestamp. Its content is never written and never read. Nothing is stored, so nothing can go stale.
What a user notices: the notice fires once per window — on the command that crosses it — instead of on every command inside it.
That persistence was deliberate; the original comment called it out: "a stale install keeps being told, for free." "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
writeLatestand its atomic write-then-renameUpdateCheckState.latest, and theknownplumbing added in fix(notice): ignore a cached answer written by a different binary #35update.ts's delete-on-swap and itsupdateCheckPathdep (fix(update): classify verification failures, and drop the notice cache after a swap #33)readChannelVersion's three-way return —""on a 404 vsnullon everything else existed only to decide what could overwrite storage. A distinction that no longer changes behaviour is worse than none.cached→throttled, because nothing is cached and a reader shouldn't have to find that outTests
About ten disappear because the behaviour they pinned no longer exists: 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:
Verified on a real binary, not only in units
A 1.2.5 build against a loopback channel serving 1.9.9:
bun testskill.test.tscase, which fails on a clean tree too)bun run typecheckbun run lintmainSupersedes #35. Refs #33.
🤖 Generated with Claude Code
https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs
Generated by Claude Code