fix(core): decouple model catalog refresh from persistence - #45363
Open
kitlangton wants to merge 1 commit into
Open
fix(core): decouple model catalog refresh from persistence#45363kitlangton wants to merge 1 commit into
kitlangton wants to merge 1 commit into
Conversation
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.
Why
The models.dev catalog is larger than Durable Object SQLite's 2 MB value limit. Although failed KV writes are now tolerated, refresh still discarded the downloaded catalog and reloaded the old persisted value or bundled snapshot, so successful downloads could leave models permanently stale.
Persistence should help the next startup, not determine whether a running server can adopt a catalog update. This replaces the storage choice from #41649 while retaining support for filesystem-less runtimes.
What Changes
Refreshed, then attempt persistence.models.fileCache Ownership
ModelsDevowns the live catalog, digest, refresh timing, and single-flight coordination. The catalog-specificModelsDevCacheinterface only reads and writes raw responses. Its local adapter uses atomic temporary-file replacement underGlobal.cache/models-dev/<source-hash>.json, with file mtime supplying startup freshness; workerd explicitly installs a dependency-free disabled adapter.sequenceDiagram participant ModelsDev participant Upstream as Catalog Endpoint participant Consumers participant Cache as Optional Local Cache ModelsDev->>Upstream: Fetch /api.json Upstream-->>ModelsDev: Raw catalog ModelsDev->>ModelsDev: Validate, normalize, adopt ModelsDev-->>Consumers: Refreshed opt Local cache enabled ModelsDev->>Cache: Atomic best-effort write endScope
No general object-store abstraction or new infrastructure. workerd restarts use the bundle and refetch; existing KV catalog entries are ignored, not migrated or deleted. The first native startup after upgrading falls back to the bundle and refreshes rather than importing the old KV cache.
Verification
retains exited sessions until removed). All 7 tests in that PTY file pass on isolated rerun; the earlier full run passed without that timeout.018b4c40f3in a separate clean worktree: two missing/cancelrequests and the both-ports-busy response returning 200 instead of 400.The Server and SDK suites use Core's existing isolated-home runner because their plain test scripts otherwise load local user configuration.