Skip to content

Move dictionary downloads off the spell-check path - #301

Merged
blopker merged 2 commits into
mainfrom
background-dictionary-prefetch
Aug 2, 2026
Merged

Move dictionary downloads off the spell-check path#301
blopker merged 2 commits into
mainfrom
background-dictionary-prefetch

Conversation

@blopker

@blopker blopker commented Aug 2, 2026

Copy link
Copy Markdown
Owner

Fixes #300. Spell checks never touch the network: get_dictionary is disk-only, and a background worker greedily prefetches every dictionary the config can resolve to (plus all per-language word lists) with per-id exponential backoff. When a Hunspell pair that previously couldn't load lands, the LSP re-checks open documents; everything else is picked up by the next natural check.

  • Downloader: split into local_path + single-attempt fetch with staged PendingDownload/commit (aff/dic pairs commit all-or-nothing, in lockstep across generations); connect/overall timeouts; NO_NETWORK env var refuses requests before any socket while stale cached copies still serve.
  • Cold cache noops instead of flagging every word: checks require a primary-capable (Hunspell or local-override) configured dictionary.
  • CLI lint still warms dictionaries synchronously, and fails the run (exit 2) when no primary dictionary is usable, instead of reporting a false clean.
  • In-memory dictionary cache is invalidation-epoch guarded so a check racing a background commit can't pin stale content, with a negative cache keyed to the same epoch keeping the per-keystroke path free of repeated disk probes.

blopker added 2 commits August 1, 2026 18:03
Fixes #300. Spell checks never touch the network: get_dictionary is
disk-only, and a background worker greedily prefetches every dictionary
the config can resolve to (plus all per-language word lists) with
per-id exponential backoff. When a Hunspell pair that previously
couldn't load lands, the LSP re-checks open documents; everything else
is picked up by the next natural check.

- Downloader: split into local_path + single-attempt fetch with staged
  PendingDownload/commit (aff/dic pairs commit all-or-nothing, in
  lockstep across generations); connect/overall timeouts; NO_NETWORK
  env var refuses requests before any socket while stale cached copies
  still serve.
- Cold cache noops instead of flagging every word: checks require a
  primary-capable (Hunspell or local-override) configured dictionary.
- CLI lint still warms dictionaries synchronously, and fails the run
  (exit 2) when no primary dictionary is usable, instead of reporting
  a false clean.
- In-memory dictionary cache is invalidation-epoch guarded so a check
  racing a background commit can't pin stale content, with a negative
  cache keyed to the same epoch keeping the per-keystroke path free of
  repeated disk probes.
@blopker
blopker marked this pull request as ready for review August 2, 2026 02:14
@blopker
blopker merged commit 9720cec into main Aug 2, 2026
12 checks passed
@jclsn

jclsn commented Aug 2, 2026

Copy link
Copy Markdown

Wow, that was fast. How do I enable this and how do I add the dictionaries?

@blopker

blopker commented Aug 2, 2026

Copy link
Copy Markdown
Owner Author

Hey! I haven't landed it yet in a public release. I wanted to test a few things first. But the 2 main changes are that downloads never block checking now, so for a no network machine you can just copy the cache folder over and it should work fine. The second is that you can disable network checks completely by having the unix standard "NO_NETWORK=1" environment variable.

Anyway, I'll do some more testing tomorrow and land it this week. Then it will propagate through the normal update channels. If you want to help test (which would be awesome), the pre-release binaries are here: https://github.com/blopker/codebook/releases/tag/v0.3.43

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.

[FEATURE]: Disable fetching dictionaries from Github

2 participants