refactor(plugins): move the config-defaults seeder out of the loader - #1022
Merged
Conversation
seedConfigDefaults is a pure function — sixteen lines, no `this`, no injected dependency — that lived inside a 1713-line service module with 31 imports. Reaching it meant loading the whole loader graph: BullMQ, ModuleRef, the sandbox worker host, plugin storage, the hook manager. Its own spec block paid that price to test schema defaulting. It now sits in config-defaults.util.ts with its tests colocated beside it, matching how search-provider-registration and webhook-subscribe were already lifted out of the same file. Behaviour is unchanged: the function moved verbatim, the four tests moved verbatim, and the suite total is identical (4011) because nothing was added — the loader spec drops from 56 to 52 and the new file accounts for the rest. The loader's PluginConfigSchema import goes with it, since seeding was its only use. Nothing imported the symbol through the core/plugins barrel, so no re-export is added; narrowing that surface is part of the point.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
First step of unpicking
plugin-loader.service.ts, taken deliberately small.Why
seedConfigDefaultsis a pure function — sixteen lines, nothis, no injected dependency — that livedinside a 1713-line service module with 31 imports. Reaching it meant loading the whole loader graph:
BullMQ, ModuleRef, the sandbox worker host, plugin storage, the hook manager. Its own spec block paid
that price just to test schema defaulting.
What changes
It moves to
config-defaults.util.tswith its tests colocated beside it, matching howsearch-provider-registration.util.tsandwebhook-subscribe.util.tswere already lifted out of thesame file.
The loader's
PluginConfigSchemaimport goes with it — seeding was its only use.Nothing imported the symbol through the
core/pluginsbarrel, so no re-export is added. Narrowing thatsurface is part of the point rather than an oversight.
Scope
Pure code motion. No behaviour change, no API surface change.
The suite total is identical at 4011 because nothing was added: the four tests moved verbatim, the
loader spec drops 56 → 52, and the new file accounts for the rest. Suite count goes 248 → 249 for the
new file alone.
No CHANGELOG entry — per CONTRIBUTING, that is for user-visible changes, and a pure function changing
files is not one.
Note on sequencing
An earlier plan justified this step as breaking a
plugin-loader↔plugin-storagerequire cycle. Thatcycle does not exist today —
plugin-storage.service.tsimports nothing from the loader. It would onlyappear if a later step moved config seeding to where storage can reach it. The justification above is
the present-tense one; the sequencing benefit is a bonus, not the reason.
Verification
Backend lint,
prettier --check,tsc --noEmitover the full project including specs, build, 4011 unittests, 137 e2e tests, and the dashboard build all pass on Node 22.