REPOSITORY CODING · MEDIUM
Resolve reader aliases without losing renamed values
A reader field named new with alias old must receive the writer old field, including numeric promotion. Exact names retain priority over aliases.
Typed schema evolutionSchema resolution laboratory
Work through a real codebase.
Choose an environment, investigate the existing implementation and use the tests to check your change. Sign in to open a workspace; execution and Ono usage follow your plan’s allowances.
Task requirements and environments
PHP · 55 minute session
- Resolve a bounded writer/reader schema pair and up to 20 JSON records. Primitive types are null, boolean, int (signed 32-bit), long (safe JSON integer), double, string and lowercase hex bytes. Records, arrays, maps, enums, fixed bytes and tagged unions are supported to depth eight; field/symbol/branch counts have explicit limits. Named types are inline declarations, not unresolved external references.
- Compatibility means every writer value can be read. Numeric widening is int->long/double and long->double, never narrowing. Every writer union branch needs a reader match; a reader union picks its first compatible branch. Union values are {branch:tag,value}, where named branches use their name.
- Record names may match reader aliases. Reader fields match writer names first, otherwise one unambiguous reader field alias. Drop writer-only fields. Missing reader fields require a validated default, including explicit null. For union defaults, the raw default must match the first branch and migration wraps it in that branch tag. Unknown writer record fields and malformed record values are errors.
- Arrays/maps resolve recursively and preserve map key spelling. Enum writer symbols must exist in the reader or use a declared reader default that belongs to its symbols. Fixed types require matching names/aliases and byte sizes. Validate all schema defaults before migrating any record.
- Return compatible for the complete schema space and independent per-record migration results, allowing an observed union branch to migrate even when other writer branches are incompatible. Schema errors fail the request; value errors identify their field/index path. PHP and Symfony share the native resolution modules and public preview.
Symfony · 55 minute session
- Resolve a bounded writer/reader schema pair and up to 20 JSON records. Primitive types are null, boolean, int (signed 32-bit), long (safe JSON integer), double, string and lowercase hex bytes. Records, arrays, maps, enums, fixed bytes and tagged unions are supported to depth eight; field/symbol/branch counts have explicit limits. Named types are inline declarations, not unresolved external references.
- Compatibility means every writer value can be read. Numeric widening is int->long/double and long->double, never narrowing. Every writer union branch needs a reader match; a reader union picks its first compatible branch. Union values are {branch:tag,value}, where named branches use their name.