Apply a trace of cache operations and return {"keys": final key rows, "values": final value rows, "length": final token count}. Operation ["append", new_keys, new_values] appends matching rows to both caches. Operation ["rollback", length] truncates both caches to that absolute prefix length, not by that many tokens.
Return independent lists and do not mutate input rows or operation payloads. An empty append is a no-op; rollback to zero clears the cache.
def update_kv_cache(keys, values, operations):
Constraints
Initial and appended K/V have matching row counts and a consistent feature width 1..8 when nonempty.
0..32 operations; every rollback target is between zero and the current length; at most 64 live rows.
Inputs satisfy these constraints; invalid-input handling is not graded. Use only Python standard library and NumPy.