Review of Totopo27's bfd56fab (the commit before this one), which makes the
plugin host start without waiting on models.dev and read the catalog again
once it is written.
What this changes on top of it:
- host.js mdev(): catalog.Sync writes models.json in place, so a host
listing providers during a refresh could read it half written. That
read replaced the catalog it had with {}, and the Go side kept that
list until its next refresh. A read that fails now keeps what was read
before (a failed read means unknown) and is tried again next time.
TestHostKeepsTheCatalogThroughAHalfWrite: red with bfd56fab's mdev()
("a catalog read half written dropped the catalog read before"), green
with this.
- TestHostStartDoesNotWaitOnHangingModelsDev bounded a real bun host start
by 3s, which a loaded runner can exceed. It now allows 15s within a 25s
context: the old blocking start still fails it (the hanging sync holds
the start until the context ends).
What was run at this head (Go 1.26.8, worktree of origin/main 429698f96,
private GOCACHE, sandbox HOME):
- gofmt -l: clean. go vet ./... (darwin), GOOS=linux go vet -tags nogui
./..., GOOS=windows go vet ./...; go build, GOOS=linux go build -tags
nogui, GOOS=windows go build: all ok.
- go test -tags nogui -count=1 ./...: every package ok except
internal/agent and internal/gateway, which hit the default 10m timeout
at load average ~190, internal/edit's TestTOMLBigFileParsesInLinearTime
(1.27s against a 1s bound, filed as #2219; passes alone -count=3) and
gateway's TestIntentClassifierFails (#1829, passes alone -count=3).
internal/agent, internal/gateway, internal/plugin, internal/catalog
then ran with -timeout 60m: all ok.
- go test -race -count=20 on the three new plugin tests and on catalog's
TestSync*: ok. -race -count=10 again with this commit's test: ok.
- A throwaway test dumping goroutines after the start and background-sync
tests (and their Settle): none of hangModelsDev, syncLock or startOn's
goroutine left.
- Broken by hand on bfd56fab, each red: forgetProviders() after the
background sync removed (TestHostBackgroundSyncForgetsProviders);
SyncIfMissing's Source() re-check removed
(TestSyncIfMissingSkipsFetchWhenCacheAppearsWhileLocked, 1 request);
ctx dropped from the lock wait (TestSyncHonorsContextLockWait, in 1s);
mdev()'s read-once caching put back
(TestHostReloadsCatalogWhenFileAppears); the blocking 30s sync put back
in startOn (both subtests, startOn failed on the deadline after 30s).
Not tried: a real models.dev outage end to end in the GUI; the Windows
box. with_sync_in_flight still sleeps 50ms for its Sync to take the lock,
so it may test the "alone" case on a slow runner; it can't go red from it.