Skip to content

refactor(plugins): move the config-defaults seeder out of the loader - #1022

Merged
rmyndharis merged 1 commit into
mainfrom
refactor/plugin-config-defaults
Jul 31, 2026
Merged

refactor(plugins): move the config-defaults seeder out of the loader#1022
rmyndharis merged 1 commit into
mainfrom
refactor/plugin-config-defaults

Conversation

@rmyndharis

Copy link
Copy Markdown
Owner

First step of unpicking plugin-loader.service.ts, taken deliberately small.

Why

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 just to test schema defaulting.

What changes

It moves to config-defaults.util.ts with its tests colocated beside it, matching how
search-provider-registration.util.ts and webhook-subscribe.util.ts were already lifted out of the
same file.

The loader's PluginConfigSchema import goes with it — 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 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-loaderplugin-storage require cycle. That
cycle does not exist today — plugin-storage.service.ts imports nothing from the loader. It would only
appear 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 --noEmit over the full project including specs, build, 4011 unit
tests, 137 e2e tests, and the dashboard build all pass on Node 22.

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.
@rmyndharis
rmyndharis merged commit 777f12b into main Jul 31, 2026
15 checks passed
@rmyndharis
rmyndharis deleted the refactor/plugin-config-defaults branch July 31, 2026 16:01
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