mirror of
https://github.com/agent-substrate/substrate.git
synced 2026-10-02 03:24:42 +08:00
#### Summary This PR introduces the `RevertActor` RPC for actor lifecycle management. It includes the API definition, the corresponding workflow execution logic, observability metrics, and updates to the authorization model to support reverting actors. Fixes #1556 Docs updated in #1711 #### Commit-wise Changes **1. Add RevertActor RPC (`1145d99`)** * Introduces the new `RevertActor` RPC to the API definitions. * Updates the corresponding protobuf bindings (affecting files like `ateapi.pb.go` and `ateapi_pb2.py`). **2. Add the revertActor workflow and observability metrics (`dcb1fae`)** * Implements the core `revertActor` workflow logic, designed to be idempotent and re-enterable. It progresses through the following steps: * **Mark Reverting:** Validates that the actor is in a revertable state (`RUNNING`, `PAUSED`, or `CRASHED`) and transitions its state to `REVERTING`. * **Discard Worker:** Safely tears down the execution environment by terminating the workload, detaching volumes, and releasing the assigned worker. * **Collect In-Progress Snapshot:** Cleans up external object storage by deleting any objects a previous suspend operation was partway through writing. * **Finalize:** Commits the actor to `SUSPENDED` and strips all node-local and in-progress state pointers (clearing `WorkerAssignment`, `LocalSnapshotInfo`, etc.), returning the actor to its untouched external snapshot. * Instruments the workflow with lifecycle operation metrics (e.g., updating `ate.actor.lifecycle.operation.duration` to track `revert` operations). * *Note/TODO:* Currently, when reverting a paused actor, the workflow drops the pointer to the node-local state but does *not* actually prune the local checkpoint bytes from the node (this is tracked in #641). **3. Add `can_revert` to the authorization model (`2fc53ae`)** * Adds the `can_revert` permission to the auth model, mirroring the shape of `can_suspend` (editor tier of the parent atespace, plus a direct grant so a machine identity can revert the actor it drives without holding an atespace role). **4. Serve RevertActor and add the CLI verb (`f04fab4`)** * Wires the `Control.RevertActor` service method to the workflow (replacing the generated stub that previously answered `Unimplemented`). * Adds the `"ate revert actor"` CLI command, making the feature usable end-to-end. * Implements `Terminate` for the fake atelet. This was necessary because reverting an actor from the `RUNNING` state is the first path to reach this call in functional tests (previously, delete tests skipped this step as they ran against actors with no worker assignment). **5. Add a manual verify script for RevertActor (`8022db3`)** * Adds a script to manually exercise `RevertActor` against a real control plane, since unit and functional tests only run against a fake atelet. * Tests reverting from `CRASHED`, `RUNNING`, and `PAUSED` states, and verifies that attempting to revert a `SUSPENDED` actor is properly rejected. * Simulates a crash by deleting the worker pod the actor runs on to verify the workflow can handle the absence of a worker to terminate. - [ ] Tests pass - [ ] Appropriate changes to documentation are included in the PR