recordmerge

package
v1.30.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

specscore: feature/cli/resolve/auto-resolve/record-merge

specscore: feature/cli/resolve/auto-resolve/record-merge

Package recordmerge implements the record-aware three-way merge engine for auto-resolving logically non-conflicting data-row conflicts.

specscore: feature/cli/resolve/auto-resolve/record-merge

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// SameRecord enables merging non-contested changes to the same record
	// (cases DM-9..DM-11). When false, any record changed on both sides
	// escalates.
	SameRecord bool
}

Options controls which case classes the engine is allowed to auto-merge.

type Outcome

type Outcome struct {
	Merged   []Record
	Escalate bool
	Reason   string
}

Outcome is the result of a merge attempt. When Escalate is true the conflict is not auto-resolvable and Reason explains why; Merged is then nil.

func Merge

func Merge(base, ours, theirs []Record, opts Options) Outcome

Merge performs a three-way merge of keyed record sets. base/ours/theirs are the records parsed from the common ancestor and the two conflict sides.

It returns Escalate=true (with a reason) for any conflict that is not provably safe to auto-resolve; otherwise Merged holds the union, ordered as surviving base records first (in base order), then records added by ours, then records added by theirs.

func MergeFiles

func MergeFiles(base, ours, theirs []byte, col *ingitdb.CollectionDef, opts Options) Outcome

MergeFiles parses the BASE/OURS/THEIRS bytes of a conflicted record file into typed records and runs the three-way merge. A nil or empty stage is treated as an absent record set (added on one side, or deleted).

It returns an Outcome whose Merged holds the union of non-conflicting changes on success, or Escalate=true (with a reason) when the conflict is not auto-resolvable — including unsupported record layouts and parse failures. Serialization of the merged records back to file bytes is the caller's responsibility.

type Record

type Record struct {
	Key    string
	Fields map[string]any
}

Record is one data row: a primary key plus its parsed, typed fields.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL