fix(features): retract contributed service metadata - #2886
Conversation
- tie contributed service discovery to feature disposal - reject duplicate providers for the same scope and service - cover feature unload and debug channel resolution
|
commit: |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b53d7bb723
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| if (_contributedServices.some((entry) => entry.scope === scope && entry.id === id)) { | ||
| return; | ||
| throw new Error(`Service ${String(id)} is already contributed at scope ${scope}`); |
There was a problem hiding this comment.
Allow duplicate metadata across App roots
When two independent App scopes are alive in the same process, the second FeatureAssemblyService run contributes the same built-in service ids again, but this module-global duplicate check now throws before the second root can finish assembling. The DI providers themselves are scoped per App root; only this debug metadata table is global, so concurrent test hosts/servers or a same-name feature replacement can fail even though the original provider is unrelated to the new root. Consider tracking provider ownership/refcounts and de-duping only in the debug lookup instead of rejecting the second live record.
AGENTS.md reference: packages/agent-core-v2/AGENTS.md:L18-L22
Useful? React with 👍 / 👎.
- remove the global contributed-service test reset - keep provider cleanup local to each regression test
- store feature service metadata in the app-local collection tree - bind debug lookup and test overrides to the owning app root - keep duplicate provider activation atomic within one app
Related Issue
No linked issue.
Problem
Feature-contributed services are removed from the live DI scope when their Feature unloads, but their debug discoverability metadata remained registered. This left the debug channel registry advertising services that could no longer resolve.
What changed
Checklist
gen-changesetsskill, or this PR needs no changeset. This is an internal agent-core-v2 lifecycle fix.gen-docsskill, or this PR needs no doc update.