Skip to content

Add proto message options to attach resource metadata. - #2454

Open
Julian Gutierrez Oschmann (juli4n) wants to merge 3 commits into
agent-substrate:mainfrom
juli4n:apitool_subresources
Open

Julian Gutierrez Oschmann (juli4n) wants to merge 3 commits into
agent-substrate:mainfrom
juli4n:apitool_subresources

Conversation

@juli4n

@juli4n Julian Gutierrez Oschmann (juli4n) commented Oct 10, 2026 •

Copy link
Copy Markdown
Collaborator

The apitool tool used to guess the resource model from names. It kept a hard-coded list of resource names and assigned each RPC to whichever one appeared longest in the method name.

That list is stale and subresource methods were therefore attributed to their parent. For example, GetActorEgressPolicy counted as an Actor method and ListWorkerActorAssignments as a Worker method. Because of that, subresources and singletons were linted against the wrong resource or not at all.

This change records the resource model in the proto itself and makes apitool read it from there.

Changes

The PR has three commits, which can be reviewed one at a time:

  1. Add proto options to annotate API resources and methods.
  2. Annotate the Control API's resources and methods.
  3. Simplify the apitool CLI to read resources from the proto annotations.

Lint rule changes:

New:

  • standard-method-naming: the verb, then for a subresource one of its parents (or Global), then the resource. List uses the plural.
  • subresource-naming: a subresource's message is named without its parent type.
  • singleton-no-list: a singleton has no List method.
  • custom-response-name-matches-method: a custom method returns {MethodName}Response, not the resource.

Changed:

  • get-request-single-objectref is now get-request-shape, and it covers subresources: the parent's ObjectRef plus name.
  • The List, Create, Update and Delete shape rules understand subresources, singletons, Global parents and scope. For example, a List request has an atespace field only for an atespace-scoped top-level resource.

Define a (resource) message option, which marks a message as an API
resource and records its parents, whether it is a singleton, and its
scope, and a (method) option, which names the resource an RPC operates
on. Tools can then read the resource model from the proto instead of
inferring it from names.

Document how to use them in a new "Annotations" section of the API
style guide.
Mark every resource message in ateapi.proto with the (resource) option
and every Control RPC with the (method) option naming the resource it
operates on.
apitool no longer hardcodes the list of resources or uses a heuristic to
detect them, which was broken: it reads the resource model from the
(resource) and (method) options instead, so subresources and singletons
are linted correctly.

Also rework the linter rules to be less verbose and more declarative,
add a rule that custom methods return a {MethodName}Response, and
tighten the API style guide where the rules enforce it: Get and Update
requests have no other fields, DeleteOptions has a closed set of
fields, and nested enum values are prefixed too.
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.

1 participant