Skip to content

api: validate manifests with k8s declarative validation #726

Open

Description

@yongruilin

Manifest validation is hand-written in internal/apivalidation: each rule is Go code plus test rows, kept apart from the field it checks. Agent Substrate uses Kubernetes declarative validation instead: most of its rules are +k8s: tags on the proto fields, and validation-gen generates the checks (guide).

Why change it:

  • A simple rule (required, name format, range, list size) becomes one line next to the field. Many input fields have no check today, for example metadata.labels, spec.env, spec.commands, and the MCP and Model fields, and no list has a size limit.
  • Gateway egress rules are Substrate's types and already carry its tags, so the rules Substrate declares that way can be generated instead of copied by hand (TODO: Validate everything that Substrate validates in ValidateGateway).
  • A request gets every problem back with its field path, not only the first one.

Proposal: declare validation rules as tags in the .proto files and generate the checks with validation-gen. Rules a tag cannot express stay hand-written.

Error messages change format, and their field paths use proto names (ate_template, not ateTemplate).

Related:

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions