Skip to content

Commit b07bfe6

Browse files
committed
refactor: finish ARCH-REFACTOR-001 convergence
1 parent 11722d5 commit b07bfe6

98 files changed

Lines changed: 6295 additions & 702 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# DI Convergence Diagram
2+
3+
This diagram reflects the post-refactor steady state for `ARCH-REFACTOR-001`.
4+
All five hosts now compose their shared MCP/UI graph through `AddMcpHost(...)`,
5+
while still preserving the two supported host shapes:
6+
7+
- Command-target hosts: Desktop, Android, Web, Director
8+
- Provider-only hosts: VSIX todo tool window
9+
10+
```mermaid
11+
graph TD
12+
AddMcpHost[AddMcpHost options]
13+
14+
AddMcpHost --> Lifetime[McpHostLifetimeStrategy]
15+
AddMcpHost --> Identity[IHostIdentityProvider]
16+
AddMcpHost --> Context[IMcpHostContext]
17+
AddMcpHost --> Logging[Logging pipeline]
18+
AddMcpHost --> HostMode[Host mode]
19+
20+
Lifetime --> Singleton[Singleton dispatcher]
21+
Lifetime --> Scoped[Scoped dispatcher]
22+
23+
Identity --> AvaloniaIdentity[AvaloniaHostIdentityProvider]
24+
Identity --> WebIdentity[WebHostIdentityProvider]
25+
Identity --> DirectorIdentity[DirectorHostIdentityProvider]
26+
27+
Context --> AvaloniaContext[AvaloniaMcpContext]
28+
Context --> WebContext[WebMcpContext]
29+
Context --> DirectorContext[DirectorMcpContext]
30+
31+
Logging --> AppLog[AppLogService composite logger factory]
32+
Logging --> CqrsProvider[AddCqrsLoggerProvider]
33+
Logging --> Serilog[Director LoggerFactory plus Serilog provider]
34+
35+
HostMode --> CommandTargetMode[Command-target host]
36+
HostMode --> ProviderOnlyMode[Provider-only host]
37+
38+
CommandTargetMode --> Desktop[Desktop]
39+
CommandTargetMode --> Android[Android]
40+
CommandTargetMode --> Web[Web]
41+
CommandTargetMode --> Director[Director]
42+
ProviderOnlyMode --> Vsix[VSIX Todo pane]
43+
44+
Desktop --> Singleton
45+
Android --> Singleton
46+
Director --> Singleton
47+
Web --> Scoped
48+
Vsix --> Singleton
49+
```
50+
51+
## Notes
52+
53+
- `AddUiCore(...)` remains the leaf shared registration API underneath `AddMcpHost(...)`.
54+
- Desktop and Android build per-connection session providers through their app service factories, then attach the main-window command target after construction.
55+
- Web stays scoped to preserve bearer-token and workspace isolation per request/circuit.
56+
- Director now has one provider entry point: `DirectorHost.CreateProvider(...)`.
57+
- VSIX uses `AddMcpHost(...)` without an `ICommandTarget`, resolving `Dispatcher` directly from the built provider.
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

Comments
 (0)