Skip to content

refactor(notice): stop caching the channel's answer; keep only the stamp - #36

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

sunny-wego merged 2 commits into
mainfrom
claude/foundations-issues-audit-7ug0hz

Conversation

@sunny-wego

Copy link
Copy Markdown
Collaborator

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-check did two jobs, and only one was load-bearing:

Mechanism Purpose
when we last asked the file's mtime throttles the network read — the real point
what the channel said the file's content lets the notice repeat on every command inside the window

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:

  1. the reinstall-hint misfire
  2. fix(update): classify verification failures, and drop the notice cache after a swap #33's delete-on-swap, which only helps when the previous binary already had it
  3. fix(notice): ignore a cached answer written by a different binary #35's writtenBy stamp, meant to cover what deletion structurally cannot

The 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

Tests

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:

404 · 403 · 500 · transport failure · timeout · captive-portal page · empty body
  -> no message, outcome "checked"

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:

it("stores nothing but the stamp", …)

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
Check Result
bun test 1472 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 7 warnings / 1 info — one below the 8-warning baseline on main

Supersedes #35. Refs #33.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Tna7gh6pBHkr8zFHL3BqFs


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