From 4140e8883ad7a65b445dbe1fcf0d8b6cca97cffc Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Tue, 3 Nov 2026 14:24:03 +0000 Subject: [PATCH 1/8] Register VR-28 and its failing process-binding case --- SPEC.md | 1 + crates/conformance/src/cases/verification.rs | 38 ++++++++++++++++++++ crates/conformance/tests/conformance.rs | 5 +++ features/suites/verification.feature | 9 +++++ model/ids.toml | 6 ++++ 5 files changed, 59 insertions(+) diff --git a/SPEC.md b/SPEC.md index daed99dbae..3b1229696d 100644 --- a/SPEC.md +++ b/SPEC.md @@ -11201,6 +11201,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `VR-21` | `verification` | A multi-module project whose imports form nontrivial frontiers verifies at width 1 and at a larger width to byte-identical verified directories and the same attestation identity, observed axiom sets, and policy rows, and no completion order orders a record or changes which failure is reported. | §22.3, §22.4, §22.11 | | `VR-22` | `verification` | Performance telemetry is written only to the CI evidence directory the environment names, a verification with telemetry on publishes byte-identical artifacts to one without, and telemetry planted in a verified artifact fails the gate. | §22.12 | | `VR-23` | `verification` | A project verified as the parts of one run, each shard running the processes its plan names with the oleans of the shards it needs and the join reading every shard's records, publishes a verified directory byte-identical to the whole verification's with the same attestation identity, and a shard whose plan leaves a module without its imports, a join missing a record, or a join reading a record of an executable other than its own, is refused. | §9.4, §22.11 | +| `VR-28` | `verification` | Generated project modules and certificates A, B, and E omit the in-process kernel check only when a successful pinned same-run replay binds the same module and complete olean parts; one publication guard covers local and imported records, the certificate tail, and staged project artifacts, while runtime, support, probe, extraction, and audit modules retain their in-process checks. | §22.3, §22.4, §22.9 | | `CL-01` | `cli-api` | Global options and upward project discovery obey the exact CLI contract. | §23.1, §23.2 | | `CL-02` | `cli-api` | Init creates the complete canonical skeleton only in an absent or empty destination and never overwrites. | §23.4 | | `CL-03` | `cli-api` | Lock check, local update, and explicit network acquisition obey their exact mutually exclusive behavior. | §23.4 | diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 3cbe4020a9..972f9bc395 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -46,6 +46,7 @@ pub(crate) fn run(id: &str) { return; } match id { + "VR-28" => binding_record_round_trip(), // §22.1: every stage runs; no suppression option exists. "VR-01" => { let fixture = support::verified(); @@ -1324,3 +1325,40 @@ fn run_platform_independent(id: &str) { } } } + +/// The platform-independent record half of VR-28. +fn binding_record_round_trip() { + use lexlean::artifact::canonical_json::Json; + use lexlean::artifact::content_id::Sha256Digest; + use lexlean::verify::child::ChildRecord; + + let digest = |bytes: &[u8]| Json::Str(Sha256Digest::of(bytes).to_hex()); + let json = Json::object(vec![ + ("tool", Json::Str("lean".to_owned())), + ("module", Json::Str("Demo.M".to_owned())), + ( + "argv", + Json::Arr(vec![ + Json::Str("env".to_owned()), + Json::Str("lean".to_owned()), + ]), + ), + ("exit_code", Json::Int(0)), + ("stdout", Json::Str(String::new())), + ("stderr", Json::Str(String::new())), + ("stdout_sha256", digest(b"")), + ("stderr_sha256", digest(b"")), + ("executable_sha256", digest(b"lean")), + ( + "olean", + Json::object(vec![("main", digest(b"compiled main"))]), + ), + ]); + let record = + ChildRecord::from_json(&json).expect("a complete olean binding is a process record"); + assert_eq!( + record.to_json().to_file_bytes(), + json.to_file_bytes(), + "the binding survives the same shard record serialization" + ); +} diff --git a/crates/conformance/tests/conformance.rs b/crates/conformance/tests/conformance.rs index 709f156ea3..93ef979200 100644 --- a/crates/conformance/tests/conformance.rs +++ b/crates/conformance/tests/conformance.rs @@ -1110,6 +1110,11 @@ fn conformance_vr_23() { repo_conformance::cases::run("VR-23"); } +#[test] +fn conformance_vr_28() { + repo_conformance::cases::run("VR-28"); +} + #[test] fn conformance_cl_01() { repo_conformance::cases::run("CL-01"); diff --git a/features/suites/verification.feature b/features/suites/verification.feature index 0444b94c7e..cea246b4c9 100644 --- a/features/suites/verification.feature +++ b/features/suites/verification.feature @@ -168,3 +168,12 @@ Feature: verification Then the join publishes a verified directory byte-identical to the whole verification's, with the same attestation identity And a shard whose plan elaborates a module before its imports, and a join that is handed one shard too few, are refused And a join reading a replay record whose executable digest is not its own leanchecker's is refused + + @VR-28 @build + Scenario: Generated project modules and certificates A, B, and E omit the in-process kernel check only when a successful pinned same-run replay binds the same module and complete olean parts; one publication guard covers local and imported records, the certificate tail, and staged project artifacts, while runtime, support, probe, extraction, and audit modules retain their in-process checks. + Given generated project and certificate modules, their same-run process records, and the staged olean artifacts + When their compile and replay bindings are checked before publication + Then each flagged compile has one successful pinned replay for the same module and identical main, server, and private olean parts + And absent companions differ from present bytes, and malformed, missing, failed, or substituted bindings are refused + And imported shard records and the certificate tail obey the same guard and staged project hashes agree + And runtime, support, probe, extraction, and audit compilations keep the in-process kernel check diff --git a/model/ids.toml b/model/ids.toml index e1f5ddc29a..a40350262d 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1333,6 +1333,12 @@ level = "build" suite = "verification" statement = "A project verified as the parts of one run, each shard running the processes its plan names with the oleans of the shards it needs and the join reading every shard's records, publishes a verified directory byte-identical to the whole verification's with the same attestation identity, and a shard whose plan leaves a module without its imports, a join missing a record, or a join reading a record of an executable other than its own, is refused." +[[id]] +id = "VR-28" +level = "build" +suite = "verification" +statement = "Generated project modules and certificates A, B, and E omit the in-process kernel check only when a successful pinned same-run replay binds the same module and complete olean parts; one publication guard covers local and imported records, the certificate tail, and staged project artifacts, while runtime, support, probe, extraction, and audit modules retain their in-process checks." + [[id]] id = "CL-01" level = "build" From 52c246fd51930a8d286136a0f31486cae212b483 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Tue, 3 Nov 2026 14:33:19 +0000 Subject: [PATCH 2/8] Prepare typed olean part bindings and the VR-28 association guard --- VERIFICATION.md | 57 ++++++++ crates/conformance/src/cases/verification.rs | 142 +++++++++++++++++++ crates/lexlean/src/verify/child.rs | 63 ++++++++ crates/lexlean/src/verify/leanchecker.rs | 86 +++++++++++ crates/lexlean/src/verify/partition.rs | 11 ++ schemas/attestation-v2.schema.json | 2 +- schemas/attestation.schema.json | 2 +- 7 files changed, 361 insertions(+), 2 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 090cf8165e..7b228d882e 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12407,3 +12407,60 @@ weighting makes its partition assertion fail. This is a harness correction, not a change to the generated packages or a resolution of #164's consumer compiler-nesting question. A Windows rerun is required to establish whether this bounded partition removes the observed compiler failure. + +## Single-kernel replay binding source preparation (VR-28, #391) + +This bounded phase prepares the record and association guard on +`0a01df682426cc54b63363e2eec7195cd8a8f318`. The register row, matching +scenario and named case were committed first in `4140e8883`. Exact +`conformance_vr_28` then failed with exit 101 because the existing process +parser refused `olean` as an unknown field. + +`ChildRecord` now carries an optional typed binding: a required main +`.olean` SHA-256 and optional `.olean.server` and `.olean.private` digests. +Omission means absence under the existing canonical JSON rules; an empty +file has a present SHA-256 and differs from absence. A private part without +its server part is refused. Both strict process schemas admit the same +closed object. The existing shard record serializer/parser transports it; +there is no additional receipt file, digest recipe, or audit framework. + +Focused evidence under the shared validation lock, with two Cargo jobs and +incremental compilation disabled: + +| Check | Observed | +| --- | --- | +| Exact `conformance_vr_28`, existing parser | Refused the new binding, exit 101 | +| Exact `conformance_vr_28`, binding and pure guard | Passed; malformed/unknown fields, invalid digests, orphan private parts, missing/failed/duplicate replay, different module/argv, substituted main/server/private bytes, absent versus present empty companions, staged mismatches, and the certificate tail are exercised | +| Existing partition unit tests | 3 passed; the round-trip now preserves all three part digests through the existing export/import transport | +| Clippy for lexlean and repo-conformance, all targets/features, warnings denied | Passed | + +This validates the platform-independent record and pure association check. +The helper is separate from existing toolchain/output gates and does not +replace them. No skip flag, compilation/replay capture, or publication +call site was changed in this phase; no full VR-28 acceptance is claimed. +The real false-declaration replay, actual-input capture, shard substitution, +width invariance, gateway/Atlas measurements, and complete gate evidence +remain integration requirements. No model, identity or artifact writer ran. +Both schema changes affect every language identity partition, so the +committed identities and generated artifacts require one coordinated writer +wave on the reviewed integration head. + +The pinned Lean sources establish two input details that call-site work +must preserve. `LeanChecker.lean`'s `replayFromImports` loads the exported +part, the server part when present, and then the private part when present; +`Lean.Environment.readModuleDataParts` reads these distinct files. A main-only +digest would not bind the checked declarations. Its CLI also enumerates a +target module prefix: accepted names such as `A` and `A.B` can make a replay +process check descendants too. Removing the in-process pass does not imply +globally exactly-once declaration replay, and this work does not replace or +modify the pinned checker. + +Actual resolution also depends on Lake's augmented search path and Lean's +first package-root rule, rather than the first existing full module path. +A proposed narrow preflight query uses bare `lake env`, through the existing +bounded runner, and decodes only raw `LEAN_PATH` before normalization. No +full environment dump belongs in tool output or canonical evidence. The +query emits unescaped `NAME=VALUE` lines, while current path rules do not +forbid newlines. Duplicate-row rejection alone therefore does not establish +unambiguous decoding for every accepted path; that design point requires +review before capture and skip flags are connected. diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 972f9bc395..713007e164 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -1361,4 +1361,146 @@ fn binding_record_round_trip() { json.to_file_bytes(), "the binding survives the same shard record serialization" ); + let Json::Obj(mut legacy_fields) = json.clone() else { + unreachable!() + }; + legacy_fields.remove("olean"); + let legacy = Json::Obj(legacy_fields); + assert_eq!( + ChildRecord::from_json(&legacy) + .expect("unbound process records remain readable") + .to_json(), + legacy + ); + let changed = |binding: Json| { + let Json::Obj(mut fields) = json.clone() else { + unreachable!() + }; + fields.insert("olean".to_owned(), binding); + Json::Obj(fields) + }; + for malformed in [ + Json::Arr(Vec::new()), + Json::object(Vec::new()), + Json::object(vec![("main", Json::Str("0".repeat(63)))]), + Json::object(vec![("main", digest(b"main")), ("server", Json::Int(0))]), + Json::object(vec![ + ("main", digest(b"main")), + ("private", digest(b"orphan")), + ]), + Json::object(vec![("main", digest(b"main")), ("extra", digest(b"extra"))]), + ] { + assert!( + ChildRecord::from_json(&changed(malformed)).is_err(), + "a malformed binding is refused" + ); + } + replay_binding_guard_plants(record); +} + +fn replay_binding_guard_plants(mut compile: lexlean::verify::child::ChildRecord) { + use lexlean::artifact::content_id::Sha256Digest; + use lexlean::verify::child::OLeanParts; + use lexlean::verify::leanchecker::check_replay_bindings; + use std::collections::{BTreeMap, BTreeSet}; + + let module = "Demo.M".to_owned(); + let parts = OLeanParts { + main: Sha256Digest::of(b"main"), + server: Some(Sha256Digest::of(b"server")), + private: Some(Sha256Digest::of(b"private")), + }; + compile + .argv + .extend(["-D".to_owned(), "debug.skipKernelTC=true".to_owned()]); + compile.olean = Some(parts.clone()); + let mut replay = compile.clone(); + replay.tool = "leanchecker".to_owned(); + replay.executable_sha256 = Sha256Digest::of(b"leanchecker"); + replay.argv = vec![ + "env".to_owned(), + "$TOOLCHAIN/bin/leanchecker".to_owned(), + module.clone(), + ]; + let staged: BTreeMap<_, _> = [(module.clone(), parts.clone())].into_iter().collect(); + let no_certificates = BTreeSet::new(); + let check = |records: &[lexlean::verify::child::ChildRecord], published: &BTreeMap<_, _>| { + check_replay_bindings(records, published, &no_certificates) + }; + check(&[compile.clone(), replay.clone()], &staged).expect("same module and complete bytes"); + let certificates = [module.clone()].into_iter().collect(); + check_replay_bindings( + &[compile.clone(), replay.clone()], + &BTreeMap::new(), + &certificates, + ) + .expect("certificate tail retains its binding after its scratch files are removed"); + let refuse = |records: &[lexlean::verify::child::ChildRecord], published: &BTreeMap<_, _>| { + let error = check(records, published).expect_err("a binding hole refuses publication"); + assert_eq!(error.code.as_str(), "LLI9001"); + }; + refuse(std::slice::from_ref(&compile), &staged); + refuse(&[compile.clone(), replay.clone(), replay.clone()], &staged); + refuse(&[compile.clone(), compile.clone(), replay.clone()], &staged); + for part in 0..3 { + let mut substituted = replay.clone(); + let binding = substituted.olean.as_mut().expect("bound"); + match part { + 0 => binding.main = Sha256Digest::of(b"another main"), + 1 => binding.server = Some(Sha256Digest::of(b"another server")), + 2 => binding.private = Some(Sha256Digest::of(b"another private")), + _ => unreachable!(), + } + refuse(&[compile.clone(), substituted], &staged); + } + for missing in [true, false] { + let mut c = compile.clone(); + let mut r = replay.clone(); + if missing { + c.olean = None; + } else { + r.olean = None; + } + refuse(&[c, r], &staged); + } + let mut failed = replay.clone(); + failed.exit_code = 1; + refuse(&[compile.clone(), failed], &staged); + let mut wrong_argument = replay.clone(); + wrong_argument.argv[2] = "Demo.Other".to_owned(); + refuse(&[compile.clone(), wrong_argument], &staged); + let mut wrong_tool = replay.clone(); + wrong_tool.tool = "lean".to_owned(); + refuse(&[compile.clone(), wrong_tool], &staged); + let mut another_name = replay.clone(); + another_name.module = Some("Demo.Other".to_owned()); + refuse(&[compile.clone(), another_name], &staged); + refuse(&[compile.clone(), replay.clone()], &BTreeMap::new()); + let mut changed_staged = staged.clone(); + changed_staged.get_mut(&module).expect("staged").private = None; + refuse(&[compile.clone(), replay.clone()], &changed_staged); + let mut omitted = compile.clone(); + let mut omitted_replay = replay.clone(); + omitted.olean.as_mut().expect("bound").private = None; + omitted_replay.olean.as_mut().expect("bound").private = None; + refuse(&[omitted, omitted_replay], &staged); + let absent = OLeanParts { + main: parts.main, + server: None, + private: None, + }; + let empty_server = OLeanParts { + server: Some(Sha256Digest::of(b"")), + ..absent.clone() + }; + assert_ne!(empty_server, absent, "empty bytes are present, not absent"); + let mut no_server_compile = compile.clone(); + let mut no_server_replay = replay.clone(); + no_server_compile.olean = Some(absent.clone()); + no_server_replay.olean = Some(absent); + let empty_staged = [(module, empty_server)].into_iter().collect(); + refuse(&[no_server_compile, no_server_replay], &empty_staged); + let mut orphan = compile.clone(); + orphan.olean.as_mut().expect("bound").server = None; + refuse(&[orphan, replay], &staged); } diff --git a/crates/lexlean/src/verify/child.rs b/crates/lexlean/src/verify/child.rs index 8ebd294dc8..b96cca13f6 100644 --- a/crates/lexlean/src/verify/child.rs +++ b/crates/lexlean/src/verify/child.rs @@ -174,6 +174,61 @@ pub fn first_unexpected_absolute_path(text: &str) -> Option<(usize, String)> { None } +/// The exact module data parts compiled or consumed by a replay (VR-28). +/// An absent companion differs from a present file, including an empty one. +#[derive(Debug, Clone, PartialEq, Eq)] +pub struct OLeanParts { + /// SHA-256 of the exported `.olean` bytes. + pub main: Sha256Digest, + /// SHA-256 of `.olean.server`, when present. + pub server: Option, + /// SHA-256 of `.olean.private`, when present after the server part. + pub private: Option, +} + +impl OLeanParts { + pub(crate) fn validate(&self) -> Result<(), String> { + if self.private.is_some() && self.server.is_none() { + return Err("a private olean part requires its server part".to_owned()); + } + Ok(()) + } + + fn to_json(&self) -> Json { + let mut fields = vec![("main", Json::Str(self.main.to_hex()))]; + for (name, digest) in [("server", self.server), ("private", self.private)] { + if let Some(digest) = digest { + fields.push((name, Json::Str(digest.to_hex()))); + } + } + Json::object(fields) + } + + fn from_json(json: &Json) -> Result { + let Json::Obj(fields) = json else { + return Err("`olean` is an object".to_owned()); + }; + if let Some(unknown) = fields + .keys() + .find(|key| !matches!(key.as_str(), "main" | "server" | "private")) + { + return Err(format!("`{unknown}` is not a field of an olean binding")); + } + let digest = |key: &str| match fields.get(key) { + None => Ok(None), + Some(Json::Str(text)) => Sha256Digest::from_hex(text).map(Some), + Some(_) => Err(format!("olean `{key}` is a SHA-256 string")), + }; + let parts = Self { + main: digest("main")?.ok_or_else(|| "olean `main` is required".to_owned())?, + server: digest("server")?, + private: digest("private")?, + }; + parts.validate()?; + Ok(parts) + } +} + /// One recorded child process (§22.3). #[derive(Debug, Clone)] pub struct ChildRecord { @@ -191,6 +246,8 @@ pub struct ChildRecord { pub stderr: String, /// SHA-256 of the executable. pub executable_sha256: Sha256Digest, + /// The module bytes produced or replayed, when this process carries a binding. + pub olean: Option, } impl ChildRecord { @@ -222,6 +279,9 @@ impl ChildRecord { if let Some(module) = &self.module { fields.push(("module", Json::Str(module.clone()))); } + if let Some(parts) = &self.olean { + fields.push(("olean", parts.to_json())); + } Json::object(fields) } @@ -281,6 +341,7 @@ impl ChildRecord { "stdout_sha256", "stderr_sha256", "module", + "olean", ] .into_iter() .collect(); @@ -295,6 +356,7 @@ impl ChildRecord { stdout, stderr, executable_sha256: Sha256Digest::from_hex(&text("executable_sha256")?)?, + olean: fields.get("olean").map(OLeanParts::from_json).transpose()?, }) } } @@ -600,6 +662,7 @@ pub fn run( stdout: normalizer.normalize(&stdout_bytes), stderr: normalizer.normalize(&stderr_bytes), executable_sha256: spec.executable_sha256, + olean: None, }) } diff --git a/crates/lexlean/src/verify/leanchecker.rs b/crates/lexlean/src/verify/leanchecker.rs index e165e573d5..0d0e7e075b 100644 --- a/crates/lexlean/src/verify/leanchecker.rs +++ b/crates/lexlean/src/verify/leanchecker.rs @@ -72,3 +72,89 @@ pub fn replay_module( } Ok(record) } + +/// Require a byte-bound replay for every compilation without its kernel pass. +/// +/// The existing toolchain and partition gates establish executable identities +/// and judge stage output. This guard checks the association of those records: +/// module identity, successful replay, complete olean parts, and the staged +/// project artifacts. Certificates retain their bindings after scratch cleanup. +/// +/// # Errors +/// A missing, failed, duplicate, malformed, or substituted binding (LLI9001). +pub fn check_replay_bindings( + records: &[ChildRecord], + staged_projects: &std::collections::BTreeMap, + certificates: &std::collections::BTreeSet, +) -> Result<(), Diagnostic> { + let hole = |message| { + Diagnostic::new( + code!("LLI9001"), + format!("phase verify: kernel replay binding: {message}"), + ) + }; + let skipped = |record: &ChildRecord| { + record.argv.iter().any(|argument| { + argument == "debug.skipKernelTC=true" || argument == "-Ddebug.skipKernelTC=true" + }) + }; + let mut compiled = std::collections::BTreeSet::new(); + for compile in records.iter().filter(|record| skipped(record)) { + let module = compile + .module + .as_deref() + .ok_or_else(|| hole("a flagged compilation has no module".to_owned()))?; + if compile.tool != "lean" + || (!staged_projects.contains_key(module) && !certificates.contains(module)) + { + return Err(hole(format!( + "`{module}` is not an eligible project or certificate compilation" + ))); + } + if !compiled.insert(module) || compile.exit_code != 0 { + return Err(hole(format!( + "`{module}` has a duplicate or unsuccessful flagged compilation" + ))); + } + let produced = compile + .olean + .as_ref() + .ok_or_else(|| hole(format!("`{module}` has no compile output binding")))?; + produced.validate().map_err(hole)?; + let mut matching = records.iter().filter(|record| { + record.tool == "leanchecker" && record.module.as_deref() == Some(module) + }); + let replay = matching + .next() + .ok_or_else(|| hole(format!("`{module}` has no replay record")))?; + if matching.next().is_some() || replay.exit_code != 0 { + return Err(hole(format!( + "`{module}` has a duplicate or unsuccessful replay" + ))); + } + if replay.argv.len() != 3 || replay.argv[0] != "env" || replay.argv[2] != module { + return Err(hole(format!( + "`{module}` replay argv does not name that module" + ))); + } + let consumed = replay + .olean + .as_ref() + .ok_or_else(|| hole(format!("`{module}` has no replay input binding")))?; + consumed.validate().map_err(hole)?; + if produced != consumed { + return Err(hole(format!( + "`{module}` replay input differs from its compiled olean parts" + ))); + } + if let Some(staged) = staged_projects.get(module) { + staged.validate().map_err(hole)?; + if produced != staged { + return Err(hole(format!( + "`{module}` staged artifacts differ from its compiled and replayed olean parts" + ))); + } + } + } + Ok(()) +} diff --git a/crates/lexlean/src/verify/partition.rs b/crates/lexlean/src/verify/partition.rs index b50a1c205a..095262fc0b 100644 --- a/crates/lexlean/src/verify/partition.rs +++ b/crates/lexlean/src/verify/partition.rs @@ -514,6 +514,7 @@ mod tests { let olean = staging.path().join("oleans/X/M.olean"); std::fs::create_dir_all(olean.parent().expect("parent")).expect("mkdir"); std::fs::write(&olean, b"olean").expect("write"); + std::fs::write(staging.path().join("oleans/X/M.olean.server"), b"server").expect("write"); std::fs::write(staging.path().join("oleans/X/M.olean.private"), b"private").expect("write"); std::fs::write(staging.path().join("oleans/X/N.olean"), b"imported").expect("write"); let record = ChildRecord { @@ -524,9 +525,15 @@ mod tests { stdout: "\n".to_owned(), stderr: String::new(), executable_sha256: crate::artifact::content_id::Sha256Digest::of(b"lean"), + olean: Some(crate::verify::child::OLeanParts { + main: crate::artifact::content_id::Sha256Digest::of(b"olean"), + server: Some(crate::artifact::content_id::Sha256Digest::of(b"server")), + private: Some(crate::artifact::content_id::Sha256Digest::of(b"private")), + }), }; let audit_record = ChildRecord { module: Some("LexLeanAudit.X.M".to_owned()), + olean: None, ..record.clone() }; for (relative, written) in [ @@ -562,6 +569,10 @@ mod tests { assert!(olean_root.join("X/M.olean.private").as_std_path().is_file()); assert_eq!(imported.lean.len(), 1); assert!(imported.lean.contains_key("X.M")); + assert_eq!( + imported.lean["X.M"].olean, record.olean, + "the existing part transport preserves all olean bindings" + ); assert!(imported.leanchecker.is_empty()); assert!(imported.audit.contains_key("LexLeanAudit.X.M")); // The records name the join's `lean`; a join whose `lean` is another diff --git a/schemas/attestation-v2.schema.json b/schemas/attestation-v2.schema.json index 918fcaf714..ac77d77b65 100644 --- a/schemas/attestation-v2.schema.json +++ b/schemas/attestation-v2.schema.json @@ -1 +1 @@ -{"$id":"https://github.com/UOR-Foundation/LexLean/schemas/attestation-v2.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"attestation_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_manifest":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"compiler_input":{"additionalProperties":false,"properties":{"byte_length":{"minimum":1,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"declarations":{"items":{"additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"observed":{"items":{"minLength":1,"type":"string"},"type":"array"},"policy":{"additionalProperties":false,"properties":{"axioms":{"items":{"minLength":1,"type":"string"},"type":"array"},"kind":{"enum":["none","allow","exact"]}},"required":["axioms","kind"],"type":"object"},"result":{"const":"ok"}},"required":["name","observed","policy","result"],"type":"object"},"type":"array"},"host":{"additionalProperties":false,"properties":{"arch":{"minLength":1,"type":"string"},"os":{"minLength":1,"type":"string"}},"required":["arch","os"],"type":"object"},"lake_workspace":{"items":{"additionalProperties":false,"properties":{"path":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["path","sha256"],"type":"object"},"type":"array"},"lexlean":{"additionalProperties":false,"properties":{"compiler_semantics":{"pattern":"^[0-9a-f]{64}$","type":"string"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"minLength":1,"type":"string"}},"required":["compiler_semantics","executable_sha256","version"],"type":"object"},"oleans":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"module":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","module","sha256"],"type":"object"},"type":"array"},"origins":{"additionalProperties":{"minLength":1,"type":"string"},"type":"object"},"pdf":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"compile":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"module":{"minLength":1,"type":"string"},"pdf_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"recipe_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"}},"required":["byte_length","compile","module","pdf_sha256","recipe_id","version"],"type":"object"},"type":"array"},"preservation":{"additionalProperties":false,"properties":{"byte_length":{"minimum":1,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"processes":{"items":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"type":"array"},"semantic_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"source_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"spec":{"const":"lexlean/attestation/2"},"status":{"const":"verified"},"toolchain":{"additionalProperties":false,"properties":{"lake":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"lean":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"leanchecker":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"}},"required":["lake","lean","leanchecker"],"type":"object"}},"required":["attestation_id","build_id","build_manifest","declarations","host","lake_workspace","lexlean","oleans","processes","semantic_id","source_id","spec","status","toolchain"],"title":"LexLean language-1.2 verification attestation (SPEC.md §22.9)","type":"object"} +{"$id":"https://github.com/UOR-Foundation/LexLean/schemas/attestation-v2.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"attestation_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_manifest":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"compiler_input":{"additionalProperties":false,"properties":{"byte_length":{"minimum":1,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"declarations":{"items":{"additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"observed":{"items":{"minLength":1,"type":"string"},"type":"array"},"policy":{"additionalProperties":false,"properties":{"axioms":{"items":{"minLength":1,"type":"string"},"type":"array"},"kind":{"enum":["none","allow","exact"]}},"required":["axioms","kind"],"type":"object"},"result":{"const":"ok"}},"required":["name","observed","policy","result"],"type":"object"},"type":"array"},"host":{"additionalProperties":false,"properties":{"arch":{"minLength":1,"type":"string"},"os":{"minLength":1,"type":"string"}},"required":["arch","os"],"type":"object"},"lake_workspace":{"items":{"additionalProperties":false,"properties":{"path":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["path","sha256"],"type":"object"},"type":"array"},"lexlean":{"additionalProperties":false,"properties":{"compiler_semantics":{"pattern":"^[0-9a-f]{64}$","type":"string"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"minLength":1,"type":"string"}},"required":["compiler_semantics","executable_sha256","version"],"type":"object"},"oleans":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"module":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","module","sha256"],"type":"object"},"type":"array"},"origins":{"additionalProperties":{"minLength":1,"type":"string"},"type":"object"},"pdf":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"compile":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"module":{"minLength":1,"type":"string"},"pdf_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"recipe_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"}},"required":["byte_length","compile","module","pdf_sha256","recipe_id","version"],"type":"object"},"type":"array"},"preservation":{"additionalProperties":false,"properties":{"byte_length":{"minimum":1,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"processes":{"items":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"type":"array"},"semantic_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"source_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"spec":{"const":"lexlean/attestation/2"},"status":{"const":"verified"},"toolchain":{"additionalProperties":false,"properties":{"lake":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"lean":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"leanchecker":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"}},"required":["lake","lean","leanchecker"],"type":"object"}},"required":["attestation_id","build_id","build_manifest","declarations","host","lake_workspace","lexlean","oleans","processes","semantic_id","source_id","spec","status","toolchain"],"title":"LexLean language-1.2 verification attestation (SPEC.md §22.9)","type":"object"} diff --git a/schemas/attestation.schema.json b/schemas/attestation.schema.json index 837f3aaa60..1910926d13 100644 --- a/schemas/attestation.schema.json +++ b/schemas/attestation.schema.json @@ -1 +1 @@ -{"$id":"https://github.com/UOR-Foundation/LexLean/schemas/attestation.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"attestation_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_manifest":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"declarations":{"items":{"additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"observed":{"items":{"minLength":1,"type":"string"},"type":"array"},"policy":{"additionalProperties":false,"properties":{"axioms":{"items":{"minLength":1,"type":"string"},"type":"array"},"kind":{"enum":["none","allow","exact"]}},"required":["axioms","kind"],"type":"object"},"result":{"const":"ok"}},"required":["name","observed","policy","result"],"type":"object"},"type":"array"},"host":{"additionalProperties":false,"properties":{"arch":{"minLength":1,"type":"string"},"os":{"minLength":1,"type":"string"}},"required":["arch","os"],"type":"object"},"lake_workspace":{"items":{"additionalProperties":false,"properties":{"path":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["path","sha256"],"type":"object"},"type":"array"},"lexlean":{"additionalProperties":false,"properties":{"compiler_semantics":{"pattern":"^[0-9a-f]{64}$","type":"string"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"minLength":1,"type":"string"}},"required":["compiler_semantics","executable_sha256","version"],"type":"object"},"oleans":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"module":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","module","sha256"],"type":"object"},"type":"array"},"pdf":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"compile":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"module":{"minLength":1,"type":"string"},"pdf_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"recipe_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"}},"required":["byte_length","compile","module","pdf_sha256","recipe_id","version"],"type":"object"},"type":"array"},"processes":{"items":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"type":"array"},"semantic_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"source_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"spec":{"const":"lexlean/attestation/1"},"status":{"const":"verified"},"toolchain":{"additionalProperties":false,"properties":{"lake":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"lean":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"leanchecker":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"}},"required":["lake","lean","leanchecker"],"type":"object"}},"required":["attestation_id","build_id","build_manifest","declarations","host","lake_workspace","lexlean","oleans","processes","semantic_id","source_id","spec","status","toolchain"],"title":"LexLean verification attestation (SPEC.md §22.9)","type":"object"} +{"$id":"https://github.com/UOR-Foundation/LexLean/schemas/attestation.schema.json","$schema":"https://json-schema.org/draft/2020-12/schema","additionalProperties":false,"properties":{"attestation_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"build_manifest":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","sha256"],"type":"object"},"declarations":{"items":{"additionalProperties":false,"properties":{"name":{"minLength":1,"type":"string"},"observed":{"items":{"minLength":1,"type":"string"},"type":"array"},"policy":{"additionalProperties":false,"properties":{"axioms":{"items":{"minLength":1,"type":"string"},"type":"array"},"kind":{"enum":["none","allow","exact"]}},"required":["axioms","kind"],"type":"object"},"result":{"const":"ok"}},"required":["name","observed","policy","result"],"type":"object"},"type":"array"},"host":{"additionalProperties":false,"properties":{"arch":{"minLength":1,"type":"string"},"os":{"minLength":1,"type":"string"}},"required":["arch","os"],"type":"object"},"lake_workspace":{"items":{"additionalProperties":false,"properties":{"path":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["path","sha256"],"type":"object"},"type":"array"},"lexlean":{"additionalProperties":false,"properties":{"compiler_semantics":{"pattern":"^[0-9a-f]{64}$","type":"string"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"minLength":1,"type":"string"}},"required":["compiler_semantics","executable_sha256","version"],"type":"object"},"oleans":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"module":{"minLength":1,"type":"string"},"sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["byte_length","module","sha256"],"type":"object"},"type":"array"},"pdf":{"items":{"additionalProperties":false,"properties":{"byte_length":{"minimum":0,"type":"integer"},"compile":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"module":{"minLength":1,"type":"string"},"pdf_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"recipe_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"}},"required":["byte_length","compile","module","pdf_sha256","recipe_id","version"],"type":"object"},"type":"array"},"processes":{"items":{"additionalProperties":false,"properties":{"argv":{"items":{"type":"string"},"type":"array"},"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"exit_code":{"type":"integer"},"module":{"minLength":1,"type":"string"},"olean":{"additionalProperties":false,"dependentRequired":{"private":["server"]},"properties":{"main":{"pattern":"^[0-9a-f]{64}$","type":"string"},"private":{"pattern":"^[0-9a-f]{64}$","type":"string"},"server":{"pattern":"^[0-9a-f]{64}$","type":"string"}},"required":["main"],"type":"object"},"stderr":{"type":"string"},"stderr_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"stdout":{"type":"string"},"stdout_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"tool":{"enum":["lean","lake","leanchecker","pdf"]}},"required":["argv","executable_sha256","exit_code","stderr","stderr_sha256","stdout","stdout_sha256","tool"],"type":"object"},"type":"array"},"semantic_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"source_id":{"pattern":"^[0-9a-f]{64}$","type":"string"},"spec":{"const":"lexlean/attestation/1"},"status":{"const":"verified"},"toolchain":{"additionalProperties":false,"properties":{"lake":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"lean":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"},"leanchecker":{"additionalProperties":false,"properties":{"executable_sha256":{"pattern":"^[0-9a-f]{64}$","type":"string"},"version_output":{"type":"string"}},"required":["executable_sha256","version_output"],"type":"object"}},"required":["lake","lean","leanchecker"],"type":"object"}},"required":["attestation_id","build_id","build_manifest","declarations","host","lake_workspace","lexlean","oleans","processes","semantic_id","source_id","spec","status","toolchain"],"title":"LexLean verification attestation (SPEC.md §22.9)","type":"object"} From ed1deb0cbe26aa2330a464224fb01e7df2739920 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Tue, 3 Nov 2026 15:40:36 +0000 Subject: [PATCH 3/8] Bind replay inputs to observed Lean search paths and artifact parts --- SPEC.md | 15 +- VERIFICATION.md | 53 +++ crates/conformance/src/cases/verification.rs | 6 +- crates/conformance/src/lean_literals.rs | 20 ++ crates/conformance/src/support.rs | 2 +- crates/lexlean/src/backend/lean.rs | 9 +- crates/lexlean/src/verify/child.rs | 63 +++- crates/lexlean/src/verify/leanchecker.rs | 341 +++++++++++++++++++ crates/lexlean/src/verify/mod.rs | 60 +++- crates/lexlean/src/verify/source_audit.rs | 45 +++ features/suites/verification.feature | 3 +- model/ids.toml | 2 +- 12 files changed, 581 insertions(+), 38 deletions(-) diff --git a/SPEC.md b/SPEC.md index 3b1229696d..7ddcfe0edd 100644 --- a/SPEC.md +++ b/SPEC.md @@ -9223,7 +9223,7 @@ A failed command removes its staging tree and leaves no verified artifact. 3. deterministic build rendering; 4. Lean/Lake/leanchecker toolchain preflight; 5. Lake-workspace lock preflight; -6. external-interface probe generation and elaboration; +6. external-interface probe generation and elaboration, including its closed escaped effective-search-path report; 7. generated-module elaboration and `.olean` production; 8. separate-process `leanchecker` replay for every generated module; 9. process-sized axiom-audit module-family generation and execution; @@ -9336,6 +9336,17 @@ Before process output is hashed: 4. trailing spaces are removed; 5. blank final lines collapse to one final LF. +The interface probe emits exactly one closed JSON search-path packet. Its +raw escaped strings are decoded before normalization. Known absolute prefixes +are normalized as above; remaining absolute roots receive packet-local tokens +`$LEAN_SEARCH_ROOT_` in first-occurrence order, reusing the token for equal +roots and preserving entry order and relative roots. Tokens do not collide +with literal relative entries. The complete normalized packet is re-encoded +and retained as stdout, whose digest is recorded normally. Only that fixed +packet uses path-root-aware validation; all other output retains the ordinary +absolute-path and unexpected-output checks. Raw roots remain operational +lookup state, not published host paths. + Unexpected absolute paths remaining in successful normalized output fail attestation construction. ### 22.8 Verification layout @@ -11181,7 +11192,7 @@ Every row below is normative, has honesty level `build`, and MUST be copied byte | `VR-01` | `verification` | Verification runs every specified stage in order and exposes no stage-suppression option. | §22.1 | | `VR-02` | `verification` | Lean, Lake, and leanchecker versions and executable hashes are checked and recorded before use. | §22.2 | | `VR-03` | `verification` | Lean execution uses the pinned Lake environment and never updates or fetches workspace dependencies. | §22.2 | -| `VR-04` | `verification` | Every used external interface is elaborated in the unique reserved probe module. | §18.8, §22.1 | +| `VR-04` | `verification` | Every used external interface is elaborated in the unique reserved probe module, which emits only its closed escaped effective-search-path report. | §18.8, §22.1 | | `VR-05` | `verification` | Generated modules compile in topological order and produce one required olean each. | §22.3 | | `VR-06` | `verification` | Verification neither requests nor includes ilean artifacts. | §22.3 | | `VR-07` | `verification` | A Lean warning, unknown informational message, overflow, or missing output fails verification. | §20.2, §22.3 | diff --git a/VERIFICATION.md b/VERIFICATION.md index 7b228d882e..fa07798c60 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12464,3 +12464,56 @@ query emits unescaped `NAME=VALUE` lines, while current path rules do not forbid newlines. Duplicate-row rejection alone therefore does not establish unambiguous decoding for every accepted path; that design point requires review before capture and skip flags are connected. + +The next source-only integration replaces that ambiguous proposed query +with the existing always-run external-interface probe. Its closed, +parameter-free command reports `Lean.searchPathRef` as compact escaped JSON. +The bounded runner decodes the raw packet before normalization and retains +its complete normalized form in the process record. Known prefixes use the +existing replacements; other absolute roots receive packet-local ordinal +aliases, preserving order and equality without colliding with relative +entries. The fixed packet's final audit validates whole decoded roots; +other stdout and every stderr retain their existing checks. + +The preservation olean directory is created empty before this probe and +shares its supplied search-path context with project and certificate +compilation/replay. Actual resolution follows the observed first package +root even when that root lacks the requested full file. Compilation records +capture the main/server/private tuple; replay captures the selected tuple, +compares it with staged output, and checks that it remains unchanged after +success. This source delta includes pure regression cases for escaped and +newline-containing roots, relative roots containing ` /segment`, aliases, +noise and shape refusal, missing-file shadowing, and companion changes. +Focused validation subsequently ran under the shared phase lock with two +Cargo jobs and incremental compilation disabled. The four new path/binding +units, probe-only source-audit unit, three existing partition units, and +correct-root exact VR-28 passed. Independent review exposed two refusal +gaps, both corrected: source-literal exactness now belongs to a fixed +catalogue independent of the live renderer constant, and the packet uses a +tiny closed typed decoder that rejects duplicate decoded keys, including +escaped key spellings. The appended-action mutation witness and literal plus +escaped duplicate-key refusal tests passed. Focused lexlean/repo-conformance +Clippy passed with warnings denied; final formatting and diff checks passed. + +The first conformance invocation linked a shared `repo-model` artifact whose +compiled root belonged to another worktree; its result was discarded. A +package-only offline clean and rebuild established this worktree's root +before authoritative conformance runs. Those runs first stopped at the +expected stale example lock. Only `examples/nat-add-zero/lexlean.lock` was +then temporarily refreshed with the freshly built official CLI: +`lexlean --project examples/nat-add-zero/lexlean.toml lock`. Original bytes +were saved outside the checkout and restored after each phase. The saved +and restored SHA-256 was +`f7ca13c5a1597c9059e3aded8e5d8609c6f4cb3cf8feb53856a55b5621e7c2e2`; +the final temporary refresh was +`a0ec39419c4b76922e33f454a7f81989aced1f4ca1baf31be68220f240772cb8`. +No helper constructor, expectations, or product pins were changed. + +Actual pinned Lean first rejected the report's untyped `p.toString` +lambda. The final closed command uses `ps.map System.FilePath.toString`. +With that ordinary type fix, unchanged exact VR-04 passed in 4.05 seconds +and VR-07 passed in 4.42 seconds, including its existing warning/noise +plants. These are focused correctness results, not performance savings. +Skip flags remain disabled, and the final publication-guard call site +remains an integration obligation. No full gate, identity regeneration, +product artifact writer, or full VR-28 acceptance is claimed. diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 713007e164..3fe12aed1b 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -207,7 +207,11 @@ pub(crate) fn run(id: &str) { "the probe elaborates: {}{}", record.stdout, record.stderr ); - assert!(record.stdout.trim().is_empty() && record.stderr.trim().is_empty()); + let packet: serde_json::Value = serde_json::from_str(&record.stdout) + .expect("the probe emits its closed search-path packet"); + assert_eq!(packet.as_object().expect("packet object").len(), 1); + assert!(packet["lexlean_search_path"].is_array()); + assert!(record.stderr.trim().is_empty()); assert_eq!(probe.lines.len(), 3, "one example line per probed entry"); // A mismatching interface fails and the failing Lean line is diff --git a/crates/conformance/src/lean_literals.rs b/crates/conformance/src/lean_literals.rs index ef09af27a1..8dce7e8f5d 100644 --- a/crates/conformance/src/lean_literals.rs +++ b/crates/conformance/src/lean_literals.rs @@ -46,6 +46,11 @@ pub struct Finding { /// The literals that are Lean syntax and are not templates: the file they are /// in (a suffix of its path), the beginning of the literal, and why. +pub const EXACT_ALLOWED: [(&str, &str, &str); 1] = [ + ("backend/lean.rs", "#eval do let ps ← Lean.searchPathRef.get; IO.println ((Lean.Json.mkObj [(\"lexlean_search_path\", Lean.toJson (ps.map System.FilePath.toString))]).compress)", "the renderer of the closed read-only search-path command"), +]; + +/// Prefix entries for existing closed renderers and diagnostic syntax. pub const ALLOWED: [(&str, &str, &str); 9] = [ ( "production/certificate.rs", @@ -355,6 +360,9 @@ pub fn scan_source(file: &str, source: &str, from: usize) -> Vec { Token::Literal(line, literal) if line >= from && is_lean_syntax(&literal) + && !EXACT_ALLOWED.iter().any(|(suffix, expected, _)| { + file.ends_with(suffix) && literal == *expected + }) && !ALLOWED.iter().any(|(suffix, beginning, _)| { file.ends_with(suffix) && literal.starts_with(beginning) }) => @@ -413,3 +421,15 @@ pub fn scan_repository(root: &Path) -> Vec { )); findings } + +#[cfg(test)] +mod search_path_literal_tests { + #[test] + fn appended_probe_action_is_not_an_allowed_literal() { + let command = super::EXACT_ALLOWED[0].1; + let original = format!("const COMMAND: &str = r#\"{command}\"#;"); + assert!(super::scan_source("backend/lean.rs", &original, 1).is_empty()); + let altered = format!("const COMMAND: &str = r#\"{command}; IO.println 1\"#;"); + assert_eq!(super::scan_source("backend/lean.rs", &altered, 1).len(), 1); + } +} diff --git a/crates/conformance/src/support.rs b/crates/conformance/src/support.rs index 2f1a6a188b..8a82387492 100644 --- a/crates/conformance/src/support.rs +++ b/crates/conformance/src/support.rs @@ -2778,7 +2778,7 @@ pub fn probe_lean( &toolchain.root, ); let bin = toolchain.root.join("bin"); - let record = lexlean::verify::child::run( + let (record, _) = lexlean::verify::child::run_probe( &lexlean::verify::child::ChildSpec { tool: "lean", module: Some(probe.name.clone()), diff --git a/crates/lexlean/src/backend/lean.rs b/crates/lexlean/src/backend/lean.rs index 6b7ce354be..cd358aef5d 100644 --- a/crates/lexlean/src/backend/lean.rs +++ b/crates/lexlean/src/backend/lean.rs @@ -2411,12 +2411,17 @@ pub struct AuxiliaryModule { pub commands: Vec, } +/// The sole read-only search-path command admitted in an interface probe. +pub const SEARCH_PATH_REPORT_COMMAND: &str = r#"#eval do let ps ← Lean.searchPathRef.get; IO.println ((Lean.Json.mkObj [("lexlean_search_path", Lean.toJson (ps.map System.FilePath.toString))]).compress)"#; + /// One command of an [`AuxiliaryModule`]: a closed set, each rendered one /// line. #[derive(Debug, Clone, PartialEq, Eq)] pub enum AuxiliaryCommand { /// `set_option autoImplicit false`. NoAutoImplicit, + /// Emit the actual Lean search path as one escaped, closed JSON packet. + SearchPathReport, /// `universe` and the named universe variables. Universe(Vec), /// `example : := `: the type as the backend's printer @@ -2475,6 +2480,7 @@ impl AuxiliaryModule { lines.push(line); match command { AuxiliaryCommand::NoAutoImplicit => text.push_str("set_option autoImplicit false"), + AuxiliaryCommand::SearchPathReport => text.push_str(SEARCH_PATH_REPORT_COMMAND), AuxiliaryCommand::Universe(names) => { text.push_str("universe "); text.push_str(&names.join(" ")); @@ -2556,7 +2562,7 @@ pub fn probe_module( closure: &Closure, ) -> Result { let name = format!("LexLeanProbe.P{semantic_hex32}"); - let mut imports: BTreeSet = BTreeSet::new(); + let mut imports: BTreeSet = ["Lean".to_owned()].into_iter().collect(); for external in externals.values() { imports.insert(external.lean_module.clone()); } @@ -2600,6 +2606,7 @@ pub fn probe_module( entries.push((index, entry)); commands.push(example); } + commands.push(AuxiliaryCommand::SearchPathReport); let (text, command_lines) = AuxiliaryModule { imports: imports.into_iter().collect(), commands, diff --git a/crates/lexlean/src/verify/child.rs b/crates/lexlean/src/verify/child.rs index b96cca13f6..282aae71d8 100644 --- a/crates/lexlean/src/verify/child.rs +++ b/crates/lexlean/src/verify/child.rs @@ -474,6 +474,37 @@ pub fn run( limits: &Limits, normalizer: &Normalizer, ) -> Result { + run_with_stdout(spec, limits, normalizer, |raw, _| { + Ok((normalizer.normalize(raw), ())) + }) + .map(|(record, ())| record) +} + +/// Run the existing interface probe and decode its sole search-path packet. +/// Failed elaboration retains its ordinary output for signature diagnostics. +/// +/// # Errors +/// The same child limits/errors as `run`, or unexpected successful output. +pub fn run_probe( + spec: &ChildSpec<'_>, + limits: &Limits, + normalizer: &Normalizer, +) -> Result<(ChildRecord, Option>), Diagnostic> { + run_with_stdout(spec, limits, normalizer, |raw, exit| { + if exit != 0 { + return Ok((normalizer.normalize(raw), None)); + } + crate::verify::leanchecker::decode_search_path(raw, normalizer) + .map(|(text, paths)| (text, Some(paths))) + }) +} + +fn run_with_stdout( + spec: &ChildSpec<'_>, + limits: &Limits, + normalizer: &Normalizer, + decode: impl FnOnce(&[u8], i32) -> Result<(String, T), Diagnostic>, +) -> Result<(ChildRecord, T), Diagnostic> { let existing_path = std::env::var_os("PATH").unwrap_or_default(); let mut command = Command::new(spec.program.as_std_path()); command @@ -650,20 +681,24 @@ pub fn run( ), )); } - Ok(ChildRecord { - tool: spec.tool.to_owned(), - module: spec.module.clone(), - argv: spec - .argv - .iter() - .map(|argument| normalizer.normalize_arg(argument)) - .collect(), - exit_code: status.code().unwrap_or(-1), - stdout: normalizer.normalize(&stdout_bytes), - stderr: normalizer.normalize(&stderr_bytes), - executable_sha256: spec.executable_sha256, - olean: None, - }) + let (stdout, decoded) = decode(&stdout_bytes, status.code().unwrap_or(-1))?; + Ok(( + ChildRecord { + tool: spec.tool.to_owned(), + module: spec.module.clone(), + argv: spec + .argv + .iter() + .map(|argument| normalizer.normalize_arg(argument)) + .collect(), + exit_code: status.code().unwrap_or(-1), + stdout, + stderr: normalizer.normalize(&stderr_bytes), + executable_sha256: spec.executable_sha256, + olean: None, + }, + decoded, + )) } #[cfg(test)] diff --git a/crates/lexlean/src/verify/leanchecker.rs b/crates/lexlean/src/verify/leanchecker.rs index 0d0e7e075b..06c708ba62 100644 --- a/crates/lexlean/src/verify/leanchecker.rs +++ b/crates/lexlean/src/verify/leanchecker.rs @@ -158,3 +158,344 @@ pub fn check_replay_bindings( } Ok(()) } + +/// Decode the probe's full, closed packet before any textual normalization. +/// Only path strings are normalized; raw roots remain operational lookup data. +pub(crate) fn decode_search_path( + bytes: &[u8], + normalizer: &Normalizer, +) -> Result<(String, Vec), Diagnostic> { + use crate::artifact::canonical_json::Json; + use std::collections::{BTreeMap, BTreeSet}; + let paths = search_path_packet(bytes)?; + let known: Vec = paths + .iter() + .map(|path| { + if absolute_root(path.as_str()) { + normalizer.normalize_arg(path.as_str()) + } else { + path.to_string() + } + }) + .collect(); + let mut occupied: BTreeSet = known.iter().cloned().collect(); + let mut aliases: BTreeMap = BTreeMap::new(); + let mut ordinal = 0usize; + let normalized = paths + .iter() + .zip(&known) + .map(|(raw, known)| { + if !absolute_root(known) { + return Json::Str(known.clone()); + } + let alias = aliases.entry(raw.to_string()).or_insert_with(|| loop { + let candidate = format!("$LEAN_SEARCH_ROOT_{ordinal}"); + ordinal += 1; + if occupied.insert(candidate.clone()) { + break candidate; + } + }); + Json::Str(alias.clone()) + }) + .collect(); + let packet = Json::object(vec![("lexlean_search_path", Json::Arr(normalized))]); + Ok(( + String::from_utf8(packet.to_file_bytes()).expect("canonical JSON is UTF-8"), + paths, + )) +} + +fn absolute_root(path: &str) -> bool { + camino::Utf8Path::new(path).has_root() + || path.starts_with("\\\\") + || matches!(path.as_bytes(), [drive, b':', b'/' | b'\\', ..] if drive.is_ascii_alphabetic()) +} + +fn search_path_packet(bytes: &[u8]) -> Result, Diagnostic> { + #[derive(serde::Deserialize)] + #[serde(deny_unknown_fields)] + struct Packet { + lexlean_search_path: Vec, + } + let noise = || { + Diagnostic::new(code!("LLV7006"), "unexpected output during the external-interface probe: expected one closed search-path packet") + }; + let packet: Packet = serde_json::from_slice(bytes).map_err(|_| noise())?; + packet + .lexlean_search_path + .into_iter() + .map(|path| { + if path.contains('\0') { + return Err(noise()); + } + Ok(camino::Utf8PathBuf::from(path)) + }) + .collect() +} + +/// Validate the normalized fixed probe packet by whole decoded roots. +/// Relative roots may contain spaces and slash fragments without being absolute. +pub(crate) fn audit_search_path_packet(bytes: &[u8]) -> Result<(), Diagnostic> { + if search_path_packet(bytes)? + .iter() + .any(|path| absolute_root(path.as_str())) + { + return Err(Diagnostic::new( + code!("LLV7006"), + "unexpected absolute root in the external-interface probe packet", + )); + } + Ok(()) +} + +/// Read the actual exported/server/private set; an empty file is present. +/// +/// # Errors +/// Missing main bytes, unreadable parts, or a private part without its server. +pub fn capture_olean_parts( + main: &Utf8Path, +) -> Result { + use crate::artifact::content_id::Sha256Digest; + let read = |path: &Utf8Path| { + std::fs::read(path.as_std_path()) + .map(|bytes| Sha256Digest::of(&bytes)) + .map_err(|error| { + Diagnostic::new( + code!("LLI9001"), + format!("phase verify: reading replay artifact `{path}`: {error}"), + ) + }) + }; + let companion = |suffix: &str| { + let path = camino::Utf8PathBuf::from(format!("{main}.{suffix}")); + match std::fs::metadata(path.as_std_path()) { + Ok(_) => read(&path).map(Some), + Err(error) if error.kind() == std::io::ErrorKind::NotFound => Ok(None), + Err(error) => Err(Diagnostic::new( + code!("LLI9001"), + format!("phase verify: reading replay artifact `{path}`: {error}"), + )), + } + }; + let parts = crate::verify::child::OLeanParts { + main: read(main)?, + server: companion("server")?, + private: companion("private")?, + }; + parts.validate().map_err(|reason| { + Diagnostic::new( + code!("LLI9001"), + format!("phase verify: `{main}`: {reason}"), + ) + })?; + Ok(parts) +} + +/// Resolve the requested module by the pinned Lean first-package-root rule. +/// A selected root with a missing full file is an error, never a fallback. +/// +/// # Errors +/// A missing package root or missing selected module file. +pub fn resolve_olean( + module: &str, + search_path: &[camino::Utf8PathBuf], + workspace: &Utf8Path, +) -> Result { + let package = module.split('.').next().unwrap_or(module); + for path in search_path { + let root = if path.is_absolute() { + path.clone() + } else { + workspace.join(path) + }; + if root.join(package).is_dir() || root.join(format!("{package}.olean")).exists() { + let selected = root.join(format!("{}.olean", module.replace('.', "/"))); + if !selected.is_file() { + return Err(Diagnostic::new(code!("LLI9001"), format!("phase verify: the first package root selects missing replay input `{selected}` for `{module}`"))); + } + return Ok(selected); + } + } + Err(Diagnostic::new( + code!("LLI9001"), + format!("phase verify: no replay package root for `{module}`"), + )) +} + +/// Operational lookup context observed by the existing interface probe. +pub struct ReplayInput<'a> { + /// Raw effective Lean search roots, in their original order. + pub search_path: &'a [camino::Utf8PathBuf], + /// The compiled artifact the replay must consume. + pub staged: &'a Utf8Path, +} + +/// Run the existing pinned checker while binding its requested actual input. +/// The checker may also replay descendant modules; it is not replaced here. +/// +/// # Errors +/// Ordinary child errors, shadowed input, or parts changed during success. +pub fn run_bound_leanchecker( + toolchain: &Toolchain, + module: &str, + lean_path: &str, + workspace: &Utf8Path, + limits: &Limits, + normalizer: &Normalizer, + input: ReplayInput<'_>, +) -> Result { + let resolved = resolve_olean(module, input.search_path, workspace)?; + let expected = capture_olean_parts(input.staged)?; + let before = capture_olean_parts(&resolved)?; + if expected != before { + return Err(Diagnostic::new(code!("LLI9001"), format!("phase verify: actual replay input of `{module}` differs from its staged compiled artifacts"))); + } + let mut record = run_leanchecker(toolchain, module, lean_path, workspace, limits, normalizer)?; + if record.exit_code == 0 { + let after_path = resolve_olean(module, input.search_path, workspace)?; + if after_path != resolved || capture_olean_parts(&after_path)? != before { + return Err(Diagnostic::new( + code!("LLI9001"), + format!( + "phase verify: actual replay input parts of `{module}` changed during replay" + ), + )); + } + } + record.olean = Some(before); + Ok(record) +} + +/// Replay a generated module with the existing LLV7003 failure classification. +/// +/// # Errors +/// A failed replay or an invalid input binding. +pub fn replay_bound_module( + toolchain: &Toolchain, + module: &str, + lean_path: &str, + workspace: &Utf8Path, + limits: &Limits, + normalizer: &Normalizer, + input: ReplayInput<'_>, +) -> Result { + let record = run_bound_leanchecker( + toolchain, module, lean_path, workspace, limits, normalizer, input, + )?; + if record.exit_code != 0 { + return Err(Diagnostic::new( + code!("LLV7003"), + format!( + "leanchecker replay of `{module}` exited {}: {}{}", + record.exit_code, + record.stdout.trim_end(), + record.stderr.trim_end() + ), + )); + } + Ok(record) +} + +#[cfg(test)] +mod path_binding_tests { + use super::*; + use crate::artifact::canonical_json::Json; + use camino::Utf8PathBuf; + + fn packet(paths: &[&str]) -> Vec { + Json::object(vec![( + "lexlean_search_path", + Json::Arr( + paths + .iter() + .map(|path| Json::Str((*path).to_owned())) + .collect(), + ), + )]) + .to_file_bytes() + } + + #[test] + fn probe_packet_preserves_escaped_relative_roots_and_aliases_unknown_roots() { + let normalizer = Normalizer::new( + Utf8Path::new("/stage"), + Utf8Path::new("/project"), + Utf8Path::new("/lake"), + Utf8Path::new("/tool"), + ); + let input = [ + "rel /segment", + "line\nbreak\"\\root", + "$LEAN_SEARCH_ROOT_0", + "/unknown", + "/unknown", + "/other", + "/stage/oleans", + ]; + let (normalized, raw) = decode_search_path(&packet(&input), &normalizer).unwrap(); + assert_eq!(raw, input.map(Utf8PathBuf::from)); + let expected = packet(&[ + input[0], + input[1], + input[2], + "$LEAN_SEARCH_ROOT_1", + "$LEAN_SEARCH_ROOT_1", + "$LEAN_SEARCH_ROOT_2", + "$STAGING/oleans", + ]); + assert_eq!(normalized.as_bytes(), expected); + audit_search_path_packet(normalized.as_bytes()).unwrap(); + assert!(normalizer.has_unexpected_absolute_path(&normalized)); + assert!(audit_search_path_packet(&packet(&["/unredacted"])).is_err()); + } + + #[test] + fn probe_packet_rejects_noise_and_nonclosed_shapes() { + assert!(audit_search_path_packet( + br#"{"lexlean_search_path":[],"lexlean_search_\u0070ath":[]}"# + ) + .is_err()); + for bytes in [ + b"{}".as_slice(), + b"{\"lexlean_search_path\":[],\"extra\":0}", + b"{\"lexlean_search_path\":[1]}", + b"{\"lexlean_search_path\":[],\"lexlean_search_path\":[]}", + b"{\"lexlean_search_path\":[]}\nwarning", + b"warning\n{\"lexlean_search_path\":[]}", + ] { + assert!(audit_search_path_packet(bytes).is_err()); + assert!(decode_search_path(bytes, &Normalizer::default()).is_err()); + } + } + + #[test] + fn first_package_root_does_not_fall_through_missing_module() { + let temp = tempfile::tempdir().unwrap(); + let root = Utf8PathBuf::from_path_buf(temp.path().to_owned()).unwrap(); + std::fs::create_dir_all(root.join("first/A")).unwrap(); + std::fs::create_dir_all(root.join("second/A")).unwrap(); + std::fs::write(root.join("second/A/B.olean"), b"later").unwrap(); + let roots = [Utf8PathBuf::from("first"), Utf8PathBuf::from("second")]; + assert!(resolve_olean("A.B", &roots, &root).is_err()); + std::fs::write(root.join("first/A/B.olean"), b"first").unwrap(); + assert_eq!( + resolve_olean("A.B", &roots, &root).unwrap(), + root.join("first/A/B.olean") + ); + } + + #[test] + fn capture_distinguishes_absent_empty_and_changed_companions() { + let temp = tempfile::tempdir().unwrap(); + let main = Utf8PathBuf::from_path_buf(temp.path().join("A.olean")).unwrap(); + std::fs::write(&main, b"main").unwrap(); + let absent = capture_olean_parts(&main).unwrap(); + std::fs::write(format!("{main}.private"), b"").unwrap(); + assert!(capture_olean_parts(&main).is_err()); + std::fs::write(format!("{main}.server"), b"").unwrap(); + let empty = capture_olean_parts(&main).unwrap(); + assert_ne!(empty, absent); + std::fs::write(format!("{main}.server"), b"changed").unwrap(); + assert_ne!(capture_olean_parts(&main).unwrap(), empty); + } +} diff --git a/crates/lexlean/src/verify/mod.rs b/crates/lexlean/src/verify/mod.rs index 1efe001374..a4b8159f75 100644 --- a/crates/lexlean/src/verify/mod.rs +++ b/crates/lexlean/src/verify/mod.rs @@ -1169,7 +1169,7 @@ pub fn run_part( return Err(fail(internal(format!("`{}`: {reason}", module.name)))); } } - if let Err(reason) = generated_source_audit(&probe.text, false) { + if let Err(reason) = source_audit::audit_probe(&probe.text) { return Err(fail(internal(format!("probe module: {reason}")))); } for audit in &audit_modules { @@ -1273,7 +1273,16 @@ pub fn run_part( )?; } release_non_diagnostic_buffers(build); - let lean_path_env = format!("{olean_root}"); + // One supplied context for probe, project, and preservation processes. + // This directory is empty until the existing certificate phase populates it. + let preserve_oleans = staging_utf8.join("preserve-oleans"); + std::fs::create_dir_all(preserve_oleans.as_std_path()) + .map_err(|error| fail(internal(format!("staging preservation oleans: {error}"))))?; + let lean_path_env = + std::env::join_paths([preserve_oleans.as_std_path(), olean_root.as_std_path()]) + .map_err(|error| fail(internal(format!("the verification search path: {error}"))))? + .to_string_lossy() + .into_owned(); // The records of this run's processes, by what they are and the module // or audit member they are of, and the records of the remaining stages // in the order they ran. The attestation lists them in the canonical @@ -1333,7 +1342,7 @@ pub fn run_part( let probe_source = staging_utf8 .join("probe") .join(format!("{probe_name}.lean")); - let probe_record = run_child( + let (probe_record, search_path) = child::run_probe( &ChildSpec { tool: "lean", module: Some(probe_name.clone()), @@ -1379,7 +1388,12 @@ pub fn run_part( } return Err(fail(diagnostic)); } - require_silent(&probe_record, "the external-interface probe", false).map_err(fail)?; + require_silent(&probe_record, "the external-interface probe", true).map_err(fail)?; + let search_path = search_path.ok_or_else(|| { + fail(internal( + "a successful interface probe has no decoded search path", + )) + })?; write_staged( staging.path(), "probe/process.json", @@ -1676,7 +1690,7 @@ pub fn run_part( }) }, |module_index, result| { - let record = result.map_err(fail)?; + let mut record = result.map_err(fail)?; let module_name = lean_names[module_index].clone(); if record.exit_code != 0 { // Lean reports compile errors on stdout under `lake env @@ -1710,6 +1724,7 @@ pub fn run_part( format!("`{module_name}` produced no olean"), ))); } + record.olean = Some(leanchecker::capture_olean_parts(&olean).map_err(fail)?); write_staged( staging.path(), &format!("process/lean/{module_name}.json"), @@ -1769,13 +1784,17 @@ pub fn run_part( &|module_index: usize| lean_names[module_index].clone(), &|module_index: usize| { let module_name = &lean_names[module_index]; - leanchecker::replay_module( + leanchecker::replay_bound_module( &toolchain, module_name, &lean_path_env, &workspace_root, &limits, &normalizer, + leanchecker::ReplayInput { + search_path: &search_path, + staged: &olean_root.join(format!("{}.olean", module_name.replace('.', "/"))), + }, ) // A replay failure is about this module, so it points at the // module's source rather than at the project manifest (§20.1). @@ -2433,12 +2452,7 @@ pub fn run_part( .collect(); let stage = preserve::stage(&generated_modules, &staged_certificates).map_err(fail)?; let preserve_src = staging_utf8.join("preserve-src"); - let preserve_oleans = staging_utf8.join("preserve-oleans"); - let preserve_path = - std::env::join_paths([preserve_oleans.as_std_path(), olean_root.as_std_path()]) - .map_err(|error| fail(internal(format!("the preservation search path: {error}"))))? - .to_string_lossy() - .into_owned(); + let preserve_path = lean_path_env.clone(); for file in stage .environment .iter() @@ -2529,7 +2543,7 @@ pub fn run_part( tail_records.push(record); } for file in &stage.certificates { - let record = compile(file, true).map_err(fail)?; + let mut record = compile(file, true).map_err(fail)?; if record.exit_code != 0 || !record.stdout.trim().is_empty() || !record.stderr.trim().is_empty() @@ -2542,19 +2556,25 @@ pub fn run_part( &file.text, ))); } + let compiled_olean = preserve_oleans.join(file.path.replace(".lean", ".olean")); + record.olean = Some(leanchecker::capture_olean_parts(&compiled_olean).map_err(fail)?); write_staged( staging.path(), &format!("process/preserve/{}.json", file.module), &record.to_json().to_file_bytes(), )?; tail_records.push(record); - let replay = leanchecker::run_leanchecker( + let replay = leanchecker::run_bound_leanchecker( &toolchain, &file.module, &preserve_path, &workspace_root, &limits, &normalizer, + leanchecker::ReplayInput { + search_path: &search_path, + staged: &compiled_olean, + }, ) .map_err(fail)?; if replay.exit_code != 0 { @@ -2816,9 +2836,14 @@ pub fn run_part( // Stage 14: no unexpected absolute paths in successful output (§22.7), // over every process record. for record in &process_records { - if normalizer.has_unexpected_absolute_path(&record.stdout) - || normalizer.has_unexpected_absolute_path(&record.stderr) - { + let unexpected_stdout = + if record.tool == "lean" && record.module.as_deref() == Some(probe_name.as_str()) { + leanchecker::audit_search_path_packet(record.stdout.as_bytes()).map_err(fail)?; + false + } else { + normalizer.has_unexpected_absolute_path(&record.stdout) + }; + if unexpected_stdout || normalizer.has_unexpected_absolute_path(&record.stderr) { return Err(fail(Diagnostic::new( code!("LLV7006"), format!( @@ -2840,6 +2865,7 @@ pub fn run_part( // are removed once every consumer — later modules, the replay, and the // audit — has run). let _ = std::fs::remove_dir_all(src_root.as_std_path()); + let _ = std::fs::remove_dir_all(preserve_oleans.as_std_path()); for entry in walkdir::WalkDir::new(olean_root.as_std_path()) .into_iter() .flatten() diff --git a/crates/lexlean/src/verify/source_audit.rs b/crates/lexlean/src/verify/source_audit.rs index b8d088fba0..553684946b 100644 --- a/crates/lexlean/src/verify/source_audit.rs +++ b/crates/lexlean/src/verify/source_audit.rs @@ -280,6 +280,34 @@ pub fn audit(text: &str, allow_print_axioms: bool) -> Result<(), String> { audit_with_options(text, allow_print_axioms, false) } +/// Audit an interface probe with exactly its fixed read-only path report. +/// Every other token retains the ordinary generated-source restrictions. +/// +/// # Errors +/// A missing/duplicate report or any unsanctioned generated source. +pub fn audit_probe(text: &str) -> Result<(), String> { + let report = crate::backend::lean::SEARCH_PATH_REPORT_COMMAND; + let mut count = 0; + let retained = text + .split('\n') + .map(|line| { + if line == report { + count += 1; + "" + } else { + line + } + }) + .collect::>() + .join("\n"); + if count != 1 { + return Err( + "an interface probe must contain exactly its closed search-path report".to_owned(), + ); + } + audit(&retained, false) +} + /// Audit a generated native-core module. Its fixed decoder and canonical /// semantic payload use strings as data; the closed core schema excludes /// backend source text before this narrowly selected audit runs. @@ -407,3 +435,20 @@ mod tests { } } } + +#[cfg(test)] +mod probe_report_tests { + use super::audit_probe; + use crate::backend::lean::SEARCH_PATH_REPORT_COMMAND; + + #[test] + fn only_one_exact_closed_probe_command_is_allowed() { + let source = + format!("import Lean\nset_option autoImplicit false\n{SEARCH_PATH_REPORT_COMMAND}\n"); + audit_probe(&source).unwrap(); + assert!(audit_probe("import Lean\n").is_err()); + assert!(audit_probe(&format!("{source}{SEARCH_PATH_REPORT_COMMAND}\n")).is_err()); + assert!(audit_probe(&source.replace("ps.map", "ps.reverse.map")).is_err()); + assert!(audit_probe(&format!("{source}#eval IO.println 1\n")).is_err()); + } +} diff --git a/features/suites/verification.feature b/features/suites/verification.feature index cea246b4c9..e814849034 100644 --- a/features/suites/verification.feature +++ b/features/suites/verification.feature @@ -26,11 +26,12 @@ Feature: verification And no argv contains `update`, `build` or `fetch` @VR-04 @build - Scenario: Every used external interface is elaborated in the unique reserved probe module. + Scenario: Every used external interface is elaborated in the unique reserved probe module, which emits only its closed escaped effective-search-path report. Given the verified nat-add-zero example and its semantic ID When the reserved probe and audit module names are derived from that semantic ID Then the probe/ directory contains exactly one .lean file named after the reserved probe module And the probe module name differs from the audit module name + And successful probe output is solely the closed escaped effective-search-path report @VR-05 @build Scenario: Generated modules compile in topological order and produce one required olean each. diff --git a/model/ids.toml b/model/ids.toml index a40350262d..31530620dc 100644 --- a/model/ids.toml +++ b/model/ids.toml @@ -1217,7 +1217,7 @@ statement = "Lean execution uses the pinned Lake environment and never updates o id = "VR-04" level = "build" suite = "verification" -statement = "Every used external interface is elaborated in the unique reserved probe module." +statement = "Every used external interface is elaborated in the unique reserved probe module, which emits only its closed escaped effective-search-path report." [[id]] id = "VR-05" From 7061691c7e4593d772afba16699618a5eb5912e1 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Tue, 3 Nov 2026 15:49:43 +0000 Subject: [PATCH 4/8] Require byte-bound replay before publishing kernel-skipped modules --- SPEC.md | 14 +++++++++ VERIFICATION.md | 20 +++++++++++++ crates/conformance/src/cases/verification.rs | 12 ++++++-- crates/lexlean/src/verify/leanchecker.rs | 18 +++++++++--- crates/lexlean/src/verify/mod.rs | 31 ++++++++++++++++---- crates/lexlean/src/verify/partition.rs | 24 +++++++++++++-- 6 files changed, 106 insertions(+), 13 deletions(-) diff --git a/SPEC.md b/SPEC.md index 7ddcfe0edd..9fb6761f8f 100644 --- a/SPEC.md +++ b/SPEC.md @@ -9272,6 +9272,20 @@ For each generated module, sorted by full module name, LexLean invokes the pinne A zero exit is required. Normalized output is recorded. +Only generated project modules and certificates A, B, and E compile with +`debug.skipKernelTC=true`; runtime, support, interface-probe, extraction, +and audit modules retain the in-process kernel check. Compilation and +successful same-run replay bind the requested module's main, server, and +private olean parts, with omitted companions distinct from present empty +files. Before cleanup or publication, one guard joins local and imported +process records with the certificate tail and freshly captured staged +tuples. Every eligible module requires exactly one successful flagged +compilation and matching successful replay; a missing record, substituted +part, or changed staged tuple refuses publication. Shards transport the +existing typed process records and artifacts; they do not publish verified +acceptance themselves. Prefix replays can also check descendant modules, +so this does not promise globally exactly-once declaration replay. + This replay checks the newly loaded environment through Lean's kernel and is intended to detect environment manipulation. It is explicitly not described as an independent verifier. ### 22.5 Axiom output diff --git a/VERIFICATION.md b/VERIFICATION.md index fa07798c60..c2dfd6a1bf 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12517,3 +12517,23 @@ plants. These are focused correctness results, not performance savings. Skip flags remain disabled, and the final publication-guard call site remains an integration obligation. No full gate, identity regeneration, product artifact writer, or full VR-28 acceptance is claimed. + +The next unpublished source phase wires the flag only at the generated +project-module compilation and certificate A/B/E compilation call sites. +The preservation environment uses the same compile helper with the flag +explicitly false; its audit also keeps the flag false. Runtime, text-law, +probe, extraction, and project axiom-audit call sites are unchanged. +Certificate oleans now survive until the final scratch-cleanup stage. +After local and imported records and the certificate tail are assembled, +one publication guard freshly captures every project's and certificate's +staged main/server/private tuple and requires its matching compile/replay +binding. Expected-name coverage refuses a wholly omitted compilation or +certificate tail; the existing diagnostic paths still classify failed +project and certificate replays before that guard. + +Additional source plants extend the existing VR-28 case and shard round-trip +unit: missing compilation, missing certificate staged tuples, dropped whole +certificate tail, removed flag, shard replay-record substitution/removal, +and a companion replaced after import. These edits have not been compiled +or executed while the Host writer owns the shared phase lock. No measurement, +full acceptance, publication, or regenerated product identity is claimed. diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 3fe12aed1b..3e18238641 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -1435,14 +1435,22 @@ fn replay_binding_guard_plants(mut compile: lexlean::verify::child::ChildRecord) let certificates = [module.clone()].into_iter().collect(); check_replay_bindings( &[compile.clone(), replay.clone()], - &BTreeMap::new(), + &staged, &certificates, ) - .expect("certificate tail retains its binding after its scratch files are removed"); + .expect("certificate tail binds staged artifacts before scratch cleanup"); + check_replay_bindings(&[compile.clone(), replay.clone()], &BTreeMap::new(), &certificates) + .expect_err("a certificate without its staged tuple refuses publication"); let refuse = |records: &[lexlean::verify::child::ChildRecord], published: &BTreeMap<_, _>| { let error = check(records, published).expect_err("a binding hole refuses publication"); assert_eq!(error.code.as_str(), "LLI9001"); }; + refuse(&[], &staged); + let mut unflagged = compile.clone(); + unflagged.argv.retain(|arg| arg != "-D" && arg != "debug.skipKernelTC=true"); + refuse(&[unflagged, replay.clone()], &staged); + check_replay_bindings(&[], &BTreeMap::new(), &certificates) + .expect_err("dropping the complete certificate tail refuses publication"); refuse(std::slice::from_ref(&compile), &staged); refuse(&[compile.clone(), replay.clone(), replay.clone()], &staged); refuse(&[compile.clone(), compile.clone(), replay.clone()], &staged); diff --git a/crates/lexlean/src/verify/leanchecker.rs b/crates/lexlean/src/verify/leanchecker.rs index 06c708ba62..78170f4e84 100644 --- a/crates/lexlean/src/verify/leanchecker.rs +++ b/crates/lexlean/src/verify/leanchecker.rs @@ -78,13 +78,13 @@ pub fn replay_module( /// The existing toolchain and partition gates establish executable identities /// and judge stage output. This guard checks the association of those records: /// module identity, successful replay, complete olean parts, and the staged -/// project artifacts. Certificates retain their bindings after scratch cleanup. +/// project and certificate artifacts before scratch cleanup. /// /// # Errors /// A missing, failed, duplicate, malformed, or substituted binding (LLI9001). pub fn check_replay_bindings( records: &[ChildRecord], - staged_projects: &std::collections::BTreeMap, + staged_artifacts: &std::collections::BTreeMap, certificates: &std::collections::BTreeSet, ) -> Result<(), Diagnostic> { let hole = |message| { @@ -105,7 +105,7 @@ pub fn check_replay_bindings( .as_deref() .ok_or_else(|| hole("a flagged compilation has no module".to_owned()))?; if compile.tool != "lean" - || (!staged_projects.contains_key(module) && !certificates.contains(module)) + || (!staged_artifacts.contains_key(module) && !certificates.contains(module)) { return Err(hole(format!( "`{module}` is not an eligible project or certificate compilation" @@ -147,7 +147,7 @@ pub fn check_replay_bindings( "`{module}` replay input differs from its compiled olean parts" ))); } - if let Some(staged) = staged_projects.get(module) { + if let Some(staged) = staged_artifacts.get(module) { staged.validate().map_err(hole)?; if produced != staged { return Err(hole(format!( @@ -156,6 +156,16 @@ pub fn check_replay_bindings( } } } + for certificate in certificates { + if !staged_artifacts.contains_key(certificate) { + return Err(hole(format!("`{certificate}` has no staged certificate artifacts"))); + } + } + for expected in staged_artifacts.keys().chain(certificates) { + if !compiled.contains(expected.as_str()) { + return Err(hole(format!("`{expected}` has no flagged compilation record"))); + } + } Ok(()) } diff --git a/crates/lexlean/src/verify/mod.rs b/crates/lexlean/src/verify/mod.rs index a4b8159f75..5d865fac51 100644 --- a/crates/lexlean/src/verify/mod.rs +++ b/crates/lexlean/src/verify/mod.rs @@ -1666,6 +1666,7 @@ pub fn run_part( argv: vec![ "env".to_owned(), "lean".to_owned(), + "-Ddebug.skipKernelTC=true".to_owned(), "-R".to_owned(), src_root.to_string(), "-o".to_owned(), @@ -2356,6 +2357,7 @@ pub fn run_part( // and certified; the certificates compile beside the shipped library and // calculus modules, are replayed, and their axioms audited exactly. let mut preservation_row: Option = None; + let mut certificate_artifacts = BTreeMap::new(); if !production_reports.is_empty() { use crate::production::preserve; // Lean's first error, from its severity on: the location before it @@ -2465,7 +2467,7 @@ pub fn run_part( file.text.as_bytes(), )?; } - let compile = |file: &preserve::StagedFile, output: bool| { + let compile = |file: &preserve::StagedFile, output: bool, skip_kernel: bool| { let source = preserve_src.join(&file.path); let mut argv = vec![ "env".to_owned(), @@ -2473,6 +2475,9 @@ pub fn run_part( "-R".to_owned(), preserve_src.to_string(), ]; + if skip_kernel { + argv.push("-Ddebug.skipKernelTC=true".to_owned()); + } if output { let olean = preserve_oleans.join(file.path.replace(".lean", ".olean")); if let Some(parent) = olean.parent() { @@ -2511,7 +2516,7 @@ pub fn run_part( { continue; } - let record = compile(file, true).map_err(fail)?; + let record = compile(file, true, false).map_err(fail)?; if record.exit_code != 0 || !record.stdout.trim().is_empty() || !record.stderr.trim().is_empty() @@ -2543,7 +2548,7 @@ pub fn run_part( tail_records.push(record); } for file in &stage.certificates { - let mut record = compile(file, true).map_err(fail)?; + let mut record = compile(file, true, true).map_err(fail)?; if record.exit_code != 0 || !record.stdout.trim().is_empty() || !record.stderr.trim().is_empty() @@ -2557,6 +2562,7 @@ pub fn run_part( ))); } let compiled_olean = preserve_oleans.join(file.path.replace(".lean", ".olean")); + certificate_artifacts.insert(file.module.clone(), compiled_olean.clone()); record.olean = Some(leanchecker::capture_olean_parts(&compiled_olean).map_err(fail)?); write_staged( staging.path(), @@ -2593,7 +2599,7 @@ pub fn run_part( )?; tail_records.push(replay); } - let audit_record = compile(&stage.audit, false).map_err(fail)?; + let audit_record = compile(&stage.audit, false, false).map_err(fail)?; let audit_output = format!("{}{}", audit_record.stdout, audit_record.stderr); if audit_record.exit_code != 0 { if let Some(exhausted) = resource_death( @@ -2667,7 +2673,6 @@ pub fn run_part( ("sha256", Json::Str(Sha256Digest::of(&bytes).to_hex())), ])); let _ = std::fs::remove_dir_all(preserve_src.as_std_path()); - let _ = std::fs::remove_dir_all(preserve_oleans.as_std_path()); } stages.enter("pdf"); @@ -2833,6 +2838,22 @@ pub fn run_part( "a part of the run recorded `{stray}`, which no module of the project owns" )))); } + // One publication guard, after all local/imported records and the + // certificate tail have joined, while every staged artifact still exists. + let mut staged_artifacts = BTreeMap::new(); + for module in &build.modules { + let main = olean_root.join(format!("{}.olean", module.lean_module.replace('.', "/"))); + staged_artifacts.insert(module.lean_module.clone(), leanchecker::capture_olean_parts(&main).map_err(fail)?); + } + for (module, main) in &certificate_artifacts { + staged_artifacts.insert(module.clone(), leanchecker::capture_olean_parts(main).map_err(fail)?); + } + leanchecker::check_replay_bindings( + &process_records, + &staged_artifacts, + &certificate_artifacts.keys().cloned().collect(), + ).map_err(fail)?; + // Stage 14: no unexpected absolute paths in successful output (§22.7), // over every process record. for record in &process_records { diff --git a/crates/lexlean/src/verify/partition.rs b/crates/lexlean/src/verify/partition.rs index 095262fc0b..f6fac0f042 100644 --- a/crates/lexlean/src/verify/partition.rs +++ b/crates/lexlean/src/verify/partition.rs @@ -520,7 +520,7 @@ mod tests { let record = ChildRecord { tool: "lean".to_owned(), module: Some("X.M".to_owned()), - argv: vec!["env".to_owned(), "lean".to_owned()], + argv: vec!["env".to_owned(), "lean".to_owned(), "-Ddebug.skipKernelTC=true".to_owned()], exit_code: 0, stdout: "\n".to_owned(), stderr: String::new(), @@ -533,11 +533,19 @@ mod tests { }; let audit_record = ChildRecord { module: Some("LexLeanAudit.X.M".to_owned()), + argv: vec!["env".to_owned(), "lean".to_owned()], olean: None, ..record.clone() }; + let replay_record = ChildRecord { + tool: "leanchecker".to_owned(), + argv: vec!["env".to_owned(), "$TOOLCHAIN/bin/leanchecker".to_owned(), "X.M".to_owned()], + executable_sha256: crate::artifact::content_id::Sha256Digest::of(b"another lean"), + ..record.clone() + }; for (relative, written) in [ ("process/lean/X.M.json", &record), + ("process/leanchecker/X.M.json", &replay_record), ("audit/LexLeanAudit.X.M.process.json", &audit_record), ] { let path = staging.path().join(relative); @@ -573,7 +581,7 @@ mod tests { imported.lean["X.M"].olean, record.olean, "the existing part transport preserves all olean bindings" ); - assert!(imported.leanchecker.is_empty()); + assert_eq!(imported.leanchecker.len(), 1); assert!(imported.audit.contains_key("LexLeanAudit.X.M")); // The records name the join's `lean`; a join whose `lean` is another // executable refuses them, naming the record and both digests. @@ -590,6 +598,18 @@ mod tests { && message.contains(&other.to_hex()), "{message}" ); + // The publication guard consumes the actual shard transport, not a + // second association format. Substitution after transport is refused. + let staged = [("X.M".to_owned(), crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")).expect("parts"))].into_iter().collect(); + let joined = [imported.lean["X.M"].clone(), imported.leanchecker["X.M"].clone()]; + crate::verify::leanchecker::check_replay_bindings(&joined, &staged, &BTreeSet::new()).expect("joined binding"); + let mut changed = joined.clone(); + changed[1].olean.as_mut().expect("bound").private = None; + assert!(crate::verify::leanchecker::check_replay_bindings(&changed, &staged, &BTreeSet::new()).is_err()); + assert!(crate::verify::leanchecker::check_replay_bindings(&joined[..1], &staged, &BTreeSet::new()).is_err()); + std::fs::write(olean_root.join("X/M.olean.server"), b"replaced after import").expect("replace"); + let replaced = [("X.M".to_owned(), crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")).expect("parts"))].into_iter().collect(); + assert!(crate::verify::leanchecker::check_replay_bindings(&joined, &replaced, &BTreeSet::new()).is_err()); // The same part imported twice is a process that ran twice. let again = import(&[output.clone(), output.clone()], &olean_root, false); assert!(again.is_err(), "a duplicate olean is refused"); From f655d0b158c69863c1351a5f5e31dc3a7aa36bb5 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Tue, 3 Nov 2026 16:44:08 +0000 Subject: [PATCH 5/8] Exercise real kernel-false replay and pipeline refusal --- VERIFICATION.md | 48 +++++ crates/conformance/src/cases/verification.rs | 182 ++++++++++++++++++- crates/lexlean/src/verify/leanchecker.rs | 8 +- crates/lexlean/src/verify/mod.rs | 13 +- crates/lexlean/src/verify/partition.rs | 63 ++++++- 5 files changed, 293 insertions(+), 21 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index c2dfd6a1bf..65e15d50b5 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12537,3 +12537,51 @@ certificate tail, removed flag, shard replay-record substitution/removal, and a companion replaced after import. These edits have not been compiled or executed while the Host writer owns the shared phase lock. No measurement, full acceptance, publication, or regenerated product identity is claimed. + +VR-28's next unexecuted regression source now exercises a real kernel-false +artifact. A scratch Lean file uses ordinary `Lean.addDecl` with a theorem +whose type is `False` and value is `True.intro`, retaining its body through +`forceExpose`; it contains no module header. The same source must fail the +unflagged compile and pass the flagged compile. The bounded runner captures +the actual companion tuple, then the real pinned checker must reject that +artifact and name its planted declaration. This uses neither an unchecked +API nor a production source-audit allowance. + +The pipeline plant reuses the existing test toolchain wrapper mechanism, +replacing only Lake's test wrapper. After source audit it substitutes that +scratch source into the eligible project compilation, delegates to real +Lean, and requires the real compile to exit zero with the skip flag present. +It records the actual checker invocation, requires its path to resolve to +the real pinned checker, and expects LLV7003 naming the planted declaration +with no verified publication. Existing Lean-backed and POSIX host helpers +remain unchanged. This new regression source has not yet been compiled or +executed while the Host writer owns the shared lock. + +The admitted focused phase then executed these source changes. All three +partition units passed, including the actual shard round-trip binding and +missing/substituted replay or changed companion refusal plants. Correct-root +exact VR-28 passed in 5.53 seconds. Its direct witness assertions establish +unflagged kernel refusal, flagged real-Lean compilation success, capture of +the produced main/server/private tuple, and real pinned-checker refusal naming +`VR28KernelFalse.bad`. The pipeline assertions establish a flagged real-Lean +compile exit of zero, invocation of the real pinned checker, LLV7003 naming +the planted declaration, and no verified publication after post-audit +substitution. The test wrapper uses the already preflighted, quoted Lake +path and the existing POSIX-backed host gate; no production audit exemption, +fake checker, or helper bypass was introduced. + +The first real attempt exposed a test-source monad error: `run_elab` expects +`TermElabM`, while the explicit command-elaborator lift returned +`CommandElabM`. The corrected witness uses ordinary `run_elab do` and the +standard lift of `Lean.addDecl`; the theorem and its expected outcomes were +unchanged. Clippy also required a borrowed singleton slice instead of a +clone. After those ordinary fixes, focused lexlean/repo-conformance Clippy +with warnings denied, formatting, and diff checks passed. The shared phase +lock was released before the Host writer resumed; frozen Host binaries were +untouched. Existing model-helper provenance was already this worktree; +an unnecessary small package-only rebuild in this phase added no evidence +and is not a repeated validation requirement. No committed example lock, +product identity, or generated artifact changed. Positive production +certificate acceptance and diagnostic fixtures, shard/join width invariance, +controlled measurements, coordinated identities/artifacts, and the full gate +remain required; these focused results are not complete VR-28 acceptance. diff --git a/crates/conformance/src/cases/verification.rs b/crates/conformance/src/cases/verification.rs index 3e18238641..e164a5bc46 100644 --- a/crates/conformance/src/cases/verification.rs +++ b/crates/conformance/src/cases/verification.rs @@ -46,7 +46,12 @@ pub(crate) fn run(id: &str) { return; } match id { - "VR-28" => binding_record_round_trip(), + "VR-28" => { + binding_record_round_trip(); + if support::lean_backed(id) { + kernel_false_replay_regression(); + } + } // §22.1: every stage runs; no suppression option exists. "VR-01" => { let fixture = support::verified(); @@ -1433,21 +1438,23 @@ fn replay_binding_guard_plants(mut compile: lexlean::verify::child::ChildRecord) }; check(&[compile.clone(), replay.clone()], &staged).expect("same module and complete bytes"); let certificates = [module.clone()].into_iter().collect(); + check_replay_bindings(&[compile.clone(), replay.clone()], &staged, &certificates) + .expect("certificate tail binds staged artifacts before scratch cleanup"); check_replay_bindings( &[compile.clone(), replay.clone()], - &staged, + &BTreeMap::new(), &certificates, ) - .expect("certificate tail binds staged artifacts before scratch cleanup"); - check_replay_bindings(&[compile.clone(), replay.clone()], &BTreeMap::new(), &certificates) - .expect_err("a certificate without its staged tuple refuses publication"); + .expect_err("a certificate without its staged tuple refuses publication"); let refuse = |records: &[lexlean::verify::child::ChildRecord], published: &BTreeMap<_, _>| { let error = check(records, published).expect_err("a binding hole refuses publication"); assert_eq!(error.code.as_str(), "LLI9001"); }; refuse(&[], &staged); let mut unflagged = compile.clone(); - unflagged.argv.retain(|arg| arg != "-D" && arg != "debug.skipKernelTC=true"); + unflagged + .argv + .retain(|arg| arg != "-D" && arg != "debug.skipKernelTC=true"); refuse(&[unflagged, replay.clone()], &staged); check_replay_bindings(&[], &BTreeMap::new(), &certificates) .expect_err("dropping the complete certificate tail refuses publication"); @@ -1516,3 +1523,166 @@ fn replay_binding_guard_plants(mut compile: lexlean::verify::child::ChildRecord) orphan.olean.as_mut().expect("bound").server = None; refuse(&[orphan, replay], &staged); } + +/// Exercise ordinary `Lean.addDecl`, rather than a source elaboration error. +/// The source is test-only and never receives a generated-source exemption. +fn kernel_false_replay_regression() { + use lexlean::verify::child::{self, ChildHome, ChildSpec, Normalizer}; + use lexlean::verify::{leanchecker, toolchain}; + let project = P::example(); + project.relock(); + let limits = support::limits_of(&project); + let guard = support::env_shared(); + let tools = toolchain::preflight(&limits).expect("real pinned toolchain"); + let scratch = project.root.join("kernel-false"); + std::fs::create_dir_all(&scratch).expect("scratch"); + let source = scratch.join("VR28KernelFalse.lean"); + // No module header: keep theorem bodies. forceExpose also explicitly + // retains this ordinary addDecl theorem's body for the real checker. + let witness = r#"import Lean +run_elab do + Lean.addDecl (.thmDecl { name := `VR28KernelFalse.bad, levelParams := [], type := Lean.mkConst ``False, value := Lean.mkConst ``True.intro }) true +"#; + std::fs::write(&source, witness).expect("witness source"); + let main = scratch.join("VR28KernelFalse.olean"); + let normalizer = Normalizer::new(&scratch, &project.root, &project.root, &tools.root); + let bin = tools.root.join("bin"); + let compile = |skip: bool| { + let mut argv = vec!["env".to_owned(), tools.lean.path.to_string()]; + if skip { + argv.push("-Ddebug.skipKernelTC=true".to_owned()); + } + argv.extend(["-o".to_owned(), main.to_string(), source.to_string()]); + child::run( + &ChildSpec { + tool: "lean", + module: Some("VR28KernelFalse".to_owned()), + program: &tools.lake.path, + executable_sha256: tools.lean.sha256, + argv, + cwd: &project.root, + extra_env: Vec::new(), + home: ChildHome::Toolchain { + toolchain_bin: &bin, + }, + }, + &limits, + &normalizer, + ) + .expect("bounded real Lean") + }; + let checked = compile(false); + assert_ne!( + checked.exit_code, 0, + "the ordinary kernel rejects False with True.intro" + ); + let skipped = compile(true); + assert_eq!( + skipped.exit_code, 0, + "the skip flag must produce the actual bad artifact: {}{}", + skipped.stdout, skipped.stderr + ); + assert!(skipped + .argv + .iter() + .any(|arg| arg == "-Ddebug.skipKernelTC=true")); + let actual = leanchecker::capture_olean_parts(&main).expect("actual complete tuple"); + let replay = leanchecker::run_bound_leanchecker( + &tools, + "VR28KernelFalse", + scratch.as_str(), + &project.root, + &limits, + &normalizer, + leanchecker::ReplayInput { + search_path: std::slice::from_ref(&scratch), + staged: &main, + }, + ) + .expect("real pinned checker ran"); + assert_ne!( + replay.exit_code, 0, + "the real kernel checker must reject that artifact" + ); + let rejection = format!("{}{}", replay.stdout, replay.stderr); + assert!( + rejection.contains("VR28KernelFalse.bad"), + "the checker rejects the planted declaration, rather than missing its input: {rejection}" + ); + assert_eq!(replay.executable_sha256, tools.leanchecker.sha256); + assert_eq!(replay.olean, Some(actual)); + assert_eq!(replay.argv[2], "VR28KernelFalse"); + drop(guard); + + if !support::posix_shell_backed("VR-28") { + return; + } + // Reuse the existing test wrapper transport, changing only lake. Both + // Lean and leanchecker remain symlinks to the real pinned executables. + let quote = |value: &str| format!("'{}'", value.replace('\'', "'\\''")); + let flag_seen = scratch.join("flag-seen"); + let compile_status = scratch.join("compile-status"); + let checker_seen = scratch.join("checker-seen"); + let script = format!( + r#"#!/bin/sh +real={real_lake} +if [ "$1" = env ] && [ "$2" = lean ]; then + for argument in "$@"; do + case "$argument" in + */lean-src/LexLeanExample/Main.lean) + case " $* " in + *" -Ddebug.skipKernelTC=true "*) printf '%s\n' yes > {flag_seen} ;; + *) exit 97 ;; + esac + cat {source} > "$argument" + "$real" "$@" + status=$? + printf '%s\n' "$status" > {compile_status} + exit "$status" + ;; + esac + done +fi +if [ "$1" = env ] && [ "$3" = LexLeanExample.Main ]; then + case "$2" in */leanchecker) printf '%s\n' "$2" > {checker_seen} ;; esac +fi +exec "$real" "$@" +"#, + real_lake = quote(tools.lake.path.as_str()), + flag_seen = quote(flag_seen.as_str()), + source = quote(source.as_str()), + compile_status = quote(compile_status.as_str()), + checker_seen = quote(checker_seen.as_str()) + ); + let wrapped = support::fake_toolchain(&[("lake", &script)]); + let wrapped_home = wrapped.path().to_str().expect("utf8 fake home"); + support::with_env(&[("ELAN_HOME", Some(wrapped_home))], || { + let rejected = project.verify_fails_with("LLV7003"); + assert!( + format!("{rejected}").contains("VR28KernelFalse.bad"), + "the pipeline rejects the actual planted declaration: {rejected}" + ); + assert_eq!( + std::fs::read_to_string(&flag_seen) + .expect("eligible flag seen") + .trim(), + "yes" + ); + assert_eq!( + std::fs::read_to_string(&compile_status) + .expect("real Lean compiled bad artifact") + .trim(), + "0" + ); + let checker = + std::fs::read_to_string(&checker_seen).expect("actual pipeline invoked checker"); + assert_eq!( + std::fs::canonicalize(checker.trim()).expect("checker path"), + std::fs::canonicalize(tools.leanchecker.path.as_std_path()).expect("real checker") + ); + assert!( + support::file_set(&project.root.join(".lexlean/verified")).is_empty(), + "kernel-false artifact publishes nothing" + ); + }); +} diff --git a/crates/lexlean/src/verify/leanchecker.rs b/crates/lexlean/src/verify/leanchecker.rs index 78170f4e84..143273b968 100644 --- a/crates/lexlean/src/verify/leanchecker.rs +++ b/crates/lexlean/src/verify/leanchecker.rs @@ -158,12 +158,16 @@ pub fn check_replay_bindings( } for certificate in certificates { if !staged_artifacts.contains_key(certificate) { - return Err(hole(format!("`{certificate}` has no staged certificate artifacts"))); + return Err(hole(format!( + "`{certificate}` has no staged certificate artifacts" + ))); } } for expected in staged_artifacts.keys().chain(certificates) { if !compiled.contains(expected.as_str()) { - return Err(hole(format!("`{expected}` has no flagged compilation record"))); + return Err(hole(format!( + "`{expected}` has no flagged compilation record" + ))); } } Ok(()) diff --git a/crates/lexlean/src/verify/mod.rs b/crates/lexlean/src/verify/mod.rs index 5d865fac51..73c61994c5 100644 --- a/crates/lexlean/src/verify/mod.rs +++ b/crates/lexlean/src/verify/mod.rs @@ -2843,16 +2843,23 @@ pub fn run_part( let mut staged_artifacts = BTreeMap::new(); for module in &build.modules { let main = olean_root.join(format!("{}.olean", module.lean_module.replace('.', "/"))); - staged_artifacts.insert(module.lean_module.clone(), leanchecker::capture_olean_parts(&main).map_err(fail)?); + staged_artifacts.insert( + module.lean_module.clone(), + leanchecker::capture_olean_parts(&main).map_err(fail)?, + ); } for (module, main) in &certificate_artifacts { - staged_artifacts.insert(module.clone(), leanchecker::capture_olean_parts(main).map_err(fail)?); + staged_artifacts.insert( + module.clone(), + leanchecker::capture_olean_parts(main).map_err(fail)?, + ); } leanchecker::check_replay_bindings( &process_records, &staged_artifacts, &certificate_artifacts.keys().cloned().collect(), - ).map_err(fail)?; + ) + .map_err(fail)?; // Stage 14: no unexpected absolute paths in successful output (§22.7), // over every process record. diff --git a/crates/lexlean/src/verify/partition.rs b/crates/lexlean/src/verify/partition.rs index f6fac0f042..194bdefb19 100644 --- a/crates/lexlean/src/verify/partition.rs +++ b/crates/lexlean/src/verify/partition.rs @@ -520,7 +520,11 @@ mod tests { let record = ChildRecord { tool: "lean".to_owned(), module: Some("X.M".to_owned()), - argv: vec!["env".to_owned(), "lean".to_owned(), "-Ddebug.skipKernelTC=true".to_owned()], + argv: vec![ + "env".to_owned(), + "lean".to_owned(), + "-Ddebug.skipKernelTC=true".to_owned(), + ], exit_code: 0, stdout: "\n".to_owned(), stderr: String::new(), @@ -539,7 +543,11 @@ mod tests { }; let replay_record = ChildRecord { tool: "leanchecker".to_owned(), - argv: vec!["env".to_owned(), "$TOOLCHAIN/bin/leanchecker".to_owned(), "X.M".to_owned()], + argv: vec![ + "env".to_owned(), + "$TOOLCHAIN/bin/leanchecker".to_owned(), + "X.M".to_owned(), + ], executable_sha256: crate::artifact::content_id::Sha256Digest::of(b"another lean"), ..record.clone() }; @@ -600,16 +608,51 @@ mod tests { ); // The publication guard consumes the actual shard transport, not a // second association format. Substitution after transport is refused. - let staged = [("X.M".to_owned(), crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")).expect("parts"))].into_iter().collect(); - let joined = [imported.lean["X.M"].clone(), imported.leanchecker["X.M"].clone()]; - crate::verify::leanchecker::check_replay_bindings(&joined, &staged, &BTreeSet::new()).expect("joined binding"); + let staged = [( + "X.M".to_owned(), + crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")) + .expect("parts"), + )] + .into_iter() + .collect(); + let joined = [ + imported.lean["X.M"].clone(), + imported.leanchecker["X.M"].clone(), + ]; + crate::verify::leanchecker::check_replay_bindings(&joined, &staged, &BTreeSet::new()) + .expect("joined binding"); let mut changed = joined.clone(); changed[1].olean.as_mut().expect("bound").private = None; - assert!(crate::verify::leanchecker::check_replay_bindings(&changed, &staged, &BTreeSet::new()).is_err()); - assert!(crate::verify::leanchecker::check_replay_bindings(&joined[..1], &staged, &BTreeSet::new()).is_err()); - std::fs::write(olean_root.join("X/M.olean.server"), b"replaced after import").expect("replace"); - let replaced = [("X.M".to_owned(), crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")).expect("parts"))].into_iter().collect(); - assert!(crate::verify::leanchecker::check_replay_bindings(&joined, &replaced, &BTreeSet::new()).is_err()); + assert!(crate::verify::leanchecker::check_replay_bindings( + &changed, + &staged, + &BTreeSet::new() + ) + .is_err()); + assert!(crate::verify::leanchecker::check_replay_bindings( + &joined[..1], + &staged, + &BTreeSet::new() + ) + .is_err()); + std::fs::write( + olean_root.join("X/M.olean.server"), + b"replaced after import", + ) + .expect("replace"); + let replaced = [( + "X.M".to_owned(), + crate::verify::leanchecker::capture_olean_parts(&olean_root.join("X/M.olean")) + .expect("parts"), + )] + .into_iter() + .collect(); + assert!(crate::verify::leanchecker::check_replay_bindings( + &joined, + &replaced, + &BTreeSet::new() + ) + .is_err()); // The same part imported twice is a process that ran twice. let again = import(&[output.clone(), output.clone()], &olean_root, false); assert!(again.is_err(), "a duplicate olean is refused"); From ec6ba36fe83908abc94dc314389764897982e634 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Wed, 4 Nov 2026 01:56:52 +0000 Subject: [PATCH 6/8] Retain kernel replay diagnostics and verify certificate bindings --- VERIFICATION.md | 62 +++++++++++++++ crates/conformance/src/cases/preservation.rs | 80 ++++++++++++++++++++ crates/lexlean/src/production/preserve.rs | 26 +++++++ crates/lexlean/src/verify/mod.rs | 46 ++++++++++- 4 files changed, 212 insertions(+), 2 deletions(-) diff --git a/VERIFICATION.md b/VERIFICATION.md index 65e15d50b5..c1ad8b75a6 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12585,3 +12585,65 @@ product identity, or generated artifact changed. Positive production certificate acceptance and diagnostic fixtures, shard/join width invariance, controlled measurements, coordinated identities/artifacts, and the full gate remain required; these focused results are not complete VR-28 acceptance. + +A further source-only certificate audit refreshed issue #391 and the remote +feature head at `f655d0b158`; no competing source owner was recorded. Existing +SP-05 already shares a real production export and the real A/B/E mutation +fixtures, so no duplicate certificate verify is added. The audit found a +concrete diagnostic gap: `failing_declaration` recognized the core decoder's +compile refusal but not Lean replay's declaration envelope, and `lean_error` +required the word `error`, discarding replay's kernel type-mismatch detail. +Pinned `Lean/Replay.lean:136` throws `while replaying declaration '':` +with the kernel exception; the executable supplies `uncaught exception:`. + +The narrow unexecuted fix recognizes that envelope, preserves the existing +compile formatting and summary bounds, and recovers the refused certificate +declaration. New pure units cover replay detail/declaration/bounds and retain +unrelated-output refusal; the existing compile-summary regression remains. +SP-05's existing positive export gains A/B/E flagged-compile and successful +same-module complete-tuple replay assertions. Its existing three rejection +executions gain real replay/kernel-message and exact fixture declaration/root +assertions, in addition to unchanged LLV7013/7015/7016 and no-publication +checks. This source has not been formatted, compiled or executed while Host +owns the shared lock. No pins, fixture expectations, writers, measurements or +full-gate acceptance change; real final-guard/shard-width and regeneration +obligations remain pending. + +The admitted certificate follow-up completed on 2026-11-04 at 01:41:17 UTC. +The three exact diagnostic units passed together (3 passed, 223 filtered +out), including the existing compile-summary control. Exact SP-05 then +passed once in 990.888 seconds (1 passed, 469 filtered out). Its shared real +production export established that each A/B/E certificate compile carries +`-Ddebug.skipKernelTC=true`, succeeds, and has one successful same-module +replay with an equal complete main/server/private artifact-parts tuple. +The three real A/B/E rejection fixtures retained LLV7013/LLV7015/LLV7016, +respectively, and now assert the replay envelope, kernel detail and exact +certificate declaration/root. The heartbeat, resource and drift controls +also retained LLV7013, LLS8002 and LLV7014. All six retain their existing +no-verified-publication assertions; no checker, source-audit, fixture or +publication guard was weakened and no extra positive export was added. + +The first queued attempt used a wrong module filter; a continuation then +stopped before tests because stable libtest rejected `--fail-fast`. The +corrected stable run passed the three units before ENOSPC stopped lock +backup, leaving SP-05 unrun. A subsequent SP-05 group failed because the +official temporary lock commands created ignored `.lexlean/.lock` helper +directories that the strict fixture loader correctly refused; that failed +group is not positive acceptance evidence. The retry archived those proven +owned empty helpers, recorded all seven helpers absent before its commands, +and archived each newly created helper immediately after its lock command, +before fixture loading. The fixture loader and expectations were unchanged. + +The passing run used frozen binaries and checked the actual linked model, +support and bootstrap-fixture roots against this worktree before and after; +all frozen hashes and the reviewed four-file source diff stayed unchanged. +Seven official temporary lock refreshes supplied the changed source identity +for this focused run; all seven original lock byte hashes were restored. +Focused lexlean/repo-conformance Clippy with all targets/features and warnings +denied, workspace formatting, and diff checks passed. Evidence is retained +in `/workspace/work/vr28-cert-stable/diagnostic-units.log` and +`/workspace/work/vr28-cert-sp05-retry/` (results, provenance and SP-05 log). +No product pin, generated expectation or all-language identity wave changed. +These results discharge the focused certificate assertions only; real final +guard/shard-join and width invariance, gateway/Atlas measurements, +coordinated regeneration and the full gate remain required. diff --git a/crates/conformance/src/cases/preservation.rs b/crates/conformance/src/cases/preservation.rs index b4bca09701..c41af61fc8 100644 --- a/crates/conformance/src/cases/preservation.rs +++ b/crates/conformance/src/cases/preservation.rs @@ -2469,6 +2469,53 @@ pub fn run(id: &str) { ), "the attestation binds preservation.json" ); + // Reuse this real export's already-executed certificate + // processes: no additional verify or checker is introduced. + let processes = attestation["processes"].as_array().expect("processes"); + let mut certificate_modules = BTreeSet::new(); + for row in rows { + certificate_modules.insert(row["module"].as_str().expect("A module")); + for rendering in row["renderings"].as_array().expect("renderings") { + certificate_modules.insert(rendering["module"].as_str().expect("B module")); + certificate_modules + .insert(rendering["composed"]["module"].as_str().expect("E module")); + } + } + for module in certificate_modules { + let stage = |tool| { + let matching: Vec<_> = processes + .iter() + .filter(|process| { + process["tool"] == tool && process["module"] == module + }) + .collect(); + assert_eq!(matching.len(), 1, "{module}: one {tool} record"); + assert_eq!(matching[0]["exit_code"], 0, "{module}: successful {tool}"); + matching[0] + }; + let compiled = stage("lean"); + let replayed = stage("leanchecker"); + assert!( + compiled["argv"] + .as_array() + .expect("argv") + .iter() + .any(|arg| arg == "-Ddebug.skipKernelTC=true"), + "{module}: eligible certificate is flagged" + ); + assert!( + compiled["olean"]["main"].is_string(), + "{module}: compile parts captured" + ); + assert_eq!( + compiled["olean"], replayed["olean"], + "{module}: complete compile/replay tuple equality" + ); + assert_eq!( + replayed["argv"][2], module, + "{module}: requested replay module" + ); + } }; let rejected = [ ("certificate-rejected", "LLV7013"), @@ -2487,6 +2534,39 @@ pub fn run(id: &str) { ) .expect("the fixture runs"); assert_eq!(observed.codes, [code], "{fixture}"); + if matches!( + fixture, + "certificate-rejected" | "certificate-b-rejected" | "certificate-e-rejected" + ) { + let diagnostics: serde_json::Value = + serde_json::from_str(&observed.expected.diagnostics_json) + .expect("diagnostics"); + let message = diagnostics[0]["message"].as_str().expect("message"); + assert!( + message.contains("while replaying declaration '"), + "{fixture}: real replay refusal retained: {message}" + ); + assert!( + message.contains("(kernel)"), + "{fixture}: kernel failure retained: {message}" + ); + let (declaration, root) = match fixture { + "certificate-rejected" => ("__rel_2", "Production.Main.quadruple"), + "certificate-b-rejected" => ("fun2", "Production.Main.quadruple"), + "certificate-e-rejected" => ("root", "Production.Main.checkedSum"), + _ => unreachable!(), + }; + assert!( + message + .contains(&format!("was rejected in `{declaration}` of root `{root}`")), + "{fixture}: certificate declaration and root retained: {message}" + ); + assert!( + !message.contains("no error was reported"), + "{fixture}: actual failure is reported" + ); + } + assert!( !observed.project.root.join(".lexlean/verified").exists() || std::fs::read_dir( diff --git a/crates/lexlean/src/production/preserve.rs b/crates/lexlean/src/production/preserve.rs index 68dacfc30c..bfc2dcb276 100644 --- a/crates/lexlean/src/production/preserve.rs +++ b/crates/lexlean/src/production/preserve.rs @@ -1917,6 +1917,14 @@ pub fn record(roots: &[CertifiedRoot]) -> crate::artifact::canonical_json::Json /// rejection concerns. #[must_use] pub fn failing_declaration(text: &str, output: &str) -> Option { + // Pinned Lean/Replay.lean reports the declaration refused by its kernel. + if let Some(named) = output.lines().find_map(|line| { + let rest = line.strip_prefix("uncaught exception: while replaying declaration '")?; + let (name, _) = rest.split_once("':")?; + name.rsplit('.').next().map(str::to_owned) + }) { + return Some(named); + } // A certificate held as data is added by the decoder, whose message // names the declaration the kernel refused. if let Some(named) = output.lines().find_map(|line| { @@ -2140,3 +2148,21 @@ mod group_tests { ); } } + +#[cfg(test)] +mod replay_declaration_tests { + #[test] + fn replay_refusal_keeps_the_certificate_declaration() { + // Pinned Lean/Replay.lean:136 throws this userError envelope; + // Lean's executable reports it with `uncaught exception:`. + let output = "uncaught exception: while replaying declaration 'LexLeanPreserve.Cexample.R2.__rel_2':\n(kernel) application type mismatch\n detail\n"; + assert_eq!( + super::failing_declaration("", output).as_deref(), + Some("__rel_2") + ); + assert_eq!( + super::failing_declaration("", "uncaught exception: unrelated failure"), + None + ); + } +} diff --git a/crates/lexlean/src/verify/mod.rs b/crates/lexlean/src/verify/mod.rs index 73c61994c5..5eb9c5d130 100644 --- a/crates/lexlean/src/verify/mod.rs +++ b/crates/lexlean/src/verify/mod.rs @@ -3211,11 +3211,22 @@ fn lean_error(output: &str) -> String { const LINES: usize = 12; const BYTES: usize = 1500; let lines: Vec<&str> = output.lines().collect(); - let Some(start) = lines.iter().position(|line| line.contains("error")) else { + let replay = |line: &str| { + line.starts_with("uncaught exception: while replaying declaration '") && line.contains("':") + }; + let Some(start) = lines + .iter() + .position(|line| replay(line) || line.contains("error")) + else { return "no error was reported".to_owned(); }; let first = lines[start]; - let mut out = first[first.find("error").unwrap_or(0)..].trim().to_owned(); + let offset = if replay(first) { + 0 + } else { + first.find("error").unwrap_or(0) + }; + let mut out = first[offset..].trim().to_owned(); for line in lines[start + 1..].iter().take(LINES - 1) { out.push('\n'); out.push_str(line.trim_end()); @@ -3368,3 +3379,34 @@ mod resource_tests { assert_eq!(lean_error("fine"), "no error was reported"); } } + +#[cfg(test)] +mod replay_error_tests { + #[test] + fn replay_exception_keeps_its_declaration_and_bounded_kernel_detail() { + // Pinned Lean/Replay.lean:136, with the executable's exception prefix. + let first = + "uncaught exception: while replaying declaration 'LexLeanPreserve.Cexample.R0.root':"; + let output = format!( + "{first}\n(kernel) application type mismatch\n{}", + " é continuation\n".repeat(500) + ); + let summary = super::lean_error(&output); + assert!(summary.starts_with(first), "{summary}"); + assert!(summary.contains("(kernel) application type mismatch")); + assert!(summary.lines().count() <= 12); + assert!(summary.len() <= 1504); + let wide = format!("{first}\n(kernel) {}\n", "é".repeat(1800)); + let bounded = super::lean_error(&wide); + assert!(bounded.ends_with(" ...")); + assert!(bounded.len() <= 1504); + assert_eq!( + super::lean_error("x.lean:2:3: error: compile refusal\n detail\n"), + "error: compile refusal\n detail" + ); + assert_eq!( + super::lean_error("uncaught exception: unrelated failure"), + "no error was reported" + ); + } +} From 104f755ae9b525df0765af08a13c68bfa715b577 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Wed, 4 Nov 2026 09:52:26 +0000 Subject: [PATCH 7/8] test(verify): bind shard joins and width results to replay artifacts --- VERIFICATION.md | 95 ++++++++++++ crates/conformance/src/cases/operational.rs | 158 ++++++++++++++++++++ 2 files changed, 253 insertions(+) diff --git a/VERIFICATION.md b/VERIFICATION.md index c1ad8b75a6..375855d1d9 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12647,3 +12647,98 @@ No product pin, generated expectation or all-language identity wave changed. These results discharge the focused certificate assertions only; real final guard/shard-join and width invariance, gateway/Atlas measurements, coordinated regeneration and the full gate remain required. + + +## VR-28 real join and width assertion follow-up (source only) + +Unexecuted source atop `ec6ba36fe` extends the existing VR-21 width-1/width-3 +results and VR-23 whole/shard/join results with typed complete-part replay +binding and kernel-scope assertions. It adds no positive verification run. +VR-23 copies its actual successful shard outputs for replay main/server/private +substitutions, missing bindings and failed replay; +original outputs and existing controls remain intact. Optional companion +presence is read from the actual record, never assumed. A deliberately inserted +companion is a substitution, not an observation about the original artifact. +Failed imported replay is expected at existing record assembly (LLV7003); +record-only tuple substitutions target +the final binding guard. Every failed part must leave no published files. + +No formatting, compilation, test, writer or identity update was run for this +follow-up. The completed real SP-05, diagnostic units and earlier focused +checks remain historical evidence for their exact source. This follow-up +requires independent source review and later explicitly admitted validation; +Atlas/gateway measurements, coordinated identities/artifacts and the full gate +remain owed. Existing checker prefix rechecks are unchanged; no globally +exactly-once kernel claim is made. + +The unexecuted follow-up was narrowed from six new negative joins to five +before validation: the newly proposed staged-companion mutation was removed +because an earlier Lean refusal would not establish extra final-guard evidence. +Existing actual-byte/path plants and the real positive whole/join staged +binding checks remain; no pre-existing acceptance assertion was removed. +The original six-plant patch and its review are preserved externally. + +## VR-28 real join and width follow-up: observed functional results + +On 2026-11-04, the reviewed five-plant follow-up above was formatted and +validated on the existing `ec6ba36fe` source preparation. The first build +attempt is retained in `/workspace/work/vr28-next-acceptance-validation/`: +its initial harness build succeeded, but its actual root probe found a stale +linked `repo-model` root. The admitted targeted official model clean ran; +the repair build then failed linking both the conformance test and Cargo's +automatically selected `bootstrap_perf` binary, with linker bus errors. +Free disk space was low, but the cause of those bus errors was not proved. +No fixture lock or test execution was reached by that attempt. + +Root separately retired two completely clean completed integration checkouts +through official Git worktree removal, retaining their commits, named refs, +restoration commands and evidence; this changed capacity, not build profiles, +source or cached proof policy. The receipt is retained in +`/workspace/work/completed-checkout-retirement-20261104/receipt.json`. +The admitted continuation reused the already formatted source without a +second formatting pass. Its Cargo-selected harness and actual linked model, +support and bootstrap-fixture roots matched this worktree; all 905 selected +embedded input paths and bytes and the errors table matched. The final test +executable was atomically transferred from its selected target path into the +phase's fresh frozen path, preserving its device, inode, byte count and hash, +and recording the original target's absence. The frozen CLI was reused; +no CLI or xtask executable was rebuilt for the continuation. + +One exact harness group ran `conformance_vr_21` and `conformance_vr_23` +serially: 2 passed, 0 failed, 468 filtered out, in 279.03 seconds. VR-21 +retained its real peano-arithmetic width-1/width-3 comparisons, scheduling and +failure controls, and production width-1/width-2 comparisons. VR-23 retained +the real whole/shard/join byte-tree and attestation equality and its original +negative controls. Five additional negative joins used separate copies of +those actual successful shard outputs: same-name main, server and private +replay-tuple substitutions and a missing binding reached the final binding +guard and refused with LLI9001; a failed imported replay was refused earlier +at record assembly with LLV7003. Every failed part checked no publication. +Optional companion presence came from actual records; deliberately inserted +companions were plants, not claims about the original files. No extra +positive verification was added by this follow-up. + +Exactly two original example locks, peano-arithmetic and production, were +saved, temporarily refreshed by the frozen official CLI, and restored byte +for byte. Only newly created owned helper directories, absent from the +preinventory and containing exactly one empty regular advisory guard, were +archived outside the fixtures. Frozen hashes and selected linked roots were +checked before and after the group; all 905 input bytes and both restored +locks were independently rehashed at the terminal boundary. After the group +passed, focused conformance-target Clippy with warnings denied, workspace +format checking and whitespace checking all passed. No completed SP-05, +diagnostic unit or kernel-false case was repeated. The tested Rust source +remained unchanged after formatting; this later entry records those results. + +Evidence is retained in +`/workspace/work/vr28-next-acceptance-continuation/`, including the original +results (SHA-256 `4d552fbd80c863f02568ca1d2a23c3158c3d4dab2ea7029c4f9e2c1c92f6588b`), +selected Cargo events, root/embedded provenance, frozen transfer receipt, +case logs, original locks and helper archives. This establishes provisional +functional results on this source preparation with prior product pins, +not final identity acceptance. Gateway and Atlas measurements, actual Atlas +publication-binding/invariance evidence, coordinated all-language identities +and generated artifacts, and the complete changed-head gate remain required. +The pinned checker's prefix rechecks remain; no globally exactly-once kernel +claim is made. No product writer, pin change, full gate, commit or push ran +as part of this focused continuation or this evidence append. diff --git a/crates/conformance/src/cases/operational.rs b/crates/conformance/src/cases/operational.rs index 5719b0f8ac..0feb6bfe34 100644 --- a/crates/conformance/src/cases/operational.rs +++ b/crates/conformance/src/cases/operational.rs @@ -74,6 +74,62 @@ fn assert_trees_equal( } } +/// Inspect existing successful outputs; do not run another verification. +fn assert_project_replay_bindings( + files: &std::collections::BTreeMap>, + expected: &BTreeSet, +) { + use lexlean::artifact::canonical_json::Json; + use lexlean::verify::child::ChildRecord; + + let Json::Obj(attestation) = + Json::parse(&files["attestation.json"]).expect("the published attestation parses") + else { + panic!("the attestation is an object"); + }; + let Json::Arr(processes) = &attestation["processes"] else { + panic!("the attestation contains the complete process list"); + }; + let records: Vec = processes + .iter() + .map(|json| ChildRecord::from_json(json).expect("a child record decodes")) + .collect(); + let mut compiled = BTreeSet::new(); + let mut unflagged = 0; + for record in &records { + let skipped = record + .argv + .iter() + .any(|arg| arg == "debug.skipKernelTC=true" || arg == "-Ddebug.skipKernelTC=true"); + let eligible = record.tool == "lean" + && record + .module + .as_ref() + .is_some_and(|name| expected.contains(name)); + assert_eq!(skipped, eligible, "unexpected kernel scope: {record:?}"); + if !eligible { + unflagged += usize::from(record.tool == "lean"); + continue; + } + let name = record.module.as_ref().expect("a project module"); + assert!(compiled.insert(name.clone()), "duplicate compile of {name}"); + assert_eq!(record.exit_code, 0); + let produced = record.olean.as_ref().expect("complete compile binding"); + let replays: Vec<_> = records + .iter() + .filter(|replay| replay.tool == "leanchecker" && replay.module.as_ref() == Some(name)) + .collect(); + assert_eq!(replays.len(), 1, "one replay record for {name}"); + assert_eq!(replays[0].exit_code, 0); + assert_eq!(replays[0].olean.as_ref(), Some(produced)); + } + assert_eq!( + &compiled, expected, + "every generated project module is bound" + ); + assert!(unflagged > 0, "in-process support checks remain exercised"); +} + /// VR-20: the width is an operational profile. fn width_is_operational() { assert_eq!(DEFAULT_WIDTH, 1, "the conservative profile is the default"); @@ -365,6 +421,15 @@ fn width_invariance() { ) .expect("width 1"); let one = tree(&at_one.root); + let expected: BTreeSet = crate::shards::import_graph( + support::repo_root() + .join("examples/peano-arithmetic") + .as_std_path(), + ) + .expect("the committed project module graph") + .into_keys() + .collect(); + assert_project_replay_bindings(&one, &expected); let attestation = |files: &std::collections::BTreeMap>| -> serde_json::Value { serde_json::from_slice(&files["attestation.json"]).expect("attestation parses") }; @@ -406,6 +471,7 @@ fn width_invariance() { .expect("width 3"); assert_eq!(verified.attestation_id, at_one.attestation_id); let three = tree(&verified.root); + assert_project_replay_bindings(&three, &expected); assert_trees_equal(&one, &three, "peano-arithmetic at widths 1 and 3"); let a3 = attestation(&three); assert_eq!( @@ -780,6 +846,8 @@ fn parts_equal_the_whole() { .as_std_path(), ) .expect("the import graph reads from the committed build"); + let expected = graph.keys().cloned().collect(); + assert_project_replay_bindings(&tree(&whole.root), &expected); let mut placed: std::collections::BTreeSet = std::collections::BTreeSet::new(); let mut remaining: Vec = graph.keys().cloned().collect(); let mut frontiers: Vec> = Vec::new(); @@ -820,6 +888,13 @@ fn parts_equal_the_whole() { part, ) }); + if outcome.is_err() { + let published = project.root.join(".lexlean/verified"); + assert!( + !published.exists() || support::file_set(&published).is_empty(), + "a refused part publishes nothing" + ); + } copies.borrow_mut().push(project); outcome }; @@ -864,6 +939,89 @@ fn parts_equal_the_whole() { "the join and the whole verification have one attestation identity" ); assert_trees_equal(&tree(&joined.root), &tree(&whole.root), "whole and joined"); + assert_project_replay_bindings(&tree(&joined.root), &expected); + + // Plant only copies of the actual successful shard outputs. Originals + // remain available to the pre-existing negative controls below. + let replayed = &first[0]; + let replay_relative = format!("process/leanchecker/{replayed}.json"); + let original_replay = std::fs::read(dir("b").join(&replay_relative)).expect("replay bytes"); + let replay_record = lexlean::verify::child::ChildRecord::from_json( + &lexlean::artifact::canonical_json::Json::parse(&original_replay) + .expect("actual replay JSON"), + ) + .expect("actual typed replay record"); + let original_parts = replay_record.olean.as_ref().expect("actual bound parts"); + for plant in [ + "main", + "server", + "private", + "missing-binding", + "failed-replay", + ] { + let changed_a = dir(&format!("plant-{plant}-a")); + let changed_b = dir(&format!("plant-{plant}-b")); + for (source, destination) in [(dir("a"), &changed_a), (dir("b"), &changed_b)] { + for (name, bytes) in tree(&source) { + let path = destination.join(name); + std::fs::create_dir_all(path.parent().expect("parent")).expect("mkdir"); + std::fs::write(path, bytes).expect("copy actual shard bytes"); + } + } + let mut record = replay_record.clone(); + match plant { + "main" | "server" | "private" => { + let digest = lexlean::artifact::content_id::Sha256Digest::of(plant.as_bytes()); + let parts = record.olean.as_mut().expect("actual bound parts"); + // Inserting a previously absent companion is an intentional + // substitution, not a claim that the original had that part. + match plant { + "main" => { + assert_ne!(original_parts.main, digest); + parts.main = digest; + } + "server" => { + assert_ne!(original_parts.server, Some(digest)); + parts.server = Some(digest); + } + "private" => { + assert_ne!(original_parts.private, Some(digest)); + if parts.server.is_none() { + parts.server = Some(digest); + } + parts.private = Some(digest); + } + _ => unreachable!(), + } + } + "missing-binding" => record.olean = None, + "failed-replay" => record.exit_code = 1, + _ => unreachable!(), + } + std::fs::write( + changed_b.join(&replay_relative), + record.to_json().to_file_bytes(), + ) + .expect("write planted replay"); + let error = run_part(VerifyPart::Join { + plan: plan(&rest, &rest), + parts: vec![changed_a, changed_b], + }) + .map(|_| ()) + .expect_err("a substituted actual shard output refuses publication"); + let text = error.to_string(); + if plant == "failed-replay" { + // Existing assembly judges failed imported replay before the guard. + support::expect_code(&error, "LLV7003"); + assert!(text.contains(replayed), "{text}"); + } else { + support::expect_code(&error, "LLI9001"); + assert!( + text.contains("kernel replay binding") && text.contains(replayed), + "{text}" + ); + } + } // A shard whose plan elaborates a module before its imports does not // converge, and names the import. From 494fc28a9fb571b20d8a0b9d738d631a0dbe7373 Mon Sep 17 00:00:00 2001 From: Alexander Flom Date: Wed, 4 Nov 2026 14:21:50 +0000 Subject: [PATCH 8/8] docs: record controlled gateway verification comparison --- VERIFICATION.md | 97 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 97 insertions(+) diff --git a/VERIFICATION.md b/VERIFICATION.md index 375855d1d9..09f11e6330 100644 --- a/VERIFICATION.md +++ b/VERIFICATION.md @@ -12742,3 +12742,100 @@ and generated artifacts, and the complete changed-head gate remain required. The pinned checker's prefix rechecks remain; no globally exactly-once kernel claim is made. No product writer, pin change, full gate, commit or push ran as part of this focused continuation or this evidence append. + +## VR-28 controlled public gateway pair: measured evidence + +On 2026-11-04, one new controlled pair completed on the source preparation +`104f755ae9b525df0765af08a13c68bfa715b577`, compared with unchanged pre-skip +`ed1deb0cbe26aa2330a464224fb01e7df2739920`. The public corpus was +`UOR-Foundation/lexlean-mcp` at +`991ab332608727306977c9850da6be182ab80071`, with MCP at +`c53816e24e16051b60fb6557b5d8ac456330c569` and PrismPM at +`706fb746100c1d220841d93820a035d07beb5323`. Its complete materialized input +manifest contains 323 files (SHA-256 +`4b0632d0c3d209e335387e74b52ab6d3cc0c2d30b0a8c809a4053160d110a60f`). +Both fresh copies retained all 11 configured entrypoints and their 58-module +closure. The four production roots were +`LexLeanMcpGateway.DraftAdmission.admitRun`, +`LexLeanMcpGateway.DraftAdmission.admitDraftRun`, +`LexLeanMcpGateway.Gateway.gatewayRun` and `LexLeanMcpGateway.Nfc.nfcRun`. +No `--all` expansion, narrowed selection or root substitution was used. +This public corpus is not asserted to be the author's historical WSL checkout. + +The independently frozen baseline CLI had SHA-256 +`3f72ffca8949262d50a1466660daa768d5d756017b6d0ecbead0cc66c8dcacdb`; +the candidate CLI had SHA-256 +`be50848d74ef98b4888bea67e29779076ca5d28426e69085dd54123ab4daa374`. +Each ran the supported `lexlean --project /gateway/lexlean.toml +lock` once, then `lexlean --project /gateway/lexlean.toml verify` +once. Both locks completed before either verification. There was no extra +standalone check, build, warmup or repeated verification. Baseline ran first, +candidate second, on the same host and pinned Lean 4.32.1, at width 1 without +hints or a memory-budget override. Each used fresh project, build, verification +and telemetry directories; no proof or verification artifact crossed runs. +Global OS and toolchain caches were left unchanged within the pair, so the +sequential order and cache effects remain limitations. + +| Observed seconds | Pre-skip ed1 | Candidate 104 | +| --- | ---: | ---: | +| Complete CLI verification wall | 1,863.117 | 1,243.365 | +| Available waited-child CPU, user plus system | 2,176.786 | 1,475.059 | +| Certificate generation stage | 153.742 | 153.209 | +| Project elaboration stage | 237.961 | 154.454 | +| Project replay stage | 146.720 | 146.105 | +| Extraction stage | 41.317 | 40.303 | +| Certificate stage | 1,258.461 | 724.466 | + +The wall observations use an outer monotonic clock. CPU is the available OS +waited-child accounting, not an assertion about total machine CPU. Raw I/O +operation, page-fault and context-switch counters and existing stage/process +RSS, swap and wall telemetry are retained. The table selects component stages; outer CLI wall time also includes work +outside the internal verifier interval. +The pair observed 619.752 seconds (33.264%) lower wall time for the candidate. +This measures the net implementation including required binding, final guard, +rehash and retention costs; it is not flag-only attribution, a general or +statistical performance estimate, or reproduction of the original WSL timing. + +Both complete verifications succeeded. Independent inspection found equal +official locks, source/semantic/build IDs, all 2,732 declaration policy and +observation rows, toolchain/workspace records, preservation records and selected +roots. Attestation identities differ, as expected for different executable and +process records; raw absolute-path artifact equality was not assumed. Each run +retained 230 process records and 233 genuine process telemetry events, with +successful begin/end and publication traces. These are observed counts, not +new fixed-count acceptance predicates. + +The candidate's 70 flagged compiles are exactly the 58 project modules plus +12 A/B/E modules. Each binds to a unique successful same-module replay with +its complete captured artifact parts. Project bindings have main, server and +private digests; the certificate bindings have main and genuinely absent +companions. Absence was not replaced with an empty-file digest. Runtime, +support, probe, extraction and audit compiles remain unflagged. All 323 original +inputs, both copied source sets and both independent frozen CLIs were preserved; +only each scratch copy's supported official lock was refreshed. Newly owned +empty advisory guards were archived outside the project copies. + +Original failed-build and empty-index attempts and their receipts remain +unchanged. The baseline build's selected cache aliases were subsequently +retired separately by an admitted official package-only Cargo clean; that +later capacity receipt is distinct from the immutable build/freeze snapshot. +Neither frozen binary changed. No cleanup, profile change or retry occurred +during the measured pair; the lowest coarse observed free space was 106 MiB. + +Terminal result `/workspace/work/vr28-public-controlled-pair/results.json` +has SHA-256 +`e5591ab5646ff2f2367df6c2c7f85784b2e6bc2c13401601d4d4ff1d061b1b42`; +independent actual review +`/workspace/work/vr28-stage3-independent-review/actual-review.json` has SHA-256 +`5a074c61c36e6cfeb9f4a3796245bd385f4537238c565e34af175b33a6147eab`. +Successful artifacts, raw telemetry and resource counters are retained beside +the terminal result. The reviewed public statement is +[#391 comment 6632959624](https://github.com/UOR-Foundation/LexLean/issues/391#issuecomment-6632959624). + +These are provisional preparation identities and measured gateway evidence, +not final acceptance. Actual Atlas publication binding/invariance and +measurements, coordinated all-language identities and artifacts, and the +complete final-head gate remain open. Existing checker prefix rechecks remain; +no globally exactly-once claim is made. Recording this evidence changed no implementation, pin or product and +repeated no conformance case. No test, build, product writer or CI run was +performed for this evidence append. This work is not included in the separate #393/#390 wave.