mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-10-22 06:56:35 +00:00
6680bc7c74
PluginsModule was 21 controllers, 24 domain imports and 10 providers in one class, which made it the hub most of the Nest graph ran through: AdminModule imported it for a single cascade-disable call and inherited all of it. It is now PluginsRuntimeModule (supervisor, capability router, hook contracts), PluginContributionsModule (the 14 read-only hook controllers, moved to contributions/), PluginOAuthModule (the credential leaf, moved to oauth/) and a composition root that keeps the install and delivery controllers. AdminModule imports the runtime alone. The three plugin files that reached for the db singleton alongside the injected DatabaseService no longer do. plugin-host-state and signature-status take the connection from the caller, and the three per-user settings functions that were bare exports 'so the RPC host wiring can call them directly' are now PluginUserSettingsService - the host wiring is providers, so it injects them. Coverage moves from one repo-wide 80% to a per-domain ratchet. The single number let a well-covered domain subsidise a thin one: booking-import sits at 50% and integrations at 20%, and the aggregate still cleared the bar, so either could have lost another ten points unnoticed. Each domain now carries its own measured floor, regenerated by scripts/coverage-thresholds.mjs. Two test-side findings on the way: expect(undefined).toContain(SomeClass) PASSES in this vitest version - it only throws for a string needle. Every '<X> is listed in its module providers' guard was written that way, so all twelve of them silently stopped guarding the moment their class moved. They go through expectRegisteredProvider now, which asserts the array shape first. The atlas region test paid for the one-off decompression of the multi-MB admin1 bundle inside its own 5s budget, which is why it failed under load and passed alone. The bundle is warmed in beforeAll instead.
22 lines
1.1 KiB
TypeScript
22 lines
1.1 KiB
TypeScript
import { expect } from 'vitest';
|
|
|
|
/**
|
|
* Asserts that `moduleClass` lists `provider` in its `providers: []`.
|
|
*
|
|
* This is the one failure the compiler cannot see: a `@PluginController()` or
|
|
* `@McpController()` class that no module registers is invisible to discovery, and
|
|
* every call to it comes back PERMISSION_DENIED with no other symptom.
|
|
*
|
|
* It is a helper rather than an inline `expect(...).toContain(...)` because that form
|
|
* is unsound here. `Reflect.getMetadata('providers', M)` is `undefined` for a module
|
|
* declared without a `providers` key, and `expect(undefined).toContain(SomeClass)`
|
|
* PASSES in this vitest version (it only throws for a string needle). Every guard
|
|
* written that way silently stopped guarding the moment its class moved to another
|
|
* module. Asserting the array shape first is what makes the check real.
|
|
*/
|
|
export function expectRegisteredProvider(moduleClass: object, provider: object): void {
|
|
const providers = Reflect.getMetadata('providers', moduleClass) as unknown[] | undefined;
|
|
expect(Array.isArray(providers)).toBe(true);
|
|
expect(providers).toEqual(expect.arrayContaining([provider]));
|
|
}
|