From c61af4b829e1f02933c6dd4721dcb661616742d5 Mon Sep 17 00:00:00 2001 From: cflmy Date: Wed, 18 Nov 2026 14:58:36 +0800 Subject: [PATCH] test(proof): reject duplicate, injected and stale composition closure receipts --- src/knowledge/composition.rs | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/knowledge/composition.rs b/src/knowledge/composition.rs index b869062..59c954a 100644 --- a/src/knowledge/composition.rs +++ b/src/knowledge/composition.rs @@ -233,6 +233,18 @@ pub fn prove(compiled:&Compilation,out:&Path,toolchain:&Toolchain)->Result, + expected:&std::collections::BTreeSet<(String,String)> +)->Result<()>{ + anyhow::ensure!(rows==expected.len() && received==expected, + "proof.compose_stale_or_ambiguous_closure"); + Ok(()) +} + /// Replay a composition certificate *against the current project source*. /// The certificate never supplies Lean source code: it must byte-match source /// recompiled from the current Marqdo AST, and both Lean modules are rechecked. @@ -277,8 +289,7 @@ pub fn replay(compiled:&Compilation,certificate:&Path,lean:&Toolchain)->Result>>()?; - anyhow::ensure!(received.len()==2 && actual_closures==expected_closures, - "proof.compose_stale_or_ambiguous_closure"); + ensure_exact_closures(received.len(),&actual_closures,&expected_closures)?; let folder=certificate.parent().context("missing certificate parent")?; let callee_path=folder.join("CalleeModule.lean"); let caller_path=folder.join("CallerModule.lean"); @@ -307,6 +318,25 @@ pub fn replay(compiled:&Compilation,certificate:&Path,lean:&Toolchain)->Result