//! The core's build stamp (`build.rs`, `cotton_ffi::build_commit`).use std::ffi::CStr;use std::path::{Path, PathBuf};use std::process::Command;fn root() -> PathBuf { cotton_store::manifest_dir().parent().and_then(Path::parent).expect("the checkout").to_path_buf()}/// RULE: the core is stamped with crates/' content exactly as/// `scripts/lib/crates-tree.sh` reads it now, so `scripts/core-fresh.sh`/// passes a core built from this checkout and refuses one built from any/// other crates/: a walk on a stale core is not evidence (22 Oct 2026, a/// deck walked on a core without `@card`).#[test]fn the_stamp_is_this_checkouts_crates_as_the_check_reads_them() {let stamp = cotton_ffi::build_commit();let now = Command::new("bash").arg(root().join("scripts/lib/crates-tree.sh")).arg(root()).output().expect("bash runs"); assert!(now.status.success(), "crates-tree.sh: {}", String::from_utf8_lossy(&now.stderr)); assert_eq!(stamp.crates_tree, String::from_utf8_lossy(&now.stdout).trim()); assert_eq!(stamp.commit.len(), 40, "{stamp:?}");}/// RULE: `cotton_version` carries the commit as semver build metadata, so the/// app's launch line names the core it runs, not only the crate's version.#[test]fn the_version_names_the_commit() {let raw = cotton_ffi::ffi::cotton_version();let version = unsafe { CStr::from_ptr(raw) }.to_string_lossy().into_owned();unsafe { cotton_ffi::ffi::cotton_string_free(raw) };let short = cotton_ffi::build_commit().short().expect("a stamped build"); assert_eq!(version, format!("{}+{short}", env!("CARGO_PKG_VERSION")));}