feat(cli): knowledge replay checks independently issued composition certificate and current semantic source

This commit is contained in:
cflmy committed 2026-11-18 13:41:34 +08:00
1 parent ccf513aa4b
commit 3a5c7478a0
1 file changed
+26
+26
View File
@@ -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<i32> {
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())