---
title: "SRBC Core Patch v0.11：Three-Way Semantic Merge、Query-Relative Reconciliation 與 Reversible Conflict"
version: "v0.11"
date: "2026-09-23"
status: "Round 11 semantic-merge patch candidate"
---

# SRBC Core Patch v0.11

Round 11 將 SREG 的：

$$
\text{Branch}
\rightarrow
\text{Merge}
$$

正式轉成可機器驗證的 three-way semantic merge。

---

# 1. Three-Way Merge

給共同 ancestor：

$$
A,
$$

以及兩個 branches：

$$
B_1,
\quad
B_2,
$$

定義：

$$
\Delta_1
=
\operatorname{Diff}(A,B_1),
$$

$$
\Delta_2
=
\operatorname{Diff}(A,B_2).
$$

merge 不應只看：

$$
\Delta_1
\cap
\Delta_2.
$$

還必須檢查 dependency interaction 與 query effect。

---

# 2. Semantic Merge 與 Query Merge 分離

新增兩個不同狀態。

## 2.1 Canonical Semantic Merge

回答：

> 是否可以產生一個單一、可追溯、無未解 semantic conflict 的 merged state？

記：

$$
M_{\mathrm{sem}}.
$$

## 2.2 Query-Relative Reconciliation

即使：

$$
M_{\mathrm{sem}}
=
\operatorname{CONFLICT},
$$

仍可對當前 query 建：

$$
\mathfrak I_{\mathrm{merge}}
=
\{
B_1,B_2,\ldots
\}
$$

並計：

$$
\operatorname{QRC},
\operatorname{QRU},
\operatorname{QDU}.
$$

因此：

$$
\boxed{
\text{semantic conflict}
\not\Rightarrow
\text{query underdetermination}.
}
$$

---

# 3. Query-Equivalent Conflict

若：

$$
B_1
\neq
B_2
$$

但：

$$
Q(B_1)=Q(B_2),
$$

則：

$$
\boxed{
M_{\mathrm{sem}}
=
\operatorname{CONFLICT}
}
$$

可以同時：

$$
\boxed{
\operatorname{QRC}
(
\{B_1,B_2\};Q
)
=
1.
}
$$

此時不能因為 query 已閉合，就把兩個 semantic branches 靜默壓成同一 state。

正確作法是：

- 保留 branch identities；
- 保留 reversible diffs；
- 對當前 query 使用 quotient；
- future query 改變時可重新 split。

---

# 4. Query-Sensitive Conflict

若：

$$
Q(B_1)\neq Q(B_2),
$$

則：

$$
\boxed{
\operatorname{QRU}=1.
}
$$

merge artifact 應保存兩個 branch answers 和 distinguishing semantic diff。

---

# 5. Dependency Interaction Conflict

即使：

$$
W_1\cap W_2=\varnothing
$$

且：

$$
B_1;B_2
=
B_2;B_1
$$

作為 state bytes 完全 commute，

仍可能有：

$$
\boxed{
\text{branch intent not preserved}.
}
$$

例如 parent branch 改變：

$$
MH\text{-}C1
$$

語義，

child branch 同時改：

$$
MH\text{-}C2
$$

的 local parameter。

兩個 absolute patches 的 final state 可交換，

但 child branch 原本的推導結果在 merged parent semantics 下可能：

- 改值；
- 變成 unresolved；
- 改變 query status。

因此新增：

$$
\boxed{
\operatorname{IntentPreserved}
(
B_i,M
)
}
$$

作為 merge gate。

---

# 6. State Commutativity 不是 Merge Safety

正式寫：

$$
\boxed{
\operatorname{Apply}
(
\Delta_2,
\operatorname{Apply}(\Delta_1,A)
)
=
\operatorname{Apply}
(
\Delta_1,
\operatorname{Apply}(\Delta_2,A)
)
}
$$

不推出：

$$
\boxed{
\operatorname{MergeSafe}(\Delta_1,\Delta_2).
}
$$

還必須：

$$
\operatorname{IntentPreserved}(\Delta_1)
\land
\operatorname{IntentPreserved}(\Delta_2).
$$

---

# 7. Multi-Query Resolution 必須逐 Query

Round 11 第一版測試器曾把兩個不同 queries 的答案直接 union 成一個 answer set，錯誤製造 QRU。

因此正式加入：

$$
\boxed{
\mathcal A_{Q_i}
\text{ 只能和同一 }Q_i\text{ 的 branch answers 比較}.
}
$$

如果：

$$
Q_1
\neq
Q_2,
$$

則不能計：

$$
\{
Q_1(M_1),
Q_2(M_2)
\}
$$

的「共同 QRU」。

multi-query 狀態應是：

$$
\boxed{
\mathbf R_{\mathcal Q}
=
\{
Q_i
\mapsto
\mathbf R_{Q_i}
\}_{i=1}^{n}.
}
$$

case-level summary只能做：

- all queries QRC；
- any query QRU；
- any query QDU；

不能把 answer domains 混在一起。

---

# 8. Merge Classification

v0.11 第一代分類：

```text
AUTO_MERGE
SAME_INTENT_COALESCE
QUERY_EQUIVALENT_CONFLICT
QUERY_SENSITIVE_CONFLICT
DEPENDENCY_INTERACTION_CONFLICT
EVIDENCE_CONFLICT
METADATA_CONFLICT
ROOT_IDENTITY_CONFLICT
```

這些類型不是同一 severity。

---

# 9. Evidence / Metadata / Root Conflict 分離

## Evidence Conflict

兩 branch 對同一 evidence metadata 有不同更新。

這不自動改變：

$$
Q.
$$

但 evidence provenance 仍不可靜默丟掉。

## Metadata Conflict

純 rendering / nuisance metadata conflict。

可由 UI policy 或 branch-preserving merge 處理。

## Root Identity Conflict

source root 本身被兩 branch 改成不同 identity。

即使當前 query answer 恰好一樣，canonical source ancestry 仍衝突。

因此：

$$
\boxed{
\text{query equality}
\not\Rightarrow
\text{root identity equivalence}.
}
$$

---

# 10. Reversible Conflict Artifact

任何 unresolved merge 都必須至少保存：

```yaml
merge:
  ancestor_hash: ...
  branch_a_patch: ...
  branch_b_patch: ...
  conflict_type: ...
  dependency_interactions: ...
  query_status:
    Q1:
      qrc: ...
      qru: ...
      qdu: ...
```

並要求：

$$
\boxed{
\operatorname{Replay}(A,\Delta_i)=B_i.
}
$$

若 branch 不能重建，就不能稱為 reversible semantic merge。

---

# 11. Query-Only Merge 是危險壓縮

若 merge engine 只問：

$$
Q(B_1)=Q(B_2)?
$$

相同就自動 collapse，

它會把：

- query-equivalent semantic conflict；
- evidence conflict；
- metadata conflict；
- root identity conflict；

全部靜默消失。

所以：

$$
\boxed{
\text{Q-equivalence permits projection merge, not canonical semantic collapse}.
}
$$

---

# 12. Field-Only Merge 也不夠

傳統 three-way field merge：

- same key 不同值 → conflict；
- different keys → merge；

會有兩種相反錯誤：

1. **false merge**：parent/child dependency interaction；
2. **over-conflict**：兩個 semantic values 雖不同，但對當前 query 完全等價。

因此需要：

$$
\boxed{
\text{field diff}
+
\text{dependency graph}
+
\text{query quotient}.
}
$$

---

# 13. Post-Merge Resolution

成功 canonical merge 後：

$$
M_{\mathrm{sem}}
$$

是一個新 completed state。

所有受影響 queries 必須重新計：

$$
\mathbf R_Q.
$$

不能沿用 branch 的 QRC / QRU / QDU label。

若 canonical merge 失敗，則 conflict branches 自動形成：

$$
\mathfrak I_{\mathrm{merge}}.
$$

再對每個 query 做：

$$
\operatorname{QRC}/\operatorname{QRU}/\operatorname{QDU}.
$$

---

# 14. Dependency Conflict 可產生 QDU

parent semantics 擴張後，child branch 可能缺少新 binding。

此時 conflict family 中可能同時存在：

- defined branch；
- undefined / unresolved derivation branch。

所以：

$$
\boxed{
\operatorname{QDU}
}
$$

可在 merge 階段新生，而不必在任何單一原 branch 中預先存在。

---

# 15. New Merge Object

建議：

$$
\boxed{
\mathcal M
=
(
A,
\Delta_1,
\Delta_2,
C_D,
C_I,
\mathcal Q,
R,
P
)
}
$$

其中：

- $A$：ancestor；
- $\Delta_i$：branch diffs；
- $C_D$：direct conflicts；
- $C_I$：dependency interactions；
- $\mathcal Q$：per-query resolution map；
- $R$：reconstruction data；
- $P$：provenance。

---

# 16. New Principles

## 原理一

$$
\boxed{
\text{Semantic merge}
\neq
\text{query-relative merge}.
}
$$

## 原理二

$$
\boxed{
\text{State commutativity}
\neq
\text{branch-intent preservation}.
}
$$

## 原理三

$$
\boxed{
Q(B_1)=Q(B_2)
\not\Rightarrow
B_1=B_2.
}
$$

## 原理四

$$
\boxed{
\text{Conflict preservation can coexist with QRC}.
}
$$

## 原理五

$$
\boxed{
\text{Multi-query closure is a map of query states, not a pooled answer set}.
}
$$
