Apply a constrained atomic state patch
Implement apply_updates(state, operations) for plain top-level dictionary paths using add, replace, remove, and test. Return a new state or raise ValueError without mutating the input.
Your task
- Accept paths of the form /key where key is nonempty and contains neither / nor ~. This intentionally excludes full JSON Pointer syntax.
- add sets a key, including an existing key; replace and remove require that key to exist.
- test requires an existing key equal to value; any failure aborts the whole update.
- Reject unsupported operations and copy nested values so result mutations cannot alter input state.
Examples
EXAMPLE 1
Input{'status':'draft'} with replace /status='ready'
Output{'status':'ready'}
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor