feat(cli,api): consume aicr.Client facade (#1077)#1108
Conversation
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (28)
📝 WalkthroughWalkthroughThis PR centralizes recipe/catalog/bundling/validation behind a per-command aicr.Client facade, expands the facade with catalog/criteria, allowlists, validation options, and bundling APIs, implements recipe and bundle HTTP handlers using the facade, refactors CLI commands to construct per-command clients, adds tests for facade behavior and handler parity, and updates docs describing validation phases and recipe sources. Estimated code review effort🎯 4 (Complex) | ⏱️ ~75 minutes Possibly related issues
Possibly related PRs
Suggested labels
Suggested reviewers
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 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.
Inline comments:
In `@pkg/cli/bundle.go`:
- Around line 605-626: The client construction here duplicates logic from
recipeClientFromCmd; replace the manual data-dir/source/NewClient block with a
call to recipeClientFromCmd(cmd, cfg) to obtain the client and error, e.g.
client, err := recipeClientFromCmd(cmd, cfg), then handle err the same way and
defer client.Close() as done now. Keep references to cmd, cfg.Recipe().DataDir()
behavior and ensure the returned client is closed in the same defer; remove the
duplicated aicr.NewClient / aicr.WithRecipeSource / aicr.WithVersion code so
behavior is consistent with recipeClientFromCmd.
In `@pkg/cli/recipe.go`:
- Around line 309-349: The function buildCriteriaFromCmd is only referenced by
tests; either wire it into the runtime criteria path or demote it to test-only:
if you want runtime usage, have mergeCriteriaFromCmdAndConfig call
buildCriteriaFromCmd(cmd, reg) to construct CLI-only criteria (replace or
consolidate existing applyCriteriaOverrides logic accordingly) so
buildCriteriaFromCmd is used by production code; otherwise move
buildCriteriaFromCmd into pkg/cli/recipe_test.go (make it unexported if
necessary) and update recipe_test.go to call the local helper, removing the
unused exported function from production code.
In `@pkg/cli/validate.go`:
- Around line 752-776: Duplicate client construction in validate.go should be
replaced with the shared helper recipeClientFromCmd to avoid code duplication:
locate the block that builds the dataDir/source and calls aicr.NewClient (and
defers client.Close) and replace it by invoking recipeClientFromCmd (the same
helper used in root.go) to obtain the client and error handling; ensure you pass
the same inputs (the command flags/context and version/config as used here) and
keep the existing defer close behavior using the returned client.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: cb86e00f-c5da-423d-82e5-cfb87cf4e05a
📒 Files selected for processing (28)
aicr.goaicr_internal_test.goaicr_test.gobundle.gobundle_test.godocs/integrator/go-library.mddocs/integrator/public-api.mdoptions.gopkg/api/bundle_handler.gopkg/api/bundle_handler_test.gopkg/api/recipe_handler.gopkg/api/recipe_handler_test.gopkg/api/server.gopkg/api/server_test.gopkg/bundler/handler.gopkg/cli/bundle.gopkg/cli/config_integration_test.gopkg/cli/mirror.gopkg/cli/query.gopkg/cli/recipe.gopkg/cli/recipe_test.gopkg/cli/root.gopkg/cli/validate.gopkg/cli/validate_evidence.gopkg/recipe/handler_query.gopkg/recipe/handler_query_test.goquery.gotypes.go
|
@hkii this PR now has merge conflicts with |
…undle (#1077) Migrate the CLI (recipe, query, validate, bundle, mirror) and REST server (/v1/recipe, /v1/query, /v1/bundle) onto the top-level aicr.Client facade instead of constructing recipe.Builder/bundler.Bundler directly or mutating the process-global data provider. server.go no longer builds recipe.Builder or bundler.Bundler; recipe/query/mirror build a per-invocation Client and seed their own per-provider criteria registry. Behavior preserved; the deliberate CLI validation-timeout uncap is opt-in via the facade. Facade surface: EmbeddedSource, WithVersion, WithAllowLists, ParseAllowListsFromEnv, ResolveRecipeFromCriteria/FromSnapshot, SelectFromRecipe, LoadRecipe/LoadRecipeBytes, AdoptRecipe, MakeBundle, ValidateState(+phase/timeout/provider), Client.LoadCatalog + CriteriaRegistry; Recipe/AllowLists/Criteria/CriteriaRegistry aliases.
2f9f028 to
98b5465
Compare
Coverage Report ✅
Coverage BadgeNo Go source files changed in this PR. |
Summary
Migrate the CLI (
recipe,query,validate,bundle,mirror) and REST server (/v1/recipe,/v1/query,/v1/bundle) onto the top-levelaicr.Clientfacade instead of constructingrecipe.Builder/bundler.Bundlerdirectly or mutating the process-global provider. PR 2 of 2 for #1077.What changes
server.gobuilds anaicr.Client; no longer constructsrecipe.Builderorbundler.Bundler→ acceptance criterion reliably use flox in CI #2.recipe/query/mirrorbuild a per-invocation Client and seed their own per-provider criteria registry;initDataProviderand the lastrecipe.SetDataProvidercalls are removed frompkg/cli→ acceptance criterion fix: remove namespaceOverride from nvidia-dra-driver-gpu values #1.EmbeddedSource,WithVersion,WithAllowLists,ParseAllowListsFromEnv,ResolveRecipeFromCriteria/FromSnapshot,SelectFromRecipe,LoadRecipe/LoadRecipeBytes,AdoptRecipe,MakeBundle,ValidateState(+ phase/timeout/provider options),Client.LoadCatalog/CriteriaRegistry;Recipe/AllowLists/Criteria/CriteriaRegistryaliases.Behavior
CLI flags and REST endpoints behave identically (criterion #3). One deliberate change, called out explicitly: CLI validation is no longer bounded by the facade's fixed
ValidationOperationTimeout(it's opt-in, default uncapped for the CLI) — the previous CLI path relied only on per-validator timeouts, and the fixed cap would cancel a legitimate all-phase run that includes the 50m inference-perf check.Testing
make qualifygreen (tree identical to the validated combined branch). New facade + handler tests assert byte-identical REST responses, allowlist rejection parity, the query hydrate-vs-selector 404/5xx split, and per-Client provider isolation.Relates to #1077. Note:
aicr.Client's*Recipealias methods are provisional pending the facade-owned wrappers in #1078.