From 3a5c7478a0e8ea5ee29f03714e79489c7c9a6c31 Mon Sep 17 00:00:00 2001 From: cflmy Date: Wed, 18 Nov 2026 13:41:34 +0800 Subject: [PATCH] feat(cli): knowledge replay checks independently issued composition certificate and current semantic source --- src/main.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/main.rs b/src/main.rs index 617aff7..67da022 100755 --- a/src/main.rs +++ b/src/main.rs @@ -626,6 +626,12 @@ enum KnowledgeAction { #[arg(long)] strict: bool, }, + /// Independently replay a previously issued composition certificate + /// against current source, Lean modules and toolchain. + Replay { + #[arg(value_name = "CERTIFICATE")] + certificate: PathBuf, + }, /// Inspect stable project symbols by exact URI or display name Inspect { /// Symbol URI (`mq://…`) or declaration name @@ -1786,6 +1792,26 @@ fn try_main(cli: Cli) -> Result { write_knowledge(KnowledgeOptions { path, out_dir: out })?; Ok(0) } + KnowledgeAction::Replay { certificate } => { + let root=if path.is_file(){ + path.parent().filter(|p|!p.as_os_str().is_empty()) + .unwrap_or_else(||std::path::Path::new(".")).to_path_buf() + }else{path.clone()}; + let compiled=marqdo::sema::ir::compile_project( + &marqdo::sema::ir::CompileOptions{ + project_root:root, + entry:path.is_file().then_some(path), + lock_mode:marqdo::sema::ir::LockMode::Off + })?; + let lean=marqdo::prove::driver::Toolchain::discover(None)? + .ok_or_else(||anyhow::anyhow!("proof.compose_lean_missing"))?; + let proof=marqdo::knowledge::composition::replay( + &compiled,&certificate,&lean)?; + if json{println!("{proof}");}else{ + println!("{}",serde_json::to_string_pretty(&proof)?); + } + Ok(0) + } KnowledgeAction::Compose { strict } => { let root=if path.is_file(){ path.parent().filter(|p|!p.as_os_str().is_empty())