Skip to content

api: align TaskState with Substrate ActorState - #731

Merged
rakyll merged 2 commits into
mainfrom
states
Nov 24, 2026
Merged

rakyll merged 2 commits into
mainfrom
states

Conversation

@rakyll

@rakyll rakyll commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Fixes #708.

TaskState used to rename and collapse Substrate's ActorState on read (RUNNING → WORKING, RESUMING/REVERTING → QUEUED, CRASHED → FAILED, DELETING → UNSPECIFIED) and defined AX-only states that nothing set. This PR makes TaskState mirror ActorState and keeps only the AX states that current behavior needs.

API (pkg/apis/v1alpha1/task.proto)

# TaskState Source
1–7 RESUMING, RUNNING, SUSPENDING, SUSPENDED, CRASHED, DELETING, REVERTING The actor's state; same names and numbers as ActorState
8–199 reserved For ActorState values Substrate may add
200 QUEUED Stored: actor not provisioned yet (until #698)
201 FAILED Stored: provisioning or resume failed, or the actor is missing (until #695/#698)
202 COMPLETED Reserved, TODO(#690); nothing sets it yet

IDLE, REQUIRES_ACTION, WORKING and CANCELLED are removed.

Breaking: enum numbers changed. Stored tasks are protojson, so states are stored by name, and the stored names QUEUED and FAILED are unchanged.

Server and CLI

  • actorTaskState maps each ActorState to the TaskState of the same name.
  • IsAXTaskState covers QUEUED, FAILED and COMPLETED. FormatTaskState prints Running, Crashed, Deleting, and so on.
  • isExecutionTerminal is removed: it checked COMPLETED, CANCELLED and FAILED with an outcome, none of which the server sets.
  • ax ssh requires the task to be Running.
  • New TestActorTaskStateMirrorsActorState fails if the enums drift apart or an AX-only state goes below 200. TestStoredStatus covers every IsAXTaskState state.

Docs

docs/concepts.md, docs/local_installer.md and README.md use the new state names.

Not in this PR

The hero demo (hack/hero-demo/) still waits for a Completed state that nothing sets. Its fix moves to #722, together with the runner's launcher-done permission fix.

Testing

  • make verify, go build ./cmd/ax ./cmd/ax-server ./cmd/ax-runner and go test ./... pass.
  • E2E not run locally.

@rakyll
rakyll requested a review from mayawang as a code owner November 23, 2026 19:38
@rakyll rakyll self-assigned this Nov 23, 2026
@rakyll
rakyll requested a review from yongruilin November 23, 2026 19:39
@rakyll

rakyll commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

We will bring REQUIRES_ACTION once we are designing the HITL use case.

@yongruilin yongruilin left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

it is quite straight forward. Only one thing about the hero demo. Rest LGTM.
Actually, should the "hero demo" be part of the CI?

Comment thread hack/hero-demo/README.md Resolved

@mayawang mayawang left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM on the TaskState alignment and mirror test. Agree with @yongruilin on splitting the hero-demo change to land with #722.

Comment thread internal/server/status_test.go Resolved
TaskState values 1-7 now have the same names and numbers as Substrate's
ActorState and are read from the task's actor without renaming:
RUNNING (was WORKING), RESUMING and REVERTING (were QUEUED), CRASHED
(was FAILED), and DELETING (was UNSPECIFIED).

AX's own stored states start at 200, with 8-199 reserved for ActorState
values Substrate may add: QUEUED (200) and FAILED (201), which are still
needed until #698 and #695 land, and COMPLETED (202), reserved for #690.
IDLE, REQUIRES_ACTION and CANCELLED are removed. Nothing set them.

isExecutionTerminal is removed: no state it checked can be reached.

Fixes #708
IsAXTaskState includes TASK_STATE_COMPLETED, so cover it in the loop of
stored states.
@rakyll

rakyll commented Nov 23, 2026

Copy link
Copy Markdown
Member Author

Removed the hero demo fixes from the PR. We will follow up on that fix.

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.

api: align TaskState with Substrate ActorState and avoid unnecessary extra states

3 participants