fix: stabilize provider registry snapshots#2548
fix: stabilize provider registry snapshots#2548CodeZeno wants to merge 2 commits intopingdotgg:mainfrom
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
Tip 💬 Introducing Slack Agent: The best way for teams to turn conversations into code.Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.
Built for teams:
One agent for your entire SDLC. Right inside Slack. Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 5576781. Configure here.
| yield* upsertProviders(missingFallbackProviders, { | ||
| persist: false, | ||
| publish: false, | ||
| }); |
There was a problem hiding this comment.
Duplicate comment block accidentally left in code
Low Severity
There are two duplicate comment blocks at the end of the ProviderRegistryLive layer definition (lines 680-707) explaining the PubSub subscription pattern. One of these can be removed.
Reviewed by Cursor Bugbot for commit 5576781. Configure here.
There was a problem hiding this comment.
Didn't touch that code
ApprovabilityVerdict: Needs human review This PR modifies provider persistence logic by introducing filtering for 'unprobed' providers and changes the subscription model from Stream to PubSub. While framed as test stabilization, the changes affect what gets persisted to disk at runtime, warranting human review. You can customize Macroscope's approvability policy. Learn more. |


What Changed
Stabilizes provider registry snapshot handling by subscribing directly to provider snapshot PubSubs instead of deriving updates from Stream.fromPubSub, which could miss updates when no stream consumer was active yet.
Also avoids persisting transient “not checked yet” fallback snapshots over real cached provider state, and changes managed provider getSnapshot so it reuses the current snapshot when settings have not changed instead of forcing a fresh probe every time.
Tests were updated to cover the new subscription shape and to wait for async provider probe results more reliably.
Why
To improve slow start times mainly but also keeps provider status more stable across startup, reconnects, and settings refreshes.
Start times are now 2-3 seconds where previously were around 7-8 seconds.
Checklist
Note
Medium Risk
Touches core provider aggregation logic (subscriptions, refresh/persist behavior) and adjusts async timing, so regressions could surface as missing/stale provider status or extra probes, though changes are localized and well-covered by updated tests.
Overview
Stabilizes provider snapshot aggregation and persistence. The registry now consumes provider updates via an explicit
subscribeChangessubscription (added toServerProviderShape/ProviderSnapshotSource) instead of relying onStream.fromPubSubstart timing, reducing dropped updates during instance rebuilds/startup.Avoids overwriting cached state with transient fallbacks. Adds
isUnprobedProviderSnapshotto detect “not checked yet” placeholder snapshots, skips persisting them, and only seeds boot-time fallback providers when no cached snapshot exists.Reduces unnecessary reprobes and hardens tests.
makeManagedServerProvider.getSnapshotnow returns the current cached snapshot when settings haven’t changed, and tests were updated for the new subscription shape plus more reliable polling/real-timer waits and path resolution assertions.Reviewed by Cursor Bugbot for commit dcb923c. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Fix provider registry snapshot stabilization by replacing stream subscriptions with PubSub
Stream.runForEach(source.streamChanges, ...)with an explicit PubSub subscription via a newsubscribeChangesAPI inProviderRegistry.ts, reducing missed change events.subscribeChangestoServerProviderShapeandProviderSnapshotSourceso providers expose a direct subscription alongside the existing stream.isUnprobedProviderSnapshotto prevent unprobed provider snapshots from being persisted to disk prematurely.syncCurrentSourceSnapshotto drive initial state population using the current snapshot while respecting the unprobed persistence policy.ProviderRegistry.test.tsaddsubscribeChangesto fake instances and replaceEffect.sleepwith real-timer polling to reduce flakiness.Macroscope summarized dcb923c.