Problem
The ObjectRegistry can be mutated at any time — during startup, during request handling, during getInheritanceChain(), etc. This makes it impossible to reason about the registry state at any given point and prevents caching optimizations.
Proposed Solution
Introduce a RegistryLockdown phase:
- After all packages are loaded and classes registered, call
ObjectRegistry.lock()
- After lockdown:
register() throws ConfigurationError("Registry is locked")
registerFromManifest() throws similarly
- All caches are frozen (inheritance chains, field maps, schemas)
- Read operations guaranteed stable
- Provide
ObjectRegistry.isLocked() for conditional checks
- In test environments, provide
ObjectRegistry.unlock() for test setup/teardown
Integration Points
- CLI: Lock after manifest discovery completes
- SvelteKit hooks: Lock after
withBackgroundJobs() / server initialization
- Vitest plugin: Lock after test manifest generation, unlock in
afterAll
Key Files
packages/core/src/registry.ts
Part of epic #1003.
Problem
The
ObjectRegistrycan be mutated at any time — during startup, during request handling, duringgetInheritanceChain(), etc. This makes it impossible to reason about the registry state at any given point and prevents caching optimizations.Proposed Solution
Introduce a
RegistryLockdownphase:ObjectRegistry.lock()register()throwsConfigurationError("Registry is locked")registerFromManifest()throws similarlyObjectRegistry.isLocked()for conditional checksObjectRegistry.unlock()for test setup/teardownIntegration Points
withBackgroundJobs()/ server initializationafterAllKey Files
packages/core/src/registry.tsPart of epic #1003.