Skip to content

refactor(plugins): consolidate connect-time driver readiness and tidy binary selection#1557

Merged
datlechin merged 1 commit into
mainfrom
refactor/plugin-connect-readiness
Jun 2, 2026
Merged

refactor(plugins): consolidate connect-time driver readiness and tidy binary selection#1557
datlechin merged 1 commit into
mainfrom
refactor/plugin-connect-readiness

Conversation

@datlechin
Copy link
Copy Markdown
Member

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.createDriver had three near-identical if driverPlugin == nil { ... } blocks reaching into PluginManager internals across the layer boundary (wait for load, reconcile outdated, install missing). Extracted them into one PluginManager.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 set reconciliationActive, so a network-reachability change could start a parallel runReconciliationLoop mutating the same reconciliationAttempts and rejectedPlugins. It now sets the flag for its duration with a defer reset, so the existing !reconciliationActive guard in retriggerReconciliation blocks the overlap.

Cleaner binary selection. resolvedBinary picked the max with ?? 0, a branch that never ran because nil pluginKitVersion was already filtered out. Rewrote with compactMap to a (binary, kit) tuple so the comparator works on a non-optional value.

Release gate reads the origin, not the CDN. check-registry-readiness.py now 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. makeRegistryPlugin is now throws instead of try!; the four callers thread try.

Testing

  • Build succeeds on top of current main.
  • PluginManagerReconciliationTests, RegistryBinarySelectionTests, and PluginInstallerHelpersTests pass.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@datlechin datlechin merged commit 9c30c0a into main Jun 2, 2026
4 checks passed
@datlechin datlechin deleted the refactor/plugin-connect-readiness branch June 2, 2026 11:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant