Repository navigation
merge3 reports conflicts as JSON and takes decisions on them - #25
Conversation
A tool putting conflicts to a person had to parse lines from standard error, and had no way to say what was decided. `--format json` writes each conflict with an id and what the three versions have there, the element around it as the file has it. `--resolve FILE` takes the decisions back, `ours ID` or `theirs ID` a line, and when all are decided the exit code is 0. An id is a hash of the conflict's kind, its path and what each side has there. No file name goes in, so a git driver's temporary files do not change it; a side changing gives a new id, so a decision kept for a later merge cannot land on another conflict. One that meets no conflict is reported. Vendors flatxml fd6e96a, whose merge3 can take theirs. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 8e7bb10474
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for side in [c.ours, c.theirs] { | ||
| parts << '${side.kind}' | ||
| parts << side.after or { '' } | ||
| parts << if side.new.ok() { own_xml(side.new) } else { '' } |
There was a problem hiding this comment.
Include move destinations in conflict IDs
When both sides move an unchanged element to different parents, the ID hashes the base path and each moved element's XML, but neither destination. If theirs subsequently moves that element to a different parent again, its XML and conflict ID remain identical. A saved theirs ID decision therefore silently accepts the new destination instead of being reported as stale, potentially placing model content somewhere the user never approved. Include each move's semantic destination (and relevant ordering information) in the fingerprint without incorporating temporary filenames.
Useful? React with 👍 / 👎.
|
Review of
Also, the base is not in the id, although a decision depends on it less than the sides do; worth settling along with the fix. All three come from one cause: the id hashes one node's source per side, which is less than what the decision covers. Merge flatxml#46 only once the id is settled, in case the fix needs more from it. |
A decision kept for a later merge could apply to a conflict that had changed: the id hashed one node per side. A move's destination was not in it, nor any change below a removed node but the first, and two items of a list with the same edits shared one id. It now has the base, the place among like items, where a move goes and, for a removal or a move, all that each side changed in the node. Vendors flatxml at its squash of #46. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 33bb302178
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| made := '${merged_path(anchors[0], base.ix)}\0${places_of(anchors[0], base.ix)}\0${c.name}\0${change_print(c, | ||
| v)}' | ||
| h := hash.sum64_string(made, 0) |
There was a problem hiding this comment.
Include insertion order in subtree conflict fingerprints
When ours removes Head and theirs changes its WATTS and appends two ordered NOTE children, swapping those new children in a later version leaves the removal conflict's ID unchanged. The representative WATTS change remains identical, while each addition's scope fingerprint contains its base parent and XML but not its insertion index; summing those fingerprints also discards their order. Consequently, a saved theirs ID decision silently accepts a different ordered list instead of becoming stale. Include the semantic insertion position of ordered additions in the scope fingerprint.
Useful? React with 👍 / 👎.
| base: conflict_side(c.node, c.ours.before) | ||
| ours: conflict_side(c.ours.new, c.ours.after) | ||
| theirs: conflict_side(c.theirs.new, c.theirs.after) |
There was a problem hiding this comment.
Report the surviving subtree for removal conflicts
When one side removes an ancestor and the other changes multiple descendants, flatxml.combine reports one removal conflict whose surviving-side change is only the first descendant change. Using that change's new node here therefore reports the wrong subtree: for example, removing Body while theirs edits WATTS in both Head and Tail reports only Head's context, omitting Tail's changes even though the decision accepts or discards both. Resolve the surviving counterpart of c.node for structural conflicts and generate its bounded context, rather than using the first changed descendant.
Useful? React with 👍 / 👎.
| "properties": { | ||
| "conflicts": {"type": "integer", "minimum": 0}, | ||
| "resolved": {"type": "integer", "minimum": 0}, | ||
| "unused": {"type": "array", "items": {"$ref": "#/definitions/id"}}, |
There was a problem hiding this comment.
Align unused-ID validation with accepted decisions
When a decisions file contains ours aa, parse_decisions accepts it (the new parser test explicitly covers such IDs), and a merge with no matching conflict emits "unused":["aa"]. This schema rejects that output because definitions/id requires exactly 16 hexadecimal digits. Thus a successfully completed merge can produce a report that schema-validating consumers cannot read, precisely when they need to display an unused-decision warning. Either allow arbitrary strings in summary.unused or reject nonconforming IDs before producing the merge result.
Useful? React with 👍 / 👎.
A removal or a move conflict names one change, but a decision takes or drops all that a side changed in the node. Each side now lists them in `changes`. The id counts where an addition goes, since a list in another order is another decision, and the schema takes an unused decision as the file spells it, which need not be an id. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed in the commit after
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 98a12352ab
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| for cur.ok() && !(int(cur.i) < ix.at.len && ix.at[cur.i] != 0) { | ||
| out << place_of(cur).str() | ||
| cur = cur.parent() |
There was a problem hiding this comment.
Include ancestor variant identities in conflict IDs
With the built-in identity rules, two LAMP elements can share SHORT-NAME Head but have different VARIATION-POINT/SHORT-LABEL values. If both variants have the same WATTS conflict (for example, 55 → 60 versus 65), they receive identical IDs: merged_path excludes variation points, this loop stops before including the referrable ancestor's identity, and the XML fingerprints contain only WATTS. Consequently, a decision intended for one variant silently resolves both, and opposite decisions cannot be expressed. Include the distinguishing merge keys of referrable ancestors in the fingerprint.
Useful? React with 👍 / 👎.
| // change_print is what a change does: to what, and for a move, where to. | ||
| fn change_print(c flatxml.Change, v &Version) string { | ||
| mut parts := ['${c.kind}', c.after or { '' }] | ||
| parts << if c.new.ok() { own_xml(c.new) } else { '' } |
There was a problem hiding this comment.
Fingerprint every contribution to an added subtree
When both sides add a conflicting element whose merged subtree spans multiple files, own_xml(c.new) fingerprints only fragment(0). Changing a descendant contributed solely by another fragment therefore leaves the addition conflict's ID unchanged: added subtrees produce one addition change, and .added conflicts receive no supplementary scope hash. A saved theirs ID decision then silently accepts the modified content, since Applier.add copies every fragment, not just the fingerprinted one. Hash the complete merged addition, or all its contributions, rather than only its first source fragment.
Useful? React with 👍 / 👎.
Two variants of one element share a path, so they shared an id too: the merge keys of the node and all above it are in it now. A node spread over several files was hashed from the first alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Fixed in
|
|
@codex review |
|
Codex Review: Didn't find any major issues. Swish! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
merge3printed its conflicts as lines on standard error and kept ours, so a tool putting conflicts to a person had to parse text and could not say what was decided. This gives it a report to read and a way to answer.Vendors flatxml at its squash of MartenH/flatxml#46.
What changes
merge3 --format json: writes the conflicts to standard output. It needs-o, since the result would otherwise go there too. Each conflict has an id, its kind and AUTOSAR path, and for each of the three versions its place, its value, and the element around it as the file has it. Described indocs/report.md, with a schema indocs/merge3.schema.json.merge3 --resolve FILE: takes the decisions back,ours IDortheirs IDa line. The result holds the side named, and when every conflict is decided the exit code is 0.cutset where that is too.The decisions file is plain lines rather than JSON, like the rule files and
@FILElists, so it needs no parser and can be read and edited by hand.Without the new options,
merge3behaves as before.Tests
v test .passes, as doscripts/merge3_cli_test.sh(new, run fromscripts/check_reports.sh, so CI runs it with no change to a workflow),scripts/git_driver_test.shandscripts/inputs_cli_test.sh.scripts/check_reports.shnow validates a merge3 report against its schema.On a large real-world model:
mainon every file.🤖 Generated with Claude Code