Cambria

Distributed software is everywhere. We consume or provide APIs, connect to databases, and load files written by others. As these systems evolve, we need to change data schemas while maintaining compatibility between different versions and components. But we don’t have powerful tools for handling this schema evolution, so we usually resort to ad hoc solutions, like conditionals peppered throughout the code and complex multi-step migration processes.

We propose a principled replacement for these messy solutions: an isolated software layer that translates data between schemas on demand. This layer allows developers to maintain strong compatibility with many schema versions without complicating the main codebase. Translation logic is defined by composing bidirectional lenses, a kind of data transformation that can run both forward and backward.

We have implemented these ideas in Cambria, a TypeScript lens library, and used it to build an experimental issue tracker. The issue tracker has full support for real-time collaboration between all of its versions, and is demonstrated throughout this piece.

We believe tools like Cambria could revolutionize the way developers handle schema change. The benefits apply in many familiar contexts, but take on particular importance in decentralized software, where no single authority controls the data format. Ultimately, we hope that better schema evolution tools will lead to a “Cambrian Era” for software, where people can customize their software more freely while preserving the ability to collaborate with one another.