---
title: "SRBC Core Patch v0.10：MVCC、Read Footprint、Predicate Dependencies 與 Multi-Writer Serialization"
version: "v0.10"
date: "2026-09-23"
status: "Round 10 concurrency-validation patch candidate"
---

# SRBC Core Patch v0.10

Round 10 將 PQRSRC 從 single-writer crash-consistent runtime 推進到 multi-writer concurrency。

本輪核心結論：

$$
\boxed{
\text{write-write conflict}
\neq
\text{semantic transaction conflict}.
}
$$

真正需要的是：

$$
\boxed{
\text{read footprint}
+
\text{write intent}
+
\text{predicate footprint}
+
\text{CAS / MVCC}.
}
$$

---

# 1. Canonical Transaction

定義：

$$
T
=
(
\mathrm{txid},
E_b,
H_b,
R_T,
W_T,
P_T,
I_T
).
$$

其中：

- $E_b$：base epoch；
- $H_b$：base snapshot hash；
- $R_T$：key / semantic read footprint；
- $W_T$：absolute write patch；
- $P_T$：predicate / invariant footprint；
- $I_T$：intent digest。

---

# 2. Absolute Patch Requirement

可 rebase transaction 不應只保存：

```text
toggle X
increment X
use whatever is current
```

而應在 base snapshot 上 canonicalize 成 absolute intent，例如：

```yaml
set:
  path: semantic/MH-C2/l1
  from: 1/2
  to: 1
```

否則 stale rebase 時，相同 operation token 可能代表不同實際意圖。

若確實需要 relative operation，必須明示：

```yaml
rebase_semantics:
  reevaluate_operator_on_new_head: true
```

並重新執行 conflict / invariant validation。

---

# 3. CAS Only 太保守

若：

$$
H_{\mathrm{HEAD}}\neq H_b,
$$

純 CAS 直接拒絕 transaction。

這可以防 lost update，但會拒絕大量可安全 serial rebase 的 disjoint transaction。

因此 v0.10 使用：

```text
if HEAD == base:
    direct commit
else:
    validate read footprint
    if unchanged:
        rebase
    else:
        conflict
```

---

# 4. Read Footprint

對 semantic transaction：

$$
R_T
$$

至少包含：

1. 自己要寫的 base key；
2. 所有 semantic derivation parents；
3. query / root / family dependency 中實際讀取的 identity；
4. evidence transaction 所依附 claim 的 semantic digest。

因此 child transaction 即使寫不同欄位，只要 parent semantic digest 被別的 writer 改掉：

$$
\boxed{
\operatorname{CONFLICT}.
}
$$

---

# 5. Direct Write-Write 不是充分 conflict detector

例如：

$$
T_A:
\text{change MH-C1 semantics},
$$

$$
T_B:
\text{change MH-C2 local parameter}.
$$

兩者 direct write keys 不同：

$$
W_A\cap W_B=\varnothing.
$$

但：

$$
MH\text{-}C2
$$

讀：

$$
SD(MH\text{-}C1).
$$

所以 $T_A$ 會使 $T_B$ 的 read footprint stale。

因此：

$$
\boxed{
W_A\cap W_B=\varnothing
\not\Rightarrow
\operatorname{MergeSafe}(A,B).
}
$$

---

# 6. Affected-Set Overlap 只是保守 Filter

如果：

$$
\operatorname{Aff}(A)
\cap
\operatorname{Aff}(B)
\neq
\varnothing,
$$

兩個 transaction 可能仍然 serial-merge safe。

例如 source root 與 query root 各自變更，最後由 full semantic rebuild 共同生成新 closure。

所以 affected overlap 適合作為：

- cheap prefilter；
- scheduling hint；

但不能當 final conflict verdict。

---

# 7. OCC Validation

stale transaction $T$ 對 current head $S_h$ 驗：

$$
\boxed{
\forall r\in R_T:
h(r,S_h)
=
h(r,S_b).
}
$$

若成立：

$$
\operatorname{RebaseAllowed}(T).
$$

否則：

$$
\operatorname{CONFLICT}.
$$

---

# 8. Predicate / Invariant Footprint

key-level read set 仍可能產生 write skew。

若 transaction 決策依賴：

$$
\phi(S),
$$

就必須保存其 dependency footprint：

$$
P_T.
$$

不能只保存：

$$
\phi(S_b)=\text{true}.
$$

因為別的 transaction 可能改變 $\phi$ 所依賴的 underlying state，但布林值在中間狀態仍暫時相同。

v0.10 因此要求 predicate fingerprint hash 其 dependency domain，而不是只 hash predicate result。

---

# 9. Snapshot Readers

reader 開始於：

$$
E_r
$$

後，writer commits：

$$
E_r+1,E_r+2,\ldots
$$

不應改變 reader 已 pin 的 snapshot：

$$
\boxed{
\operatorname{Read}_{E_r}(x)
=
\text{stable}.
}
$$

current-head reader 則可在下一次 read transaction 看到新 epoch。

---

# 10. Serialization Order

成功 rebase 後：

$$
T_A
\prec
T_B
$$

的 committed order 就是 serialization order。

runtime 必須驗：

$$
\boxed{
S_{\mathrm{MVCC}}
=
\operatorname{Apply}
(
T_B,
\operatorname{Apply}(T_A,S_b)
).
}
$$

如果雙向 read footprints 都穩定，還可以測：

$$
A;B
=
B;A.
$$

本輪 safe bidirectional rebase pairs 全部 commute。

---

# 11. Same-Intent Coalescing

conservative OCC 對同一 base、同一 direct key 的兩個 transaction 會 conflict，即使：

$$
W_A=W_B
$$

且：

$$
\operatorname{After}(A)
=
\operatorname{After}(B).
$$

對純 closure state，可以額外做：

$$
\boxed{
\operatorname{IntentDigest}(A)
=
\operatorname{IntentDigest}(B)
\Rightarrow
\operatorname{Coalesce}.
}
$$

但若 transaction 有：

- external API action；
- email；
- payment；
- non-idempotent side effect；

不能只靠 semantic patch 相等判定 exactly-once。

必須沿用 v0.9 的 txid / idempotency key / outbox discipline。

---

# 12. Conflict 與 Contradiction 分離

Concurrency conflict 表示：

> transaction 的讀取前提已 stale，不能無審計 rebase。

它不等於：

> 兩個 semantic claims 邏輯矛盾。

因此：

$$
\boxed{
\operatorname{MVCCConflict}
\neq
\operatorname{SemanticContradiction}.
}
$$

若要判語義矛盾，仍需另外的 logic / admissibility checker。

---

# 13. Multi-Writer Closure Transaction

第一代 commit protocol：

```text
BEGIN TX on snapshot E_b
↓
capture R_T / P_T / W_T / I_T
↓
compute preview
↓
CAS HEAD
├─ success → commit
└─ stale
   ↓
   validate R_T + P_T against current HEAD
   ├─ unchanged → deterministic rebase
   │              ↓
   │              recompute affected closure
   │              ↓
   │              CAS current HEAD
   └─ changed → CONFLICT / reopen
```

---

# 14. New Principles

## 原理一

$$
\boxed{
\text{Conflict detection is dependency validation, not merely write overlap}.
}
$$

## 原理二

$$
\boxed{
\text{Closure overlap is conservative, not exact}.
}
$$

## 原理三

$$
\boxed{
\text{MVCC rebase requires canonical transaction intent}.
}
$$

## 原理四

$$
\boxed{
\text{Predicate dependencies are first-class semantic reads}.
}
$$

## 原理五

$$
\boxed{
\text{Snapshot isolation of readers does not by itself guarantee serializable writers}.
}
$$
