fix: Fix merge for multiresourceyaml resources (#122)#28
Merged
Ruari-Phipps merged 2 commits intomainfrom Mar 19, 2026
Merged
Conversation
## Summary Fix incorrect merge behaviour for `MultiResourceYamlResource` types by performing the 3-way merge at the file level rather than per-resource. ## Motivation `MultiResourceYamlResource` types (e.g. entities) store multiple resources in a single YAML file. The previous code performed the 3-way merge per-resource and then wrote each resource individually, which meant the common ancestor used for the merge was wrong and resources from the same file would overwrite each other. It would also crash. <img width="415" height="133" alt="image (1)" src="https://github.com/user-attachments/assets/388eff5f-2185-4a5b-ab5f-0b32f866452d" /> ## Changes - Before the merge loop, serialise the original resources into a file-level cache to use as the common ancestor - Skip the per-resource string merge for `MultiResourceYamlResource` types during the main loop; instead accumulate them into the cache - After the main loop, perform the 3-way merge at the file level and write the result - Gate `write_cache_to_file` behind `force` mode, since non-force mode now handles writing via the file-level merge loop ## Test strategy - [x] Added/updated unit tests - [x] Manual CLI testing (`poly pull`) - [x] Tested against a live Agent Studio project - [ ] N/A (docs, config, or trivial change) ## Checklist - [ ] `ruff check .` and `ruff format --check .` pass - [x] `pytest` passes - [ ] No breaking changes to the `poly` CLI interface (or migration path documented) - [ ] Commit messages follow [conventional commits](https://www.conventionalcommits.org/) - [ ] ## Screenshots / Logs <img width="1291" height="582" alt="Screenshot 2026-03-13 at 18 57 34" src="https://github.com/user-attachments/assets/44a0cf5d-7024-42c4-8b51-8b2b3fc1b267" /> --------- Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
oeisenberg
approved these changes
Mar 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fix incorrect merge behaviour for
MultiResourceYamlResourcetypes by performing the 3-way merge at the file level rather than per-resource.Motivation
MultiResourceYamlResourcetypes (e.g. entities) store multiple resources in a single YAML file. The previous code performed the 3-way merge per-resource and then wrote each resource individually, which meant the common ancestor used for the merge was wrong and resources from the same file would overwrite each other.It would also crash.
Changes
MultiResourceYamlResourcetypes during the main loop; instead accumulate them into the cachewrite_cache_to_filebehindforcemode, since non-force mode now handles writing via the file-level merge loopTest strategy
poly pull)Checklist
ruff check .andruff format --check .passpytestpassespolyCLI interface (or migration path documented)