Design an Immutability Helper Utility for Nested State Updates
Build an immutability helper (inspired by React's immutability-helper or Immer) that allows you to declaratively describe nested state updates using command objects like $set, $push, $splice, $merge, and $apply without mutating the original object. The function should perform a deep clone-and-update operation, returning a brand new object tree with only the specified paths changed. Crucial for Redux reducers, undo/redo stacks, and time-travel debugging.