feat: passive update check (cached, opt-out, install-aware)#21
Open
hakimjonas wants to merge 1 commit into
Open
feat: passive update check (cached, opt-out, install-aware)#21hakimjonas wants to merge 1 commit into
hakimjonas wants to merge 1 commit into
Conversation
On a normal query or REPL run, lam checks at most once a day whether a newer release exists and, if so, prints a one-line notice to stderr with the upgrade command for how it was installed. Closes the 0.14.0 update-ergonomics item. Design (bin/update_check.dart, all IO behind injectable seams): - The notice shown THIS run is decided synchronously from a small JSON cache (sub-millisecond, never blocks the query). The network refresh only updates the cache for the NEXT run, so it's fire-and-forget — unawaited, its result never needed — which sidesteps the background-future-vs-exit() race entirely. - Gated: fires only for the interactive query path and the REPL. OFF for -n/--null-input, --ndjson, --assert, --print-shape, --explain*, --version/--skill/--completions, in CI (CI env var), when stderr is not a terminal, via --no-update-check, or LAM_NO_UPDATE_CHECK. - Install-method detection (brew/scoop/pub/manual) from Platform.resolvedExecutable picks the upgrade command. No binary self-replacement. - Version compare is a small hand-rolled numeric semver; unparseable upstream => not-newer, so a bad response can't produce a bogus notice. The language (lib/) stays dart:io-free — this is all CLI harness, the same category as the existing file/stdin IO. MCP server untouched. Tests: 25 unit tests with in-memory fakes + fixed clock (no real network/disk) covering isNewer, decideNotice staleness, refreshCache, detectChannel, render per channel, the shouldCheck truth table, and cache-path resolution; plus integration tests asserting no notice leaks on the non-TTY path and --no-update-check is accepted. Docs: getting-started "Updating" section; man page --update-check option, ENVIRONMENT (LAM_NO_UPDATE_CHECK, CI), and FILES (cache path); CHANGELOG. analyze --fatal-infos, format, lint-changelog, generated-files all green; full suite 1714 + lambe_test 19 pass.
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.
Item 1c of the 0.14.0 cycle — the update-ergonomics feature.
What
On a normal query or REPL run,
lamchecks at most once a day whether a newer release exists and, if so, prints a one-line notice to stderr with the upgrade command for how it was installed:Design (the careful bits)
unawaited) — its result is never needed, which sidesteps the background-future-vs-exit()race entirely.bin/update_check.dart, so the policy is unit-tested with in-memory fakes — no real network/disk.bin/(the CLI harness);lib/remainsdart:io-free / WASM-clean. MCP server untouched.Platform.resolvedExecutablejust prints the right upgrade command.Gating (fires only when ALL hold)
stderr is a TTY · not CI (
CIenv) · not--no-update-check· notLAM_NO_UPDATE_CHECK· not a suppressed mode (-n,--ndjson,--assert,--print-shape,--explain*;--version/--skill/--completionsalready exit earlier).Tests
test/update_check_test.dart):isNewer(incl. unparseable→not-newer so a bad response can't notice),decideNoticestaleness/malformed-cache,refreshCachewrite-only-on-success,detectChannelper platform,renderper channel, theshouldChecktruth table, cache-path resolution (XDG/HOME/LOCALAPPDATA).cli_integration_test.dart): no notice leaks to stderr on the non-TTY path;--no-update-checkaccepted.Docs
getting-started "Updating" section; man page
--update-checkoption +ENVIRONMENT(LAM_NO_UPDATE_CHECK,CI) +FILES(cache path); CHANGELOG.Verification
analyze --fatal-infos, format, lint-changelog, generated-files (man page idempotent) all green; full suite 1714 + lambe_test 19 pass. Purely additive (753 insertions, 0 deletions).