Skip to content

feat(api): own typed references for models and MCP servers - #3604

Open
codyhartsook wants to merge 1 commit into
mainfrom
codyhartsook/ownedRefs
Open

codyhartsook wants to merge 1 commit into
mainfrom
codyhartsook/ownedRefs

Conversation

@codyhartsook

@codyhartsook codyhartsook commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Description

v1alpha3 model and MCP server references can't name another kind:

Reference Type today Issue
MCP server corev1.TypedObjectReference An omitted apiGroup means the core group, so CEL rules pin it to RemoteMCPServer. The CRD docs describe ReferenceGrant and a feature gate kagent doesn't use.
Model v1alpha3.ObjectReference No kind

This PR gives both one kagent-owned shape, like v1alpha2's TypedReference: optional group and kind next to name. Omitted values keep today's meaning, and a group other than api.kagent.dev must name its own kind. Any other kind fails with reason InvalidKind on ResolvedRefs, as in Gateway API. Egress policy references keep LocalObjectReference until a second policy kind exists.

A second kind must ship at least one release after this one. A v1.0.x controller ignores group and kind on a model reference and quietly resolves the same-named ModelConfig, which may call the model with a different credential. Before rolling back to v1.0.x, point model references back to ModelConfig.

Compatibility with v1.0.x

  • Stored objects and manifests need no changes, and their revision digests stay the same.
  • MCP kind defaults to RemoteMCPServer in the schema, so v1.0.x controllers and clients can still update the object.
  • apiGroup stays as a deprecated MCP field that must be omitted. v1.0.x Go clients, including the kagent CLI, send it as null, and the gRPC API rejects unknown fields.
  • Go: ObjectReference is renamed ModelConfigReference, and MCPToolBinding.Server changes type.
  • Rolling the CRDs back to v1.0.x drops group and kind from model references at the next write.

docs/kubernetes-api.md and STYLE.md now say to own reference types instead of reusing corev1 ones. The name must not be empty CEL rules on model references are gone, since the schema already requires a non-empty name.

Stacked on this: #3607 keeps group and kind on references the UI saves.

Change Type

/kind feature

Changelog

Model and MCP server references accept optional `group` and `kind` fields. Omitted values keep their current meaning; other kinds report `InvalidKind`.

Validation

  • make lint, including kube-api-linter, and make manifests.
  • Unit and envtest suites for api/v1alpha3, translator, controller, grpcserver, substrate and cli.
  • CRD admission: v1.0.x client JSON is accepted under default and strict validation, and a foreign group without its own kind is rejected on both references.
  • Swapped the CRDs between this branch and v1.0.x in envtest. Objects stay updatable after rollback, and a v1.0.x client round trip succeeds.
  • Compiled the same v1.0.x-shaped Agents on main and this branch for the kagent, Codex and Claude harnesses. The revision digests match.

@github-actions github-actions Bot added the enhancement New feature or request label Nov 9, 2026
@blacksmith-sh

This comment was marked as outdated.

@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 9, 2026
@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from 394029c to be0e138 Compare November 9, 2026 20:20
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 9, 2026
@codyhartsook
codyhartsook added this pull request to stack #3608 November 9, 2026 20:22
@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from be0e138 to 97287a8 Compare November 9, 2026 20:30
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2026
@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from 97287a8 to 65f7e29 Compare November 10, 2026 18:50
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2026
@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from 65f7e29 to a1b1e84 Compare November 10, 2026 19:07
@codyhartsook codyhartsook changed the title feat(api): own typed references for models, MCP servers, and egress policies feat(api): own typed references for models and MCP servers Nov 10, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2026
@codyhartsook
codyhartsook marked this pull request as ready for review November 10, 2026 19:38
@codyhartsook
codyhartsook requested a review from a team as a code owner November 10, 2026 19:38
Comment thread go/api/v1alpha3/common_types.go Resolved
shashankram
shashankram previously approved these changes Nov 10, 2026

@shashankram shashankram left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the updated head a1b1e84. The egress reference changes are fully removed, and the remaining model and MCP reference changes look correct. No blocking findings.

@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from a1b1e84 to 26d670e Compare November 10, 2026 20:21
Comment thread go/api/v1alpha3/agenttemplate_types.go Resolved
Comment thread go/api/v1alpha3/agenttemplate_types.go Resolved
Comment thread go/api/v1alpha3/common_types.go Resolved
Comment thread go/api/v1alpha3/common_types.go Resolved
Comment thread go/api/v1alpha3/common_types.go Outdated
// +kubebuilder:validation:XValidation:rule="!has(self.apiGroup)",message="use group instead of apiGroup"
// +kubebuilder:validation:XValidation:rule="!has(self.group) || self.group == 'api.kagent.dev' || (has(self.kind) && self.kind != 'RemoteMCPServer')",message="a group other than api.kagent.dev requires its own kind"
type MCPServerReference struct {
// v1.0.x Go clients encode an unset apiGroup as null. Keeping the field lets

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same thing as below. I might be missing something. I don't think we care about breaking Go clients right now, so I think we can remove this field. Rollbacks aren't currently supported afaik

@codyhartsook codyhartsook Nov 10, 2026 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decided to keep the field and reworded its comment to give the reason. The kagent CLI sends apiGroup: null, and the gRPC API rejects unknown fields (structuredobject.go:75), so a v1.0.x CLI would break against a new server. The kind default stays because the upgrade suite rolls back to the previous release.

Comment thread go/api/v1alpha3/common_types.go Resolved
Comment thread go/api/v1alpha3/common_types.go Resolved
Comment thread go/api/v1alpha3/common_types.go Resolved
Comment thread go/core/test/upgrade/upgrade_test.go Resolved

@timflannagan timflannagan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also something that I forgot to mention. I think we should update STYLE.md + any other relevant docs to avoid using types where we don't own the API evolution, e.g. corev1

Signed-off-by: Cody Hartsook <cody.hartsook@solo.io>
@codyhartsook
codyhartsook force-pushed the codyhartsook/ownedRefs branch from 26d670e to 98d76a3 Compare November 10, 2026 22:12
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 10, 2026
@codyhartsook

Copy link
Copy Markdown
Contributor Author

On the STYLE.md note: updated STYLE.md and docs/kubernetes-api.md. References use kagent-owned types, not corev1 ones. Existing corev1 fields keep their type until they need to change.

@codyhartsook
codyhartsook removed this pull request from stack #3608 November 11, 2026 18:54
@codyhartsook
codyhartsook added this pull request to stack #3648 November 11, 2026 18:55
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels Nov 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants