Skip to main content

Composition and service registration

The authoritative server composes explicit module registrations through AddAgentstration and named host extensions. ADR-0189 records the ownership and selection rules. This map covers production registration sites affected by #240, including the Console and API projects extracted since the original issue.

Each row assigns the complete registration body of its methods, including aliases, options, framework builders, typed/named HTTP clients and helper-generated descriptors. Façades delegate ownership; dictionary TryAdd calls in business services are outside this DI inventory. Project/source paths below are relative to src/Agentstration..

Infrastructure pipeline​

Infrastructure/DependencyInjection.cs retains both public AddAgentstration overloads. The options overload constructs validated shared composition state before adding descriptors, then invokes these internal extensions in order. Each lives in Infrastructure/Composition/{Owner}ServiceCollectionExtensions.cs.

Owner/file prefixExtensionComplete responsibility
FoundationAddAgentstrationFoundationClock, bootstrap fallback, shared request/trigger context and aliases, resource reference/scope services, GenAI fallback options/handler, Management events.
AiAddAgentstrationAiAI options and mutually exclusive deterministic or OpenAI-compatible fallback client; Managed mode delegates resolution to Model Providers.
StorageAddAgentstrationStorageStorage selection/options, initialization coordinator, Workspace provisioning aliases, initializer and one provider's control, Resource Planning, Runtime, Work and Flow stores.
StorageResourcesAddStorageResources (called by AddAgentstrationStorage)Storage type/resource services, neutral resolver/content gateway, pure local definition validation, AEP type provisioning, protected invocation, local backend and idempotent defaults. Artifact composition registers the exact-receipt usage provider and durable adapter alias.
SecurityAddAgentstrationSecurityMaster key/Vault providers, resource identity/access policies, Parameters, Secrets/capabilities, Principal/topology provisioning, authorization, administrator/external-identity lifecycle, auditing, membership/preferences/PAT services.
BootstrapAddAgentstrationBootstrapHandlersScoped declarative resource handlers, including StorageType and Storage; local-account/administrator handling stays in Identity.
ResourcePlanningAddAgentstrationResourcePlanningPlan validation/materialization/options/state reader, Plan/ChangeSet services and canonical validation/application adapters.
AgentsAddAgentstrationAgentsCompilation, runtime resolution/access, deferred profile-validator and single-client resolver defaults, deployment reconciliation, routing, retention and execution/preparation aliases.
PacksAddAgentstrationPacksArchive/artifact stores, all resource handlers, workspace catalog, management, authoring, composition and Source-catalog Pack integration.
SourcesAddAgentstrationSourcesScope/manifest/verification, bounded HTTP clients, snapshot/cache stores, Channel materialization/refresh, catalog readers/resolution, Registry management/trust/discovery.
SchemasAddAgentstrationSchemasBuilt-in and AEP format contributions/options, registry, management and binding adapter.
ToolsAddAgentstrationToolsMCP module, Tool/ToolSet/category/definition/hook services, enrollment provisioners, artifact guard, capture default, Runtime/Flow audit sinks, governance/pipeline and Flow Tool adapters.
TriggerSchedulingAddAgentstrationTriggerSchedulingSchedule/context/target/authorization/Work adapters, management/firing, Quartz persistence and ordered optional scheduler hosting.
RuntimeRunsAddAgentstrationRuntimeRunsAWP queue/scope, Run state/lifecycle, Worker lease/dispatch options/signals/guards, assignment projection, execution material/operation gateways and observability.
ArtifactsAddAgentstrationArtifactsArtifact filesystems, staging executor, management/materialization, built-in provisioners, cleanup options and optional worker.
WorkPlaneAddAgentstrationWorkPlaneExecution gateway/queue aliases, Work/Workplace lifecycle/projections/discovery/operations, Task deletion, Entries/Dashboards, concrete Entry deletion guard and its resource-guard alias, and Flow input projection/response.
InternalToolsAddAgentstrationInternalToolsNotification Tool, documentation catalog, all explicit diagnostics/time/planning/artifact/acquisition/retrieval Tool contributions, projection and lazy collection. AddInternalTool<TTool> owns each concrete Tool and its definition/handler aliases.
DataAndKnowledgeAddAgentstrationDataAndKnowledgeData Source profiles/discovery/targets/acquisition, HTTP fetcher, Knowledge management/projection/retrieval/Snapshots/exposure, Flow/artifact adapters, AEP bundle installer and optional recovery worker.
FlowPlaneAddAgentstrationFlowPlaneScope/discovery/Agent/Tool resolution, guards/retention, Run queue/cancellation/scope/accessor, root submission, default sink, expression parser aliases, validation/artifact capture/drafts/Runs.

AgentstrationCompositionOptions groups the data directory, AI/storage choices, optional per-plane SQLite connection strings, hosting toggle, Source verification/transport limits and Worker lease/dispatch options. The compatibility overload maps its existing arguments to this object. AgentstrationCompositionContext validates and selects storage before mutation; registration performs no initialization, bootstrap or discovery.

Module-owned extensions​

The following extensions retain their complete registration bodies. Calling them does not transfer ownership to Infrastructure or a host.

Project/sourceOwner extensionRegistration scope
Models.Application/ModelManagementServiceCollectionExtensions.csAddAgentstrationModelManagementProvider management/discovery/configuration, Parameter usage contribution, Profile management/migration/stores and authoritative validator.
ModelProviders/ModelProviderServiceCollectionExtensions.csAddAgentstrationModelProvidersConfigured AEP security/GenAI options, capture handler, HTTP provider transport/aliases, Source materialization, provider resolver and optional Managed profile resolver.
Tools.Mcp/McpToolCatalog.csAddAgentstrationMcpToolsConfiguration/security defaults, three named HTTP clients, extension/environment resolution, transport, catalog/discovery/runner/invoker.
Security.AspNetCoreIdentity/LocalIdentityDatabaseServices.csAddAgentstrationLocalIdentity → AddAgentstrationIdentitySQLite selection, EF Identity context/stores, claims factory, bootstrap/account/security/authentication services, lock/initializer and Data Protection persistence.
Security.AspNetCoreIdentity.PostgreSql/PostgreSqlIdentity.csAddAgentstrationPostgreSqlIdentity → AddAgentstrationIdentityPostgreSQL context/migrations selection and the shared Identity registration.
ResourceManagement.Storage.Sqlite/SqliteResourceStore.csAddSqliteResourceManagementContext/governance defaults, EF factory, resource/query/scope/policy/Trigger stores and Identity/audit/PAT aliases. AddSqliteControlPlane delegates for compatibility.
ResourceManagement.Storage.PostgreSql/PostgreSqlResourceStore.csAddPostgreSqlResourceManagementEquivalent PostgreSQL contracts. AddPostgreSqlControlPlane delegates for compatibility.
ResourcePlanning.Storage.Sqlite/SqliteResourcePlanRepository.csAddSqliteResourcePlanningEF factory and Plan/ChangeSet persistence.
ResourcePlanning.Storage.PostgreSql/PostgreSqlResourcePlanRepository.csAddPostgreSqlResourcePlanningPostgreSQL EF factory and Plan/ChangeSet persistence.
Runtime.Storage.Sqlite/SqliteRuntimeRunStore.csAddSqliteRuntimeRunsRuntime EF factory and Run/event/assignment persistence.
Runtime.Storage.PostgreSql/PostgreSqlRuntimeRunStore.csAddPostgreSqlRuntimeRunsEquivalent PostgreSQL Runtime persistence.
Work.Storage.Sqlite/WorkStorageSchema.csAddSqliteWorkPlaneWork EF factory and Work/Interaction/Task/Entry/Dashboard/notification persistence.
Work.Storage.PostgreSql/PostgreSqlWorkItemRepository.csAddPostgreSqlWorkPlaneEquivalent PostgreSQL Work persistence.
Flows.Storage.Sqlite/SqliteFlowRepository.csAddSqliteFlowStorageFlow EF factory and definition/Run persistence.
Flows.Storage.PostgreSql/PostgreSqlFlowRepository.csAddPostgreSqlFlowStorageEquivalent PostgreSQL Flow persistence.
Web.Components/ServiceCollectionExtensions.csAddAgentstrationWebComponentsCircuit state/navigation, clock and empty context/search/status/palette/conversation/preferences defaults.
Web.Components/Localization/AgentstrationLocalization.csAddAgentstrationLocalizationRESX localization and validated localization/request-culture options.
Web.FlowDesigner/DependencyInjection/FlowDesignerServiceCollectionExtensions.csAddAgentstrationFlowDesignerScoped editor state; backend/resource adapters stay in their hosts.
Workplace.Client/WorkplaceApiClient.csAddAgentstrationWorkplaceClientTyped Workplace API and reconnecting realtime client.

SQLite and PostgreSQL rows are alternatives. The standalone host selects local-account Identity with the same provider, and Quartz uses that provider's scheduler store. Existing lifetimes and separate persistence boundaries remain unchanged.

Authoritative host and transport​

Web/Program.cs creates, composes, builds, configures, initializes and runs. Web/Hosting/StandaloneHostComposition.cs reads the standalone profile/configuration and paths, delegates registration, and keeps endpoint mapping and ordered startup explicit. Web/Hosting/StandaloneHostServiceCollectionExtensions.cs owns:

Owner extensionComplete registration scope
AddAgentstrationBootstrapHostingConfigured bootstrap/capture options and scoped declarative bootstrap service.
AddAgentstrationExtensionHostingSource Provider/Extension management/inventory, AEP enrollment/settings/policy/discovery/provisioning, AWP identity, standard Runtime Profile seeder and scope inventory.
AddAgentstrationServerPresentationAPI façade, optional Razor/interactive rendering and localization.
AddAgentstrationHostIdentitySelected SQLite/PostgreSQL local-account Identity.
AddAgentstrationBackgroundWorkersOptional Work execution, assignment lease reaper, Flow recovery and Source refresh workers.
AddAgentstrationTestingCleanupPrivate test-directory cleanup with its selected SQLite connection strings.
AddAgentstrationHostObservabilityLogging/tracing/metrics and optional OTLP with existing source/meter configuration.

Api/Configuration/ApiTransportServiceCollectionExtensions.cs preserves AddAgentstrationApi, owns SignalR/Problem Details, and delegates to the existing family Add*Api extensions and these focused methods:

Owner/sourceComplete registration scope
AddAgentstrationBootstrapTransport in API compositionBootstrap catalog, Source loader, admission/execution locks, profile management/API alias and the hosted durable application processor (ADR-0246).
AddAgentstrationConsoleResourceQueries in API compositionSource Console query service/alias and Resource scope API service.
AddAgentstrationRealtimeProjection in API compositionWorkplace Flow conversation projection and explicit composite Flow sink selection.
AddIdentityApi in Identity.Api/IdentityApiModule.csFaçade over AddAgentstrationWorkloadTrust (BFF/AWP/delegation options, keys/caches/services and trust-audit worker), AddAgentstrationEnrollmentRateLimiting, AddAgentstrationApiAuthentication (scheme selection/token validation), and AddAgentstrationApiAuthorization (handlers/policies).
AddFlowsApi in Flows.Api/FlowsApiModule.csConcrete SignalR Flow Run sink consumed by the composite.
AddWorkplaceApi in Workplace.Api/WorkplaceApiModule.csSignalR Workplace event sink.
AddAgentstrationOpenApi in Api/Configuration/OpenApiConfiguration.csOpenAPI document/security/schema transformers.

Other family API extensions aggregate owned endpoints without relocating application registrations. Shared API authentication/authorization also serves the embedded Console; scheme selection retains its configured order.

Console hosts​

Web/Configuration/WebConsoleServiceCollectionExtensions.cs preserves AddAgentstrationWebConsole. Its façade owns validated API options and the HTTP context accessor, then delegates:

Embedded Console ownerComplete registration scope
AddAgentstrationConsoleComponentsShared UI/Designer, concrete context/search/palette/status adapters and designer ports.
AddAgentstrationConsoleApiClientsAll Management/Work/Runtime/Flow and cleanup clients, event stream/preferences, sensitive no-retry clients, context factory and helper-owned handler/resilience configuration.
AddAgentstrationConsoleRealtimeShared standalone realtime session/configurator and scoped Work operations client.

Console.Web/Configuration/ConsoleHostServiceCollectionExtensions.cs preserves AddAgentstrationConsoleHost, delegating to:

Independent Console ownerComplete registration scope
AddAgentstrationConsoleOptionsValidated API endpoint options.
AddAgentstrationConsoleComponentsShared UI/Designer, concrete context/search/status and designer adapters.
AddAgentstrationConsoleApiClientsAll API/cleanup/event/preferences clients, enumerable audience/origin targets, scoped BFF/context HTTP factories and client configuration helpers.
AddAgentstrationConsoleRealtimeClientIndependent realtime configurator and Work operations client.
AddAgentstrationConsoleBffAuthenticationWorkload/session options, store/cache/token provider, cookie postconfiguration, signing handler, workload/session/delegation clients and cookie authentication.
AddAgentstrationConsoleAuthorizationConsole authorization services.

Console.Web/Configuration/ConsolePresentationServiceCollectionExtensions.cs owns AddAgentstrationConsolePresentation (Razor, localization, Problem Details/health) and AddAgentstrationConsoleObservability (traces/metrics and optional OTLP). These client-host registrations add no authoritative stores or execution workers.

Workplace executable root​

Workplace.Web/Program.cs deliberately retains its small composition: interactive Razor, shared UI/localization, recent-conversation adapter, HTTP context accessor, transient API session handler, scoped realtime configurator, typed Workplace/preferences clients with session/redirect handlers, Problem Details, health and OpenTelemetry. API/hub origin validation remains here. Module ownership for the shared/client extensions is listed above; no authoritative application/store is registered.

Defaults, selections and contributions​

Exactly-one contracts have one descriptor in the standard graph. Clock/context/GenAI defaults, the deferred profile validator, single-client resolver and Flow no-op sink use TryAdd*. Model management explicitly replaces the validator; configured Model Providers replace AEP security/GenAI options and the Managed resolver, while capture uses TryAddTransient. API composition replaces the Flow sink with its composite. Concrete Console providers/clients replace shared-component empty defaults. The independent BFF explicitly selects its scoped IHttpClientFactory adapter while retaining the framework singleton IHttpMessageHandlerFactory that owns named handlers. Runtime Run execution has one scope descriptor. Flow execution shares WorkspaceFlowRunExecutionScope with the ambient member of Work's ordered scope-accessor collection.

Multiple registrations below are intentional enumerable or framework contributions:

ContractContribution owners/set
ISecretVaultProviderLocal encrypted and shared-key file providers in Security.
IBootstrapResourceHandlerSixteen Infrastructure handlers plus Identity's administrator/local-account handler.
IPackResourceHandlerEleven resource-family handlers in Packs, in explicit source order.
IAepEnrollmentResourceProvisionerTool and bundle provisioners in Tools.
IToolExecutionEventSinkRuntime and Flow sinks in Tools.
IFlowVersionActivationGuardTool Definition, Knowledge, Artifact transformation and Data Source guards in Flow.
IFlowDeletionGuardFlow composition registers Tool Definition, Knowledge and Entry guards in that order; Work owns the concrete shared Entry guard.
IWorkExecutionScopeAccessorFlow composition preserves the HTTP request accessor CurrentWorkExecutionScopeAccessor, then the ambient WorkspaceFlowRunExecutionScope alias. Work submission services consume this ordered collection to support request and background execution contexts.
Internal MCP definition/handler portsNotification plus every explicitly listed internal Tool, sharing concrete singletons through aliases.
Model provider/validation/discovery/capability and extension inspection portsAEP contributions in Model Providers preserve provider-neutral collection contracts.
IParameterUsageProviderModel Provider reference checks from Model management.
IAuthorizationHandlerPermission/resource-permission, Platform administrator and interactive-user handlers in Identity API.
BffDelegationTargetNamed-client audience/origin targets in independent Console client composition.
Framework options, HTTP clients, EF configuration, authentication schemes and telemetry/logging providersNamed/configuration contributions owned by their listed extension.
IHostedServiceExplicit scheduler, recovery, cleanup, security-audit and host-worker contributions below.

Quartz hosting preserves its significant order: logging initialization, SQLite schema initialization when selected, Quartz hosted scheduler, then Trigger reconciliation. Infrastructure separately owns staged Artifact cleanup and Data Source acquisition recovery. The host adds Work execution, assignment lease reaping, Flow recovery and Source refresh. Identity API's BFF trust-audit service retains its independent lifecycle.

Testing disables the optional application/scheduler worker set by default; Agentstration:Testing:HostedServicesEnabled enables it. Agentstration:Testing:OpenTelemetryEnabled independently controls server telemetry. The transport security audit service remains registered under either worker setting. Cleanup retains ownership of only its private paths/pools. Endpoint mapping and ordered initialization remain outside registration.

Descriptor tests inspect service type, lifetime, selection and cardinality before provider construction, then validate SQLite/PostgreSQL and deterministic/Managed graphs with ValidateOnBuild and ValidateScopes. Host lifecycle tests cover workers/telemetry. New registrations belong in the appropriate owner and must update tests when these contracts change.

Additional startup configuration​

The authoritative host loads and validates the frozen additional-settings selection before diagnostics/options/service composition. Core and selected GUID Bootstrap applications then reuse the existing fenced phases and catalogue validation with independent directory references. See ADR-0274.