- 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 已經能保證正常執行時:
但真正 long-horizon runtime 還有更危險的問題:
如果在 recompute / commit 的中間 crash 呢?
要求不是「重啟後程式能跑」。
真正要求:
只能看到完整舊 epoch 或完整新 epoch。
1. Durable transaction protocol
本輪採:
BEGIN
↓
EVENT
↓
PREPARE
↓
IMMUTABLE CHILD SNAPSHOT
↓
COMMIT
↓
HEAD ADVANCE
↓
CHECKPOINT
其中關鍵 durable barrier:
2. Crash matrix
建立:
個連續 transactions。
每個 transaction 在:
個 crash cuts 重啟。
總 crash scenarios:
結果:
符合預期 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 前:
COMMIT durable 後:
沒有一次 mixed closure 被接受為 HEAD。
3. Staged snapshot 在 COMMIT 前不是 closure
cut 4 時 child snapshot blob 已經 durable。
但尚未有:
COMMIT
recovery 仍必須回:
child blob 只是:
可以在 recovery 後 GC。
因此:
4. COMMIT 後、HEAD 前
這是最關鍵 crash window。
COMMIT 已 durable:
但 HEAD 仍指 parent。
crash 後 recovery 必須:
本輪:
此 cut 正確 roll-forward。
5. Idempotent replay
每個 committed transaction 又測:
- duplicate WAL 再加 1 份;
- duplicate WAL 再加 5 份。
共:
duplicate replay tests。
failure:
也就是:
在本地 closure-state recovery 中成立。
這不代表所有外部 side effect 都 exactly-once;如果未來 transaction 會發 email、呼叫 API、寫遠端 DB,仍需要外部 idempotency key / outbox。
6. Snapshot lineage
完整 canonical chain:
epochs:
- genesis;
- 1000 committed child epochs。
lineage validation:
每個 manifest 綁定:
7. Lineage tamper tests
四種 tamper:
- parent manifest hash;
- state content;
- certificate snapshot;
- duplicate txid。
結果:
因此 current lineage 不只是一串 epoch numbers,而是 content-addressed chain。
8. Negative control:HEAD before COMMIT
故意使用錯誤 protocol:
- BEGIN;
- EVENT;
- child snapshot;
- HEAD := child;
- 尚未 COMMIT。
結果:
crash recovery 最後雖然能 rollback parent,
但:
所以 HEAD 不得先於 COMMIT。
9. Negative control:過早截斷 WAL
故意:
- child snapshot durable;
- COMMIT durable;
- HEAD 尚未 advance;
- WAL 先被清掉;
- crash。
結果:
也就是 durability 被破壞。
因此:
WAL truncation 不是 housekeeping 細節,而是 closure lineage protocol 的一部分。
10. Redo from WAL
另一個 failure:
- COMMIT 存在;
- child snapshot blob 遺失;
- BEGIN / EVENT 還在。
recovery 直接從:
重算 child,
再驗:
本輪:
所以 durable event log 可以作第二條 recovery route。
11. Commit 存在但沒有 blob,也沒有 event
故意留下:
- BEGIN;
- COMMIT;
但拿掉:
- child snapshot;
- EVENT。
recovery:
沒有猜測、沒有靜默回退、沒有假裝 transaction 沒 commit。
這是正確失敗。
12. Round 08 replay artifact gap
Round 08 notebook 內部確實做:
但 package 裡的 round08_replay.py 只重新驗證:
- existing transaction log;
- existing final snapshot hashes。
沒有完整 engine 去重跑 mutation。
Round 09 因此正式區分:
與:
本輪的:
round09_crash_runtime.py
是後者。
13. Recovery correctness
本輪第一代 crash criterion:
並要求:
8000/8000 crash scenarios 滿足。
14. Persistent QRSRC
現在 QRSRC 已從純語義狀態一路進入持久化 runtime:
其中:
- :dependency graph;
- :certificate snapshot;
- :roots / semantic runtime state;
- :write-ahead log;
- :committed HEAD;
- :snapshot lineage。
15. v0.9 的 transaction visibility rule
reader 不讀 staging snapshot。
reader 只做:
HEAD 是 closure visibility 的唯一入口。
這避免:
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
Duplicate replay
Lineage
Tamper detection
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。
沒有證明:
- 真實檔案系統 fsync ordering;
- sector tearing;
- power-loss hardware semantics;
- multi-process concurrent writer;
- distributed consensus;
- network partition;
- cloud object-store consistency;
- external side-effect exactly-once。
所以這輪證據是:
不是 storage hardware certification。
19. 下一輪
Round 10 最自然的是:
測:
- 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.mdSRBC_Core_Patch_v0.9_2026-09-23.mdpqrsrc_wal_protocol_v09.yamlround09_crash_runtime.pyresults_round09.jsoncrash_matrix_round09.csvlineage_manifest_round09.jsongenesis_blob_round09.jsonfinal_blob_round09.jsoncrash_examples_round09.jsoninput_certificates_v07/*.jsonvalidation.json