refactor(plugins): consolidate connect-time driver readiness and tidy binary selection#1557
Conversation
… binary selection
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c91ad2aa5b
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| private func reconcileOutdated(matchingTypeId typeId: String) async { | ||
| let targets = rejectedPlugins.filter { $0.isOutdated && $0.providedDatabaseTypeIds.contains(typeId) } | ||
| guard !targets.isEmpty else { return } | ||
| reconciliationActive = true |
There was a problem hiding this comment.
Avoid marking connect reconciles active without tracking the task
When a background reconciliation has scheduled a delayed retry, reconciliationTask still points at that sleeping retry while reconciliationActive is false. A connect-time reconcile now flips reconciliationActive to true without replacing reconciliationTask, so a second connection attempt during this reconcile enters ensurePluginReady, sees reconciliationActive, and awaits the stale sleeper instead of the in-flight connect reconcile. In the transient-failure path this can unnecessarily block connecting for the configured retry delay (30s/300s/600s) even if the direct reconcile finishes quickly and installs the driver.
Useful? React with 👍 / 👎.
Follow-up cleanups on top of the merged #1555 (self-heal incompatible drivers at connect). No user-facing behavior change.
What changed
Connect-time readiness moved to PluginManager.
DatabaseDriverFactory.createDriverhad three near-identicalif driverPlugin == nil { ... }blocks reaching intoPluginManagerinternals across the layer boundary (wait for load, reconcile outdated, install missing). Extracted them into onePluginManager.prepareForConnecting(to:). The factory now just asks the manager to make the driver ready. Same behavior, fewer cross-layer reach-ins.Guard against overlapping reconciliation.
reconcileOutdated(the connect path) did not setreconciliationActive, so a network-reachability change could start a parallelrunReconciliationLoopmutating the samereconciliationAttemptsandrejectedPlugins. It now sets the flag for its duration with adeferreset, so the existing!reconciliationActiveguard inretriggerReconciliationblocks the overlap.Cleaner binary selection.
resolvedBinarypicked the max with?? 0, a branch that never ran because nilpluginKitVersionwas already filtered out. Rewrote withcompactMapto a(binary, kit)tuple so the comparator works on a non-optional value.Release gate reads the origin, not the CDN.
check-registry-readiness.pynow fetches the raw GitHub manifest instead of the jsDelivr CDN. The gate sees the manifest the moment the registry push lands rather than racing or waiting out the edge cache. Clients still use jsDelivr.Tests.
makeRegistryPluginis nowthrowsinstead oftry!; the four callers threadtry.Testing