You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add polyglot hosting integrations through ATS projection - #16110
Part of #16220. Adds support for hosting integrations authored outside .NET through Aspire's ATS metadata, SDK generation, and runtime dispatch pipeline. A consuming AppHost gets normal generated builder methods, while the integration executes in its own runtime and configures the same .NET resource model as a managed integration.
Integration-host ownership belongs to the AppHost server rather than the CLI. The CLI and server share process execution, command resolution, containment, and owner-liveness primitives instead of maintaining independent launching and polling implementations.
The PR includes TypeScript-authored Kafka and Deno examples, plus a real, packable @aspire/nuxt preview integration. TypeScript integration hosting is implemented today. The metadata contract is intended to support other authoring languages without making the consumer depend on the integration's language.
Architecture
flowchart TB
Config["aspire.config.json<br/>Managed packages + external integration entry points"]
CLI["Aspire CLI<br/>Restore, bootstrap, session launch, diagnostics"]
Guest["Guest AppHost<br/>Generated fluent SDK"]
subgraph Server[".NET AppHost server process"]
Session["Server session<br/>Integration discovery and supervision"]
Managed["Managed integration assemblies<br/>AspireExport capabilities"]
ATS["Merged ATS metadata<br/>Consumer SDK generation"]
Dispatch["Capability dispatcher<br/>Shared handles and callback routing"]
Model["Authoritative .NET resource model<br/>Resources, annotations, deferred configuration"]
end
subgraph External["External integration process scope"]
Guardian["Server-owned guardian<br/>Parent liveness + OS containment"]
Host["TypeScript integration host<br/>Generated runIntegrationHost runtime<br/>Author code + generated core SDK"]
end
subgraph Restore["Dependency-install process scope"]
InstallGuardian["CLI-owned guardian<br/>Same shared supervisor and OS containment"]
Npm["npm install<br/>Lifecycle scripts and workers"]
end
DCP["DCP / container runtime"]
Workloads["Application workloads<br/>Nuxt, Deno, Kafka, backend services"]
Config --> CLI
CLI -.->|starts and owns| Session
CLI -.->|starts guest runtime| Guest
Session -.->|supervises| Guardian
Guardian -.->|launches node --import tsx directly| Host
CLI -.->|owns during integration restore| InstallGuardian
InstallGuardian -.->|launches and contains| Npm
Session -->|loads and scans| Managed
Managed -->|capability metadata| ATS
Host -->|getCapabilities| ATS
ATS -->|generated SDK| Guest
Guest -->|invokeCapability JSON-RPC| Dispatch
Dispatch -->|in-process invocation| Managed
Dispatch <-->|external invocation, core API calls, callbacks| Host
Managed -->|configures| Model
Model -->|workload orchestration| DCP
DCP --> Workloads
Loading
Dashed arrows show process-launch and lifetime responsibility; solid arrows show metadata, invocation, or workload flow. The external host connects back to the server over authenticated JSON-RPC. The guardian is a separate supervisor process, not part of the integration's event loop. Application workloads created through the resource model belong to DCP/the container runtime, not to the integration host's descendant tree.
The important separation is:
CLI: resolves configuration, restores dependencies inside a CLI-owned guardian scope, launches the server and guest AppHost, and retains linked diagnostics. It does not directly launch or supervise runtime integration hosts.
AppHost server: owns the resource model, managed integrations, external-host discovery and supervision, the merged ATS contract, and capability/callback routing.
Integration host: advertises its exported methods and executes author code against its generated core SDK. Resource handles refer back to server-owned objects; this is not a second resource model.
The architecture document distinguishes this implementation from the future Native AOT direction. Today the single runtime representation is server-owned C# objects. The target is one ATS-native runtime model, backed by core C# primitives and consumed through language projections, not parallel CLR and ATS models. This PR does not implement that runtime or an AOT server.
Authoring and invocation model
Integration authors write ordinary TypeScript functions using generated hosting APIs. AspireExport(metadata, function) marks methods for projection, and defineIntegration(...) collects the package's capabilities. The generated SDK also emits runIntegrationHost, which handles connection setup, authentication, registration, metadata discovery, dispatch, and callback transport. Packages do not copy private RPC/bootstrap boilerplate.
Integration hosts reuse the normal AspireClient transport for marshalling, structured errors, cancellation, and fluent work. Each export and inbound callback gets its own async promise scope, so unawaited fluent continuations complete before the request returns without making concurrent exports or reentrant callbacks wait on each other. Deferred guest callback relays survive export return and belong to both participating connections. Void guest callbacks apply returned positional DTO properties to the integration's original argument objects according to the callback projection. Non-DTO arguments and ordinary return-value callbacks are unchanged.
For an exported integration, there is one delivery path regardless of the consumer's language:
The server gathers managed exports and the external host's capability metadata into one ATS context.
Codegen projects that context into the consumer's fluent SDK.
A generated call such as builder.addNuxtApp(...) reaches the server dispatcher, which forwards it to the owning integration host.
The integration uses its own generated core SDK to call managed hosting APIs and configure server-owned resources.
Plain same-language helper libraries can still be imported and called directly. That library pattern does not need an integration-host process, but it also does not contribute exported methods to another language's generated SDK.
Configuration and bootstrap
External integrations currently use explicit entry-point paths in aspire.config.json. For the installed Nuxt preview package:
Restore, run, and publish share a two-pass bootstrap:
A temporary server skips external hosts, generates the managed SDK, and allows the required dependencies to be installed.
That server is disposed before the final server starts the configured integration hosts, discovers their capabilities, and generates the combined SDK.
The final SDK is not generated until every configured host has registered and completed capability discovery. Registration and discovery have per-host bounds; missing hosts, early exits, invalid metadata, and duplicate capability IDs fail startup rather than silently freezing an incomplete SDK.
The server obtains launch commands through the language provider's optional, reflection-discovered JSON GetIntegrationHostSpec() hook. Launch metadata remains internal, without adding a new member or contract type to the shared ILanguageSupport interface. Paths resolve relative to the configuration file that declares them.
Server-session configuration is parsed and validated once by IntegrationHostConfiguration. IntegrationHostProcessLauncher resolves commands and owns contained process creation through an injectable factory; IntegrationHostLauncher coordinates readiness, recovery, and shutdown. Failed launches dispose their executions, and launch plus cleanup failures retain both causes. Accepted RPC connections are closed and logged if service activation or connection setup fails.
TypeScript hosts launch directly as node --import tsx <entryPoint>; there is no npx/tsx wrapper process. Command lookup fails with actionable installation guidance. Dependency installation uses the CLI's process factory, forwards both output streams, closes unused stdin, and verifies the complete guardian scope is gone before accepting npm's private completion status.
TypeScript-authored Nuxt integration
src/Aspire.Hosting.Nuxt contains @aspire/[email protected], a TypeScript-authored npm package, not a C# wrapper or a NuGet integration. It is packable but has not been published to npm. Consumers install the tarball and explicitly configure its host entry point; npm registry discovery through aspire add is not implemented yet.
addNuxtApp runs the development script locally and publishes Nitro's standalone .output with .output/server/index.mjs as the production entry point. withNuxtReference projects deferred endpoint references into Nuxt runtime configuration, so local endpoints become deployment-native addresses at publish time. Existing JavaScript hosting APIs remain available.
The package includes its compiled implementation and generated core SDK. CI packs it, installs it into a separate consumer, runs a real Nuxt dev server and backend, verifies server-rendered backend data, then publishes, builds, and runs the generated production images. The sample is in playground/NuxtApp. Current prerequisites are Node.js 22.12+, a TypeScript AppHost, and Docker for production-image validation; Nuxt 4 with the Node-server Nitro preset is the validated scenario.
The Deno example remains the deeper deferred-callback exercise: argument replacement, build tasks, Dockerfile generation/adoption, certificate trust, and executable debug metadata. Its state is stored as resource-attached annotations rather than in a process-local map of resource handles.
Process ownership and recovery
The current implementation launches each external runtime through a server-owned guardian. Unix containment uses a session/process group; Windows uses a kill-on-close job. The guardian watches the server's process identity independently of integration code, so a blocked Node event loop is not the only mechanism available for cleanup. Registration uses a fresh identity for each launch attempt.
Failure
Current behavior
Startup, registration, or discovery failure
Fail readiness, retain diagnostics, and clean up already-launched hosts.
Callback-free integration runtime or guardian failure
Clean up the old scope before replacement; rediscover and validate the same capability IDs and projection signatures. Up to three retries with 1/2/4-second backoff.
External capability stalls or its request is canceled
Bound the call, retire the connection, and clean up the old process scope before recovery. Never replay the call. Callback owners require session restart.
Deferred guest callback stalls
Bound the relay, retire both connections, and require session restart to rebuild captured callbacks.
Integration host that has contributed callbacks fails
Stop the AppHost session with explicit restart-required diagnostics. aspire start rebuilds the resource model and callbacks.
AppHost server or owning CLI dies
End the session and reap the integration scope; recovery requires explicit restart.
CLI dies during integration dependency installation
The independent guardian reaps npm, blocked lifecycle scripts, and descendants; the user explicitly reruns restore.
Recovery budget exhausted or old-scope cleanup fails
Stop the session and surface the failure instead of starting another owner.
Metadata rediscovery is not callback recovery. Deferred callbacks capture the old connection and process-local callback IDs. A replacement host cannot reconstruct those closures merely by advertising the same methods. Callback admission is retired atomically with failure handling, and all admitted integration-owned delegates are conservatively treated as potentially persistent. Callback-free recovery preserves server-owned handles, not arbitrary integration-local state. In-flight calls fail and are never replayed because they may already have mutated the model.
External invocations and callbacks each default to an independent one-minute deadline. The server setting IntegrationHost:InvocationTimeout accepts a positive TimeSpan, also configurable through IntegrationHost__InvocationTimeout. Registration/discovery, callback, shutdown/output-drain, and recovery policy are also configurable and validated centrally. Outer callback budgets must exceed inner invocation budgets when callback-free integration recovery is desired. An injected TimeProvider drives deadlines and recovery. Server/runtime diagnostics and startup profiling activities correlate invocation IDs, capability, connection, runtime PID, elapsed time, deadlines, cancellation, callback lifecycle, and cleanup/recovery. Responsive runtimes report their active phase every ten seconds; a blocked event loop remains bounded by the server deadline. Hosts advertising protocol version 2 receive correlation IDs; older hosts retain the two-argument wire shape without changing capability signatures.
Guardian diagnostics use a structured ILogger bridge over inherited stderr, decoded by the owning process with the original severity preserved. Raw AppHost server stdout and stderr are retained at Debug in the CLI file log rather than printed during normal usage; collected startup failures are surfaced at Error. Expected launch cancellation is Debug, and malformed guardian records produce a warning while remaining available through ordinary stderr forwarding. Diagnostics do not add authentication tokens or invocation payloads.
The process plumbing is source-shared across the net11 CLI and net10 AppHost server. ChildProcess owns the common graceful-shutdown ladder, bounded force escalation, contained descendant-cleanup verification, output draining, and process-handle disposal. The CLI's ProcessExecution supplies its existing command-wide shutdown window and process-tree signaler rather than implementing another ladder. ProcessScope only retains ownership and the root-exit signal; it no longer implements OS termination or cleanup deadlines. Contained cleanup also works without that wrapper or after guardian death. Shutdown policy is evaluated when teardown begins, and cancellation plus termination failures retain both causes.
The guardian establishes Unix process-group or Windows kill-on-close-job containment and independently monitors owner liveness using the existing stable-identity parent monitor. Its runtime cleanup uses the same shared execution. Windows batch formatting is also shared with the net8/net472 MSBuild task. Cleanup failures are logged and prevent replacement; operation and cleanup errors are retained together.
Automatic full-session replay and transparent callback rebinding are not implemented. Intentionally escaping the guardian's process scope is unsupported. Persistent containers are an explicit workload policy, not proof of integration-process cleanup. Authoring providers beyond TypeScript and richer custom-resource/package-manager support are outside the scope of this PR.
Supporting hosting APIs
Resource-scoped annotations: stable annotation IDs and typed JSON payloads, with generated serialized-annotation capabilities and TypeScript helpers. Bare resource handles work in deferred callbacks, not only builder handles.
Deferred argument replacement:CommandLineArgsEditor.clear() lets a callback recompute final arguments after configuration is complete.
Certificate and debug projection: runtime-specific certificate environment variables and VS Code executable launch metadata without exposing the corresponding generic .NET APIs directly.
Callback and handle transport: integration-owned callback execution, uniquely identified connection-owned deferred guest callback relays, recursive handle wrapping, and shared server-owned handle resolution across integration connections.
AppHost-relative paths:builder.appHostDirectory() separates application paths from the integration package's own working directory.
Security considerations
External integration hosting executes project-configured packages and entry points, accepts authenticated integration registrations, and routes callbacks and shared resource handles. Opaque random handle IDs prevent sequential enumeration; passing a handle delegates access to its object. These mechanisms are not a sandbox for locally running integration code.
Configuration/package trust, command arguments, registration and callback ownership, annotation access, and process containment still require a threat model and security review before release.
Validation
Current head: 6d3a718b3e. Matching-head CI run 37637520546, attempt 2 completed successfully: 336 passing checks and six skips, with no pending or failed checks. Both Windows/Linux RemoteHost suites and all nine hostile lifetime E2Es passed. Guest callback relays now honor IntegrationHost:CallbackTimeout independently of external capability invocation deadlines, including their structured diagnostics and surfaced timeout errors.
Current CI retry caveat: the extension Windows producer failed restoring supports-color from the internal npm feed with HTTP 429, so downstream extension E2Es could not download the aspire-extension artifact. Separate hosting failures were MongoDB replica readiness, a Windows file-app marker read blocked by a file lock, and a Windows rebuild-command state assertion (expected 2, actual 3). The callback fix did not modify those tests or extension inputs. Both a failed-jobs rerun and a targeted extension-producer rerun were initially rejected by GitHub with HTTP 500; a later failed-jobs rerun was accepted and passed. No code or assertions changed for the retry, and its success does not establish the causes or prove those failures fixed.
The previous merge head 4c0e1a09d4, merging main at 809a672cc4, passed CI run 37575522858, attempt 3: 337 passing checks and six skips, with no pending or failed checks. The generated CLI resource conflict is reconciled with one accessor for each of the 59 resource keys, including the integration-feature message.
Merge-head retry caveat: the macOS CLI suite hit the ten-minute hang watchdog, with process escalation, a PowerShell telemetry hook, and a Git process test still running. The Windows Blazor release-configuration test failed twice deleting a locked temporary directory; that test is unchanged from main. Repository automatic retries passed on the same commit. No product code or assertions changed for these retries, and their success does not establish the causes or prove either failure fixed.
The previous head 05bf5e4915 passed CI run 37532173488, attempt 2: 337 passing checks and five skips, with no pending or failed checks. That head added runtime-only E2E routing for the generated TypeScript resources, with focused cases for all four current inputs.
Previous-head retry caveat: the first attempt's Windows Hosting-1 job lost communication with the hosted runner. The repository's automatic same-commit retry passed. No product code or test assertions changed, and the runner annotation does not establish the underlying cause.
The implementation head 6bf02c798e passed CI run 37524173726, attempt 2: 337 passing checks and five skips, with no pending or failed checks. Windows/Linux/macOS CLI suites, Windows/Linux RemoteHost suites, and all six native CLI archive builds passed.
All nine hostile lifetime E2Es executed and passed on 6d3a718b3e, with zero failures and zero skips, verified in the job log. These cover actual runtime, guardian, server, CLI, and dependency-installer crashes, deferred callback ownership, stalls, bounded recovery, diagnostics, descendant cleanup, and no side-effect replay.
Previous implementation-head retry caveat:6bf02c798e attempt 1 reported two Linux tray-watch assertions (expected exit code 0, actual 7), a Windows registration/discovery test timeout, and an Azure Functions stop timeout. The repository's automatic retry passed on the same commit. No code or assertions changed for that retry, and its success does not establish the underlying causes or prove those intermittent failures fixed.
Current local validation:
Coverage
Result
RemoteHost
634 passed, zero skips, on 6d3a718b3e, including configured callback deadlines and shared .NET 10 lifetime/shutdown-failure cases.
Callback/invocation deadlines
Three regressions failed before the fix. All five focused deadline cases passed 20 repeated runs afterward: 100 executions, zero skips. These use an injected fake clock and real in-memory JSON-RPC connections, not wall-clock sleeps.
CLI
6,888 passed, 54 platform skips, on merge head 4c0e1a09d4 in a complete serial run using the repository's CI timeout budgets. Earlier default-parallel local runs encountered command/discovery timeouts and a stall; they are not claimed as passing.
Infrastructure
Earlier implementation-head coverage: 1,477 passed in the full run; all eight initially failing summary-tool cases passed separately after excluding stale generated sources from child builds through the environment. This is not a full-suite result for the merge head.
Trigger-map selectors
304 passed, zero skips, on merge head 4c0e1a09d4, including the four generated-runtime routing regressions.
JavaScript
Previous-head coverage: 197 passed across eight files, including actual callback-wrapper DTO round trips with serialized requests and responses. The RPC connection in these unit tests is mocked; this suite has not been rerun on the merge head locally.
TypeScript code generation
136 passed on merge head 4c0e1a09d4.
Local Linux lifetime E2Es
Earlier local execution was blocked during Docker image preparation because the shared Docker VM disk was full; no current local E2E pass is claimed. All nine scenarios passed in matching-head CI as recorded above.
The new process cases cover cancellation and disposal through the same shared graceful budget, signalling failure diagnostics, cancellation/termination error preservation, and direct contained-execution cleanup without ProcessScope after guardian death. CLI cases also verify that shutdown policy is evaluated at teardown rather than construction.
Previously pushed head 50f202c19d passed CI run 37505069826, attempt 2: 337 passing checks and five skips, with all nine lifetime E2Es executed. Attempt 1 had Deno fixture startup failures with a DCP SQLite SQLITE_BUSY error; the same-code retry passed. That is historical evidence, not validation of the current shutdown changes. An earlier Windows starter FailedToStart also passed on retry without an established cause.
Earlier macOS diagnostics captured process-wait lock contention, and earlier process-tree termination investigation is tracked by dotnet/runtime#131944. Current results are not a claim that an upstream runtime issue was fixed. The removed playground script test used fake CLI/compiler permutations rather than exercising real restore/typecheck behavior; real playground and Nuxt validation remain the relevant evidence. No Markdown test documentation was added.
Focused TypeScript compilation of the changed runtime and integration-host tests passed in earlier validation with explicit test dependency resolution. The standalone project's broad typecheck had generated-playground-module/import-resolution and ESLint typing issues; it is not claimed as passing.
Earlier Redis/Kafka/Deno run and Docker Compose publish evidence is retained in the cross-platform validation report. Validation covers the stated run, publish, and process-recovery scenarios; complete dashboard coverage and cloud deployment validation are not claimed. Package publishing/discovery and trust productization are deliberately deferred.
Are you including unit tests for the changes and scenario tests if relevant?
Yes
No
Did you add public API?
Yes
If yes, did you have an API Review for it?
Yes
No
Did you add <remarks /> and <code /> elements on your triple slash comments?
Yes
No
No
Does the change make any security assumptions or guarantees?
Yes
If yes, have you done a threat model and had a security review?
Yes
No
No
The new public surface is exported ATS capabilities, generated language APIs, and the TypeScript integration-authoring/preview-package API. CLR hosting adapters remain internal; the shared Aspire.TypeSystem contract and generated CLR API baselines are unchanged. The triple-slash checklist is not applicable to the new TypeScript APIs.
Re-running the failed jobs in the CI workflow for this pull request because 1 job was identified as retry-safe transient failures in the CI run attempt.
GitHub was asked to rerun all failed jobs for that attempt, and the rerun is being tracked in the rerun attempt.
The job links below point to the failed attempt jobs that matched the retry-safe transient failure rules.
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR is a large spike proving that non-.NET integrations (here, TypeScript-authored Deno) can participate in Aspire's ATS projection pipeline, enabling TypeScript AppHosts to consume external integrations through generated SDK methods. It introduces the AtsAnnotation cross-language resource state model, ExternalCapabilityRegistry for integration host capabilities, IntegrationHostLauncher for process lifecycle, two-pass npm codegen, certificate trust/debug metadata projections, and a playground Deno integration exercising the full run/build/deployment path.
Changes:
Adds ATS annotation infrastructure (AtsAnnotation, AnnotationDefinition<T>, serialized + typed accessors) enabling cross-language resource state that round-trips between C# and TypeScript via JSON serialization.
Introduces external integration host support: IntegrationHostLauncher (process lifecycle), ExternalCapabilityRegistry (capability + callback routing), polymorphic PackageEntry JSON for aspire.config.json, two-pass npm codegen in GuestAppHostProject, and AppHostServerAppSettingsWriter for integration host config.
Adds TypeScript integration authoring primitives (AspireExport, defineIntegration, callback relay, annotation helpers) and a full playground Deno integration covering permissions, tasks, Dockerfile generation, certificate trust, and debug metadata.
Show a summary per file
File
Description
src/Aspire.Hosting/AtsAnnotation.cs
New AtsAnnotation record implementing IResourceAnnotation for cross-language resource state
src/Aspire.Hosting/AnnotationDefinition.cs
New generic AnnotationDefinition<TData> with stable annotation ID
Spike that projects the Aspire app model into TypeScript via the Aspire
Type System (ATS), enabling integrations to be authored in TypeScript and
to interoperate with C# integrations.
- Polyglot integration host support and ATS projection of the app model.
- TypeScript Deno integration spike (build-time + deploy/publish paths).
- Cross-language resource annotations: typed annotation state declared via
AnnotationDefinition<TData>, stored as AtsAnnotation(id, json), set in C#
and read in TypeScript (and vice versa).
- Annotation capabilities exported as resource-target so deferred run-time
callbacks (which receive bare resource handles) can reach them.
- Specs updated: docs/specs/polyglot-integrations.md and
docs/specs/polyglot-apphost.md document the annotation model and the
builder -> resource one-way handle/dispatch rule.
Co-authored-by: Copilot <[email protected]>
- ExternalCapabilityRegistry: use ConcurrentBag for _integrationHosts so
concurrent registration from connection-handler threads is thread-safe.
- RemoteHost DI: move HandleRegistry under the singleton section with a
comment explaining the cross-connection lifetime; correct the stale
"per-client" comment in JsonRpcServer.
- JsonRpcServer: gate wire-level Verbose tracing on Trace log level,
defaulting to Warning, to avoid per-frame trace overhead in production.
- IntegrationHostLauncher and GuestAppHostProject: read stdout/stderr by
looping on ReadLineAsync until null instead of gating on HasExited, so
final buffered output is not dropped.
- AppHostServerAppSettingsWriter: escape ATS assembly names via JsonString.
- DotNetBasedAppHostServerProject: emit AppHost server stdout/stderr at
Debug instead of Information/Warning to avoid noisy default CLI output.
Co-authored-by: Copilot <[email protected]>
…and as project ref
After the rebase onto main, the Go/Java/Python/Rust code-generation Verify
snapshots were stale (missing both the spike's annotation capabilities and
main's WithArgsReplace/WithCertificateTrustEnvironment/WithRequiredCommandValidation
capabilities). Regenerate all four.
Also fix a regression in PackageEntryConverter where a bare-string aspire.config.json
package value ending in .csproj was always treated as a NuGet version. This broke the
TypeScriptAppHostRunDoesNotDeadlockWhenLazyOptionsInvokeAsyncCallback E2E test, whose
extension is referenced as "DeadlockExtension/DeadlockExtension.csproj" and failed
restore with 'not a valid version string'. Restore the legacy shorthand (matching
AspireConfigFile.FromLegacy and AspireJsonConfiguration) so such values are parsed as
project references and routed to the SDK-based ProjectReference path.
Co-authored-by: Copilot <[email protected]>
Port external integration hosts to the current server-session lifecycle, scaffold caching, SDK export settings, and ATS projection. Migrate playgrounds to the current generated module layout and add compatibility regressions.
Co-authored-by: Copilot App <[email protected]>
Copilot-Session: f534a1fc-0aa1-47f3-8d3e-73aaf5088a66
The reason will be displayed to describe this comment to others. Learn more.
Copilot review overview
🔵 Needs a closer look
It introduces security-sensitive cross-process RPC, callback, and lifecycle infrastructure while the stated threat model and security review remain incomplete.
The reason will be displayed to describe this comment to others. Learn more.
One regression-coverage request: exercise Windows batch-shim argument preservation through the actual ProcessSupervisor launch chain. I also followed up in the existing lifecycle thread to request a single generic child-lifetime ownership implementation; adopting ProcessSupervisor for other existing enforcement paths is an acceptable direction.
Select owned-tree policy through the shared ChildProcess implementation, preserve runtime completion status, and verify descendant cleanup after exit, cancellation, and disposal. Keep AppHost breakaway and detached launch policies distinct, and route guest launches through the injected factory.
Add real-process lifecycle, signal, and Windows argument regressions. Document shared process management separately from the polyglot integration protocol.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 73357635-b9b6-41bc-b3f9-b18cac70b36c
Host selection is driven by generated startup settings; external registration, capability discovery, and invocation still use authenticated JSON-RPC.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 73357635-b9b6-41bc-b3f9-b18cac70b36c
A non-string value for any recognized field (for example, "source": 1) makes Utf8JsonReader.GetString() throw InvalidOperationException. AspireConfigFile.Load only wraps JsonException, so malformed package configuration bypasses the normal file/path diagnostic and surfaces an unexpected raw exception. Reject wrong token kinds as JsonException for all three fields.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
It introduces a large authenticated RPC and cross-platform process-containment boundary while the PR explicitly notes that required threat modeling and security review remain outstanding.
Honor root-only escalation for Windows AppHost lifetimes while retaining full-tree termination for owned trees. Add real Windows cancel/dispose regression coverage and document the policy.
Co-authored-by: Copilot <[email protected]>
Copilot-Session: 73357635-b9b6-41bc-b3f9-b18cac70b36c
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
It introduces security-sensitive execution, RPC, callback, and handle-sharing boundaries without the acknowledged threat-model review, and two correctness findings remain.
0 open findings
Previously missed (2)
In code that hasn't changed since last review
Validate package entry token types before calling GetString
A non-string source, version, or path value calls Utf8JsonReader.GetString() directly, which throws InvalidOperationException. AspireConfigFile.Load only catches JsonException, so malformed package entries bypass the normal config-file/path diagnostic. Validate token kinds and throw JsonException from the converter so invalid user configuration follows the existing error path.
Document or fix addNuxtApp options-object signature mismatch
src/Aspire.Hosting.Nuxt/README.md:85
The documented options-object call does not match the exported ATS projection: addNuxtApp exposes runScriptName and buildScriptName as separate optional positional parameters, so generated consumers cannot pass { runScriptName, buildScriptName } as the third argument. Document the actual generated signature (or change the projection and its generated-signature coverage if an options object is intended).
Verified both “Previously missed” findings in the latest review overview against the actual runtime/generated SDK; neither requires the proposed production or README change.
Package configuration diagnostics: Added real AspireConfigFile.Load coverage for all 15 non-string/non-null token cases across source, version, and path, plus the three invalid required-null cases. They already produce JsonException, with the config file path, $.packages.Test, and a wrapped JsonException, without changing PackageEntryConverter. System.Text.Json wraps these reader errors before the config loader receives them. Coverage also preserves omitted/null/blank NuGet-version defaults and unknown nested-field compatibility. The focused class passed 67 tests, with one Windows-only platform skip, on the unchanged converter.
Nuxt documentation: The generated public API is addNuxtApp(name: string, appDirectory: string, options?: AddNuxtAppOptions), where AddNuxtAppOptions contains runScriptName? and buildScriptName?. Only _addNuxtAppInternal uses positional arguments. The documented options-object call type-checks against the actual generated SDK with strict TypeScript settings. Changing the README to positional arguments would introduce the mismatch rather than fix it.
The useful config regression coverage is committed in 4f46f00. No production converter or Nuxt README/API changes were made. Exact-new-head CI is still required before the completed-round Teams update.
The reason will be displayed to describe this comment to others. Learn more.
🔵 Needs a closer look
It introduces a large security-sensitive cross-process execution and capability boundary, while the PR explicitly notes that threat modeling and security review remain outstanding.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Part of #16220. Adds support for hosting integrations authored outside .NET through Aspire's ATS metadata, SDK generation, and runtime dispatch pipeline. A consuming AppHost gets normal generated builder methods, while the integration executes in its own runtime and configures the same .NET resource model as a managed integration.
Integration-host ownership belongs to the AppHost server rather than the CLI. The CLI and server share process execution, command resolution, containment, and owner-liveness primitives instead of maintaining independent launching and polling implementations.
The PR includes TypeScript-authored Kafka and Deno examples, plus a real, packable
@aspire/nuxtpreview integration. TypeScript integration hosting is implemented today. The metadata contract is intended to support other authoring languages without making the consumer depend on the integration's language.Architecture
flowchart TB Config["aspire.config.json<br/>Managed packages + external integration entry points"] CLI["Aspire CLI<br/>Restore, bootstrap, session launch, diagnostics"] Guest["Guest AppHost<br/>Generated fluent SDK"] subgraph Server[".NET AppHost server process"] Session["Server session<br/>Integration discovery and supervision"] Managed["Managed integration assemblies<br/>AspireExport capabilities"] ATS["Merged ATS metadata<br/>Consumer SDK generation"] Dispatch["Capability dispatcher<br/>Shared handles and callback routing"] Model["Authoritative .NET resource model<br/>Resources, annotations, deferred configuration"] end subgraph External["External integration process scope"] Guardian["Server-owned guardian<br/>Parent liveness + OS containment"] Host["TypeScript integration host<br/>Generated runIntegrationHost runtime<br/>Author code + generated core SDK"] end subgraph Restore["Dependency-install process scope"] InstallGuardian["CLI-owned guardian<br/>Same shared supervisor and OS containment"] Npm["npm install<br/>Lifecycle scripts and workers"] end DCP["DCP / container runtime"] Workloads["Application workloads<br/>Nuxt, Deno, Kafka, backend services"] Config --> CLI CLI -.->|starts and owns| Session CLI -.->|starts guest runtime| Guest Session -.->|supervises| Guardian Guardian -.->|launches node --import tsx directly| Host CLI -.->|owns during integration restore| InstallGuardian InstallGuardian -.->|launches and contains| Npm Session -->|loads and scans| Managed Managed -->|capability metadata| ATS Host -->|getCapabilities| ATS ATS -->|generated SDK| Guest Guest -->|invokeCapability JSON-RPC| Dispatch Dispatch -->|in-process invocation| Managed Dispatch <-->|external invocation, core API calls, callbacks| Host Managed -->|configures| Model Model -->|workload orchestration| DCP DCP --> WorkloadsDashed arrows show process-launch and lifetime responsibility; solid arrows show metadata, invocation, or workload flow. The external host connects back to the server over authenticated JSON-RPC. The guardian is a separate supervisor process, not part of the integration's event loop. Application workloads created through the resource model belong to DCP/the container runtime, not to the integration host's descendant tree.
The important separation is:
The architecture document distinguishes this implementation from the future Native AOT direction. Today the single runtime representation is server-owned C# objects. The target is one ATS-native runtime model, backed by core C# primitives and consumed through language projections, not parallel CLR and ATS models. This PR does not implement that runtime or an AOT server.
Authoring and invocation model
Integration authors write ordinary TypeScript functions using generated hosting APIs.
AspireExport(metadata, function)marks methods for projection, anddefineIntegration(...)collects the package's capabilities. The generated SDK also emitsrunIntegrationHost, which handles connection setup, authentication, registration, metadata discovery, dispatch, and callback transport. Packages do not copy private RPC/bootstrap boilerplate.Integration hosts reuse the normal
AspireClienttransport for marshalling, structured errors, cancellation, and fluent work. Each export and inbound callback gets its own async promise scope, so unawaited fluent continuations complete before the request returns without making concurrent exports or reentrant callbacks wait on each other. Deferred guest callback relays survive export return and belong to both participating connections. Void guest callbacks apply returned positional DTO properties to the integration's original argument objects according to the callback projection. Non-DTO arguments and ordinary return-value callbacks are unchanged.For an exported integration, there is one delivery path regardless of the consumer's language:
builder.addNuxtApp(...)reaches the server dispatcher, which forwards it to the owning integration host.Plain same-language helper libraries can still be imported and called directly. That library pattern does not need an integration-host process, but it also does not contribute exported methods to another language's generated SDK.
Configuration and bootstrap
External integrations currently use explicit entry-point paths in
aspire.config.json. For the installed Nuxt preview package:{ "packages": { "Aspire.Hosting.JavaScript": "", "@aspire/nuxt": { "source": "npm", "path": "./node_modules/@aspire/nuxt/dist/src/host.js" } } }Restore, run, and publish share a two-pass bootstrap:
The final SDK is not generated until every configured host has registered and completed capability discovery. Registration and discovery have per-host bounds; missing hosts, early exits, invalid metadata, and duplicate capability IDs fail startup rather than silently freezing an incomplete SDK.
The server obtains launch commands through the language provider's optional, reflection-discovered JSON
GetIntegrationHostSpec()hook. Launch metadata remains internal, without adding a new member or contract type to the sharedILanguageSupportinterface. Paths resolve relative to the configuration file that declares them.Server-session configuration is parsed and validated once by
IntegrationHostConfiguration.IntegrationHostProcessLauncherresolves commands and owns contained process creation through an injectable factory;IntegrationHostLaunchercoordinates readiness, recovery, and shutdown. Failed launches dispose their executions, and launch plus cleanup failures retain both causes. Accepted RPC connections are closed and logged if service activation or connection setup fails.TypeScript hosts launch directly as
node --import tsx <entryPoint>; there is nonpx/tsxwrapper process. Command lookup fails with actionable installation guidance. Dependency installation uses the CLI's process factory, forwards both output streams, closes unused stdin, and verifies the complete guardian scope is gone before accepting npm's private completion status.TypeScript-authored Nuxt integration
src/Aspire.Hosting.Nuxtcontains@aspire/[email protected], a TypeScript-authored npm package, not a C# wrapper or a NuGet integration. It is packable but has not been published to npm. Consumers install the tarball and explicitly configure its host entry point; npm registry discovery throughaspire addis not implemented yet.addNuxtAppruns the development script locally and publishes Nitro's standalone.outputwith.output/server/index.mjsas the production entry point.withNuxtReferenceprojects deferred endpoint references into Nuxt runtime configuration, so local endpoints become deployment-native addresses at publish time. Existing JavaScript hosting APIs remain available.The package includes its compiled implementation and generated core SDK. CI packs it, installs it into a separate consumer, runs a real Nuxt dev server and backend, verifies server-rendered backend data, then publishes, builds, and runs the generated production images. The sample is in
playground/NuxtApp. Current prerequisites are Node.js 22.12+, a TypeScript AppHost, and Docker for production-image validation; Nuxt 4 with the Node-server Nitro preset is the validated scenario.The Deno example remains the deeper deferred-callback exercise: argument replacement, build tasks, Dockerfile generation/adoption, certificate trust, and executable debug metadata. Its state is stored as resource-attached annotations rather than in a process-local map of resource handles.
Process ownership and recovery
The current implementation launches each external runtime through a server-owned guardian. Unix containment uses a session/process group; Windows uses a kill-on-close job. The guardian watches the server's process identity independently of integration code, so a blocked Node event loop is not the only mechanism available for cleanup. Registration uses a fresh identity for each launch attempt.
aspire startrebuilds the resource model and callbacks.Metadata rediscovery is not callback recovery. Deferred callbacks capture the old connection and process-local callback IDs. A replacement host cannot reconstruct those closures merely by advertising the same methods. Callback admission is retired atomically with failure handling, and all admitted integration-owned delegates are conservatively treated as potentially persistent. Callback-free recovery preserves server-owned handles, not arbitrary integration-local state. In-flight calls fail and are never replayed because they may already have mutated the model.
External invocations and callbacks each default to an independent one-minute deadline. The server setting
IntegrationHost:InvocationTimeoutaccepts a positiveTimeSpan, also configurable throughIntegrationHost__InvocationTimeout. Registration/discovery, callback, shutdown/output-drain, and recovery policy are also configurable and validated centrally. Outer callback budgets must exceed inner invocation budgets when callback-free integration recovery is desired. An injectedTimeProviderdrives deadlines and recovery. Server/runtime diagnostics and startup profiling activities correlate invocation IDs, capability, connection, runtime PID, elapsed time, deadlines, cancellation, callback lifecycle, and cleanup/recovery. Responsive runtimes report their active phase every ten seconds; a blocked event loop remains bounded by the server deadline. Hosts advertising protocol version 2 receive correlation IDs; older hosts retain the two-argument wire shape without changing capability signatures.Guardian diagnostics use a structured
ILoggerbridge over inherited stderr, decoded by the owning process with the original severity preserved. Raw AppHost server stdout and stderr are retained at Debug in the CLI file log rather than printed during normal usage; collected startup failures are surfaced at Error. Expected launch cancellation is Debug, and malformed guardian records produce a warning while remaining available through ordinary stderr forwarding. Diagnostics do not add authentication tokens or invocation payloads.The process plumbing is source-shared across the net11 CLI and net10 AppHost server.
ChildProcessowns the common graceful-shutdown ladder, bounded force escalation, contained descendant-cleanup verification, output draining, and process-handle disposal. The CLI'sProcessExecutionsupplies its existing command-wide shutdown window and process-tree signaler rather than implementing another ladder.ProcessScopeonly retains ownership and the root-exit signal; it no longer implements OS termination or cleanup deadlines. Contained cleanup also works without that wrapper or after guardian death. Shutdown policy is evaluated when teardown begins, and cancellation plus termination failures retain both causes.The guardian establishes Unix process-group or Windows kill-on-close-job containment and independently monitors owner liveness using the existing stable-identity parent monitor. Its runtime cleanup uses the same shared execution. Windows batch formatting is also shared with the net8/net472 MSBuild task. Cleanup failures are logged and prevent replacement; operation and cleanup errors are retained together.
Automatic full-session replay and transparent callback rebinding are not implemented. Intentionally escaping the guardian's process scope is unsupported. Persistent containers are an explicit workload policy, not proof of integration-process cleanup. Authoring providers beyond TypeScript and richer custom-resource/package-manager support are outside the scope of this PR.
Supporting hosting APIs
CommandLineArgsEditor.clear()lets a callback recompute final arguments after configuration is complete.builder.appHostDirectory()separates application paths from the integration package's own working directory.Security considerations
External integration hosting executes project-configured packages and entry points, accepts authenticated integration registrations, and routes callbacks and shared resource handles. Opaque random handle IDs prevent sequential enumeration; passing a handle delegates access to its object. These mechanisms are not a sandbox for locally running integration code.
Configuration/package trust, command arguments, registration and callback ownership, annotation access, and process containment still require a threat model and security review before release.
Validation
Current head:
6d3a718b3e. Matching-head CI run 37637520546, attempt 2 completed successfully: 336 passing checks and six skips, with no pending or failed checks. Both Windows/Linux RemoteHost suites and all nine hostile lifetime E2Es passed. Guest callback relays now honorIntegrationHost:CallbackTimeoutindependently of external capability invocation deadlines, including their structured diagnostics and surfaced timeout errors.Current CI retry caveat: the extension Windows producer failed restoring
supports-colorfrom the internal npm feed with HTTP 429, so downstream extension E2Es could not download theaspire-extensionartifact. Separate hosting failures were MongoDB replica readiness, a Windows file-app marker read blocked by a file lock, and a Windows rebuild-command state assertion (expected 2, actual 3). The callback fix did not modify those tests or extension inputs. Both a failed-jobs rerun and a targeted extension-producer rerun were initially rejected by GitHub with HTTP 500; a later failed-jobs rerun was accepted and passed. No code or assertions changed for the retry, and its success does not establish the causes or prove those failures fixed.The previous merge head
4c0e1a09d4, mergingmainat809a672cc4, passed CI run 37575522858, attempt 3: 337 passing checks and six skips, with no pending or failed checks. The generated CLI resource conflict is reconciled with one accessor for each of the 59 resource keys, including the integration-feature message.Merge-head retry caveat: the macOS CLI suite hit the ten-minute hang watchdog, with process escalation, a PowerShell telemetry hook, and a Git process test still running. The Windows Blazor release-configuration test failed twice deleting a locked temporary directory; that test is unchanged from
main. Repository automatic retries passed on the same commit. No product code or assertions changed for these retries, and their success does not establish the causes or prove either failure fixed.The previous head
05bf5e4915passed CI run 37532173488, attempt 2: 337 passing checks and five skips, with no pending or failed checks. That head added runtime-only E2E routing for the generated TypeScript resources, with focused cases for all four current inputs.Previous-head retry caveat: the first attempt's Windows Hosting-1 job lost communication with the hosted runner. The repository's automatic same-commit retry passed. No product code or test assertions changed, and the runner annotation does not establish the underlying cause.
The implementation head
6bf02c798epassed CI run 37524173726, attempt 2: 337 passing checks and five skips, with no pending or failed checks. Windows/Linux/macOS CLI suites, Windows/Linux RemoteHost suites, and all six native CLI archive builds passed.All nine hostile lifetime E2Es executed and passed on
6d3a718b3e, with zero failures and zero skips, verified in the job log. These cover actual runtime, guardian, server, CLI, and dependency-installer crashes, deferred callback ownership, stalls, bounded recovery, diagnostics, descendant cleanup, and no side-effect replay.Previous implementation-head retry caveat:
6bf02c798eattempt 1 reported two Linux tray-watch assertions (expected exit code 0, actual 7), a Windows registration/discovery test timeout, and an Azure Functions stop timeout. The repository's automatic retry passed on the same commit. No code or assertions changed for that retry, and its success does not establish the underlying causes or prove those intermittent failures fixed.Current local validation:
6d3a718b3e, including configured callback deadlines and shared .NET 10 lifetime/shutdown-failure cases.4c0e1a09d4in a complete serial run using the repository's CI timeout budgets. Earlier default-parallel local runs encountered command/discovery timeouts and a stall; they are not claimed as passing.4c0e1a09d4, including the four generated-runtime routing regressions.4c0e1a09d4.The new process cases cover cancellation and disposal through the same shared graceful budget, signalling failure diagnostics, cancellation/termination error preservation, and direct contained-execution cleanup without
ProcessScopeafter guardian death. CLI cases also verify that shutdown policy is evaluated at teardown rather than construction.Previously pushed head
50f202c19dpassed CI run 37505069826, attempt 2: 337 passing checks and five skips, with all nine lifetime E2Es executed. Attempt 1 had Deno fixture startup failures with a DCP SQLiteSQLITE_BUSYerror; the same-code retry passed. That is historical evidence, not validation of the current shutdown changes. An earlier Windows starterFailedToStartalso passed on retry without an established cause.Earlier macOS diagnostics captured process-wait lock contention, and earlier process-tree termination investigation is tracked by dotnet/runtime#131944. Current results are not a claim that an upstream runtime issue was fixed. The removed playground script test used fake CLI/compiler permutations rather than exercising real restore/typecheck behavior; real playground and Nuxt validation remain the relevant evidence. No Markdown test documentation was added.
Focused TypeScript compilation of the changed runtime and integration-host tests passed in earlier validation with explicit test dependency resolution. The standalone project's broad typecheck had generated-playground-module/import-resolution and ESLint typing issues; it is not claimed as passing.
Earlier Redis/Kafka/Deno run and Docker Compose publish evidence is retained in the cross-platform validation report. Validation covers the stated run, publish, and process-recovery scenarios; complete dashboard coverage and cloud deployment validation are not claimed. Package publishing/discovery and trust productization are deliberately deferred.
Design details:
docs/specs/polyglot-integrations.mdanddocs/specs/polyglot-apphost.md.Checklist
<remarks />and<code />elements on your triple slash comments?The new public surface is exported ATS capabilities, generated language APIs, and the TypeScript integration-authoring/preview-package API. CLR hosting adapters remain internal; the shared
Aspire.TypeSystemcontract and generated CLR API baselines are unchanged. The triple-slash checklist is not applicable to the new TypeScript APIs.