Files
substrate/cmd/ateapi/internal/controlapi
Troy Chiu 07da819da1 controlapi: refactor workflows to typed ensure-steps (#797)
Fixes #554 

Each workflow becomes a plain method orchestrating typed, idempotent
ensureX steps, e.g.:

```go
func (w *ActorWorkflow) ResumeActor(ctx, ref, boot) (*Actor, bool, error) {
    // acquire actor lock, metrics defer — unchanged
    actor, tmpl, snapSrc, err := w.loadActorForResume(ctx, ref, boot)
    if actor.Status == RUNNING { return actor, false, nil }        // explicit no-op
    actor, err         = w.ensureVolumesCreated(ctx, actor, tmpl)
    actor, worker, err = w.ensureWorkerAssigned(ctx, actor, tmpl)
    err                = w.ensureVolumesAttached(ctx, actor, worker, tmpl)
    tele, err          = w.ensureAteletRestored(ctx, actor, worker, tmpl, snapSrc)
    actor, err         = w.finalizeRunning(ctx, ref)
    return actor, true, nil
}
```
Each `ensureX` 
- early-returns if its postcondition already holds, which is derived
from persisted state only, replacing `IsComplete`
- validates the state machine edge internally, replacing
`CheckPrerequisite`
- takes explicit typed inputs and returns what it produced.
- persists what it changed before returning, returning the stored copy
so the optimistic lock version threads forward. No shared
`*ResumeState`.

There is one behavioral change: worker ownership/eligibility validation
for a re-entered resume now runs before volumes are attached (it used to
run in `CallAteletRestoreStep`'s prerequisite, after attach), so a
resume that is about to crash on a reassigned/ineligible worker no
longer attaches volumes to it first.

- [X] Tests pass
- [ ] Appropriate changes to documentation are included in the PR
2026-08-10 14:19:43 -04:00
..
2026-06-26 20:05:03 -07:00
2026-08-07 18:20:22 +00:00
2026-08-07 18:20:22 +00:00
2026-05-31 19:45:36 -07:00
2026-08-07 18:20:22 +00:00
2026-08-07 18:20:22 +00:00
2026-08-07 18:20:22 +00:00
2026-08-07 18:20:22 +00:00
2026-08-07 18:20:22 +00:00