Shape-Aware Three-Way Merge: Defining RDF Knowledge Graph Conflicts with SHACL

Shape-aware three-way merge uses SHACL cardinality constraints to define conflicts, reducing manual decisions without data loss, but cannot identify entity aliases.
This article introduces a three-way merge method based on SHACL shapes for detecting semantic conflicts in RDF knowledge graph merging. Traditional methods only handle syntactic concatenation and cannot determine semantic conflicts. The method uses SHACL shape cardinality constraints to define contended slots: when a shape stipulates at most one value and two branches give different values, it is marked as a conflict and handed to humans; unbounded predicates are simply unioned. Synthetic tests show it reduces manual inquiries from 845 to 33 while maintaining detection. Production replay reveals limitations: it cannot identify different names for the same entity, detecting 0 of 93 alias repairs. Conservative shape definitions are safer than loose ones because missing constraints cause silent data loss. The method unifies conflict determination and result validation in the same shape graph, suitable for teams already using SHACL.

Knowledge graph merging has long faced an awkward problem: different RDF serializations can be concatenated syntactically without issue, yet semantic conflicts go unnoticed. A technical report from RSS describes a three-way merge implementation that uses SHACL shapes as conflict criteria, along with evaluation results in a production-grade multi-agent store. It does not claim to be the first to do three-way RDF merging; instead, it focuses on a verifiable contribution: letting the schema determine what counts as a conflict, thereby reducing manual decisions on cardinality constraints without losing data.
Why Traditional Three-Way Merge Falls Short
RDF data merging typically relies on set algebra or context-based override rules. Such methods can handle additions and deletions of triples, but they struggle to answer a key question: are two versions' modifications to the same property truly contradictory? For example, the same predicate is given a single value in one version and a second value is appended in another—if the schema stipulates that the predicate has at most one value, this is a conflict; if the schema allows any number of values, it is merely a normal union.
The report points out that simply merging RDF serializations produces ordering conflicts while missing semantic conflicts. In other words, tools can tell you "these two files are different," but cannot tell you "these two files cannot both be true in the business sense." The core idea of shape-aware merging is to treat SHACL shapes as the arbiter of conflicts: only when a slot is constrained by a shape's cardinality and the changes from both sides cannot simultaneously fall within that cardinality range is it judged a contended slot and handed to humans. Unbounded predicates are simply unioned.
SHACL (Shapes Constraint Language) is a language proposed by the W3C for describing and validating the structure of RDF graphs. It allows users to define "shapes," i.e., a set of constraints that nodes should satisfy, such as how many values a predicate must have (cardinality constraints), what type or class the values must belong to, which properties must exist, etc. SHACL shapes are usually expressed in RDF and come with a target specifying which nodes need validation. In knowledge graph engineering, SHACL is often used as a data contract to ensure data conforms to business rules. This article introduces SHACL shapes into merge conflict determination, precisely leveraging their cardinality constraint capability to clarify "when two modifications are contradictory." Understanding the basic concepts of SHACL helps grasp the operating mechanism of shape-aware merging.
How the Shape-Aware Operator Works
Set Algebra and Contended Slots
In the implementation, canonical triples are first merged via set algebra. Then, the system checks whether each slot is covered by a SHACL shape's cardinality constraints. If the shape stipulates that a predicate has at most one value and the two branches each provide different values, that slot is marked as contended and enters the manual decision queue. If the shape does not restrict cardinality, the values from both sides are merged directly without issue.
The same shape graph is also used to validate the merge result, ensuring the final output does not violate any SHACL constraints. This practice of using the same set of shapes for both "defining conflicts" and "validating results" keeps conflict determination and final verification consistent, avoiding a disconnect between rules and checks.
In description logic and knowledge representation, a cardinality constraint specifies the range of the number of values a property can have. Common cardinality constraints include "at most one value" (maxCardinality 1), "at least one value" (minCardinality 1), and "exactly one value" (cardinality 1). In SHACL, these constraints can be expressed via properties such as sh:maxCount and sh:minCount. When two branches assign different values to the same property, if that property is constrained to at most one value, the two values cannot coexist, thus constituting a conflict; if the constraint allows any number of values, the two values can coexist. Cardinality constraints are the core basis for determining contended slots in shape-aware merging, transforming semantic conflicts into computable cardinality checks.
Comparison with Context Merge
The report compares this operator with a reimplementation of Quit Store's Context Merge overlap rules, emphasizing that it is an extension rather than a replacement. In tests on five synthetic seeds, the shape-aware operator raised 33 conflicts, all judged true positives by the same set of shapes, with no triples lost or fabricated and no SHACL violations introduced.
As a baseline, the slot-counting context overlap method detected the same 33 conflicts but produced 845 inquiries. This gap shows that the shape-aware method substantially reduces the number of issues requiring human intervention while maintaining detection capability. The report also candidly notes that this does not prove general correctness of merging, but only supports the claim of "fewer manual decisions without silent loss" for a specific deployment and a specific conflict type (cardinality conflicts).
Context Merge is an RDF merging strategy implemented in Quit Store that detects overlaps and conflicts by comparing the contexts to which triples belong in different versions. Its basic idea is: if two branches give different objects for the same subject-predicate pair, it is considered a potential conflict requiring further inquiry. However, Context Merge typically does not rely on schema information but triggers inquiries based on slot counts (i.e., the number of distinct values under the same slot). While this method can detect conflicts, it produces a large number of unnecessary inquiries because it does not know which slots are actually constrained by cardinality. Shape-aware merging, by introducing SHACL shapes as conflict criteria, can distinguish truly conflicting slots from safely mergeable ones, thereby significantly reducing the number of manual decisions. The comparative experiment in the report shows that both detect the same number of conflicts, but the shape-aware method requires far fewer inquiries than Context Merge.
Blind Spots Revealed by Production Replay
Alias Repair: The Limit of the Triple Level
Beyond synthetic tests, the report also constructs a replay from recorded production incidents, covering 105 manual alias repairs (93 after excluding 12 chained pairs) and 939 duplicate-value incidents. The replay reproduces a triple-level limitation: different names for the same entity remain invisible. Of the 93 alias repairs, the system detected 0; of 21 synthetic cases, it also detected 0.
This means shape-aware merging can handle cardinality conflicts but cannot identify semantic equivalence issues such as "two URIs actually point to the same entity." This is not an implementation flaw but the boundary of the triple-level approach. The report explicitly presents this limitation as part of the evaluation results rather than avoiding it.
Detection Blind Spots in Shape Contract Evolution
In the study of shape contract evolution, merging shape declarations first can handle the tested cardinality changes. However, datatype evolution exposed a detector blind spot, which was caught by post-merge validation. In other words, when the shapes themselves change, relying solely on pre-merge shape definitions may miss certain conflicts, and post-merge SHACL validation serves as the last line of defense.
The report also tested an "oracle" that reads no shapes, and it remained consistent with the delivered operator at both the fact and history levels across all 23 reachable single-slot cases. This indirectly shows that the shape-aware operator introduces no additional factual bias within the scope it claims to cover.
Two Failure Modes Under Incorrect Shapes
A notable finding from the evaluation is that when the shapes themselves are incorrect, the failure modes are asymmetric. If a shape lacks a cardinality constraint it should have (missing boundary), data is silently lost; if a shape has an extra constraint it should not have (spurious boundary), it only increases manual inquiries and does not lose data. This distinction has direct implications for practical deployment: conservative shape definitions (more constraints) are safer than loose ones (fewer constraints), because the former places the cost on manual decisions while the latter places the cost on data integrity.
Entity resolution is the process in knowledge graphs of identifying and merging different URIs or identifiers that refer to the same real-world object. It typically involves alias detection, similarity computation, and link inference. Triple-level merging methods, such as the shape-aware operator in this article, focus only on additions, deletions, and conflicts of individual triples and cannot identify semantic equivalence between different URIs. Therefore, when the same entity appears under multiple names, shape-aware merging will not treat them as conflicts nor automatically merge them. This explains why in the production replay, all 93 manual alias repairs were missed by the system. Solving the alias problem requires dedicated entity resolution techniques, such as matching algorithms based on string similarity, graph structure, or external knowledge bases, or reasoning using ontological relations like owl:sameAs. The boundary of shape-aware merging reminds us that knowledge graph operations require multiple tools working together.
Implications for Knowledge Graph Engineering
The value of this work lies not in inventing a new algorithm but in delegating the judgment of "what counts as a conflict" from generic rules to the domain schema. SHACL shapes were originally meant to describe data contracts; using them to define merge conflicts is equivalent to letting the data contract also assume the responsibility of conflict detection. For teams already using SHACL for validation, the migration cost of this path is relatively manageable.
But the boundaries the report draws are equally clear: it handles cardinality conflicts, not entity resolution, not all scenarios of datatype evolution, and not general merge correctness. The triple-level invisibility of aliases reminds us that shape-aware merging is one tool in the knowledge graph operations toolbox, not the whole. Defining shapes well and preserving post-merge validation are the prerequisites for this method to hold up in practical deployment.
One-line Summary
Shape-aware three-way merge uses SHACL cardinality constraints to define conflicts, reducing manual decisions without data loss, but cannot identify entity aliases.
Paragraph Summary
This article introduces a three-way merge method based on SHACL shapes for detecting semantic conflicts in RDF knowledge graph merging. Traditional merging methods can only handle syntactic concatenation and cannot determine semantic conflicts. The method uses SHACL shape cardinality constraints to define contended slots: when a shape stipulates that a predicate has at most one value and two branches give different values, it is marked as a conflict and handed to humans; unbounded predicates are simply unioned. Synthetic tests show that the method reduces manual inquiries from 845 to 33 while maintaining conflict detection capability. Production replay reveals its limitations: it cannot identify different names for the same entity, detecting 0 of 93 alias repairs. Additionally, conservative shape definitions (more constraints) are safer than loose ones, because missing constraints lead to silent data loss. The method unifies conflict determination and result validation in the same shape graph, suitable for teams already using SHACL.
Related articles

Nothing CMF Buds 2A Drops to $17.89 on Black Friday: A New Low for ANC Earbuds
Nothing CMF Buds 2A wireless earbuds Black Friday deal: just $17.89 on Amazon, about $11 off retail and a record low. ANC earbuds at an entry-level price.

When AI Creation Gets Accused of "Spitting": Hacker News Heats Up Over the Glaude Controversy
A Hacker News post, "Spitting in the Face of Glaude," sparks debate on AI creation transparency and attribution ethics. This analysis examines the blurred creator identity behind the controversy and offers practical advice for AI content production.

Akai Embraces Custom Firmware: MPC Sample 1.4 Lets Users AI-Program Their Sampler
Akai embraces the modding community with MPC Sample 1.4 firmware, supporting vibe-coded custom firmware and effects. We analyze the impact of this open strategy on music hardware and AI-assisted programming.