Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Copilot stopped work on behalf of
hotlong due to an error
February 2, 2026 06:19
Contributor
|
@copilot 继续 |
Copilot stopped work on behalf of
hotlong due to an error
February 2, 2026 06:40
Contributor
|
继续 @copilot |
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
Contributor
Author
Implementation completed! ✅ All tasks finished:
Commits:
The API Registry is now ready for use. Plugins can access it via |
Copilot
AI
changed the title
[WIP] Discuss the implementation of API registration in the kernel
Implement API Registry in the kernel
Feb 2, 2026
- Add auxiliary indices (apisByType, apisByTag, apisByStatus) for O(1) lookups - Optimize findApis() to use indices instead of full array filtering - Add safety guard to clear() method (requires force flag in production) - Add comprehensive documentation about route conflict detection limitations - Clarify ObjectQL schema reference resolution responsibility - Add 20+ new tests for performance optimizations and safety guards - Maintain full backward compatibility All 244 tests passing. Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
- Add ensureIndexSet() helper to reduce duplication in updateIndices() - Add removeFromIndexSet() helper to reduce duplication in removeFromIndices() - Improve code maintainability and readability - No functional changes, all tests still passing Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
- Improve route conflict detection example (use semantically identical patterns) - Extract isProductionEnvironment() helper to avoid duplication - Enhance documentation clarity All tests still passing (244/244) Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
- Add try-finally blocks to ensure NODE_ENV is always restored in tests - Refactor ensureIndexSet to avoid non-null assertion operator - Improve test robustness and code safety All tests passing (244/244) Co-authored-by: xuyushun441-sys <255036401+xuyushun441-sys@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Implements a centralized, kernel-level API Registry service and plugin, aligned with the ObjectStack microkernel architecture, plus protocol-level typing updates and documentation.
Changes:
- Extends the spec API registry schema with input types and clarifies responsibility boundaries for schema resolution.
- Adds an
ApiRegistrycore service with conflict resolution, indexing, and discovery APIs, and exposes it via a kernel plugin (createApiRegistryPlugin) and the core package exports. - Provides comprehensive tests, documentation (
API_REGISTRY.md), and executable examples (api-registry-example.ts) demonstrating registration, discovery, conflict strategies, and multi-protocol usage.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
packages/spec/src/api/registry.zod.ts |
Adds Zod z.input-based input types for responses/entries and expands documentation to clarify that schema resolution is delegated to downstream tools, keeping the registry protocol lightweight. |
packages/core/src/index.ts |
Re-exports the new ApiRegistry service and createApiRegistryPlugin, making them part of the core public API surface. |
packages/core/src/api-registry.ts |
Introduces the ApiRegistry service implementation with Zod-based validation, route conflict strategies, safety-guarded clearing, indexing by type/status/tags, and registry snapshot/statistics APIs. |
packages/core/src/api-registry.test.ts |
Adds a focused Vitest suite validating construction, registration/unregistration, route conflict policies, discovery/indexing behavior, stats, multi-protocol support, and environment-guarded clear(). |
packages/core/src/api-registry-plugin.ts |
Implements createApiRegistryPlugin to instantiate and register a shared ApiRegistry service in the kernel service registry with configurable conflict strategy and versioning. |
packages/core/src/api-registry-plugin.test.ts |
Adds integration tests ensuring the plugin registers the service, works across multiple plugins, respects conflict policies, shares a single registry instance, and participates correctly in the kernel lifecycle. |
packages/core/examples/api-registry-example.ts |
Provides end-to-end usage examples showing basic registration, multi-plugin discovery, conflict resolution, custom protocol metadata (WebSocket), and dynamic ObjectQL schema references. |
packages/core/API_REGISTRY.md |
Documents the API Registry architecture, configuration, RBAC integration, dynamic schema linking, protocol-specific configuration, public methods, test commands, and links to related specs and tests. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
API Registry Implementation in Kernel
Based on the problem statement "是否应该在内核实现API注册表?" (Should an API registry be implemented in the kernel?), this PR implements a centralized API registry service in the ObjectStack kernel/core package.
Implementation Plan
packages/core/src/api-registry.tsFeatures Implemented
✅ Centralized endpoint registration and discovery
✅ Route conflict detection with configurable resolution strategies (error, priority, first-wins, last-wins)
✅ RBAC permission validation support - endpoints can specify required permissions
✅ Dynamic schema linking with ObjectQL references - ready for future integration
✅ Protocol-specific configuration support - supports gRPC, tRPC, WebSocket extensions
✅ Plugin API registration capabilities - plugins can register custom APIs
✅ Kernel Integration - API Registry available as a service via
createApiRegistryPlugin()✅ Runtime Validation - Uses Zod schema parsing for type safety
Test Coverage
All 82 tests passing:
Test categories:
Security
✅ CodeQL Scan: 0 vulnerabilities found
✅ Runtime Validation: Zod schema parsing ensures input validation
✅ Type Safety: Full TypeScript support with Input/Output types
Documentation
Architecture Alignment
The API Registry follows the microkernel pattern where the kernel provides core services (DI, Events, Logging, API Registry) that plugins can use to register their endpoints.
Plugins can access the API Registry through the kernel's service registry:
Original prompt
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.