Repository navigation
Commit 1aaa2fc
fix(workflows): keep an overlay's
* fix(workflows): keep an overlay's replace when it also inserts on that anchor
`_traverse_and_apply` decided an anchor's fate with `edits[-1]`, which treats
declaration order *inside a single overlay file* as a precedence signal.
Priority is a per-overlay property, so two edits from one overlay have no
priority relation to break — yet a trailing `insert_after` reverted the
anchor to the base step and silently discarded that same overlay's
`replace`.
Measured through the real resolver, one overlay declaring both edits:
replace-then-insert (main): implement run='make build' <-- LOST
attribution: ('implement', 'base')
insert-then-replace (main): implement run='make build-hardened'
either order (fixed): implement run='make build-hardened'
attribution: ('implement', 'project:my-overlay')
So `specify workflow run demo` executed `make build` instead of
`make build-hardened`, with no error, and `workflow resolve` attributed the
untouched step to "base".
Scoped to `replace` only. A replace leaves the anchor in place so both edits
can be honoured; `remove` destroys it, so an insert relative to it cannot
also apply and choosing between them is a separate question — that
combination keeps its existing behaviour, pinned by a test.
The ancestor-conflict map uses the same fate rule so the guard cannot drift,
while still listing every anchor: `_check_anchor_conflicts` reads its key set
to find descendant anchors.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* fix(workflows): scope the fate rescue to unambiguous replace-plus-insert
Addresses review feedback on the same-overlay fate rescue.
1. `_winning_fate_edit` also rescued the `replace` when the winning layer
declared `replace`, `remove` AND a trailing insert on one anchor. That
changed behaviour for a combination this PR deliberately scoped out. The
rescue now bails out when the winning layer has a `remove` on the anchor,
so such layers stay byte-identical to their pre-rescue outcome:
one overlay's edits upstream/main before now
replace, remove, insert base kept replaced base kept
remove, replace, insert base kept replaced base kept
replace, insert (target) base kept replaced replaced
remove, insert base kept base kept base kept
Only the intended case now differs from main.
2. `_traverse_and_apply`'s docstring still said the winning edit "is
`edits[-1]`", which stopped being true on this path. It now points at
`_winning_fate_edit` so future changes do not bypass it.
3. The test class docstring said an overlay's "replace/remove" must survive a
trailing insert; only `replace` is rescued. Limited to `replace` and made
the `remove` exclusion explicit.
New parametrized regression test pins the ambiguous layer in both declaration
orders, so the rescue cannot start honouring whichever of replace/remove
happens to come first.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
* test(workflows): cover insert_before and the conflict-guard use of the fate rule
Addresses two review comments, both correct.
1. `_winning_fate_edit` treats `insert_after` and `insert_before` alike, but
every same-overlay fate test used only `insert_after` -- the pre-existing
`insert_before` tests use separate layers and never reach this branch.
`test_replace_then_insert_same_overlay_keeps_replacement` is now
parametrized over both, asserting the resulting order in each case
(`[implement, lint, tail]` vs `[lint, implement, tail]`).
2. The conflict guard's use of `_winning_fate_edit` had no regression test.
Every existing conflict test ends the parent's edits with `replace` or
`remove`, so all of them pass under either rule. New parametrized
`test_replace_parent_with_trailing_insert_still_conflicts` gives the parent
a `replace` plus a trailing insert alongside a descendant edit: under
`anchor_edits[-1]` the parent's apparent fate becomes the insert, which
`_check_anchor_conflicts` deliberately skips, so the conflict would go
undetected and the subtree would be replaced out from under the descendant.
Mutation-verified: reverting the guard to `anchor_edits[-1]` fails exactly the
two new tests and nothing else.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>replace when the same overlay also inserts on that anchor (#4140)1 parent 61c26fe commit 1aaa2fc
2 files changed
Lines changed: 263 additions & 7 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
230 | 230 | | |
231 | 231 | | |
232 | 232 | | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
233 | 278 | | |
234 | 279 | | |
235 | 280 | | |
| |||
244 | 289 | | |
245 | 290 | | |
246 | 291 | | |
247 | | - | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
248 | 296 | | |
249 | 297 | | |
250 | 298 | | |
| |||
255 | 303 | | |
256 | 304 | | |
257 | 305 | | |
258 | | - | |
| 306 | + | |
| 307 | + | |
259 | 308 | | |
260 | 309 | | |
261 | 310 | | |
| |||
274 | 323 | | |
275 | 324 | | |
276 | 325 | | |
277 | | - | |
| 326 | + | |
278 | 327 | | |
279 | 328 | | |
280 | 329 | | |
| |||
352 | 401 | | |
353 | 402 | | |
354 | 403 | | |
355 | | - | |
356 | | - | |
357 | | - | |
358 | | - | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
359 | 418 | | |
360 | 419 | | |
361 | 420 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
591 | 591 | | |
592 | 592 | | |
593 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
| 610 | + | |
| 611 | + | |
| 612 | + | |
| 613 | + | |
| 614 | + | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
| 620 | + | |
| 621 | + | |
| 622 | + | |
| 623 | + | |
| 624 | + | |
| 625 | + | |
| 626 | + | |
| 627 | + | |
594 | 628 | | |
595 | 629 | | |
596 | 630 | | |
| |||
733 | 767 | | |
734 | 768 | | |
735 | 769 | | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
| 799 | + | |
| 800 | + | |
| 801 | + | |
| 802 | + | |
| 803 | + | |
| 804 | + | |
| 805 | + | |
| 806 | + | |
| 807 | + | |
| 808 | + | |
| 809 | + | |
| 810 | + | |
| 811 | + | |
| 812 | + | |
| 813 | + | |
| 814 | + | |
| 815 | + | |
| 816 | + | |
| 817 | + | |
| 818 | + | |
| 819 | + | |
| 820 | + | |
| 821 | + | |
| 822 | + | |
| 823 | + | |
| 824 | + | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
| 831 | + | |
| 832 | + | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
| 836 | + | |
| 837 | + | |
| 838 | + | |
| 839 | + | |
| 840 | + | |
| 841 | + | |
| 842 | + | |
| 843 | + | |
| 844 | + | |
| 845 | + | |
| 846 | + | |
| 847 | + | |
| 848 | + | |
| 849 | + | |
| 850 | + | |
| 851 | + | |
| 852 | + | |
| 853 | + | |
| 854 | + | |
| 855 | + | |
| 856 | + | |
| 857 | + | |
| 858 | + | |
| 859 | + | |
| 860 | + | |
| 861 | + | |
| 862 | + | |
| 863 | + | |
| 864 | + | |
| 865 | + | |
| 866 | + | |
| 867 | + | |
| 868 | + | |
| 869 | + | |
| 870 | + | |
| 871 | + | |
| 872 | + | |
| 873 | + | |
| 874 | + | |
| 875 | + | |
| 876 | + | |
| 877 | + | |
| 878 | + | |
| 879 | + | |
| 880 | + | |
| 881 | + | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
| 885 | + | |
| 886 | + | |
| 887 | + | |
| 888 | + | |
| 889 | + | |
| 890 | + | |
| 891 | + | |
| 892 | + | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
| 896 | + | |
| 897 | + | |
| 898 | + | |
| 899 | + | |
| 900 | + | |
| 901 | + | |
| 902 | + | |
| 903 | + | |
| 904 | + | |
| 905 | + | |
| 906 | + | |
| 907 | + | |
| 908 | + | |
| 909 | + | |
| 910 | + | |
| 911 | + | |
| 912 | + | |
| 913 | + | |
| 914 | + | |
| 915 | + | |
| 916 | + | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
| 928 | + | |
| 929 | + | |
| 930 | + | |
| 931 | + | |
| 932 | + | |
0 commit comments