Apply a batch of updates to a keyed table so the operation is idempotent — running it twice with the same input gives the same result as running it once (no duplicates, no drift). This is what makes a pipeline safe to retry.
table is a dict mapping id -> record. updates is a list of record dicts, each with an "id" key. Upsert each update (insert if new, overwrite if the id exists — the update replaces the whole record, it is not merged into it) and return the new table. Do not mutate the input table, and don't share record dicts with table or updates — editing a record in the returned table must not change the caller's data.
What the tests check
6 on Run · 7 on Submit01inserts a new record
02overwrites existing by id
03does not mutate the input table
04idempotent: applying twice equals applying once
05an update replaces the whole record (no stale fields survive)
06returned records are independent of the caller's table and updates
Submit runs these and one more check you don’t see, so code written for the visible tests alone can still miss.