Skip to content

merge3: two additions alike but for what it ignores are one - #29

Merged
MartenH merged 3 commits into
mainfrom
merge3-alike-additions
Nov 18, 2026
Merged

MartenH merged 3 commits into
mainfrom
merge3-alike-additions

Conversation

@MartenH

@MartenH MartenH commented Nov 18, 2026

Copy link
Copy Markdown
Owner

When both sides add the same element, merge3 keeps one if the two added subtrees are equal. flatxml compares them whole, every attribute included, so two additions that differ only in an attribute the policy ignores, such as a UUID each side generated, or only in layout, were reported as "two of one identity added".

  • path_conflict now drops such a conflict, as it already drops a change of an ignored attribute, and ours is kept. The two added nodes are compared node by node, leaving out the ignored attributes, blank text and the content the merge does not compare, and the comparison stops at the first difference. Additions that differ in what the merge compares still conflict.
  • conflict_id no longer hashes the node a conflict lies in when the conflict is two additions. That node is the list they were added to, whole. In a long list this was most of the time a merge took, since it was hashed again for each such conflict, and the id changed with anything else in the list.

On one file of a large real-world model, nearly every conflict was such a pair, and the merge went from about two minutes to a few seconds.

The ids of addition conflicts change, so a decision recorded for one with an earlier build no longer applies to it.

Tests: test_merge3_two_additions_alike_but_for_what_it_ignores_are_one on the synthetic model: another UUID and layout give no conflict and keep ours, another value still conflicts, and the conflict's id is the same when the rest of the list differs. It fails without the change.

🤖 Generated with Claude Code

Both sides adding one element, alike but for an attribute the policy
ignores (a UUID generated per side) or its layout, was a conflict:
flatxml compares the two added subtrees whole, every attribute
included. merge3 now drops it, as it drops a change of an ignored
attribute, and keeps ours. Two additions that differ in what the merge
compares still conflict.

The id of such a conflict hashed the node it lies in, which for two
additions is the list they were added to, whole: in a long list that
was most of a merge's time, hashed again for each such conflict, and
the id changed with anything else in the list. It is left out now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-18T10:59:42.982143Z 9d2aa52 Manual request
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 55b0a63478

ℹ️ 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".

Comment thread arxmodel/compare.v Outdated
Comment on lines +520 to +522
text := run.text.trim_space()
if text != '' {
runs << '${run.slot}\0${text}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Preserve significant whitespace when comparing added text

When both sides add the same identity with text values that differ only in leading or trailing whitespace (for example, <NOTE> first</NOTE> versus <NOTE>first</NOTE>), trimming every run makes alike suppress the addition conflict and silently keep ours. This also discards whitespace-only CDATA content. The parser already drops layout-only whitespace in flatxml/parser.v:add_text, while flatxml/diff.v:pair compares the remaining text runs verbatim, so this introduces a different equality rule that can hide meaningful string or mixed-content changes. Preserve the text of retained runs rather than trimming it.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 423801b: text runs are compared as the file has them, as the diff compares them. A leading blank still conflicts; test_merge3_two_additions_differ_in_what_the_diff_compares covers it.

Comment thread arxmodel/compare.v Outdated
Comment on lines +533 to +535
name := tab.name(a.tag)
if name !in r.ignore {
out << '${name}=${a.value}'

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare retained attributes by their expanded namespace names

When both sides add the same identity with an attribute such as ext:mode="x", but bind ext to different namespace URIs on an ancestor, this comparison treats the attributes as equal because MNode.attrs() supplies their names as written. The ancestor declarations are not visited by alike, so the addition conflict is suppressed and theirs is silently discarded even though the attributes have different identities. In contrast, flatxml/diff.v:attr_key includes the resolved namespace URI and therefore correctly reports these additions as different. Compare retained attributes using their namespace URI and local name, preserving the existing ignored-attribute filtering.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 423801b: attributes are compared by attr_id, their expanded name when they are in a namespace, so one prefix bound to two namespaces names two attributes. The same test covers it, with the bindings on an ancestor.

Two additions were alike when their trimmed text and their attribute
names as written agreed. That was looser than the diff: text that
differs only in leading or trailing blanks is a change there, since the
parser has already dropped the runs that are layout alone, and an
attribute is its expanded name, so one prefix bound to two namespaces
names two attributes. Text is now compared as the file has it, and an
attribute by what identifies it, taken from the first contribution that
has it, as the merge takes it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MartenH

MartenH commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 423801bfb1

ℹ️ 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".

Comment thread arxmodel/compare.v Outdated
// differ: the attributes it ignores, layout, and content it does not compare. Compared node by
// node, it stops at the first difference.
fn (r &Ruling) alike(a flatxml.MNode, b flatxml.MNode) bool {
if a.name() != b.name() || own_text(a) != own_text(b) || r.kept_attrs(a) != r.kept_attrs(b) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Compare element names by their resolved namespaces

When the ruling has no local_ns (including built-in rules for a model whose root has no namespace), MNode.name() returns the name as written, not its expanded namespace name (flatxml/ns.v:name_in). If both sides add the same named LAMP containing <ext:data>x</ext:data>, but bind ext to different URIs on an ancestor, this comparison considers the subtrees alike and suppresses the addition conflict, silently discarding theirs. Namespace declarations are excluded by kept_attrs, so nothing else detects the difference. Compare element names using their resolved namespace URI and local name, as flatxml/diff.v:name_key does.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9d2aa52: an element is compared by its namespace and local name where its document's names are resolved, as name_key names it. test_merge3_two_additions_differ_in_what_the_diff_compares now covers it, with the bindings on an ancestor.

An element was compared by its name as written, and a ruling's names
can be as written, so one prefix bound to two namespaces on an
ancestor named two elements alike, and the addition conflict was
dropped. An element is now compared by its namespace and local name
where its document's names are resolved, as the diff names it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MartenH

MartenH commented Nov 18, 2026

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. More of your lovely PRs please.

Reviewed commit: 9d2aa52973

ℹ️ 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".

@MartenH
MartenH merged commit 9ffe8f4 into main Nov 18, 2026
2 checks passed
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.

1 participant