feat(recipe): add mixin composition for OS and platform fragments#501
Merged
mchmarny merged 1 commit intoNVIDIA:mainfrom Apr 8, 2026
Merged
feat(recipe): add mixin composition for OS and platform fragments#501mchmarny merged 1 commit intoNVIDIA:mainfrom
mchmarny merged 1 commit intoNVIDIA:mainfrom
Conversation
76c8674 to
64855b2
Compare
678b9a4 to
94b3e09
Compare
8a7504a to
f8a47c8
Compare
ArangoGutierrez
suggested changes
Apr 8, 2026
Contributor
ArangoGutierrez
left a comment
There was a problem hiding this comment.
Nice work on the mixin system — the byte-identical output verification is great and the conflict detection / fallback-to-base logic is solid. A couple things to fix before merging.
2640b02 to
dc49140
Compare
4d209ea to
94980fc
Compare
94980fc to
bacb855
Compare
|
@yuanchen8911 this PR now has merge conflicts with |
1fc135b to
f7848e2
Compare
Introduce RecipeMixin kind and spec.mixins field on overlays to enable composable, shared recipe fragments for cross-cutting concerns like OS constraints and platform components. This eliminates duplication across leaf overlays that share the same OS or platform content. - Add recipes/mixins/ directory with os-ubuntu and platform-kubeflow - Wire mixin loading, conflict detection, and constraint evaluation into the metadata store build pipeline - Add mixin-aware tests for composition, conflicts, and constraint evaluation fallback - Update all recipe documentation for mixin consistency Signed-off-by: Yuan Chen <yuanchen97@gmail.com>
f7848e2 to
2829bb6
Compare
mchmarny
approved these changes
Apr 8, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Add
RecipeMixinkind andspec.mixinsfield for composing orthogonal fragments (OS constraints, platform components) into leaf overlays without duplicating content across files. Update all recipe-related documentation to reflect the new mixin composition system.Motivation / Context
Ubuntu OS constraints (3 lines) are duplicated in 12 leaf overlays. Kubeflow-trainer component definition (9 lines) is duplicated in 4 leaf overlays. Inference gateway components (kgateway-crds + kgateway, 20 lines) are duplicated in 5 service-inference overlays. When Ubuntu version, kubeflow chart version, or kgateway version changes, all copies must be updated — increasing review burden, merge conflict surface, and drift risk.
This is Phase 3 of the revised ADR-005 (#439): add composition abstractions after correctness fixes (Phase 1: #492, #493) and candidate selection (Phase 2: #496) are stable.
Fixes: N/A
Related: #439, #305, #492, #493, #496
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/api,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)Implementation Notes
Mixin system
RecipeMixinkind withconstraintsandcomponentRefsonly — nocriteria,base,mixins, orvalidationMixins []stringfield onRecipeMetadataSpec— accumulated duringMerge(), stripped from materialized outputmergeMixins()helper called from bothBuildRecipeResultandBuildRecipeResultWithEvaluatoraftermergeOverlayChainsmetadata.name, loading fails with a clear errorrecipes/mixins/are loaded separately from overlays — distinctkind: RecipeMixinprevents them from being treated as matchable overlaysMixin files
os-ubuntu.yamlOS.release.ID,OS.release.VERSION_ID,OS.sysctl.kernelconstraintsplatform-inference.yamlkgateway-crds+kgatewaycomponents with CRD manifests and inference gatewayplatform-kubeflow.yamlkubeflow-trainercomponent with deps and manifestsOverlay conversions
Ubuntu leaf overlays — inline OS constraints →
mixins: [os-ubuntu]:h100-eks-ubuntu-training,h100-eks-ubuntu-inference,h100-aks-ubuntu-training,h100-aks-ubuntu-inferencegb200-eks-ubuntu-training,gb200-eks-ubuntu-inferencegb200-oke-ubuntu-training,gb200-oke-ubuntu-inference(new OKE overlays from Add GB200 overlays for OKE #497)Kubeflow leaf overlays — inline OS constraints + kubeflow-trainer →
mixins: [os-ubuntu, platform-kubeflow]:h100-eks-ubuntu-training-kubeflow,h100-aks-ubuntu-training-kubeflowgb200-eks-ubuntu-training-kubeflowgb200-oke-ubuntu-training-kubeflow(new OKE overlay from Add GB200 overlays for OKE #497)Service-inference overlays — inline kgateway-crds + kgateway →
mixins: [platform-inference]:eks-inference,aks-inference,gke-cos-inference,kind-inferenceoke-inference(new OKE overlay from Add GB200 overlays for OKE #497)Unchanged:
What a converted overlay looks like
Documentation updates
All recipe-related docs updated for mixin consistency:
docs/contributor/data.mdspec.mixinsto schema table/YAML example, new Mixin Composition section, Step 5 (Apply Mixins) in recipe generation processdocs/integrator/recipe-development.mddocs/integrator/data-flow.mdDEVELOPMENT.mdrecipes/mixins/*.yamlto Recipe Engine data sourcesite/docs/getting-started/index.mdrecipes/README.md.claude/CLAUDE.mdMaintenance impact
mixins: [os-ubuntu]mixins: [platform-inference]Testing
go test -race ./pkg/recipe/...spec.mixinsdoes not appear in materialized recipe outputTestBothBuildPathsProduceIdenticalContentverifies both build paths produce identical results across all 16 leaf overlaysRisk Assessment
Rollout notes: Backward compatible. To revert: remove
spec.mixinsfrom leaf overlays and inline the mixin content back. TheRecipeMixinloader can remain dormant (no mixins referenced = no code path exercised). No recipe output format changes.Checklist
make testwith-race)make lint)git commit -S) — GPG signing infoPost-compose constraint evaluation
Mixin-contributed constraints (e.g.,
kernel >= 6.8fromos-ubuntu) are evaluated against the snapshot inBuildRecipeResultWithEvaluatoraftermergeMixins. Per-overlay constraints are evaluated before merge (existing behavior); mixin constraints get their first evaluation post-compose.Fallback behavior: If any mixin constraint fails, the entire composed candidate is reset to base-only output — all applied overlays from the inheritance chain are excluded, not just the mixin. This is a conservative choice: a failing mixin constraint means the composed recipe is not valid for the target environment, so partial results (chain content without mixin content) would be inconsistent. This is tested in
TestMixinConstraintFailureExcludesCandidate.Bundle verification
All recipe combinations are byte-identical. All platforms (EKS, GKE, AKS, Kind, OKE), intents (training, inference), accelerators (H100, GB200), OS variants (Ubuntu, COS), and platform overlays (kubeflow, dynamo, NIM) produce exactly the same recipe output before and after the mixin changes. Verified via binary comparison of
aicr recipeoutput between main and PR branch.GPU test dependency