跳到內容

決策生命週期

每一個 LLM / tool 呼叫的邊界,都會觸發一筆 8 個階段的決策交易:

#階段在哪裡執行產出
1snapshotsidecar(in-process)snapshot_hash
2evaluatesidecar Contract DSLmatched_rules_hash
3prepare_effectsidecar(純運算)effect_hash
4reserveledger 原子操作reservation_id
5audit_decision併入 reserveaudit_outbox row
6publish_effectadapter(in-process)套用變更
7commit_or_releaseledgercommit_estimated / release
8audit_outcome併入 commit/releaseaudit_outbox row

最關鍵的硬不變式:階段 1–5 是原子地一起發生(同一筆 Postgres transaction);萬一 sidecar 在 publish 中途掛掉,會靠 effect_hash 的 idempotency 把階段 6 重放一次。

正式規格請看 docs/contract-dsl-spec-v1alpha1.md §6。