inkandswitch / cambria-project

Schema evolution with bi-directional lenses.
MIT License
592 stars 24 forks source link

Enforcing conservation #12

Open michielbdejong opened 1 month ago

michielbdejong commented 1 month ago

It seems to me, at first sight, that it should be possible to enforce the conservation design goal at compile time, if desired.

For instance, in the example from appendix III of the research paper where the single-value writer is [...] overwriting data they are unaware of, maybe Cambria could track which schema is aware/unaware of which bits of data, and make sure no write that happens under a given schema ever affects data that is not covered by that schema.

One could maybe model the lens more precisely by keeping the common information separate from the one-sided information, in an intermediate step:

Schema A: assignee: string | null <- lens 1 (trivially) -> Intermediate: { mainAssignee: string | null, otherAssignees: string[] } <- lens 2 (lossless) -> Schema B: assignees: string[]

I'll think about this some more.