S7-12 · 进阶S7-12 · Advanced

检查点与恢复 · 锁住已提交步骤,只重跑未完成部分Checkpoint and Resume · Lock Committed Steps; Rerun Only Incomplete Work

commit boundary → power loss at step 3 → load checkpoint 2 → rerun incomplete steps

检查点与恢复(Checkpoint and Resume)在安全边界保存执行状态,使中断后可从已确认位置继续。长任务不能因一次断线从头重做或重复副作用。Checkpoint and resume saves execution state at safe boundaries so interrupted work continues from the last confirmed point. A long task should not restart or repeat side effects after one outage.

01 · 搬家到第三箱停电,前两箱要重新打包吗01 · Power fails at box three—repack boxes one and two?

前两步已经扣款并记账,第三步执行中突然断电。恢复时怎样证明前两步不再执行,又让第三步重新跑?Payment and ledger steps are committed when power fails during step three. How can recovery prove the first two will not run again while step three does?

02运行到第三步断电,再从检查点恢复并观察锁定与重跑Run to Step Three, Cut Power, Then Resume and Inspect Locked versus Rerun Work

提交边界 · 审计轨迹commit boundary · audit trail
状态 AMetric A
状态 BMetric B
状态 CMetric C

所有概率、成本、成功率与输出均为固定种子的教学模拟,不代表真实模型输出。把主变量拖回即可复核结论。All probabilities, costs, success rates, and outputs are fixed-seed teaching simulations, not real model output. Move the main variable back to verify the conclusion.

03把刚才的变化拆成 4 个零件Break the Change into Four Parts

Checkpoint and Resume
BOUNDARY

安全边界Safe boundary

只在结果已确认且副作用可追踪处落检查点。Checkpoint only after a result is confirmed and its side effect is traceable.

SNAPSHOT

执行快照Execution snapshot

保存步骤、输入版本、输出引用与幂等键。Store step, input version, output reference, and idempotency key.

LOCK

已提交锁定Committed lock

恢复后前两步只读,不允许重复执行。After recovery, the first two steps are read-only and cannot execute again.

RERUN

未完成重跑Incomplete rerun

第三步没有提交证明,因此从相同输入重新执行。Step three lacks commit proof, so it reruns from the same input.

04最小机制:主交互能逐项验证Minimal Mechanism: Verify Each Link in the Interaction

MECHANISM
resume_from = max(committed_checkpoint) + 1
断电时第三步没有 commit;恢复点仍是 2,步骤 1–2 锁定,步骤 3 起重跑并新增审计事件。Step three has no commit at power loss. Recovery remains at 2, steps 1–2 lock, and execution restarts at step 3 with a new audit event.
逐步提交Commit安全边界落点checkpoint at safe boundary
中断Interrupt第三步无提交step 3 lacks commit
恢复Resume锁 1–2,重跑 3+lock 1–2, rerun 3+

05没有检查点却从头重跑全部五步Rerun All Five Steps without a Checkpoint

主动制造失败Create a failure

边界实验Boundary experiment

从头重跑会重复已提交副作用。失败实验把前两步标成重复风险,并对照正确恢复轨迹。Restarting repeats committed side effects. The failure experiment marks the first two steps as duplicate risks and contrasts the correct recovery trace.

尚未执行。先在主交互中观察正常机制。Not run yet. Observe the normal mechanism in the main interaction first.
检查点就是保存聊天文本。A checkpoint is saved chat text.→ ✓ 检查点要记录步骤、版本、输出引用与提交证明。A checkpoint records step, version, output reference, and commit proof.
恢复等于从第一步再来。Resume means restart from step one.→ ✓ 已提交步骤锁定,只有未完成部分重跑。Committed steps lock; only incomplete work reruns.
每一行代码后都落检查点。Checkpoint after every line of code.→ ✓ 检查点放在可验证、可恢复的安全边界。Place checkpoints at verifiable, recoverable boundaries.
06 · 一句话带走06 · One line to keep

检查点记录最后已提交的安全边界;断电恢复时锁住已提交步骤,并从第一个未完成步骤重跑。A checkpoint records the last committed safe boundary. Recovery locks committed steps and reruns from the first incomplete one.