An EXCEPT construct updates a function / record at a fixed number of positions, so it is not suitable by itself to perform an update on a number of positions that is determined by a variable or parameter. Also, the deep nesting of records will make the notation a little heavy-handed.
You could write the following
inMemoryState' =
LET hks(ims,m) == ims.hkState[m] \* retrieve the hkState component for a machine from an inMemoryState
IN [p \in RMs |->
[inMemoryState[p]
EXCEPT !.hkState = [m \in 1 .. MachinesInRing |->
[hks(@,m) EXCEPT !.state = "working"]]]]
Alternatively, you can encapsulate the update in a suitable operator definition and use it in your action, such as
SetToWorking(ims) ==
[ims EXCEPT !.hkState = [m \in 1 .. MachinesInRing |-> [@[m] EXCEPT !.state = "working"]]]
\* within the action definition:
...
/\ inMemoryState' = [p \in RMs |-> SetToWorking(inMemoryState[p])]
...
Note that "@" in the definition of SetToWorking refers to ims.hkState.
Hope this helps,
Stephan