8000 Allow creating a task from an actor template · Issue #491 · google/ax · GitHub
[go: up one dir, main page]

Skip to content

Allow creating a task from an actor template #491

Open

Description

@rakyll

Add an optional template field to TaskSpec that references a Substrate ActorTemplate. A task sets at most one of image and template:

  • If image is set, the task runs from that image, as today.
  • If template is set, the task runs from the referenced template.
  • If neither is set, keep today's default (DefaultTaskImage).

The API server rejects a Task that sets both image and template. It also rejects command together with template, because the template defines what runs.

Example

apiVersion: ax.io/v1alpha1
kind: Task
metadata:
  name: lint
  atespace: default
spec:
  # The actor is created from this ActorTemplate.
  template:
    name: node-agent
    atespace: ax-system  # optional, defaults to the task's atespace
  workspaces:
    - name: default-workspace

Rejected at apply time:

spec:
  image: gcr.io/ax-substrate/ate-images/ax-task-runner:latest
  template:  # error: set image or template, not both
    name: node-agent
message TaskSpec {
  // ...existing fields 1-6...

  // template references the Substrate ActorTemplate to run the task from.
  // It can't be combined with image or command.
  ObjectRef template = 7;
}

// ObjectRef references a resource by name.
message ObjectRef {
  string name = 1;
  // atespace defaults to the referencing resource's atespace.
  string atespace = 2;
}

Activity

  1. cloudonly commented on Oct 21, 2026

    @cloudonly
    Contributor

    Following up on @rakyll's note on #505 — I'd like to take this on.

    The spec above is clear on the API surface. Three points where I'd want a decision before coding:

    1. Template lifecycle and ownership. Today the reconciler provisions <task>-tmpl-<digest> ActorTemplates and ReconcileDelete sweeps them by that name pattern. For a user-supplied template, AX should neither create nor delete it — so deleting a task with spec.template set skips template cleanup and only deletes the actor. Related edge: a user-supplied template whose name happens to match another task's generated pattern could be swept by that task's deletion. I'd restrict the sweep to templates AX itself created rather than rejecting names at apply time, but either works.

    2. Existence check at apply time. Reject a Task whose bound Workspace does not exist #461 rejects Tasks whose referenced Workspaces don't exist. Should CreateTask do the same for the referenced template, or is a late TemplateCreationFailed at reconciliation acceptable for v1? I'd lean toward the apply-time check, same reasoning as Reject a Task whose bound Workspace does not exist #461, accepting that the template can still disappear later.

    3. Template drift. Tasks are immutable but ActorTemplates are mutable in Substrate, and the reference is by name — a recreated or edited template changes what the actor boots on the next resume. Is name-reference drift acceptable for v1, or should the task pin something stronger once Substrate exposes it?

    Minor: the example still shows the pre-#496 workspaces: list; I'll use the singular workspace binding in the implementation and tests.

    Unless the answers change the shape, the plan is: the proto field, apply-time validation (image XOR template, no command with template), reconciler paths that run against an existing template without provisioning one, deletion that never touches user templates, and tests for each.

  2. siyuanfoundation commented on Nov 2, 2026

    @siyuanfoundation
    Collaborator

    /assign

  3. siyuanfoundation commented on Nov 2, 2026

    @siyuanfoundation
    Collaborator

    Thanks @cloudonly for your interest.
    I have already created a PR for it.

    For your questions:

    1. deleting a task with spec.template set skips template cleanup in the PR
    2. a task is rejected at creation time if the referenced ActorTemplate does not exist, as explained in the PR description
    3. The ActorTemplate itself is actually immutable after creation, see https://github.com/agent-substrate/substrate/blob/ae3ac05b0140c30bed1f323b2e62d2c28f580079/cmd/ateapi/internal/controlapi/actor_template.go#L140
  4. mayawang commented on Nov 2, 2026

    @mayawang
    Collaborator

    @cloudonly sorry we didn't get back to you on this sooner, that's on us. Thanks for the questions, they shaped the PR. If you're up for another one, #424 or anything labeled devx would be great.

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

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    0