Skip to content

fix: stabilize provider registry snapshots#2548

Open
CodeZeno wants to merge 2 commits intopingdotgg:mainfrom
CodeZeno:fix/provider-registry-snapshots
Open

fix: stabilize provider registry snapshots#2548
CodeZeno wants to merge 2 commits intopingdotgg:mainfrom
CodeZeno:fix/provider-registry-snapshots

Conversation

@CodeZeno
Copy link
Copy Markdown
Contributor

@CodeZeno CodeZeno commented May 6, 2026

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

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

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 subscribeChanges subscription (added to ServerProviderShape/ProviderSnapshotSource) instead of relying on Stream.fromPubSub start timing, reducing dropped updates during instance rebuilds/startup.

Avoids overwriting cached state with transient fallbacks. Adds isUnprobedProviderSnapshot to 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.getSnapshot now 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

  • Replaces Stream.runForEach(source.streamChanges, ...) with an explicit PubSub subscription via a new subscribeChanges API in ProviderRegistry.ts, reducing missed change events.
  • Adds subscribeChanges to ServerProviderShape and ProviderSnapshotSource so providers expose a direct subscription alongside the existing stream.
  • Introduces isUnprobedProviderSnapshot to prevent unprobed provider snapshots from being persisted to disk prematurely.
  • Adds syncCurrentSourceSnapshot to drive initial state population using the current snapshot while respecting the unprobed persistence policy.
  • Test fixes in ProviderRegistry.test.ts add subscribeChanges to fake instances and replace Effect.sleep with real-timer polling to reduce flakiness.

Macroscope summarized dcb923c.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 6, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: a470f117-ac1a-4c05-afd4-2b112e75fe4a

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions github-actions Bot added size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels May 6, 2026
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ 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,
});
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5576781. Configure here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Didn't touch that code

@macroscopeapp
Copy link
Copy Markdown
Contributor

macroscopeapp Bot commented May 6, 2026

Approvability

Verdict: 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:M 30-99 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant