← Back to Pull requests

feat(bundler): --split renders a class-partitioned bundle set #3420

Closed
unknown closed this pull request without merging on Oct 26, 2026 21:32 UTC
View on GitHub
unknown unknown commented on Oct 26, 2026 16:33 UTC
Author

Summary

Adds --split to aicr bundle (CLI, SDK and REST): the bundle is rendered as a class-partitioned set per ADR-018, one directory per registry class (core, then ops) under a set root that holds the full recipe.yaml, split.yaml, checksums.txt and the attestation. Without --split nothing changes.

Motivation / Context

ADR-018 (#3341) partitions a bundle by the registry class so two owners can deploy their parts separately. #3350 landed the class field, the catalog edge fixes and the direction guard. This is the second implementation step: the plan/validate-once/render-subsets pipeline, partition validation, the set-level layout and provenance, and create-only atomic publication, for the Helm-local deployer only.

Fixes: #3158
Related: #3156
Related: #3159

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

  • New feature (non-breaking change that adds functionality)

  • Breaking change (fix or feature that would cause existing functionality to change)

  • Documentation update

  • Refactoring (no functional changes)

  • Build/CI/tooling
  • Component(s) Affected

  • CLI (cmd/aicr, pkg/cli)

  • API server (cmd/aicrd, pkg/server)

  • Recipe engine / data (pkg/recipe)

  • Bundler and deployers (pkg/bundler, pkg/component)

  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)

  • Validator (pkg/validator)

  • Core libraries (pkg/errors, pkg/k8s)

  • Docs/examples (docs/, examples/)

  • Other: pkg/client/v1 facade, pkg/header, OpenAPI contract
  • Implementation Notes

    Pipeline. DefaultBundler.Make runs every existing gate on the complete component set exactly as today: coherence, enable/disable filtering, override policy, value extraction, the ADR-015 profile lock and the component validations. Only then, when Config.Split() is set, does it branch into makeSplit (new pkg/bundler/split.go) instead of the single-bundle writer. Each class is rendered by the existing helm Generator on a subset RecipeResult whose ComponentRefs are the class's enabled components and whose DeploymentOrder is the induced subsequence, with the matching slice of the already-extracted component values. A dependency on a component in another class is absent from the subset and so is treated as satisfied externally, the same path a disabled component's edge takes.

    Partition validation (planSplit), before any write: OCP recipes are rejected; every enabled component needs a registry entry, and its class must be a known one; any dependency from an earlier class to a later enabled component is rejected; the ADR-016 accounting set (slinky-slurm, mariadb-operator-crds, mariadb-operator, slurm-accounting-mariadb) must share one class; a class the recipe declares whose every component is disabled is rejected, while a class with no declared component is skipped. Config.Validate rejects --split with any deployer other than helm, with checksums disabled, or together with the bundlers filter, and the CLI rejects it with OCI output. Before rendering, validateSplitHelmIdentities claims every (namespace, release) pair the whole set will emit, including the injected -pre, -post and -readiness releases, counting a -pre release only when its manifests render an object, as the writer does, so a collision across classes fails instead of slipping past per-class rendering.

    Set layout. Class directories are ordinary Helm per-component bundles (deploy.sh, README.md, NNN-<component>/) without their own checksums.txt or bundle-info.yaml; the set root is the verification unit and carries recipe.yaml (the same bytes an ordinary bundle writes), split.yaml, bundle-info.yaml whose entrypoint is the first class's deploy.sh and whose release paths are class-prefixed (so aicr upgrade-check --from <set> and aicr recipe --inherit-from <set> read a set like a bundle; the record's strict schema has no set marker yet, so the bundling guide documents that the entrypoint installs only its own class's releases and how a consumer recognizes a set from the record), UPGRADING.md when transition records apply, any copied --data files, checksums.txt over the whole tree, and the attestation with --attest. The final inventory is re-read and verified from the root before publication, as for a single bundle.

    split.yaml is aicr.run/v1 BundleSplit: recipeDigest (sha256: plus evidence/attestation.SubjectDigestV3 of the set-root recipe.yaml, so it matches recipe-evidence subjects), classOrder, and components mapping every component to its class. Its header comment restates the scope note from the ADR: it identifies the recipe and its partition, not the payload, which checksums.txt identifies.

    Per-class scripts. The helm Generator gains a Split context. A class deploy.sh keys its orphaned-CRD scan by the component that ships the CRDs (monitoring.coreos.com under prometheus-operator-crds), so a later class does not report an earlier class's CRDs as orphans, and carries a header naming the class order. A class README.md gains a "Bundle Set" section stating the install and teardown order and listing the namespaces and CRD groups the class shares with an earlier class, which its teardown must keep. With a nil context the templates render exactly as before: the ordinary deploy.sh keeps its historical table keyed by kube-prometheus-stack.

    Publication is create-only and atomic. --output is required with --split (the CLI rejects the flag without it) and must name an absent path under an existing parent. The set renders into a private .aicr-split-<name>-* sibling under the destination's parent, is verified from its root, and is published with one no-replace rename: renameat2(RENAME_NOREPLACE) on Linux and renamex_np(RENAME_EXCL) on macOS, the two platforms aicr ships for, with a check-then-rename fallback elsewhere. The destination stays absent until that syscall; anything created there meanwhile, even an empty directory, makes it fail with a conflict and is left untouched, and the stage is removed. Only an occupied destination (EEXIST, ENOTEMPTY, EISDIR) is reported as a conflict; any other rename failure is an internal error, and a filesystem without the no-replace flag (EINVAL, ENOSYS, ENOTSUP) falls back to the two-step check-then-rename. Any failure before publication likewise removes the stage and leaves the destination absent, so concurrent attempts have at most one winner. The set root is published with mode 0755 like an ordinary bundle directory, and the attestation records the published path, not the stage. Each class README carries only the upgrade notes for its own components and links the guide at the set root as ../UPGRADING.md. This holds at pkg/bundler and the pkg/client/v1 facade, so the REST handler now renders a split set into a child of its private temp directory and zips that child; the ordinary path still writes the temp directory itself.

    Canonicalization moved to a leaf package. split.yaml's digest must match recipe evidence, but importing pkg/evidence/attestation from the bundler created an import cycle through pkg/oci, whose tests import the bundler. The canonicalization and subject digests now live in pkg/evidence/canonical (yaml and pkg/errors only); pkg/evidence/attestation keeps every exported function as a wrapper, so its API and the evidence it verifies are unchanged.

    Surfaces. --split flag (category Deployment); BundleOptions.Split and config.WithSplit, where a non-nil BundleOptions.Config supersedes Split and MakeBundle rejects Split=true with a Config that lacks it; split query parameter on POST /v1/bundle with its OpenAPI entry; header.KindBundleSplit. Registry merging now warns when an external entry replaces an embedded non-core component without declaring class, since the replacement defaults to core.

    Docs. docs/user/bundling.md gains "Split a bundle by class" (layout, ordering contract, verification unit, create-only publication, rejections) and a note in "Bundle layout"; docs/user/cli-reference.md gains the flag row, a class-directory paragraph under the deploy.sh behavior section and a set-root note under aicr verify; docs/user/api-reference.md gains the split parameter; docs/integrator/recipe-development.md and docs/contributor/recipe.md replace their "planned --split" wording; docs/integrator/supply-chain-verification.md states the set as the closed world; docs/integrator/go-library.md notes Split as a caller-set option outside the config-derived fields and shows an SDK example; the "Deploy the bundle" walkthrough in bundling.md has a set-specific command block; docs/README.md defines "Bundle set".

    Out of scope, per the ADR's deferred list: non-Helm deployers and OCI output (rejected explicitly), standalone class artifacts and a class selector, OCP, per-class bundle-info.yaml, a deploy-time compatibility protocol, and class-aware --inherit-from.

    Testing

    make qualify
    golangci-lint run -c .golangci.yaml ./pkg/bundler/... ./pkg/cli/... ./pkg/server/... ./pkg/client/... ./pkg/recipe/... ./pkg/header/...
    make check-docs-filenames check-docs-mdx check-docs-mdx-parse check-docs-yaml check-docs-shell check-docs-links
    

    New tests. pkg/bundler/split_test.go: a four-component recipe (two core, two ops, monitoring shared across classes) renders a verified set with the expected root files, class folders, split.yaml contents, class README and deploy.sh content and deployment steps; rejections for a core → ops edge, an edge to a disabled later-class component (accepted), OCP, an unregistered component and an all-disabled class each leave no destination and no stage behind; create-only publication rejects an existing destination untouched, an implicit output path and a missing parent; a failing attester after full rendering leaves no destination and no stage; the support-matrix rejections; and the ordinary path still writes one bundle with deploy.sh at the root. pkg/bundler/deployer/helm: the split context's effect on deploy.sh and README.md for an ops class without the CRD shipper, a core class with it, and the unchanged ordinary bundle, plus CRDGroupsInstalledBy. pkg/bundler/config: Validate for the split rules. pkg/bundler: the split query parameter and its presence in the strict allowlist. pkg/server: POST /v1/bundle?split=true through the strict query gate returns a zip rooted at the set with split.yaml and the class directories. pkg/cli: the flag and its OCI rejection. A review round added the class README upgrade-link test, the published-root mode test, the attestation path test, the publish-conflict tests where the destination appears before the final rename, once empty and once populated, and must be left exactly as found, a recipeDigest equality check against canonical.SubjectDigestV3 of the set-root recipe.yaml, the set-root bundle-info.yaml (entrypoint, class-prefixed release paths, ReadReleaseValues), the CLI rejection of --split without --output, the per-class upgrade notice, and the Split/Config precedence rejection in pkg/client/v1.

    Byte identity without --split. TestStockRenderParityGolden (every catalog leaf through the helm deployer) and the helm deployer goldens are unchanged. With a binary from this branch, an EKS / H100 / Ubuntu / training / Kubeflow recipe bundled once with --split and once without: all 16 per-component folders are byte-identical between the class directories and the ordinary bundle (diff -r, ignoring the NNN- index), and the set-root recipe.yaml and UPGRADING.md are identical to the ordinary bundle's. aicr verify passes at the set root; a second run into the same path is rejected with CONFLICT and leaves no staging directory.

    Local gate (make qualify at 82c400aed, pinned tool versions, exit 0; 2588c5bef is that content rebased onto main, followed by docs-only and review-round commits up to the head 57dc6ca84, each checked with the touched packages' tests, lint and the six docs gates):

    | Stage | Result |
    |---|---|
    | Unit tests with -race | 125 packages ok, 0 failures |
    | Coverage | 86.0% total (floor 83%) |
    | golangci-lint, yamllint, license headers, agents sync, docs gates | 0 issues |
    | tuning-check | pass |
    | e2e | 31 passed, 0 failed, 0 skipped |
    | Vulnerability scan (--fail-on high) | pass; the two pre-existing Low/Unknown advisories in transitive modules, identical on main |
    | license check | pass |
    | api-diff | no incompatible SDK facade or alias changes since v1.1.0 |
    | openapi-diff | no unacknowledged breaking changes (the split parameter is additive) |

    Per-package coverage against main (go test -cover, same command both sides): pkg/bundler 88.5% → 88.1%, pkg/bundler/config 95.9% → 95.8%, pkg/bundler/deployer/helm 92.7% → 92.8%, pkg/header 100% → 100%, pkg/evidence/attestation 80.2% → 79.5% (its canonicalization code and tests moved to the new pkg/evidence/canonical, at 89.4%). Every new exported function is covered.

    CLI surface and architecture gates. pkg/cli/testdata/cli-surface.golden is regenerated for the new flag, and tests/architecture/facade-policy.yaml records config.WithSplit and Config.Split as behavioral, the same classification as the sibling options.

    KWOK deployment (kind + KWOK, the repo's kwok/scripts/validate-scheduling.sh flags and conditional --set values, recipe gb300-eks-training, branch binary). Baseline with one ordinary deploy.sh: 14 releases, 41 pods, all scheduled. Then on the same clean cluster, the split set: core/deploy.sh alone installs the 10 core releases (aws-ebs-csi-driver, aws-efa, cert-manager, gpu-operator and gpu-operator-pre, nfd, nodewright-operator, nvidia-dra-driver-gpu, nvsentinel, prometheus-operator-crds) with 32 pods running and none unscheduled; ops/deploy.sh then installs the remaining 4, for 14 releases and 41 pods, none unscheduled. The release set after core then ops is identical to the ordinary bundle's. The ops preflight ran with core's monitoring.coreos.com CRDs present and did not report them as orphans. Deploying ops/ alone on a clean cluster fails loudly at its first component, kube-prometheus-stack, with "no matches for kind ServiceMonitor", exit 1 and no release left behind, which is the ordering contract the class README states.

    GB300 EKS deployment (aws-us-east-2-nhensley-gb300, 2 × p6e-gb300r.36xlarge, recipe gb300-eks-ubuntu-inference-dynamo, branch binary, the scheduling flags of the previous install). After tools/cleanup and a reboot of both GPU nodes, core/deploy.sh installed its 12 releases; with only core present a plain GPU pod scheduled on a GB300 node and ran nvidia-smi (driver 580.173.02), and the deployment-phase aicr validate against the set-root recipe.yaml passed operator-health, gpu-operator-version and check-nvidia-smi, failing expected-resources only on the first absent ops component. ops/deploy.sh then installed its 10 releases; the cluster ended with the same 22 releases an ordinary bundle built with the same flags would install, all deployed, every pod Running or Completed, and aicr validate passed every phase on the split deployment: deployment 4 of 4, conformance 11 of 11, performance 1 of 1 (the Dynamo inference-perf run: Qwen3-8B on 4 GPUs, 84,487 tokens/s against a 60,000 floor, TTFT p99 178 ms against a 2,000 ms ceiling). The interventions needed were teardown debris, not the split: an empty namespace stuck behind a dead CRD conversion webhook Grove CRDs stuck behind orphaned instance finalizers, and the Dynamo CRD being swept away by that pending deletion after dynamo-platform had installed, which a reinstall of that one release restored; all from removing the previous operators while a user workload held their objects (#3422).

    Not run in the lanes: the chainsaw and UAT lanes exercise ordinary bundles; wiring a split lane is #3159.

    Risk Assessment

  • Low — Isolated change, well-tested, easy to revert

  • Medium — Touches multiple components or has broader impact

  • High — Breaking change, affects critical paths, or complex rollout
  • Rollout notes: Opt-in. Without --split the bundler, templates, CLI, SDK and REST behave as before; the golden tests pin the ordinary output. The new split query parameter is additive in the OpenAPI contract. The registry merge warning is log-only.

    Checklist

  • Tests pass locally (make test with -race)

  • Linter passes (make lint)

  • I did not skip/disable tests to make CI green

  • I added/updated tests for new functionality

  • I updated docs if user-facing behavior changed

  • Changes follow existing patterns in the codebase

  • Commits are signed off and cryptographically signed (git commit -s -S) — GPG signing info
  • Diff: 650 lines (+487 / -163) across 8 files Reviewer: yuanchen8911 Review duration: 299m
    All Vouch review confidence checks passed
    Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)). Review depth and reviewer attention state are adequate.
    Model 1 · Change Risk (XGBoost)
    Score: 0.52 · 650 lines diff across 8 files
    0.52
    Model 2 · Review Depth (DistilBERT)
    Depth Score: 0.17 · 1 substantive comment(s)
    0.17
    Model 3 · Review Timing & Attention
    Session adequacy: 100% · Reviewer familiarity: 35%
    60%
    Bedrock Claude 3 · Risk Narration
    (disconnected)
    Groq
    Groq Risk Narration
    AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
    Model 1 · Change Risk Attribution
    SHAP Weights
    Diff Size diff_size
    0.388
    Shallow Review Depth shallow_review_depth
    0.289
    Real PR Conversation Timeline
    1 comments
    "Review active on #3420"
    general weight: 0.35
    Reviewers
    Assignees
    Unassigned
    Labels
    risk: low confidence: 60.5% reviewed
    Vouch Risk Breakdown
    AI-powered review risk analysis
    Change Risk
    Change Risk · Model 1 (XGBoost)
    Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
    Score: 52% (MEDIUM) · Higher = larger blast radius
    52%
    Review Confidence
    Review Confidence · Models 2 & 3
    Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
    Score: 60.5% · Lower = rushed or shallow review
    60.5%
    Residual Risk
    Residual Risk · Core Equation
    Residual = Change × (1 − Confidence)
    Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
    Score: 20.5% · Safe to merge
    20.5%
    Repository