Repository navigation
docs(sdk): reconcile the integrator guide and add a runnable example - #2565
Conversation
Add Example_workflow to pkg/client/v1/example_test.go, covering the full snapshot -> criteria -> recipe -> bundle -> verify integration path in one runnable example with an Output: block, backed by a checked-in snapshot fixture (testdata/snapshot.yaml). Closes the last v1 blocker of #2016. Signed-off-by: Mark Chmarny <[email protected]>
Fix the quick-start comment claiming OCISource is unimplemented, which contradicted the fully documented "Digest-pinned OCI recipe sources" section further down the same page. Rewrite the snapshot criteria-relaxation example to use the facade's Client.CriteriaFromSnapshot (added by #2437) instead of reaching past the stable surface into pkg/fingerprint and pkg/recipe, and drop the now-false "escape hatch, not stable API" callout that pointed at #2016 as an open gap. Also drop the matching stale cross-reference in "The integrator contract". List the new Example_workflow in the runnable-examples table. Signed-off-by: Mark Chmarny <[email protected]>
Signed-off-by: Mark Chmarny <[email protected]>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (3)
Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review. 📝 WalkthroughWalkthroughThe Go SDK adds a runnable end-to-end example for loading a snapshot, deriving criteria, assigning intent, resolving a recipe, creating a bundle, and verifying it. It adds a snapshot fixture with EKS and H100 data. The integrator guide now documents this workflow, the Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to This change updates the Go SDK integration guide and adds a runnable facade-only workflow example with a checked-in fixture. No production behavior changes or remaining merge-readiness risks are identified. Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation The PR satisfies the documentation, OCI, facade, API-boundary, and compilation requirements in ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Coverage Report ✅
Coverage BadgeNo Go source files changed in this PR. |
Summary
Reconciles the Go SDK integrator guide with what the epic actually shipped, and adds
Example_workflow— a runnable end-to-end example covering snapshot → criteria → recipe → bundle → verify using onlypkg/client/v1.Motivation / Context
#2029 is the last v1 blocker of #2016. The facade capabilities landed across the epic, but the guide did not keep up, and it had drifted into contradicting both itself and the code:
OCISource"is reserved but not yet implemented (NewClient returnsErrCodeUnavailable)", while the same file lists it as "Production" and documents it fully under Digest-pinned OCI recipe sources.pkg/fingerprint(Internal) andpkg/recipe, wrapped in a caveat that closed with "a facade-owned snapshot-to-criteria helper is the obvious gap it exposes." sdk: derive facade Criteria from Snapshot #2437 filled that gap; the guide was still advertising it.The net effect was that the documented workflow could not be completed through
pkg/client/v1alone — which is the epic's whole acceptance criterion.Fixes: #2029
Related: #2016, #2437, #2245
Type of Change
Component(s) Affected
cmd/aicr,pkg/cli)cmd/aicrd,pkg/server)pkg/recipe)pkg/bundler,pkg/component/*)pkg/collector,pkg/snapshotter)pkg/validator)pkg/errors,pkg/k8s)docs/,examples/)pkg/client/v1)Implementation Notes
The escape hatch is gone. The snapshot-to-criteria block now calls
Client.CriteriaFromSnapshot(pkg/client/v1/aicr.go:640) and imports only the facade. The "escape hatch, not stable API" block quote is deleted outright — it was false, and its closing invitation pointed at a gap that no longer exists. The criteria-relaxation semantics around it are preserved unchanged, including the rule that undetermined dimensions stayanyand are never guessed.A deliberate deviation from the issue's wording, flagged for the record. #2029 asks for a compile-only example. A Go
Examplewithout an// Output:block never executes — it only has to compile. Since most of this chain is hermetic (Example_bundleAndVerifyalready runs againstEmbeddedSource()with no cluster and no network), a compile-only example would have proven far less than it appears to. SoExample_workflowis runnable:It executes in 0.86s on every
go testrun and catches a resolve that returns nothing, a bundle that writes no files, or a verify that silently degrades — none of which a compile-only example would notice. The two legs that genuinely need a cluster, liveCollectSnapshotandValidateState, are documented in the example's comment and deliberately not executed rather than faked.For context on why this mattered: of the 19 examples already in this file, only 5 carry an
Output:. The other 14 pin signatures, not behavior.Backed by a real fixture.
pkg/client/v1/testdata/snapshot.yamlcarriesK8s{node.provider=eks}+GPU{hardware.model=h100}measurements, soCriteriaFromSnapshotderivesservice/acceleratorand the example layersintentexplicitly — demonstrating the documented "wildcards are not guessed, you state the rest" semantic rather than just describing it.Testing
Verified by hand rather than assumed:
Example_workflow's body references onlyaicr.*— nopkg/errors, nopkg/recipe, nopkg/fingerprint. The file-levelpkg/errorsimport belongs to the pre-existingExample_errorCodes, and that package is documented "Public (evolving)" inpublic-api.md, not an escape hatch.Self-review caught one real defect before push: the first draft pointed readers at
ExampleClient_CriteriaFromSnapshotas the "runnable version," but that example has noOutput:and reads a snapshot path it does not ship — so it is compile-only. Fixed in326bd7352to point at the example that actually runs, and to say plainly why the other one does not.Two of the five issue items were confirmed no-ops rather than edited for their own sake:
public-api.mdis already correct (pkg/fingerprintrightly stays Internal — the package still exists, only the guide's routing changed), and the #2245 config-derivation table from #2548 is already present and accurate.Risk Assessment
Rollout notes: No production code in this PR. The new example runs in the normal test suite, so it is self-policing: if a facade entry point or type contract changes, it fails to compile, and if the workflow's behavior changes, the
Output:mismatch fails the run.Follow-up found, not fixed here
ExampleClient_CriteriaFromSnapshotandExampleClient_MirrorInventoryare both missing from the guide's examples table, and no test enforces that the table and the code stay in sync — so that drift was silent. Pre-existing onmainand out of scope here; worth its own issue, since it is the same shape as the gate landed in #2028.Checklist
make testwith-race)make lint)git commit -S) — GPG signing info