Repository navigation
refactor(update): make the still-latest verdict a pure function a quiet feed read can share - #17495
chenmingwei23 wants to merge 1 commit into
Conversation
The still-latest question -- "is the staged build still the newest thing the
followed channel serves?" -- was spread across the update-available /
update-not-available handlers in runtime/update/feed-lane.js as inline branches
that also mutated staged state and emitted renderer events (direction gate,
supersede/already-staged, retraction). That meant the only way to ask the
question was to run the stateful autoUpdater.checkForUpdates() pipeline and
suppress every side effect it produced; nothing that must NOT touch state could
consult the verdict.
Extract the decision into a pure function, runtime/update/still-latest.js:
classifyFeedVerdict({ stagedVersion, candidate, followedChannel, runningVersion,
defaultChannel, shouldAutoOffer }) returns a tagged verdict (offer / suppress /
still-latest / superseded / retracted / up-to-date) with no I/O, no mutation and
no emit. candidate === null is the feed's "nothing newer" answer. The direction
gate (shouldAutoOffer) is PASSED IN, not duplicated, so the one copy of that rule
stays the one copy.
The feed-lane handlers now MAP the verdict onto their state transitions and
events via a small feedVerdict() closure that only gathers the four facts from
live lane state -- behaviour is unchanged, including the feedChannel-vs-live-read
channel pairing and the stage-cleanup on a suppressed downgrade. The lane handle
also exposes stillLatest(candidate): a side-effect-free query that returns the
same verdict the live handlers act on, so a quiet feed read can share it without
driving the real update lifecycle.
Context: the machinery the issue describes (verifyStageIsLatest and the
abandonedCheck / verifyQuiet / inFlightCheckError / preparingDownload suppression
flags) came from the still-unmerged kirodotdev#9367 and never landed; the update lifecycle
was reorganised into runtime/update/ (kirodotdev#14569) with the verdict inline in
feed-lane.js. This factors that inline verdict out so the quiet feed read the
issue asks for has a pure function to call.
Tested: new unit tests for classifyFeedVerdict (test/still-latest.test.js) using
the real shouldAutoOffer; the full website/electron node:test suite passes
(2444 pass / 0 fail / 4 skipped). The runtime-module load-time-effects contract
and the lane-handle-shape contract in auto-update.test.js were updated to admit
the new pure helper and the new handle key.
The sibling kirodotdev#10282 (phase-enum refactor) has no open PR yet; this change does not
edit the boolean-lattice declarations that refactor will touch.
Fixes kirodotdev#10333
UX Review (Opus 5.5, fork) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 6e7e05a Description read[DESCRIPTION-READ] 3ef0ab2652fdd1e988edcefc2e6865845e377355184541fc1053ff69140f4663 That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5, fork) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS
Watch
[DESIGN-REVIEWED] 6e7e05a Description read[DESCRIPTION-READ] bb3dd86c741efcc509f3095567268fd9473d593794f4b6bc5cae60ab42ca77ab That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Opus 5.5 Review (fork) — ✅ no blocking findingsReviewed |
First Principles Review (Opus 5.5, fork) — 🔴 BLOCKPremise-level review of First-Principles-Verdict: BLOCK
Not justified as shipped
What this change shipsInventory (5 items) — 4 justifiedIntent: give a side-effect-free feed read a way to ask whether the staged update is still the newest; an ADDITION framed as a refactor.
Blockers
[FIRST-PRINCIPLES-REVIEWED] 6e7e05a Description read[DESCRIPTION-READ] b319cf95d4fee89f2051299c3a6d5a7a3cdd7c288fe01066bb780032c04c8cd4 That sha256 names the PR description this verdict read. Recompute it with |
GPT 6.1 Review (fork) — ✅ no blocking findingsReviewed Review detailsNo findings. |
|
Superseded by #17741; moved to a same-repo branch so CI runs on CodeBuild. |
What broke / why
runtime/update/feed-lane.jsanswers one question — is the staged build stillthe newest thing the followed channel serves? — but it answered it inline in the
update-available/update-not-availablehandlers, in branches that alsomutated staged state and emitted renderer events. The three parts of the verdict
(direction gate, supersede/already-staged, retraction) were tangled with their
side effects, so the only way to ask the question was to run the stateful
autoUpdater.checkForUpdates()pipeline and suppress every effect it produced.A caller that must not touch state — a quiet feed read for a freshness gate — had
no way to share the verdict.
What changed
runtime/update/still-latest.js→classifyFeedVerdict({ stagedVersion, candidate, followedChannel, runningVersion, defaultChannel, shouldAutoOffer }). It returns a taggedverdict —
offer/suppress/still-latest/superseded/retracted/up-to-date— with no I/O, no mutation, no emit.candidate === nullisthe feed's "nothing newer" answer (
update-not-available). The direction gate(
shouldAutoOffer, the downgrade-nag suppressor) is passed in, notduplicated, so the one copy of that rule stays the one copy.
feedVerdict()closure that only gathers the four facts from live lane state.The
update-availablehandler switches onsuppress/still-latest/superseded; theupdate-not-availablehandler uses the shared verdict(
candidate = null) for the retraction decision. Behaviour is unchanged,including the
feedChannel-vs-live-read channel pairing (the mid-checkpreference-flip TOCTOU guard) and the stage cleanup on a suppressed downgrade.
stillLatest(candidate), a query that returns the same verdict the livehandlers act on, so a quiet feed read can share it without driving the real
update lifecycle.
Why this scope (code on
main, not the issue'sverifyStageIsLatest)The issue describes machinery —
verifyStageIsLatest()and theabandonedCheck/
verifyQuiet/inFlightCheckError/preparingDownloadsuppression flags —that was introduced by the still-unmerged #9367 and never landed on
main.The update lifecycle was instead reorganised into
website/electron/runtime/update/(#14569), with the still-latest verdict living inline in
feed-lane.js. This PRfactors that inline verdict out into the pure function the issue asks for, so the
quiet feed read has a function to call — the same architectural goal, against the
code that is actually on
main.Relation to #10282
The sibling #10282 (replace the boolean lattice with an explicit phase enum) has
no open PR yet. This change does not edit the boolean-lattice declarations that
refactor will touch; it adds a pure verdict function and routes the handlers
through it.
Tested
classifyFeedVerdict(test/still-latest.test.js), usingthe real
shouldAutoOfferso the direction gate is exercised, not astand-in.
website/electronnode:testsuite passes: 2444 pass / 0 fail /4 skipped (
npm test, the command CI's Electron Shell Tests job runs).contract in
auto-update.test.jswere updated to admit the new pure helper andthe new handle key.
Fixes #10333