Repository navigation
Conversation
Two independent call sites (ensureService's inst.manifest injection and pluginRegistryFor's PluginRegistryApi facade) each called publicPluginManifest(manifest) separately, producing two distinct JSON-cloned copies for the same third-party plugin registration. A keepLoaded, service-kind third-party plugin that compares its own injected manifest against pluginRegistry.installedPlugins[pluginId] by reference - to detect a stale registration surviving past a rescan - saw that comparison fail on every load, never just a genuinely stale one, because the two clones were never the same object. Cache the scrubbed copy per raw manifest object (stable within one scan generation; naturally invalidated by garbage collection once a rescan replaces it) so every caller for the same raw manifest gets back the identical copy, restoring reference-comparability without weakening the isolation from the raw, internal-only manifest fields.
a135bf7 to
6458b79
Compare
|
Reviewed at 6458b79 by Claude Opus 5.5 and, as a second opinion, Codex Medium, with the shell run on a disposable Omarchy ISO VM (Quickshell 0.3.1, Qt 6.11.2) linked to this branch and to its merge base. It is not ready to merge: the manifest cache in the second commit crashes the shell, and the race the first commit fixes did not show up on a stock install. The The load race was not reproduced. Instrumenting Scope. The second change is an API addition, not a fix:
|
|
Thanks @bavanchun. The pending-service ownership race this addressed is fixed on |
|
Thanks, @bavanchun, for the service lifecycle fixtures. GPT-6.2 Sol High in Codex, Opus 5.5 High, and muse-wonder via pi (high) compared this branch with current Could you narrow the fix to keeping the existing token through registration and add a regression test that saves settings through the third-party API during initialization? Please leave out the manifest cache. It crashed Quickshell in the earlier worker review, and this branch still removes |
Two related defects in the shell's service loader let an enabled
service-kind plugin end up with no live service, or with a service that can never admit itself. Both surface on third-party plugins that pair aserviceentry point with a bar widget or panel.1. Pending service loads are not owned across reloads
ensureServicecompiled a component and registered whatever itsfinalizecallback produced, with no claim on the in-flight load. When an asynchronous load completed after a reload had already started a fresh load for the same plugin, the obsolete finalizer still ran_services[key] = inst, displacing the fresh owner with a stale, inactive instance._syncServicesthen skipped the key as occupied, so nothing recovered it until the next shell restart — where the same race could repeat.The fix adds a per-key pending claim plus a reload generation:
ensureService/_syncServicesrequests share a single in-flight load rather than racing;unloadPluginServicesso pending loads from a previous generation can never register.Public service APIs, the injection order and synchronous creation are unchanged.
2.
publicPluginManifestre-clones per call siteEvery call independently
JSON.parse(JSON.stringify(...))-ed the raw manifest, so a plugin's own injectedmanifestand the copy handed to its scopedPluginRegistryApifacade were different objects. A plugin that compares the two — to notice that its registration was superseded by a newer scan — saw them differ on every load, not just a stale one.Reference equality is not a dependable contract here anyway: reading a plain JS object back out of a
property varthrough the facade does not preserve strict identity (it arrives as aV4ReferenceObjectwrapper). So the copy is now memoized per raw manifest object and stamped with__registryRevision, a plain number pinned to the scan generation the raw manifest was first seen in. Numbers survive the property round trip, so plugins have something reliable to compare. Memoization also removes the redundant re-cloning on every facade construction and rescan.Tests
test/shell.d/service-lifecycle-test.sh— 45 Node cases driving the extracted production loader: late/duplicate completion order, disable/remove/rescan invalidation, loading/error/null status, reentrant creation and injection, cancellation, and unaffected neighbours. They fail against the unpatched loader and pass with it.test/shell.d/service-lifecycle-runtime-test.sh— the same production block inside a real QtQuick host viaqmltestrunner, covering component cleanup, realstatusChangeddisconnection and reload-during-construction/injection. Skips cleanly whenqmltestrunneris absent.The existing authentication-boundary coverage in
plugin-auth-boundary-test.shstill passes.Verification
Built as a local
omarchypackage and installed on a 4.0.3 desktop. Before: an enabled third-partyserviceplugin never got a live service instance, and once the loader race was fixed it was still rejected permanently by its own stale-registration check. After both fixes the service registers, admits itself and its helper process runs.Happy to split this into two PRs or adjust naming — whatever suits.