DynamicPatch: Untyped patch representation operating on DynamicValue\n- Operation ADT: Set, PrimitiveDelta, SequenceEdit, MapEdit\n- PrimitiveOp: All numeric deltas (IntDelta, LongDelta, DoubleDelta, etc.), StringEdit with LCS algorithm\n- SeqOp: Insert, Append, Delete, Modify with LCS-based sequence diffing\n- MapOp: Add, Remove, Modify for map entries\n- PatchMode: Strict, Lenient, Clobber semantics for patch application\n- StringOp: Insert(index, text), Delete(index, length) for character-level edits\n\n### Integration Points\n\n- Schema#diff - Typed diffing API producing Patch[A]\n- DynamicValue.diff - Untyped diffing producing DynamicPatch\n- Patch[A] updated to wrap DynamicPatch with schema context\n- New error types in SchemaError for patch-specific failures\n\n### Files Changed\n\n| File | Status | Description |\n|——|––––|———––|\n| DynamicPatch.scala | NEW | Core patch types and operations (~800 LOC) |\n| DynamicValue.scala | MODIFIED | Added diff methods |\n| Patch.scala | MODIFIED | Added DynamicPatch integration |\n| Schema.scala | MODIFIED | Added diff method |\n| SchemaError.scala | MODIFIED | Added patch-specific error types |\n| DynamicPatchSpec.scala | NEW | Comprehensive test suite (~400 LOC) |\n\n### Algorithms\n\n- String diff: LCS (Longest Common Subsequence) algorithm producing minimal StringOp sequence\n- Sequence diff: LCS-based algorithm producing minimal SeqOp sequence\n- Map diff: Key-based comparison producing MapOp sequence\n\n### Laws Verified\n\n- Roundtrip: schema.diff(old, new).apply(old) == Right(new)\n- Monoid Identity: p ++ Patch.empty == p and Patch.empty ++ p == p\n- Monoid Associativity: (p1 ++ p2) ++ p3 == p1 ++ (p2 ++ p3)\n\n## Test Plan\n\n- [x] DynamicPatch basics (empty, set, composition)\n- [x] Primitive operations (all numeric deltas, string edit)\n- [x] Record navigation (field access, strict/lenient/clobber modes)\n- [x] Variant navigation (case matching)\n- [x] Sequence operations (insert, delete, append, modify)\n- [x] Map operations (add, remove, modify)\n- [x] PatchMode semantics (Strict fails, Lenient skips, Clobber overwrites)\n- [x] StringOp.diff LCS algorithm\n- [x] SeqOp.diff LCS algorithm\n- [x] Monoid laws\n\n## Demo Video\n\n[VIDEO_LINK_TODO]\n\n60-second demo showing: test suite execution, core implementation structure, all tests passing\n\n## Success Criteria Checklist\n\n- [x] DynamicPatch defined with all operation types\n- [x] Patch[A] wraps DynamicPatch with Schema[A]\n- [x] Typed API in Patch companion object\n- [x] Schema#diff implements smart diffing strategy\n- [x] PatchMode controls application behavior\n- [x] Operations return Either[SchemaError, A]\n- [x] Roundtrip law holds\n- [x] Monoid laws hold\n- [x] String diffs use LCS algorithm\n- [x] Sequence diffs use LCS algorithm\n- [x] Comprehensive tests\n\n/claim #516\nSolari Systems
@SolariSystems
ZIO
@ZIO