← Archive
lm-004649 · 2026-10

SRBC Theory Validation Program — Round 09:Failure Recovery _ Crash Consistency _ Snapshot Lineage

下載 MD 檔 ⬇
📎 附件 · Companion files — 隨文交付的程式 / 證明 / 資料,可獨立下載重驗
title
SRBC Theory Validation Program — Round 09:Failure Recovery / Crash Consistency / Snapshot Lineage
author
Neo.K with Aletheia (GPT-5.6 Sol)
institution
EveMissLab / 一言諾科技有限公司
version
v0.1
date
2026-09-23
language
zh-TW
document_type
Persistent QRSRC Crash-Recovery Validation Report
status
Round 09 completed

SRBC Theory Validation Program — Round 09

Failure Recovery / Crash Consistency / Snapshot Lineage

作者: Neo.K with Aletheia (GPT-5.6 Sol)
機構: EveMissLab / 一言諾科技有限公司
日期: 2026-09-23
版本: v0.1


Canonical Source Note

本報告以 UTF-8 Markdown 保存;數學 source 僅使用 $...$ 與 $$...$$。

本輪不再只測 in-memory correctness,而是建立第一代 persistent QRSRC transaction simulator:

WAL
→ immutable staged snapshot
→ durable COMMIT
→ atomic HEAD
→ checkpoint
→ lineage

並在 transaction 的各 durable cut 主動 crash / restart。

完整可執行 simulator:

round09_crash_runtime.py

已放入 package,能直接重新執行本輪 crash matrix;這修正了 Round 08 downloadable replay artifact 只做既有 hash comparison、沒有真正重跑 engine 的 reproducibility gap。


0. 本輪問題

Round 08 已經能保證正常執行時:

St+1inc=St+1full.S_{t+1}^{\mathrm{inc}} = S_{t+1}^{\mathrm{full}}.

但真正 long-horizon runtime 還有更危險的問題:

如果在 recompute / commit 的中間 crash 呢?

要求不是「重啟後程式能跑」。

真正要求:

Recover⁡(Crash⁡k(T))∈{St,St+1}.\boxed{ \operatorname{Recover} ( \operatorname{Crash}_k(T) ) \in \{ S_t, S_{t+1} \}. }

只能看到完整舊 epoch 或完整新 epoch。


1. Durable transaction protocol

本輪採:

BEGIN
↓
EVENT
↓
PREPARE
↓
IMMUTABLE CHILD SNAPSHOT
↓
COMMIT
↓
HEAD ADVANCE
↓
CHECKPOINT

其中關鍵 durable barrier:

child snapshot≺COMMIT≺HEAD≺WAL truncation.\boxed{ \text{child snapshot} \prec \text{COMMIT} \prec \text{HEAD} \prec \text{WAL truncation}. }

2. Crash matrix

建立:

1000\boxed{ 1000 }

個連續 transactions。

每個 transaction 在:

8\boxed{ 8 }

個 crash cuts 重啟。

總 crash scenarios:

8000\boxed{ 8000 }

結果:

8000/8000\boxed{ 8000/8000 }

符合預期 recovery epoch。

crash cut scenarios pass legal recovered epoch
0 1000 1000 parent
1 1000 1000 parent
2 1000 1000 parent
3 1000 1000 parent
4 1000 1000 parent
5 1000 1000 child
6 1000 1000 child
7 1000 1000 child

在 COMMIT 前:

rollback parent.\boxed{ \text{rollback parent}. }

COMMIT durable 後:

roll-forward / remain child.\boxed{ \text{roll-forward / remain child}. }

沒有一次 mixed closure 被接受為 HEAD。


3. Staged snapshot 在 COMMIT 前不是 closure

cut 4 時 child snapshot blob 已經 durable。

但尚未有:

COMMIT

recovery 仍必須回:

St.S_t.

child blob 只是:

orphan staged artifact.\boxed{ \text{orphan staged artifact}. }

可以在 recovery 後 GC。

因此:

snapshot exists⇏snapshot committed.\boxed{ \text{snapshot exists} \not\Rightarrow \text{snapshot committed}. }

4. COMMIT 後、HEAD 前

這是最關鍵 crash window。

COMMIT 已 durable:

C(T)=1.C(T)=1.

但 HEAD 仍指 parent。

crash 後 recovery 必須:

RollForwardHead⁡(St+1).\boxed{ \operatorname{RollForwardHead}(S_{t+1}). }

本輪:

1000/1000\boxed{ 1000/1000 }

此 cut 正確 roll-forward。


5. Idempotent replay

每個 committed transaction 又測:

  • duplicate WAL 再加 1 份;
  • duplicate WAL 再加 5 份。

共:

2000\boxed{ 2000 }

duplicate replay tests。

failure:

0.\boxed{ 0. }

也就是:

Replay⁡(T)n=Replay⁡(T)\boxed{ \operatorname{Replay}(T)^n = \operatorname{Replay}(T) }

在本地 closure-state recovery 中成立。

這不代表所有外部 side effect 都 exactly-once;如果未來 transaction 會發 email、呼叫 API、寫遠端 DB,仍需要外部 idempotency key / outbox。


6. Snapshot lineage

完整 canonical chain:

1001\boxed{ 1001 }

epochs:

  • genesis;
  • 1000 committed child epochs。

lineage validation:

PASS.\boxed{ \text{PASS}. }

每個 manifest 綁定:

(Et,Et−1,Ht−1,txidt,h(μt),h(St),h(Ct)).( E_t, E_{t-1}, H_{t-1}, \mathrm{txid}_t, h(\mu_t), h(S_t), h(\mathcal C_t) ).

7. Lineage tamper tests

四種 tamper:

  1. parent manifest hash;
  2. state content;
  3. certificate snapshot;
  4. duplicate txid。

結果:

4/4 detected.\boxed{ 4/4\ \text{detected}. }

因此 current lineage 不只是一串 epoch numbers,而是 content-addressed chain。


8. Negative control:HEAD before COMMIT

故意使用錯誤 protocol:

  1. BEGIN;
  2. EVENT;
  3. child snapshot;
  4. HEAD := child;
  5. 尚未 COMMIT。

結果:

未提交 child 在 crash 前已可見.\boxed{ \text{未提交 child 在 crash 前已可見}. }

crash recovery 最後雖然能 rollback parent,

但:

recoverable≠atomic visibility.\boxed{ \text{recoverable} \neq \text{atomic visibility}. }

所以 HEAD 不得先於 COMMIT。


9. Negative control:過早截斷 WAL

故意:

  1. child snapshot durable;
  2. COMMIT durable;
  3. HEAD 尚未 advance;
  4. WAL 先被清掉;
  5. crash。

結果:

committed transaction lost.\boxed{ \text{committed transaction lost}. }

也就是 durability 被破壞。

因此:

WAL compaction≻durable HEAD / checkpoint.\boxed{ \text{WAL compaction} \succ \text{durable HEAD / checkpoint}. }

WAL truncation 不是 housekeeping 細節,而是 closure lineage protocol 的一部分。


10. Redo from WAL

另一個 failure:

  • COMMIT 存在;
  • child snapshot blob 遺失;
  • BEGIN / EVENT 還在。

recovery 直接從:

St+μtS_t+\mu_t

重算 child,

再驗:

Hcredo=HcCOMMIT.H_c^{\mathrm{redo}} = H_c^{\mathrm{COMMIT}}.

本輪:

REDO succeeds.\boxed{ \text{REDO succeeds}. }

所以 durable event log 可以作第二條 recovery route。


11. Commit 存在但沒有 blob,也沒有 event

故意留下:

  • BEGIN;
  • COMMIT;

但拿掉:

  • child snapshot;
  • EVENT。

recovery:

UNRECOVERABLE⁡.\boxed{ \operatorname{UNRECOVERABLE}. }

沒有猜測、沒有靜默回退、沒有假裝 transaction 沒 commit。

這是正確失敗。


12. Round 08 replay artifact gap

Round 08 notebook 內部確實做:

genesis→5000 transactions→same final hash.\text{genesis} \rightarrow 5000\text{ transactions} \rightarrow \text{same final hash}.

但 package 裡的 round08_replay.py 只重新驗證:

  • existing transaction log;
  • existing final snapshot hashes。

沒有完整 engine 去重跑 mutation。

Round 09 因此正式區分:

artifact-consistency replay\boxed{ \text{artifact-consistency replay} }

與:

executable state reconstruction.\boxed{ \text{executable state reconstruction}. }

本輪的:

round09_crash_runtime.py

是後者。


13. Recovery correctness

本輪第一代 crash criterion:

∀T,∀k:Recover⁡(Crash⁡k(T))∈{St,St+1}.\boxed{ \forall T,\forall k: \operatorname{Recover} ( \operatorname{Crash}_k(T) ) \in \{ S_t,S_{t+1} \}. }

並要求:

Integrity⁡=1.\boxed{ \operatorname{Integrity} = 1. }

8000/8000 crash scenarios 滿足。


14. Persistent QRSRC

現在 QRSRC 已從純語義狀態一路進入持久化 runtime:

PQRSRC⁡=(GC,C,R,W,H,L).\boxed{ \operatorname{PQRSRC} = ( G_C, \mathcal C, R, W, H, L ). }

其中:

  • GCG_C:dependency graph;
  • C\mathcal C:certificate snapshot;
  • RR:roots / semantic runtime state;
  • WW:write-ahead log;
  • HH:committed HEAD;
  • LL:snapshot lineage。

15. v0.9 的 transaction visibility rule

reader 不讀 staging snapshot。

reader 只做:

ReadClosure⁡()=Snapshot⁡(HEAD⁡).\boxed{ \operatorname{ReadClosure}() = \operatorname{Snapshot} ( \operatorname{HEAD} ). }

HEAD 是 closure visibility 的唯一入口。

這避免:

mixed epoch.\boxed{ \text{mixed epoch}. }

16. Checkpoint

正式 production checkpoint 還應保存:

  • epoch;
  • HEAD manifest hash;
  • committed tx watermark;
  • root-registry digest;
  • certificate-registry digest;
  • runtime version;
  • evaluator digest。

Round 09 simulator 尚未加入 runtime-version migration attack;v0.9 已將它列為下一層必要欄位。


17. Round 09 的直接結果

Crash safety

8000/8000.\boxed{ 8000/8000. }

Duplicate replay

2000/2000.\boxed{ 2000/2000. }

Lineage

1001 epochs valid.\boxed{ 1001\text{ epochs valid}. }

Tamper detection

4/4.\boxed{ 4/4. }

Bad ordering controls

  • HEAD-before-COMMIT:確實有 atomic visibility violation;
  • WAL truncate before durable HEAD:確實會失去 committed tx;
  • COMMIT + missing blob + event present:可 redo;
  • COMMIT + no blob + no event:正確標 unrecoverable。

18. 本輪沒有證明什麼?

這仍然是 single-process persistence simulator。

沒有證明:

  1. 真實檔案系統 fsync ordering;
  2. sector tearing;
  3. power-loss hardware semantics;
  4. multi-process concurrent writer;
  5. distributed consensus;
  6. network partition;
  7. cloud object-store consistency;
  8. external side-effect exactly-once。

所以這輪證據是:

transaction protocol / recovery semantics validation,\boxed{ \text{transaction protocol / recovery semantics validation}, }

不是 storage hardware certification。


19. 下一輪

Round 10 最自然的是:

Concurrency / MVCC / Multi-Writer Conflict.\boxed{ \text{Concurrency / MVCC / Multi-Writer Conflict}. }

測:

  • reader 在長 transaction 中看到哪個 epoch;
  • 兩個 writer 同時從同一 parent 修改不同 roots;
  • disjoint mutation 能不能 merge;
  • overlapping mutation 如何 conflict;
  • compare-and-swap HEAD;
  • lost update;
  • serializability;
  • snapshot isolation;
  • certificate graph merge。

到了這裡,SRBC 已經從:

自然語言到底有沒有說完?

一路推到:

多個 agent / writer 同時修改一個可驗證語義 closure 時,如何保持真實的 epistemic state consistency?


附錄 A:Crash Matrix

cut scenarios pass expected recovery
0 1000 1000 parent
1 1000 1000 parent
2 1000 1000 parent
3 1000 1000 parent
4 1000 1000 parent
5 1000 1000 child
6 1000 1000 child
7 1000 1000 child

附錄 B:Machine Results

{
  "round": "SRBC Theory Validation Round 09",
  "transactions": 1000,
  "crash_cuts_per_transaction": 8,
  "crash_scenarios": 8000,
  "crash_pass": 8000,
  "crash_fail": 0,
  "cut_stats": {
    "0": {
      "n": 1000,
      "pass": 1000
    },
    "1": {
      "n": 1000,
      "pass": 1000
    },
    "2": {
      "n": 1000,
      "pass": 1000
    },
    "3": {
      "n": 1000,
      "pass": 1000
    },
    "4": {
      "n": 1000,
      "pass": 1000
    },
    "5": {
      "n": 1000,
      "pass": 1000
    },
    "6": {
      "n": 1000,
      "pass": 1000
    },
    "7": {
      "n": 1000,
      "pass": 1000
    }
  },
  "idempotency": {
    "duplicate_replay_tests": 2000,
    "failures": 0
  },
  "lineage": {
    "epochs": 1001,
    "valid": true,
    "reason": "ok",
    "tamper_tests": {
      "parent_hash_tamper_detected": true,
      "state_tamper_detected": true,
      "certificate_tamper_detected": true,
      "duplicate_tx_detected": true
    }
  },
  "negative_controls": {
    "head_before_commit": {
      "uncommitted_child_became_visible_before_crash": true,
      "recovery_rolled_back_to_parent": true
    },
    "wal_truncate_before_head": {
      "committed_transaction_lost": true
    },
    "redo_from_wal_without_snapshot_blob": {
      "success": true
    },
    "commit_without_snapshot_or_event": {
      "unrecoverable_detected": true
    }
  },
  "recovery_rule": {
    "cuts_0_to_4": "rollback to parent epoch",
    "cuts_5_to_7": "roll forward / remain at fully committed child epoch"
  }
}

附錄 C:Artifacts

  • SRBC_Theory_Validation_Round09_Report_v0.1_2026-09-23.md
  • SRBC_Core_Patch_v0.9_2026-09-23.md
  • pqrsrc_wal_protocol_v09.yaml
  • round09_crash_runtime.py
  • results_round09.json
  • crash_matrix_round09.csv
  • lineage_manifest_round09.json
  • genesis_blob_round09.json
  • final_blob_round09.json
  • crash_examples_round09.json
  • input_certificates_v07/*.json
  • validation.json