Skip to content

Add ATS exported value catalogs - #16287

Merged
Sébastien Ros (sebastienros) merged 17 commits into
mainfrom
sebastienros/add-ats-exported-values
Apr 27, 2026
Merged

Sébastien Ros (sebastienros) merged 17 commits into
mainfrom
sebastienros/add-ats-exported-values

Conversation

@sebastienros

@sebastienros Sébastien Ros (sebastienros) commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

Description

Adds ATS support for exporting predefined immutable values so polyglot guest SDKs can surface generated value catalogs such as FoundryModels.OpenAI.Gpt41Mini. This lets AppHost code use shared predefined DTO instances in guest languages instead of reconstructing those DTOs manually.

The implementation introduces [AspireValue] and scans annotated static fields and properties into AtsContext.ExportedValues. Each guest generator then emits those values in a language-appropriate form, while Foundry model generation annotates the predefined models so addDeploymentFromModel and addModelDeploymentFromModel can use the exported catalog values directly. The PR also updates ATS docs and the Foundry polyglot apphost coverage in TypeScript, Java, and Python.

Checklist

  • Is this feature complete?
    • Yes. Ready to ship.
    • No. Follow-up changes expected.
  • 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
  • Does the change require an update in our Aspire docs?

Copilot Bot review requested due to automatic review settings April 17, 2026 23:16
@github-actions

ghost commented Apr 17, 2026 •

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 16287

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/microsoft/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 16287"

ghost left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds ATS support for exporting predefined immutable values (via a new [AspireValue] attribute) so generated guest SDKs can expose value catalogs (e.g., FoundryModels.OpenAI.Gpt41Mini) and polyglot AppHosts can reuse shared DTO instances instead of reconstructing them.

Changes:

  • Introduces [AspireValue] plus ATS scanning/storage of exported values in AtsContext.ExportedValues.
  • Extends guest SDK generators (TypeScript/Java/Python/Go/Rust) to emit exported value catalogs and updates tests/snapshots accordingly.
  • Updates Foundry model generation to annotate predefined models for export, and updates polyglot Foundry AppHosts + docs to use/describe catalogs.

Reviewed changes

Copilot reviewed 38 out of 38 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/TypeScript/apphost.ts Uses FoundryModels catalog values instead of hand-constructed model DTOs.
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Python/apphost.py Uses FoundryModels catalog values and aligns Python validation AppHost with TS surface.
tests/PolyglotAppHosts/Aspire.Hosting.Foundry/Java/AppHost.java Uses FoundryModels catalog values instead of mutating a DTO instance.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/TestTypes/TestTypes.cs Adds [AspireValue]-annotated static members to drive exported-value codegen tests.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.ts Updates TS snapshot to include exported value namespaces/constants.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/Snapshots/AtsGeneratedAspire.verified.ts Updates TS snapshot to include exported value namespaces/constants.
tests/Aspire.Hosting.CodeGeneration.TypeScript.Tests/AtsTypeScriptCodeGeneratorTests.cs Adds assertions that exported values are scanned and emitted in TS output.
tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.rs Updates Rust snapshot to include exported value modules/functions.
tests/Aspire.Hosting.CodeGeneration.Rust.Tests/Snapshots/AtsGeneratedAspire.verified.rs Updates Rust snapshot to include exported value modules/functions.
tests/Aspire.Hosting.CodeGeneration.Rust.Tests/AtsRustCodeGeneratorTests.cs Adds assertions that exported values are scanned and emitted in Rust output.
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.py Updates Python snapshot to include exported values (SimpleNamespace catalogs).
tests/Aspire.Hosting.CodeGeneration.Python.Tests/Snapshots/AtsGeneratedAspire.verified.py Updates Python snapshot to include exported values (SimpleNamespace catalogs).
tests/Aspire.Hosting.CodeGeneration.Python.Tests/AtsPythonCodeGeneratorTests.cs Adds assertions that exported values are scanned and emitted in Python output.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.java Updates Java snapshot to include an exported-values catalog type.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/Snapshots/AtsGeneratedAspire.verified.java Updates Java snapshot to include an exported-values catalog type.
tests/Aspire.Hosting.CodeGeneration.Java.Tests/AtsJavaCodeGeneratorTests.cs Adds assertions that exported values are scanned and emitted in Java output.
tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/TwoPassScanningGeneratedAspire.verified.go Updates Go snapshot to include exported value catalog struct/literals.
tests/Aspire.Hosting.CodeGeneration.Go.Tests/Snapshots/AtsGeneratedAspire.verified.go Updates Go snapshot to include exported value catalog struct/literals.
tests/Aspire.Hosting.CodeGeneration.Go.Tests/AtsGoCodeGeneratorTests.cs Adds assertions that exported values are scanned and emitted in Go output.
src/Aspire.TypeSystem/HostingTypeHelpers.cs Adds HostingTypeNames.AspireValueAttribute constant.
src/Aspire.TypeSystem/AttributeDataReader.cs Adds attribute parsing for [AspireValue] (field/property) and AspireValueData.
src/Aspire.TypeSystem/AtsExportedValueInfo.cs Introduces exported-value metadata model (path/type/value/description).
src/Aspire.TypeSystem/AtsContext.cs Extends ATS context to include ExportedValues and updates docs in XML comments.
src/Aspire.Hosting/Ats/AspireValueAttribute.cs Adds new public [AspireValue] attribute API.
src/Aspire.Hosting.RemoteHost/AtsContextFilter.cs Filters ExportedValues when slicing context by assemblies.
src/Aspire.Hosting.RemoteHost/AtsContextFactory.cs Logs exported-value count during scanning.
src/Aspire.Hosting.RemoteHost/AtsCapabilityScanner.cs Scans static fields/properties with [AspireValue] and snaps JSON payloads.
src/Aspire.Hosting.Foundry/tools/GenModel.cs Annotates generated Foundry model descriptors with [AspireValue("FoundryModels")].
src/Aspire.Hosting.Foundry/FoundryModel.Local.Generated.cs Adds [AspireValue("FoundryModels")] to local Foundry model descriptors.
src/Aspire.Hosting.Foundry/FoundryModel.Generated.cs Adds [AspireValue("FoundryModels")] to hosted Foundry model descriptors.
src/Aspire.Hosting.CodeGeneration.TypeScript/AtsTypeScriptCodeGenerator.cs Emits exported value namespaces/constants into generated TypeScript SDK.
src/Aspire.Hosting.CodeGeneration.Rust/AtsRustCodeGenerator.cs Emits exported value modules/functions into generated Rust SDK.
src/Aspire.Hosting.CodeGeneration.Python/PythonModuleBuilder.cs Adds module section support + types import for exported values.
src/Aspire.Hosting.CodeGeneration.Python/AtsPythonCodeGenerator.cs Emits exported value SimpleNamespace catalogs into generated Python SDK.
src/Aspire.Hosting.CodeGeneration.Java/AtsJavaCodeGenerator.cs Emits exported value catalog classes into generated Java SDK.
src/Aspire.Hosting.CodeGeneration.Go/AtsGoCodeGenerator.cs Emits exported value catalog structs/literals into generated Go SDK.
docs/specs/polyglot-apphost.md Documents exported values and [AspireValue] in the ATS/polyglot spec.
docs/specs/bundle.md Updates ATS attribute list to include [AspireValue].

@sebastienros

ghost commented Apr 18, 2026

Copy link
Copy Markdown
Contributor Author

In reply to the Copilot review summary at #16287 (review): no action was needed on the overview itself. I addressed the actionable inline review comments separately.

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the exported value catalog implementation. Found 2 issues:

  • 1 bug in Rust code generation (missing use imports in generated pub mod blocks)
  • 1 bug in all code generators (BuildExportedValueTree silently drops child values when a node is both a leaf and a parent)

@github-actions

ghost commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

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.

Sebastien Ros and others added 2 commits April 24, 2026 16:45

ghost left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the full PR (56 files, ~3.9K additions). No issues found.

The exported value feature is well-structured: proper type validation (rejects mutable collections/handles), deduplication with exact-path and prefix-conflict detection, defensive error handling with diagnostics, and consistent tree-building across all 5 language generators. Test coverage is thorough — scanner validation tests, context filter tests with referenced type traversal, snapshot tests for all languages, and SDK dump format tests including Unicode content. Previous review comments have all been addressed.

ghost left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great overall - the design is solid, the diagnostic coverage for duplicate / parent-child / mutable-shape paths is good, and the snapshot coverage across all five guest languages plus the Foundry polyglot harness is thorough.

I left four inline comments (one false-negative validation gap on [AspireExportIgnore], one identifier-sanitization concern on [AspireValue(Name = ...)], plus two minor cleanups). None are blockers.

One additional non-blocking note (no inline because it's not tied to a specific line): DeduplicateExportedValues / TryFindConflictingExportedValuePath is O(N^2) in the number of exported values * path depth. With Foundry exporting ~80 entries today this is fine, but if exported-value catalogs become a popular pattern across integrations it's worth replacing with a path trie keyed by PathSegments. Not a bug today, just a heads-up.

Immutable predefined values can be emitted into generated guest SDKs with `[AspireValue]`:

```csharp
[AspireDto]

ghost Apr 27, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is more of an observation about the naming of these attributes. It's bugging me that they don't include Ats in their name (or AspireTypeSystem*), just simply being prefixed with Aspire* doesn't really tell me as a consumer - what they're really used for. I think we should consider renaming them.

Sebastien Ros and others added 3 commits April 27, 2026 10:51
@github-actions github-actions Bot added this to the 13.3 milestone Apr 27, 2026
@github-actions

ghost commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

🎬 CLI E2E Test Recordings — 77 recordings uploaded (commit afa7288)

View all recordings
Status Test Recording
❔ AddPackageInteractiveWhileAppHostRunningDetached ▶️ View Recording
❔ AddPackageWhileAppHostRunningDetached ▶️ View Recording
❔ AgentCommands_AllHelpOutputs_AreCorrect ▶️ View Recording
❔ AgentInitCommand_DefaultSelection_InstallsSkillOnly ▶️ View Recording
❔ AgentInitCommand_MigratesDeprecatedConfig ▶️ View Recording
❔ AspireAddPackageVersionToDirectoryPackagesProps ▶️ View Recording
❔ AspireUpdateRemovesAppHostPackageVersionFromDirectoryPackagesProps ▶️ View Recording
❔ Banner_DisplayedOnFirstRun ▶️ View Recording
❔ Banner_DisplayedWithExplicitFlag ▶️ View Recording
❔ Banner_NotDisplayedWithNoLogoFlag ▶️ View Recording
❔ CertificatesClean_RemovesCertificates ▶️ View Recording
❔ CertificatesTrust_WithNoCert_CreatesAndTrustsCertificate ▶️ View Recording
❔ CertificatesTrust_WithUntrustedCert_TrustsCertificate ▶️ View Recording
❔ ConfigSetGet_CreatesNestedJsonFormat ▶️ View Recording
❔ CreateAndRunAspireStarterProject ▶️ View Recording
❔ CreateAndRunAspireStarterProjectWithBundle ▶️ View Recording
❔ CreateAndRunEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunJavaEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunJsReactProject ▶️ View Recording
❔ CreateAndRunPythonReactProject ▶️ View Recording
❔ CreateAndRunTypeScriptEmptyAppHostProject ▶️ View Recording
❔ CreateAndRunTypeScriptStarterProject ▶️ View Recording
❔ CreateJavaAppHostWithViteApp ▶️ View Recording
❔ CreateTypeScriptAppHostWithViteApp_UsesConfiguredToolchain ▶️ View Recording
❔ DashboardRunWithOtelTracesReturnsNoTraces ▶️ View Recording
❔ DeployK8sBasicApiService ▶️ View Recording
❔ DeployK8sWithGarnet ▶️ View Recording
❔ DeployK8sWithMongoDB ▶️ View Recording
❔ DeployK8sWithMySql ▶️ View Recording
❔ DeployK8sWithPostgres ▶️ View Recording
❔ DeployK8sWithRabbitMQ ▶️ View Recording
❔ DeployK8sWithRedis ▶️ View Recording
❔ DeployK8sWithSqlServer ▶️ View Recording
❔ DeployK8sWithValkey ▶️ View Recording
❔ DeployTypeScriptAppToKubernetes ▶️ View Recording
❔ DescribeCommandResolvesReplicaNames ▶️ View Recording
❔ DescribeCommandShowsRunningResources ▶️ View Recording
❔ DetachFormatJsonProducesValidJson ▶️ View Recording
❔ DetachFormatJsonProducesValidJsonWhenRestartingExistingInstance ▶️ View Recording
❔ DoListStepsShowsPipelineSteps ▶️ View Recording
❔ DocsCommand_RendersInteractiveMarkdownFromLocalSource ▶️ View Recording
❔ DoctorCommand_DetectsDeprecatedAgentConfig ▶️ View Recording
❔ DoctorCommand_TypeScriptAppHostReportsMissingConfiguredToolchain ▶️ View Recording
❔ DoctorCommand_WithSslCertDir_ShowsTrusted ▶️ View Recording
❔ DoctorCommand_WithoutSslCertDir_ShowsPartiallyTrusted ▶️ View Recording
❔ DotnetToolInstall_CreateAndRunAspireStarterProject ▶️ View Recording
❔ GlobalMigration_HandlesCommentsAndTrailingCommas ▶️ View Recording
❔ GlobalMigration_HandlesMalformedLegacyJson ▶️ View Recording
❔ GlobalMigration_PreservesAllValueTypes ▶️ View Recording
❔ GlobalMigration_SkipsWhenNewConfigExists ▶️ View Recording
❔ GlobalSettings_MigratedFromLegacyFormat ▶️ View Recording
❔ InitTypeScriptAppHost_AugmentsExistingViteRepoAtRoot ▶️ View Recording
❔ InteractiveCSharpInitCreatesExpectedFiles ▶️ View Recording
❔ InvalidAppHostPathWithComments_IsHealedOnRun ▶️ View Recording
❔ LegacySettingsMigration_AdjustsRelativeAppHostPath ▶️ View Recording
❔ LogsCommandShowsResourceLogs ▶️ View Recording
❔ OtelLogsReturnsStructuredLogsFromStarterAppCore ▶️ View Recording
❔ PsCommandListsRunningAppHost ▶️ View Recording
❔ PsFormatJsonOutputsOnlyJsonToStdout ▶️ View Recording
❔ PublishWithConfigureEnvFileUpdatesEnvOutput ▶️ View Recording
❔ PublishWithDockerComposeServiceCallbackSucceeds ▶️ View Recording
❔ PublishWithoutOutputPathUsesAppHostDirectoryDefault ▶️ View Recording
❔ RestoreGeneratesSdkFiles ▶️ View Recording
❔ RestoreGeneratesSdkFiles_WithConfiguredToolchain ▶️ View Recording
❔ RestoreRefreshesGeneratedSdkAfterAddingIntegration ▶️ View Recording
❔ RestoreSupportsConfigOnlyHelperPackageAndCrossPackageTypes ▶️ View Recording
❔ RunFromParentDirectory_UsesExistingConfigNearAppHost ▶️ View Recording
❔ SecretCrudOnDotNetAppHost ▶️ View Recording
❔ SecretCrudOnTypeScriptAppHost ▶️ View Recording
❔ StagingChannel_ConfigureAndVerifySettings_ThenSwitchChannels ▶️ View Recording
❔ StartAndWaitForTypeScriptSqlServerAppHostWithNativeAssets ▶️ View Recording
❔ StopAllAppHostsFromAppHostDirectory ▶️ View Recording
❔ StopAllAppHostsFromUnrelatedDirectory ▶️ View Recording
❔ StopNonInteractiveMultipleAppHostsShowsError ▶️ View Recording
❔ StopNonInteractiveSingleAppHost ▶️ View Recording
❔ StopWithNoRunningAppHostExitsSuccessfully ▶️ View Recording
❔ UnAwaitedChainsCompileWithAutoResolvePromises ▶️ View Recording

📹 Recordings uploaded automatically from CI run #25022871799

@aspire-repo-bot

ghost commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

Pull request created: #757

Generated by PR Documentation Check

@aspire-repo-bot

ghost commented Apr 27, 2026

Copy link
Copy Markdown
Contributor

A draft documentation PR has been opened on microsoft/aspire.dev to document the new [AspireValue] exported value catalogs feature introduced by this PR.

Target branch: main (falling back from release/13.3, which does not yet exist on aspire.dev)

Branch: docs/ats-exported-value-catalogs

Documentation changes

  • extensibility/multi-language-integration-authoring.mdx — Added a new Export value catalogs section covering how to use [AspireValue] to emit predefined catalog constants into guest SDKs (TypeScript, Python, Java, etc.). Includes C# annotation examples, TypeScript and Python consumption examples, name override guidance, and catalog constraints. Also added an Exported values row to the supported types table.

  • diagnostics/aspireats001.mdx — Added [AspireValue] to the list of types/attributes protected by the ASPIREATS001 experimental diagnostic.

The draft PR needs human review before merging.

Generated by PR Documentation Check for issue #16287 · ● 2.4M · ◷

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants