Skip to main content

merge

Function merge 

Source
pub fn merge(
    class: MergeClass,
    base: &Body,
    ours: &Body,
    theirs: &Body,
) -> MergeOutcome
Expand description

Attempt to merge ours and theirs given their common base, according to class.

  • AppendOnly: ours verbatim, followed by the tail of theirs past the shared line-prefix of the two sides. A strict append-only union that preserves committed content byte-exact — it never drops blank lines and never dedups repeated lines (doing so is silent data loss, ADR 0005). Suits append-only topics and session transcripts.
  • Structured: field-level 3-way merge of JSON object bodies (see [structured_merge]). Disjoint field edits auto-merge; the same field changed differently on both sides is a genuine conflict.
  • Opaque: always NeedsResolution.
  • Derived: never NeedsResolution. The body is regenerable and views are single-writer (ADR 0012), so a divergence is a rare race. merge receives only bodies (no Meta), so it cannot compare updated timestamps; it resolves the race deterministically in favor of side A (ours) — the discarded side can be re-derived from source.