Skip to content

Add CI check for amctl client codegen drift#888

Merged
RAVEENSR merged 2 commits into
wso2:mainfrom
jhivandb:cli-drift-protection
May 16, 2026
Merged

Add CI check for amctl client codegen drift#888
RAVEENSR merged 2 commits into
wso2:mainfrom
jhivandb:cli-drift-protection

Conversation

@jhivandb
Copy link
Copy Markdown
Contributor

Purpose

The amctl CLI client at cli/pkg/clients/amsvc/gen/ is generated from agent-manager-service/docs/api_v1_openapi.yaml. There is currently no automated check that the committed client stays in sync with the spec, so silent drift accumulates and only surfaces when someone notices a build break or wrong field name at runtime. This PR adds a PR-time check.

Goals

  • Fail a PR when the committed amctl AM-service client is out of sync with the OpenAPI spec
  • Catch up the existing drift in types.gen.go so the new check passes on main

Approach

New workflow .github/workflows/cli-codegen-check.yaml triggered on PRs that touch:

  • agent-manager-service/docs/api_v1_openapi.yaml
  • cli/pkg/clients/amsvc/**
  • Makefile
  • the workflow file itself

Steps:

  1. Install oapi-codegen pinned to v2.6.0 (matches the version recorded in the existing generated files).
  2. Run make amctl-gen-client (the existing target).
  3. git diff --exit-code -- cli/pkg/clients/amsvc/gen — fail with a clear message telling the developer to run make amctl-gen-client and commit the result.
  4. cd cli && go build ./... so a regen that still type-mismatches consumer code fails the workflow rather than silently passing.

The regenerated types.gen.go is included to clear pre-existing drift:

  • New Metadata field on AddAgentKindVersionRequest, AgentKindVersionResponse, PublishAgentKindRequest
  • AgentFromKind struct removed, replaced by flat KindName *string on AgentResponse

go build ./... in cli/ passes against the regenerated types — no consumer code referenced the removed symbols.

User stories

N/A — internal CI safeguard.

Release note

N/A — internal CI change, not user-facing.

Documentation

N/A — no user-facing change.

Training

N/A.

Certification

N/A — no impact on certification exams.

Marketing

N/A — internal CI change.

Automation tests

  • Unit tests

    N/A — workflow change.

  • Integration tests

    The workflow itself is the test. It was validated locally: make amctl-gen-client reproduced the drift on the committed file (catch-up included here), and cd cli && go build ./... passes against the regenerated client.

Security checks

Samples

N/A.

Related PRs

None.

Migrations (if applicable)

N/A.

Test environment

  • Linux, Go 1.25.x
  • oapi-codegen v2.6.0

Learning

Used the same pattern the agent-manager-service workflow uses for its codegenfmt-check job — regenerate in CI and fail on diff. The workflow caught real existing drift on first run, which is the desired behavior.

Regenerate cli/pkg/clients/amsvc/gen/types.gen.go from the current
api_v1_openapi.yaml to catch up to existing drift (new Metadata
fields, AgentFromKind -> KindName).
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Warning

Rate limit exceeded

@jhivandb has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 33 minutes and 16 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0252baac-3aa7-482e-b45b-63ec673d30f9

📥 Commits

Reviewing files that changed from the base of the PR and between a6e334c and bebde00.

⛔ Files ignored due to path filters (1)
  • cli/pkg/clients/amsvc/gen/types.gen.go is excluded by !**/gen/**
📒 Files selected for processing (1)
  • .github/workflows/cli-codegen-check.yaml
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@RAVEENSR RAVEENSR merged commit 36808fd into wso2:main May 16, 2026
4 checks passed
RAVEENSR added a commit to RAVEENSR/agent-manager that referenced this pull request May 27, 2026
Add CI check for amctl client codegen drift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants