Skip to content

docs(sdk): attach each criteria converter's godoc to its own function - #2246

Merged
mchmarny merged 1 commit into
mainfrom
fix/exported-criteria-godoc
Aug 18, 2026
Merged

mchmarny merged 1 commit into
mainfrom
fix/exported-criteria-godoc

Conversation

@mchmarny

Copy link
Copy Markdown
Member

Summary

Separates the ToInternalCriteria and toInternalCriteria doc comments so each attaches to its own function. Comment-only; no non-comment line changes.

Motivation / Context

The ToInternalCriteria paragraph landed in #2243 with no blank line separating it from the pre-existing toInternalCriteria block, so Go reads the two as one contiguous comment attached to the exported function. On merged main:

$ go doc ./pkg/client/v1.ToInternalCriteria
func ToInternalCriteria(c *Criteria) *recipe.Criteria
    toInternalCriteria translates a facade Criteria back into the
    pkg/recipe.Criteria enum-typed shape the resolver consumes. The string
    values are wrapped in the corresponding pkg/recipe enum types without
    validation — registry-strict mode at resolve time is the gate that rejects
    unknown values (with ErrCodeInvalidRequest). ToInternalCriteria projects

So the public, semver-pinned symbol documents itself under the wrong lowercase name and leads with the unexported helper's semantics, while toInternalCriteria is left with no doc at all. It would also trip revive's exported comment rule if that linter is enabled later.

Caught in review of #2243 (thread). Landing it standalone rather than folding into #2245 because that issue may be a while out, and leaving incorrect documentation on the stability-guaranteed surface in the meantime is the thing worth avoiding.

Related: #2243, #2026

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)
  • 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 (pkg/client/v1)

Implementation Notes

Each block now sits directly above the function it describes. After:

$ go doc ./pkg/client/v1.ToInternalCriteria
func ToInternalCriteria(c *Criteria) *recipe.Criteria
    ToInternalCriteria projects a facade Criteria back onto the upstream
    pkg/recipe shape, parsing the plain-string fields into their enum types.
    Returns nil for nil input.

and toInternalCriteria carries its own doc again.

Testing

make qualify   # exit 0

Verified the diff touches no executable line:

git diff -U0 pkg/client/v1/translate.go | grep -E '^[+-]' | grep -vE '^(\+\+\+|---)' \
  | grep -vE '^[+-]\s*//' | grep -vE '^[+-]\s*$'
# (no output)

go doc output before and after is quoted above; the existing TestToInternalCriteria still passes unchanged.

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

Comment-only, single file.

Rollout notes: N/A.

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)
ToInternalCriteria's doc paragraph landed in #2243 with no blank line
separating it from the pre-existing toInternalCriteria block, so Go read
the two as one comment attached to the exported function. On merged
main:

  $ go doc ./pkg/client/v1.ToInternalCriteria
  func ToInternalCriteria(c *Criteria) *recipe.Criteria
      toInternalCriteria translates a facade Criteria back into the
      pkg/recipe.Criteria enum-typed shape the resolver consumes...

The public, semver-pinned symbol documented itself under the wrong
lowercase name and led with the unexported helper's semantics, while
toInternalCriteria was left undocumented. It would also trip revive's
exported-comment rule if that linter is enabled later.

Comment-only: each block now sits directly above the function it
describes. No non-comment line changes.

Signed-off-by: Mark Chmarny <mark@chmarny.com>
@mchmarny mchmarny self-assigned this Aug 18, 2026
@coderabbitai

coderabbitai Bot commented Aug 18, 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: 7f72af74-8e98-4e6c-adc9-6df24565dbbf

📥 Commits

Reviewing files that changed from the base of the PR and between 710b2b9 and 8154f19.

📒 Files selected for processing (1)
  • pkg/client/v1/translate.go

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


📝 Walkthrough

Walkthrough

The change adds exported ToInternalCriteria in pkg/client/v1/translate.go. The function delegates to the existing private conversion helper. The helper remains nil-safe, performs enum casting without validation, and defers validation until resolution. Documentation now describes the public API and private implementation separately.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to 8154f

This change only corrects which SDK functions receive their Go documentation and does not alter runtime behavior, so no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: almaslennikov

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the documentation change for the criteria converter functions.
Description check ✅ Passed The description directly explains the documentation issue, the correction, testing, scope, and risk of the changeset.
✨ 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 fix/exported-criteria-godoc

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

@mchmarny
mchmarny marked this pull request as ready for review August 18, 2026 17:49
@mchmarny
mchmarny requested a review from a team as a code owner August 18, 2026 17:49
@mchmarny
mchmarny merged commit 05e5e03 into main Aug 18, 2026
41 of 43 checks passed
@mchmarny
mchmarny deleted the fix/exported-criteria-godoc branch August 18, 2026 17:51
@github-actions

Copy link
Copy Markdown
Contributor

Coverage Report ✅

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

No Go source files changed in this PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

2 participants