|
| 1 | +# DI Convergence Matrix |
| 2 | + |
| 3 | +This matrix captures the corrected steady state after `ARCH-REFACTOR-001`. |
| 4 | +The hosts no longer use separate runtime/provider factory stacks; they converge |
| 5 | +on the shared `AddMcpHost(...)` contract and differ only where host lifetime, |
| 6 | +identity, or UI shell behavior genuinely require it. |
| 7 | + |
| 8 | +## Shared invariants |
| 9 | + |
| 10 | +| Area | Steady state | |
| 11 | +| :--- | :--- | |
| 12 | +| Canonical registration contract | `src/McpServer.UI.Core/Hosting/McpHostBuilderExtensions.cs` via `AddMcpHost(...)` | |
| 13 | +| Shared leaf registration | `AddUiCore(...)` | |
| 14 | +| Host identity abstraction | `IHostIdentityProvider` | |
| 15 | +| Host context abstraction | `IMcpHostContext` | |
| 16 | +| Dispatcher lifetime control | `McpHostLifetimeStrategy.Singleton` or `Scoped` | |
| 17 | +| CQRS logging | Singleton hosts use `AddCqrsLoggerProvider()` through provider-aware logger factories | |
| 18 | +| Legacy runtime/provider wrappers | Removed from `src/` | |
| 19 | + |
| 20 | +## Host matrix |
| 21 | + |
| 22 | +| Host | Host mode | Dispatcher lifetime | Composition root | Identity source | MCP context | Logging shape | Notes | |
| 23 | +| :--- | :--- | :--- | :--- | :--- | :--- | :--- | :--- | |
| 24 | +| Desktop | Command-target | Singleton | `DesktopAppServiceFactory` builds per-connection session providers with `AddMcpHost(...)` | `AvaloniaHostIdentityProvider` | `AvaloniaMcpContext` | `AppLogService` plus `AddCqrsLoggerProvider()` | Main window command target is attached after construction through a deferred accessor. | |
| 25 | +| Android | Command-target | Singleton | `AndroidAppServiceFactory` builds per-connection session providers with `AddMcpHost(...)` | `AvaloniaHostIdentityProvider` | `AvaloniaMcpContext` | `AppLogService` plus `AddCqrsLoggerProvider()` | Preserves Android-specific clipboard, notifications, and lifecycle adapters on top of the shared graph. | |
| 26 | +| Web | Command-target | Scoped | `WebServiceRegistration.AddWebServices()` layers scoped Web overrides on `AddMcpHost(...)` | `WebHostIdentityProvider` | `WebMcpContext` | Scoped dispatcher surfaces stay in request scope; no singleton dispatcher logger provider | Keeps bearer-token forwarding and per-user workspace isolation. | |
| 27 | +| Director | Command-target | Singleton | `DirectorServiceRegistration.Configure(...)` plus `DirectorHost.CreateProvider(...)` | `DirectorHostIdentityProvider` | `DirectorMcpContext` | `LoggerFactory.Create(...)` honoring DI providers plus Serilog file logging and `AddCqrsLoggerProvider()` | All five Director entry points now converge on `DirectorHost.CreateProvider(...)`. | |
| 28 | +| VSIX Todo | Provider-only | Singleton | `McpServerMcpTodoToolWindowPane` uses `AddMcpHost(...)` without `ICommandTarget` | Solution path through `WorkspaceContextViewModel` | Shared workspace context only; no host command target | `AppLogService` shared pipeline | Keeps tool-window-owned `ServiceProvider` disposal and resolves `Dispatcher` directly from DI. | |
| 29 | + |
| 30 | +## Logging convergence |
| 31 | + |
| 32 | +| Concern | Final behavior | |
| 33 | +| :--- | :--- | |
| 34 | +| `AppLogService.AddProvider(...)` | Retains attached `ILoggerProvider` instances and fans out log writes to them | |
| 35 | +| Singleton host CQRS log capture | Registered through `AddCqrsLoggerProvider()` rather than post-build `ILoggerFactory.AddProvider(...)` hacks | |
| 36 | +| Director logger factory | Uses `LoggerFactory.Create(...)` over DI-provided providers, including Serilog | |
| 37 | +| Web logging | Remains scoped and avoids introducing singleton/scoped cycles | |
| 38 | + |
| 39 | +## Identity convergence |
| 40 | + |
| 41 | +| Host family | Bearer token | API key | Workspace path | |
| 42 | +| :--- | :--- | :--- | :--- | |
| 43 | +| Desktop and Android | Mutable Avalonia session state | Mutable Avalonia session state | Active `WorkspaceContextViewModel` path | |
| 44 | +| Web | `BearerTokenAccessor` | ASP.NET configuration | Scoped workspace context, then config fallback | |
| 45 | +| Director | Cached CLI token state | Active or control client configuration | `DirectorMcpContext.ActiveWorkspacePath` | |
| 46 | +| VSIX Todo | Not required for the todo-only host shape | Not required for the todo-only host shape | Active solution directory | |
0 commit comments