Files
marqdo/verification/replay-policy
cflmy 9331af78e2 release(2.8.0): 合入 CHANGELOG/README/发版说明/skills prove 任务;CI 链接指向 doc/releases
- CHANGELOG.md:v2.8.0 条目(中英双语);
- README.md:版本行 2.7.1→2.8.0 + 愿景第 6 条(知识可证明);
- doc/releases/v2.8.0.md:双语发版说明(亮点/用法/已知限制);
- skills/marqdo-dev/index.mq.md:新增 prove 任务(路径/目录模式/
  require_lean/json;参数用 + 行声明升参,check 与 narrative-ratio 通过);
- 设计文档 §12.5 标记已合入;发版链接统一指向 doc/releases/v2.8.0.md。
2026-11-18 10:29:26 +08:00
..

Executable replay policy

Strict protocol replay uses this Lean policy to decide request permissions, reply acceptance and final-history exhaustion. The Rust transport adapter does not contain a second implementation of these decisions. Ordinary recording does not start a policy process.

The JSON-lines transport sends a complete PolicyCommand record on every operation: op, steps, and value are always present. Lean structure defaults are not missing-field defaults for the derived JSON decoder. In particular, initialization and finish still need an empty value, while prepare/receive still need an empty steps array:

{"op":"init","steps":[],"value":""}
{"op":"finish","steps":[],"value":""}

The Rust adapter uses one typed wire record for all four operations. Transport failures stop the companion and include its exit status and a bounded stderr tail, so a decoder error is not reduced to a closed-channel message. Neither this transport nor its diagnostics replace Lean's replay verdict.

Build the companion before building or testing strict replay:

python3 verification/replay-policy/build_policy.py --lake /path/to/lake
cargo build --locked

The toolchain is pinned in lean-toolchain. The build writes POLICY-SHA256, the compiled executable and BUILD-IDENTITY.json. Compile Rust after generating the identity: its adapter rejects a companion with a different policy identity. Do not modify policy sources during a build.

For deployment, install the companion next to the marqdo executable as marqdo-replay-policy. MARQDO_REPLAY_POLICY can select a trusted installation. Development builds also find this package's .lake/build/bin/replayPolicy. An unavailable, stale or malformed companion stops strict replay; there is no fallback to the historical handwritten Rust policy.

ReplayPolicy/Cursor.lean contains the executable transitions and their basic invariants. The paper proof project imports this module and proves interaction- program correspondence in MarqdoProof/ReplayCursor.lean. The compiler, process transport, JSON/string encoding and host dispatch adapter remain explicit trust interfaces. These files do not establish correctness of the full Rust frontend.