Skip to content

fix: Fix merge for multiresourceyaml resources (#122)#28

Merged
Ruari-Phipps merged 2 commits intomainfrom
ruari/fix_merge_mutliresourceyaml
Mar 19, 2026
Merged

fix: Fix merge for multiresourceyaml resources (#122)#28
Ruari-Phipps merged 2 commits intomainfrom
ruari/fix_merge_mutliresourceyaml

Conversation

@Ruari-Phipps
Copy link
Copy Markdown
Collaborator

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.
image (1)

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

  • Added/updated unit tests
  • Manual CLI testing (poly pull)
  • Tested against a live Agent Studio project
  • N/A (docs, config, or trivial change)

Checklist

  • ruff check . and ruff format --check . pass
  • pytest passes
  • No breaking changes to the poly CLI interface (or migration path documented)
  • Commit messages follow conventional commits
  • ## Screenshots / Logs
Screenshot 2026-03-13 at 18 57 34

Ruari-Phipps and others added 2 commits March 18, 2026 13:59
## 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>
@Ruari-Phipps Ruari-Phipps merged commit 054d552 into main Mar 19, 2026
2 checks passed
@Ruari-Phipps Ruari-Phipps deleted the ruari/fix_merge_mutliresourceyaml branch March 19, 2026 10:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants