Skip to content

refactor: add registerSync() to PluginRegistry, eliminate registryInternals hack (#77)#102

Merged
MarcosBrendonDePaula merged 1 commit intomainfrom
fix/plugin-registry-sync-api
Mar 14, 2026
Merged

refactor: add registerSync() to PluginRegistry, eliminate registryInternals hack (#77)#102
MarcosBrendonDePaula merged 1 commit intomainfrom
fix/plugin-registry-sync-api

Conversation

@MarcosBrendonDePaula
Copy link
Copy Markdown
Collaborator

Summary

  • Added registerSync(), refreshLoadOrder(), and getPluginsMap() public methods to PluginRegistry
  • Removed the PluginRegistryInternals interface and all 12 as unknown as encapsulation violations from server.ts
  • Added 20 unit tests covering sync registration, load order, and edge cases

Closes #77

What was the problem?

// server.ts — 12 occurrences of this pattern:
(this.pluginRegistry as unknown as PluginRegistryInternals).plugins.set(...)
(this.pluginRegistry as unknown as PluginRegistryInternals).dependencies.set(...)
(this.pluginRegistry as unknown as PluginRegistryInternals).updateLoadOrder()
(this.pluginRegistry as unknown as PluginRegistryInternals).loadOrder = ...

Breakable silently if private fields are renamed, contradicts the framework's type safety goals.

What changed?

  • core/plugins/registry.ts: Added 3 typed public methods (registerSync, refreshLoadOrder, getPluginsMap)
  • core/framework/server.ts: Replaced 12 private-field accesses with public API calls; removed PluginRegistryInternals interface and getter (-54 lines, +5 lines)
  • tests/unit/core/plugins/registry-sync-api.test.ts: 20 tests covering dependency chains, diamond deps, priority ordering, circular detection, mixed scenarios

Test plan

  • New test file passes (20/20 tests)
  • Full test suite passes (588 passed, 0 failed)
  • bun run dev starts without regressions

🤖 Generated with Claude Code

…ernals hack (#77)

Add typed public methods (registerSync, refreshLoadOrder, getPluginsMap)
to PluginRegistry so the framework no longer needs to bypass private
fields via `as unknown as PluginRegistryInternals`.

Remove the PluginRegistryInternals interface and all 12 encapsulation
violations from server.ts. Add 20 unit tests covering sync registration,
dependency chains, diamond deps, priority ordering, circular detection,
and mixed priority+dependency scenarios.

Closes #77

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@MarcosBrendonDePaula MarcosBrendonDePaula merged commit 3182210 into main Mar 14, 2026
11 checks passed
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.

Adicionar registerSync() ao PluginRegistry para eliminar 11 casts as any

1 participant