Skip to content

docs(sdk): reconcile the integrator guide and add a runnable example - #2565

Merged
mchmarny merged 5 commits into
mainfrom
feat/2029-sdk-integrator-guide
Sep 3, 2026
Merged

mchmarny merged 5 commits into
mainfrom
feat/2029-sdk-integrator-guide

Conversation

@mchmarny

@mchmarny mchmarny commented Sep 3, 2026

Copy link
Copy Markdown
Member

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 only pkg/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:

  • The quick start told readers OCISource "is reserved but not yet implemented (NewClient returns ErrCodeUnavailable)", while the same file lists it as "Production" and documents it fully under Digest-pinned OCI recipe sources.
  • The snapshot-to-criteria section routed integrators through pkg/fingerprint (Internal) and pkg/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/v1 alone — which is the epic's whole acceptance criterion.

Fixes: #2029
Related: #2016, #2437, #2245

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change
  • 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)
  • Bundlers (pkg/bundler, pkg/component/*)
  • Collectors / snapshotter (pkg/collector, pkg/snapshotter)
  • Validator (pkg/validator)
  • Core libraries (pkg/errors, pkg/k8s)
  • Docs/examples (docs/, examples/)
  • Other: SDK facade 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 stay any and are never guessed.

A deliberate deviation from the issue's wording, flagged for the record. #2029 asks for a compile-only example. A Go Example without an // Output: block never executes — it only has to compile. Since most of this chain is hermetic (Example_bundleAndVerify already runs against EmbeddedSource() with no cluster and no network), a compile-only example would have proven far less than it appears to. So Example_workflow is runnable:

// Output:
// criteria(service=eks, accelerator=h100, intent=training)
// unverified

It executes in 0.86s on every go test run 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, live CollectSnapshot and ValidateState, 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.yaml carries K8s{node.provider=eks} + GPU{hardware.model=h100} measurements, so CriteriaFromSnapshot derives service/accelerator and the example layers intent explicitly — demonstrating the documented "wildcards are not guessed, you state the rest" semantic rather than just describing it.

Testing

make qualify                                              # passes
GOFLAGS= go test ./pkg/client/v1/ -run Example_workflow -v # PASS (0.86s), executes
golangci-lint run -c .golangci.yaml ./pkg/client/v1/...    # 0 issues
./tools/check-docs-filenames && make check-docs-mdx        # OK

Verified by hand rather than assumed: Example_workflow's body references only aicr.* — no pkg/errors, no pkg/recipe, no pkg/fingerprint. The file-level pkg/errors import belongs to the pre-existing Example_errorCodes, and that package is documented "Public (evolving)" in public-api.md, not an escape hatch.

Self-review caught one real defect before push: the first draft pointed readers at ExampleClient_CriteriaFromSnapshot as the "runnable version," but that example has no Output: and reads a snapshot path it does not ship — so it is compile-only. Fixed in 326bd7352 to 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.md is already correct (pkg/fingerprint rightly 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

  • Low — Documentation plus one test-only example and fixture. No production code changed.
  • Medium
  • High

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_CriteriaFromSnapshot and ExampleClient_MirrorInventory are 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 on main and out of scope here; worth its own issue, since it is the same shape as the gate landed in #2028.

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 cryptographically signed (git commit -S) — GPG signing info

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]>
@mchmarny
mchmarny requested a review from a team as a code owner September 3, 2026 20:11
@mchmarny mchmarny added the theme/community Contributor onboarding, docs, and external engagement label Sep 3, 2026
@mchmarny mchmarny self-assigned this Sep 3, 2026
@mchmarny mchmarny changed the title docs(sdk): reconcile the integrator guide and add a runnable workflow example docs(sdk): reconcile the integrator guide and add a runnable example Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai

coderabbitai Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

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: dd0afd1f-a075-43f0-9f63-18b1a8ac6b3a

📥 Commits

Reviewing files that changed from the base of the PR and between ffe0cc2 and d6f0d3b.

📒 Files selected for processing (3)
  • docs/integrator/go-library.md
  • pkg/client/v1/example_test.go
  • pkg/client/v1/testdata/snapshot.yaml

Included review availability: Your plan provides up to 12 included reviews per hour; 11 remain after this review.


📝 Walkthrough

Walkthrough

The 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 CriteriaFromSnapshot facade method, and the implemented digest-pinned OCI source.

Estimated code review effort: 2 (Simple) | ~10 minutes

Merge Risk: ⚪ Minimal · up to 7d65e

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: almaslennikov

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning The PR satisfies the documentation, OCI, facade, API-boundary, and compilation requirements in #2029. However, the linked issue explicitly requires an example covering snapshot → criteria → recipe → v… Add the required validation step to the example or to a compiled helper within the example. Ensure the validation entry point and type contract are compile-checked while keeping cluster-dependent execution disabled if necessary.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the documentation reconciliation and runnable example, which are the main changes.
Description check ✅ Passed The description directly explains the guide updates, facade-only workflow example, fixture, testing, and scope.
Out of Scope Changes check ✅ Passed The changes remain within scope. They update the integrator guide, add the requested SDK example and fixture, and do not modify production code or unrelated components.
Full details: Linked Issues check

Explanation

The PR satisfies the documentation, OCI, facade, API-boundary, and compilation requirements in #2029. However, the linked issue explicitly requires an example covering snapshot → criteria → recipe → validate → bundle → verify, while this example omits validation and states that cluster-dependent validation is not executed.

✨ 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/2029-sdk-integrator-guide

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

@github-actions

github-actions Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Report ✅

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

No Go source files changed in this PR.

@mchmarny
mchmarny merged commit 5cda08f into main Sep 3, 2026
46 checks passed
@mchmarny
mchmarny deleted the feat/2029-sdk-integrator-guide branch September 3, 2026 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs size/M theme/community Contributor onboarding, docs, and external engagement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sdk: integrator guide and runnable example for the Go SDK

2 participants