Skip to content

Registry lockdown phase after initialization #1011

@willgriffin

Description

@willgriffin

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:

  1. After all packages are loaded and classes registered, call ObjectRegistry.lock()
  2. After lockdown:
    • register() throws ConfigurationError("Registry is locked")
    • registerFromManifest() throws similarly
    • All caches are frozen (inheritance chains, field maps, schemas)
    • Read operations guaranteed stable
  3. Provide ObjectRegistry.isLocked() for conditional checks
  4. 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.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions