Resolve discovered command and query extension points from the request scope - #2529
Conversation
…t scope The collections that hold Arc's discovered extension points - command response value handlers, command filters, command execution scopes and query filters - are singletons, and IInstancesOf<T> resolves each implementation from the IServiceProvider that constructed it. For a singleton that is the root provider, where an implementation depending on a scoped service cannot be created at all: the container rejects it outright once scope validation is on, which is what the host enables in Development. Every Chronicle command response value handler depends on the scoped IEventLog, so a Development application throws on every command that returns an event. Keep the collections singletons - they are held by the command and query pipelines, which are singletons because they create the scope the work runs in - and resolve their implementations from that scope at the point of use instead, through the IServiceProvider already carried on CommandContext and QueryContext. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Covers the defect from both ends: a real Development host with scope validation on, resolving a command response value handler that needs a scoped service, and unit specs pinning that each collection resolves from the scope the work carries rather than the provider that constructed it. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
It is a lifetime detail of the pipelines that use it, not public surface, matching the sibling ParameterDependencyResolver in the same namespace. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
Reviewer context. The mechanism is one step further down than #2505 describes. This matters for the choice of fix: it is not about when handlers are built, it is about which provider builds them. Why resolve-per-invocation rather than a scoped registration. Making the collections scoped only moves the failure. Resolving from the scope at the point of use is what Arc already does everywhere else in this pipeline: Audit of the siblings in
Scope note — this PR also fixes Verification. The four unit specs were run against the unfixed source: 9 of the 10 facts fail, and the host spec fails with the exception above. With the fix, all pass. Debug and Release builds clean with zero warnings on Not verified: no Chronicle-backed application was started end to end against these bits. The host spec reproduces the exact container failure with a stand-in scoped service rather than the real |
Fixed
IEventLogcould not be created once the host turned scope validation on, and every such command threw. (Arc 21.1.0 cannot start a Development app that uses a Chronicle command response value: its own handler is resolved from the root provider but needs a scoped IEventLog #2505)