In a provided mono repo (backend, frontend, mocked DB with seed data), implement an effective-dating change that mutates DB records via an API, including the relevant frontend update and unit tests.
Asked in the coding challenge stage. Implement the core behavior as apply_effective_change(records, record_id, effective_date, changes).
Each record has id, valid_from, valid_to, and a fields dictionary. Date strings use YYYY-MM-DD; intervals are half-open: [valid_from, valid_to), and null means no end. If the date matches an existing version, merge the changes into that version. Otherwise, split the active version at the effective date, carrying forward unchanged fields. Return all records sorted by (id, valid_from) without mutating the input.
def apply_effective_change(records, record_id, effective_date, changes):