Skip to content

chore(recipe): remove back-compat shims introduced by #1107#1118

Merged
mchmarny merged 3 commits into
mainfrom
feat/remove-recipe-shims
May 30, 2026
Merged

chore(recipe): remove back-compat shims introduced by #1107#1118
mchmarny merged 3 commits into
mainfrom
feat/remove-recipe-shims

Conversation

@mchmarny

Copy link
Copy Markdown
Member

Summary

Remove the back-compat shims in pkg/recipe and pkg/validator/catalog that were retained from #1107 so the deprecated package-global path is gone from the public surface. The Stage 2 of #983.

Fixes: #1114
Related: #983, #987, #1076 (epic, closed), #1107, #1108

Motivation

#1107 introduced per-DataProvider isolation but kept the legacy entry points as thin shims so #1108 could land without forcing every caller to migrate in lockstep. Now that #1108 has shipped and all in-tree callers consume the per-provider path through pkg/client/v1.Client, the shims serve no in-tree purpose. Keeping them invites new code to reach for the global path and leaks the deprecated symbols into pkg/recipe's Public (evolving) surface indefinitely.

Type of Change

  • Bug fix
  • New feature
  • Breaking change — for external Go importers using the deprecated path
  • Documentation update
  • Refactoring (no in-tree behavior change)
  • Build/CI/tooling

Component(s) Affected

  • CLI (pkg/cli)
  • API server (pkg/api)
  • Recipe engine (pkg/recipe)
  • Bundlers (pkg/bundler)
  • Validator (pkg/validator, pkg/validator/catalog)
  • Core libraries (pkg/config, pkg/fingerprint, pkg/evidence/attestation)
  • Other: pkg/client/v1 facade, validators/*

Symbols removed

Package Symbol Replacement
pkg/recipe SetDataProvider, GetDataProvider (and the globalDataProvider/dataProviderGeneration/dataProviderMu/getDataProviderGeneration package-globals) recipe.NewBuilder(recipe.WithDataProvider(dp)); hold and pass DataProvider explicitly
pkg/recipe EffectiveDataProvider (bound-first/global-fallback shim) Pass the provider directly; LayeredDataProvider type assertion is nil-safe
pkg/recipe DefaultRegistry (singleton over GetCriteriaRegistryFor(GetDataProvider())) recipe.NewCriteriaRegistry() for an ephemeral one; recipe.GetCriteriaRegistryFor(dp) for per-provider
pkg/recipe ParseCriteriaServiceType / …Accelerator / …Intent / …OS / …Platform (*CriteriaRegistry).ParseService / .ParseAccelerator / .ParseIntent / .ParseOS / .ParsePlatform
pkg/recipe AllCriteriaServiceTypes / …Accelerator / …Intent / …OS / …Platform (*CriteriaRegistry).AllServiceTypes etc., or GetCriteriaServiceTypes etc. (static OSS lists)
pkg/recipe BuildCriteria + WithCriteriaService / …Accelerator / …Intent / …OS / …Platform / …Nodes (and the CriteriaOption type) BuildCriteriaWithRegistry + WithServiceRegistry / WithAcceleratorRegistry / etc. (RegistryCriteriaOption type)
pkg/recipe LoadFromFile LoadFromFileWithProvider
pkg/validator/catalog Load(version, commit) LoadWithDataProvider(dp, version, commit)
pkg/config (*RecipeSpec).ResolveCriteria() (*RecipeSpec).ResolveCriteriaWithRegistry(reg)

Signature changes (registry threading)

Function Before After
recipe.ParseCriteriaFromRequest (r *http.Request) (r *http.Request, reg *CriteriaRegistry)
recipe.ParseCriteriaFromValues (values url.Values) (values url.Values, reg *CriteriaRegistry)
recipe.ParseCriteriaFromBody (body io.Reader, contentType string) (body io.Reader, contentType string, reg *CriteriaRegistry)
recipe.LoadCriteriaFromFile (path string) (path string, reg *CriteriaRegistry)
recipe.LoadCriteriaFromFileWithContext (ctx, path) (ctx, path, reg *CriteriaRegistry)
fingerprint.(*Fingerprint).ToCriteria () (reg *recipe.CriteriaRegistry)
attestation.ComputeRecipeDigest (ctx, path, kubeconfig, version) (ctx, dp recipe.DataProvider, path, kubeconfig, version)
(*Criteria).Validate unchanged (uses fresh empty registry internally) new sibling ValidateWithRegistry(reg) for callers holding a registry

A nil registry on any of the new signatures falls back to a fresh ephemeral NewCriteriaRegistry() — only hardcoded OSS values will validate. Callers that need --data overlay values to flow through must pass a non-nil registry (typically client.CriteriaRegistry()).

In-tree call-site migrations

  • pkg/api/recipe_handler.go → passes h.client.CriteriaRegistry()
  • pkg/recipe/handler.go, handler_query.goGetCriteriaRegistryFor(b.DataProvider())
  • pkg/cli/snapshot.go, pkg/cli/recipe.go → fresh NewCriteriaRegistry() / static GetCriteria*Types()
  • pkg/cli/evidence_digest.go → constructs an embedded DataProvider for ComputeRecipeDigest
  • pkg/client/v1/aicr.gocriteriaFromRequest(req, GetCriteriaRegistryFor(builder.DataProvider()))
  • pkg/bundler/bundler.go → inline nil-check + direct type assertion (provider.(*recipe.LayeredDataProvider))
  • All nil-fallback paths in pkg/recipe/components.go, metadata_store.go, adapter.goNewEmbeddedDataProvider(GetEmbeddedFS(), "") instead of GetDataProvider()
  • pkg/recipe/criteria_registry.go GetCriteriaRegistryFor(nil) → returns a fresh ephemeral registry (not cached) instead of caching against the global

Test updates

Deleted (their target symbols are gone):

  • TestDataProviderGeneration, TestEffectiveDataProvider in pkg/recipe/provider_test.go
  • TestRecipeResult_GetValuesForComponent_BoundProviderSurvivesGlobalSwap in pkg/recipe/adapter_test.go
  • TestLoadCatalog_DoesNotLeakRegistryOnFailure, TestDefaultRegistry_Singleton in pkg/recipe/criteria_registry_test.go
  • TestBuildCriteria, TestWithCriteriaOS, TestWithCriteriaNodes in pkg/recipe/criteria_test.go
  • Entire pkg/recipe/criteria_registry_parse_test.go file — every test in it targeted a deleted symbol
  • TestMain in validators/deployment/expected_resources_test.go (workaround for a parallel-test race in globalDataProvider lazy init; race is gone with the global)

Migrated:

  • Remaining tests use method-form reg.ParseService(...) instead of ParseCriteriaServiceType(...)
  • Tests using DefaultRegistry() now use NewCriteriaRegistry()
  • pkg/bundler/bundler_test.go's Set/GetDataProvider swap → recipeResult.BindDataProvider(layered)
  • pkg/validator/catalog/catalog_test.go's Set/GetDataProvider swap → pass the layered provider directly to LoadWithDataProvider
  • pkg/client/v1/aicr_internal_test.go, aicr_test.go BuildCriteria + WithCriteria*BuildCriteriaWithRegistry(nil, ...) + WithXRegistry

Behavior

No in-tree behavior change. All in-tree callers were migrated by #1108; this PR only removes the deprecated entry points and updates a few remaining call sites that still hit them.

For external Go importers: any caller still on the deprecated path must migrate. See the symbol mapping table above.

Testing

make qualify
$ go vet ./...     # clean
$ make lint        # 0 issues
$ go test -race ./...
ok      github.com/NVIDIA/aicr/pkg/recipe         16.875s
ok      github.com/NVIDIA/aicr/pkg/cli            3.571s
ok      github.com/NVIDIA/aicr/pkg/api            5.869s
ok      github.com/NVIDIA/aicr/pkg/client/v1     12.815s
ok      github.com/NVIDIA/aicr/pkg/bundler        ...
ok      github.com/NVIDIA/aicr/pkg/validator      1.710s
ok      github.com/NVIDIA/aicr/pkg/validator/catalog  2.349s
ok      github.com/NVIDIA/aicr/validators/...     ...

pkg/trust fails locally due to a sandbox network restriction (TUF endpoint not in allowlist); CI has network access and the test passed there for prior PRs of mine.

Risk Assessment

  • Low
  • Medium — Breaking change for external Go importers using the deprecated path. In-tree callers were migrated by feat(cli,api): consume aicr.Client facade (#1077) #1108, so the in-tree blast radius is just the call-site migrations enumerated above. Net diff: -1067 / +249 lines (deletion-heavy).
  • High

Rollout notes: Release notes for the next minor must call this out as a breaking change. External importers update per the symbol mapping table above. No // Deprecated: warnings preceded this removal in tree, but the symbols carried //nolint:staticcheck // back-compat fallback ... (#983 Stage 2) comments indicating their intended lifetime.

Checklist

  • make test (race) passes locally (modulo pre-existing pkg/trust sandbox-network failure)
  • make lint passes
  • No skipped/disabled tests
  • Tests updated/added for the new functionality
  • No // Deprecated: symbols intentionally left behind
  • Changes follow existing patterns in the codebase
  • Commits are cryptographically signed (git commit -S)

Closes #1114. The Stage 2 of #983.

Now that #1108 migrated all in-tree CLI/API callers off the deprecated
package-global path, remove the back-compat shims so the deprecated
symbols are gone from the public surface. External Go importers using
the deprecated path must migrate to the per-DataProvider variants.

Symbols removed from pkg/recipe:

- SetDataProvider / GetDataProvider (and the globalDataProvider /
  dataProviderGeneration / dataProviderMu / getDataProviderGeneration
  package-globals)
- EffectiveDataProvider (was the bound-first / global-fallback shim)
- DefaultRegistry (package-singleton criteria registry shim over
  GetCriteriaRegistryFor(GetDataProvider()))
- ParseCriteriaServiceType / ParseCriteriaAcceleratorType /
  ParseCriteriaIntentType / ParseCriteriaOSType /
  ParseCriteriaPlatformType (package-level shims over
  DefaultRegistry().ParseService / .ParseAccelerator / etc.)
- AllCriteriaServiceTypes / AllCriteriaAcceleratorTypes /
  AllCriteriaIntentTypes / AllCriteriaOSTypes /
  AllCriteriaPlatformTypes (package-level shims over
  DefaultRegistry().AllServiceTypes / etc.)
- BuildCriteria + WithCriteriaService / WithCriteriaAccelerator /
  WithCriteriaIntent / WithCriteriaOS / WithCriteriaPlatform /
  WithCriteriaNodes (and the CriteriaOption type — its sibling
  RegistryCriteriaOption + BuildCriteriaWithRegistry path remains)
- LoadFromFile (package-level wrapper over LoadFromFileWithProvider)

Symbols removed from pkg/validator/catalog:

- Load(version, commit) — back-compat shim over LoadWithDataProvider

Symbols removed from pkg/config:

- (*RecipeSpec).ResolveCriteria — back-compat shim over
  ResolveCriteriaWithRegistry(DefaultRegistry())

Migration & ripples:

- pkg/api/recipe_handler.go: ParseCriteriaFromRequest /
  ParseCriteriaFromBody / ParseCriteriaFromValues now take an explicit
  *recipe.CriteriaRegistry parameter; the handler passes
  h.client.CriteriaRegistry().
- pkg/recipe/handler.go and handler_query.go: pass
  GetCriteriaRegistryFor(b.DataProvider()) on the registry-aware path.
- pkg/recipe/criteria.go: validateAndConvertRawSpec /
  LoadCriteriaFromFile / LoadCriteriaFromFileWithContext /
  loadCriteriaFromHTTPWithContext now take an explicit *CriteriaRegistry.
- (*Criteria).Validate now uses an ephemeral registry and is paired
  with a new ValidateWithRegistry(reg) for callers holding a real one.
- pkg/fingerprint/(*Fingerprint).ToCriteria now takes a
  *recipe.CriteriaRegistry; pkg/cli/query.go passes
  client.CriteriaRegistry().
- pkg/cli/snapshot.go: uses recipe.NewCriteriaRegistry().ParseOS
  instead of the package-level shim.
- pkg/cli/recipe.go: help text + tab completions use the static
  GetCriteria*Types instead of the package-singleton's AllCriteria*Types,
  matching the pre-PR effective behavior at help-generation time.
- pkg/cli/evidence_digest.go: constructs an explicit embedded
  DataProvider for ComputeRecipeDigest.
- pkg/evidence/attestation/ComputeRecipeDigest now takes a
  recipe.DataProvider parameter (was: relied on the package-global).
- pkg/client/v1/aicr.go criteriaFromRequest takes a
  *recipe.CriteriaRegistry; the resolve path passes the Client's own
  registry via GetCriteriaRegistryFor(builder.DataProvider()).
- pkg/config/resolve.go ResolveCriteriaWithRegistry's nil-fallback now
  builds NewCriteriaRegistry() (an ephemeral empty registry) instead
  of DefaultRegistry().
- pkg/validator/catalog/LoadWithDataProvider's nil-fallback now uses
  NewEmbeddedDataProvider directly instead of GetDataProvider().
- pkg/recipe/adapter.go / components.go / metadata_store.go nil-fallbacks:
  same swap.
- pkg/bundler/bundler.go: drops recipe.EffectiveDataProvider in favor
  of inline nil-check on provider before the LayeredDataProvider type
  assertion (type assertions on nil interface return zero/false).
- pkg/recipe/criteria_registry.go GetCriteriaRegistryFor(nil) now
  returns a fresh NewCriteriaRegistry() (not cached) instead of
  caching against the package-global provider.

Test updates:

- Deleted TestDataProviderGeneration, TestEffectiveDataProvider,
  TestRecipeResult_GetValuesForComponent_BoundProviderSurvivesGlobalSwap,
  TestLoadCatalog_DoesNotLeakRegistryOnFailure,
  TestDefaultRegistry_Singleton, TestBuildCriteria, TestWithCriteriaOS,
  TestWithCriteriaNodes — they exercised the deleted shim paths.
- Deleted pkg/recipe/criteria_registry_parse_test.go in full — every
  test in it targeted a deleted symbol.
- Updated remaining tests to use the per-provider variants
  (NewCriteriaRegistry() in place of DefaultRegistry(), method-form
  reg.ParseService in place of ParseCriteriaServiceType, etc.).
- Removed TestMain in validators/deployment that pre-initialized the
  package-global to avoid a parallel-test race — that race is gone
  with the global itself.

External Go importers must update:

  - import path / call patterns from the deleted symbols above
  + per-provider equivalents (recipe.WithDataProvider, the
  + (*CriteriaRegistry).Parse* methods, BuildCriteriaWithRegistry,
  + LoadFromFileWithProvider, catalog.LoadWithDataProvider,
  + ResolveCriteriaWithRegistry).

No behavior change for in-tree CLI/REST callers (they were migrated
in #1108). make qualify clean.
@github-actions

github-actions Bot commented May 30, 2026

Copy link
Copy Markdown
Contributor

Coverage Report ✅

Metric Value
Coverage 76.6%
Threshold 75%
Status Pass
Coverage Badge
![Coverage](https://img.shields.io/badge/coverage-76.6%25-green)

Merging this branch changes the coverage (2 decrease, 3 increase)

Impacted Packages Coverage Δ 🤖
github.com/NVIDIA/aicr/pkg/api 54.60% (ø)
github.com/NVIDIA/aicr/pkg/bundler 72.64% (ø)
github.com/NVIDIA/aicr/pkg/cli 65.23% (+0.02%) 👍
github.com/NVIDIA/aicr/pkg/client/v1 76.79% (ø)
github.com/NVIDIA/aicr/pkg/config 92.72% (+0.26%) 👍
github.com/NVIDIA/aicr/pkg/evidence/attestation 71.31% (ø)
github.com/NVIDIA/aicr/pkg/fingerprint 98.08% (+0.02%) 👍
github.com/NVIDIA/aicr/pkg/recipe 86.75% (-2.09%) 👎
github.com/NVIDIA/aicr/pkg/validator/catalog 97.53% (-0.03%) 👎

Coverage by file

Changed files (no unit tests)

Changed File Coverage Δ Total Covered Missed 🤖
github.com/NVIDIA/aicr/pkg/api/recipe_handler.go 69.39% (ø) 98 68 30
github.com/NVIDIA/aicr/pkg/bundler/bundler.go 72.07% (ø) 605 436 169
github.com/NVIDIA/aicr/pkg/cli/evidence_digest.go 69.23% (+2.56%) 13 (+1) 9 (+1) 4 👍
github.com/NVIDIA/aicr/pkg/cli/query.go 43.59% (ø) 78 34 44
github.com/NVIDIA/aicr/pkg/cli/recipe.go 83.62% (ø) 116 97 19
github.com/NVIDIA/aicr/pkg/cli/snapshot.go 63.04% (ø) 92 58 34
github.com/NVIDIA/aicr/pkg/client/v1/aicr.go 81.44% (ø) 334 272 62
github.com/NVIDIA/aicr/pkg/config/resolve.go 94.85% (+0.49%) 194 (-1) 184 10 (-1) 👍
github.com/NVIDIA/aicr/pkg/config/validate.go 100.00% (ø) 54 54 0
github.com/NVIDIA/aicr/pkg/evidence/attestation/recipe_digest.go 0.00% (ø) 9 0 9
github.com/NVIDIA/aicr/pkg/fingerprint/to_criteria.go 100.00% (ø) 14 (+2) 14 (+2) 0
github.com/NVIDIA/aicr/pkg/recipe/adapter.go 88.41% (ø) 69 61 8
github.com/NVIDIA/aicr/pkg/recipe/allowlist.go 95.77% (+0.06%) 71 (+1) 68 (+1) 3 👍
github.com/NVIDIA/aicr/pkg/recipe/components.go 85.59% (ø) 111 95 16
github.com/NVIDIA/aicr/pkg/recipe/criteria.go 71.01% (-10.94%) 345 (-43) 245 (-73) 100 (+30) 💀
github.com/NVIDIA/aicr/pkg/recipe/criteria_registry.go 100.00% (ø) 93 93 0
github.com/NVIDIA/aicr/pkg/recipe/handler.go 80.00% (+0.51%) 40 (+1) 32 (+1) 8 👍
github.com/NVIDIA/aicr/pkg/recipe/handler_query.go 84.21% (+0.21%) 76 (+1) 64 (+1) 12 👍
github.com/NVIDIA/aicr/pkg/recipe/loader.go 91.30% (-0.36%) 23 (-1) 21 (-1) 2 👎
github.com/NVIDIA/aicr/pkg/recipe/metadata_store.go 85.83% (-0.83%) 360 309 (-3) 51 (+3) 👎
github.com/NVIDIA/aicr/pkg/recipe/provider.go 90.52% (-1.15%) 211 (-17) 191 (-18) 20 (+1) 👎
github.com/NVIDIA/aicr/pkg/validator/catalog/catalog.go 97.53% (-0.03%) 81 (-1) 79 (-1) 2 👎

Please note that the "Total", "Covered", and "Missed" counts above refer to code statements instead of lines of code. The value in brackets refers to the test coverage of that file in the old version of the code.

@coderabbitai

coderabbitai Bot commented May 30, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: 9c5b325f-2eb6-4f8f-a4da-4653b0f1519d

📥 Commits

Reviewing files that changed from the base of the PR and between cac8a55 and 14fe82b.

📒 Files selected for processing (3)
  • pkg/api/recipe_handler.go
  • pkg/bundler/bundler.go
  • pkg/recipe/handler_query.go

📝 Walkthrough

Walkthrough

This PR removes package-global recipe DataProvider/DefaultRegistry shims and makes provider and criteria-registry usage explicit across the codebase. It adds NewCriteriaRegistry, switches parsing/validation to registry-bound methods, introduces LoadFromFileWithProvider, changes nil-provider fallbacks to an embedded provider, updates handlers/CLI/client to thread registries from their DataProvider, and migrates tests to the new APIs while deleting tests that asserted global-provider/singleton behavior.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~60 minutes

Possibly related issues

Possibly related PRs

  • NVIDIA/aicr#1016: Overlaps on bundler provider plumbing and external-vs-embedded data handling changes.
  • NVIDIA/aicr#1108: Introduced facade-backed API handlers that this PR further wires to use client-bound CriteriaRegistry.
  • NVIDIA/aicr#1055: Related to evidence-digest and provider argument/embedded-provider changes that this PR adjusts.

Suggested labels

area/recipes, area/tests

Suggested reviewers

  • lalitadithya
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The PR title clearly describes the main change: removing back-compat shims from the recipe package that were introduced by a previous PR.
Description check ✅ Passed The PR description is comprehensive and directly related to the changeset, detailing symbol removals, migrations, and all affected components.
Linked Issues check ✅ Passed All coding requirements from issue #1114 are met: shims removed, in-tree callers migrated, registry threading implemented, tests updated/deleted appropriately, and make qualify passes.
Out of Scope Changes check ✅ Passed All changes are directly aligned with the linked issue objectives—removals of deprecated symbols and migrations of call sites to per-provider variants. No extraneous refactoring or feature additions present.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/remove-recipe-shims

Comment @coderabbitai help to get the list of available commands and usage tips.

coderabbitai[bot]

This comment was marked as resolved.

…rror wrap

Addresses CodeRabbit review on #1118:

- pkg/recipe: introduce a package-level defaultEmbeddedProvider
  singleton used as the nil-fallback by LoadMetadataStoreFor,
  GetComponentRegistryFor, and GetManifestContentWithProvider.
  Constructing a fresh *EmbeddedDataProvider on every nil call would
  change the registryCache / storeCache key identity each time,
  defeating the per-DataProvider cache and causing unbounded growth on
  the default path. A single instance gives the cache a stable key.
- pkg/recipe/adapter.go, components.go, metadata_store.go: switch
  every nil-fallback site to use defaultEmbeddedProvider.
- pkg/recipe/adapter.go: update GetManifestContentWithProvider and
  RecipeResult.GetValuesForComponent godoc to reflect the embedded
  fallback (was: "falls back to GetDataProvider()").
- pkg/recipe/criteria_registry.go: drop the now-stale "use
  DefaultRegistry for the package singleton consulted by
  ParseCriteria*Type" wording; retarget the docs to NewCriteriaRegistry
  (ephemeral) and GetCriteriaRegistryFor (per-DataProvider). Drop the
  "global default" reference on GetCriteriaRegistryFor.
- pkg/client/v1/aicr.go criteriaFromRequest: replace errors.Wrap with
  errors.PropagateOrWrap when surfacing recipe.BuildCriteriaWithRegistry
  failures so structured error codes (e.g., ErrCodeInvalidRequest from
  registry parse) survive the boundary instead of being clobbered with
  a fixed ErrCodeInvalidRequest wrapper.

Build, lint, and tests clean on affected packages.
@mchmarny mchmarny enabled auto-merge (squash) May 30, 2026 02:38

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
pkg/recipe/metadata_store.go (1)

90-92: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

GoDoc still references removed GetDataProvider() fallback.

Lines 90-92 state "A nil provider falls back to GetDataProvider()" but the implementation at line 118 now uses defaultEmbeddedProvider. Update the comment to reflect the actual embedded-data singleton fallback behavior.

Suggested fix
-// A nil provider falls back to GetDataProvider() so the legacy
-// loadMetadataStore(ctx) entry point — which consults the package-global
-// provider — continues to work transparently.
+// A nil provider falls back to the package-level embedded-data singleton
+// (defaultEmbeddedProvider) so the legacy loadMetadataStore(ctx) entry
+// point continues to work transparently.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/recipe/metadata_store.go` around lines 90 - 92, Update the GoDoc to
reflect the actual fallback behavior: change the comment that says "A nil
provider falls back to GetDataProvider()" to state that a nil provider falls
back to the package-level embedded-data singleton `defaultEmbeddedProvider` so
that `loadMetadataStore(ctx)` continues to work; reference `loadMetadataStore`
and `defaultEmbeddedProvider` in the comment to make the behavior explicit.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@pkg/recipe/metadata_store.go`:
- Around line 90-92: Update the GoDoc to reflect the actual fallback behavior:
change the comment that says "A nil provider falls back to GetDataProvider()" to
state that a nil provider falls back to the package-level embedded-data
singleton `defaultEmbeddedProvider` so that `loadMetadataStore(ctx)` continues
to work; reference `loadMetadataStore` and `defaultEmbeddedProvider` in the
comment to make the behavior explicit.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Enterprise

Run ID: a2874611-02b0-4add-8119-97c7f07ebda9

📥 Commits

Reviewing files that changed from the base of the PR and between 8f8ef57 and cac8a55.

📒 Files selected for processing (6)
  • pkg/client/v1/aicr.go
  • pkg/recipe/adapter.go
  • pkg/recipe/components.go
  • pkg/recipe/criteria_registry.go
  • pkg/recipe/metadata_store.go
  • pkg/recipe/provider.go

@yuanchen8911 yuanchen8911 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.

Review verified against cac8a55a.

Two functional findings are posted inline below (query POST criteria validation). The remaining items are doc/godoc cleanup that can't be attached inline because those files aren't part of this PR's diff:

Doc/godoc cleanup (files not in this PR):

  1. docs/contributor/data.md (~L1698–L1816) — the global-provider section still documents removed/global APIs and stale guidance: SetDataProvider, GetDataProvider, GetDataProviderGeneration, DefaultRegistry(), ParseCriteriaServiceType, AllCriteria{...}Types(), and "call LoadCatalog right after SetDataProvider". (recipe.LoadCatalog(ctx) itself still exists — only the surrounding guidance is stale.) Suggest rewriting around the per-provider API: NewBuilder(WithDataProvider(dp)), GetCriteriaRegistryFor(dp) / NewCriteriaRegistry(), (*CriteriaRegistry).ParseService (and siblings), GetCriteria{...}Types() for the static lists, LoadMetadataStoreFor(ctx, dp), GetComponentRegistryFor(dp), and (*client.Client).LoadCatalog(ctx).

  2. docs/contributor/validator.md (L235) — image-tag resolution is described as "applied by catalog.Load", but catalog.Load(version, commit) was removed in favor of catalog.LoadWithDataProvider(dp, version, commit).

  3. pkg/recipe/doc.go (L158–L164) — package godoc still says callers "may continue to use SetDataProvider / GetDataProvider … remain functional for back-compat" and that a nil provider "falls back to GetDataProvider()". Both are now false — the accessors are gone and the nil fallback routes through defaultEmbeddedProvider. This is misleading to the external-importer audience the PR's breaking-change note targets.

Minor: stale code comments still reference the removed EffectiveDataProvider / GetDataProvider() / AllCriteriaServiceTypes in pkg/recipe/{adapter,criteria,metadata,metadata_store,components,builder}.go (the bundler.go ones are flagged inline below).

Note: the earlier cache-key-stability findings (fresh *EmbeddedDataProvider per nil-call defeating storeCache/registryCache) were verified as already resolved on this head by the defaultEmbeddedProvider singleton in provider.go — not re-raised here.

Comment thread pkg/recipe/handler_query.go
Comment thread pkg/api/recipe_handler.go
Comment thread pkg/bundler/bundler.go
…ale comments

Addresses three more findings on #1118:

- pkg/recipe/handler_query.go: the POST branch validated req.Criteria
  with the no-arg Validate() (which uses a fresh ephemeral
  NewCriteriaRegistry — OSS-only), while the GET branch parsed against
  the per-provider registry already in scope (`reg`). A criteria value
  contributed by a `--data` overlay would be accepted on GET and
  rejected with HTTP 400 on POST against the same handler — a real
  GET/POST asymmetry. Switch the POST validation to
  ValidateWithRegistry(reg) so both verbs honor the same registry.
- pkg/api/recipe_handler.go: same fix in the API server's query
  handler — POST now validates with
  ValidateWithRegistry(h.client.CriteriaRegistry()).
- pkg/bundler/bundler.go: two stale comments referenced
  EffectiveDataProvider (removed by this PR) falling back to the
  package-global. Rewrite both to describe the current behavior:
  bundler asserts on the bound provider directly; a nil interface
  returns (nil, false) from the LayeredDataProvider type assertion
  without panicking, equivalent to no external data.

Build + lint + tests clean.

@yuanchen8911 yuanchen8911 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.

Approving. The two functional findings — query POST --data criteria validation in pkg/recipe/handler_query.go and pkg/api/recipe_handler.go — are resolved via ValidateWithRegistry, CI is green, and no blockers remain.

A few minor doc/godoc cleanups remain (non-blocking — fine as a follow-up):

  • docs/contributor/data.md still documents removed global-provider and criteria-registry APIs (SetDataProvider, GetDataProvider, GetDataProviderGeneration, DefaultRegistry(), AllCriteria{...}Types()).
  • pkg/recipe/doc.go still tells external importers that SetDataProvider / GetDataProvider remain functional for back-compat — worth correcting since this PR removes them.
  • docs/contributor/validator.md still references the removed catalog.Load (now catalog.LoadWithDataProvider).

@mchmarny mchmarny merged commit 338a519 into main May 30, 2026
31 checks passed
@mchmarny mchmarny deleted the feat/remove-recipe-shims branch May 30, 2026 03:27
yuanchen8911 added a commit to yuanchen8911/aicr that referenced this pull request May 30, 2026
PR NVIDIA#1118 removed the package-global data-provider and criteria-registry
shims, but three docs still referenced the deleted APIs:

- docs/contributor/data.md: rewrote the CLI-init example to the per-command
  aicr.Client pattern, dropped the "package-global accessors" subsection,
  and refreshed the Criteria Registry prose + API-surface table to the
  per-DataProvider API (GetCriteriaRegistryFor / NewCriteriaRegistry /
  (*CriteriaRegistry).Parse*/All*Types, (*aicr.Client).LoadCatalog).
- pkg/recipe/doc.go: removed the "SetDataProvider/GetDataProvider remain
  functional" claim and updated the ParseCriteriaFromRequest/Body and
  LoadCriteriaFromFile examples to pass the new registry argument.
- docs/contributor/validator.md: catalog.Load -> catalog.LoadWithDataProvider.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

chore(recipe): remove back-compat shims introduced by #1107

2 participants