Expand description
Lean 4 toolchain discovery, fingerprinting, allowlist re-export, and build-script helpers.
Sits one layer above lean_rs_abi, which owns link-free ABI/toolchain metadata. This crate
composes on top: a typed ToolchainFingerprint, the workspace-only Lake LAKE_FIXTURE_DIGEST, a layered
LinkDiagnostics error type, and reusable build-script helpers
(emit_lean_link_directives_checked, build_lake_target,
build_lake_target_quiet) that downstream embedders and higher layers can use to get
consistent link/rerun directives and Lake dylib paths without duplicating policy.
§Single typed entry point
LEAN_VERSION, LEAN_HEADER_PATH, LEAN_HEADER_DIGEST, and LEAN_RESOLVED_VERSION
are resolved by this crate’s build.rs (probing the active toolchain, degrading to the latest
supported entry when none is installed), so embedders need only one import for build metadata.
Live toolchain identity lives here, not in lean_rs_abi, which is purely static. The
allowlist comes through required_symbols (no copy).
§Layering
lean-rs-abi → lean-toolchain for link-free metadata, and lean-rs-sys → lean-rs
for raw runtime FFI. Raw lean_* symbols never appear in this crate’s public surface.
Re-exports§
pub use manifest_validation::CapabilityManifest;
Modules§
- manifest_
validation - Static, link-free validation of Lean capability manifests.
Structs§
- Built
Lean Capability - Metadata produced by
CargoLeanCapability. - Cargo
Lean Capability - Build-script helper for shipping a Rust crate with bundled Lean code.
- Discover
Options - Knobs that gate which discovery probes run.
- Generated
Source File - Source-root-relative generated file written during materialization.
- Lean
Built Capability - Runtime descriptor for a Lean capability built by a downstream
build.rs. - Lean
Export ArgAbi - ABI shape of one exported function argument.
- Lean
Export Return Abi - ABI shape of an exported result.
- Lean
Export Signature - Trusted manifest signature for one Lean export.
- Lean
Lake Project Modules - A discovered Lake project and its Lean modules.
- Lean
Library Dependency - Dependency dylib that must stay alive while a capability is loaded.
- Lean
Loader Check - One bounded preflight finding.
- Lean
Loader Report - Structured result of loader preflight for one capability manifest.
- Lean
Module Descriptor - A discovered Lean source module in a Lake project.
- Lean
Module Discovery Options - Options for Lake module discovery.
- Lean
Module Initializer - Initializer for a Lean module hosted by a loaded dylib.
- Lean
Module SetFingerprint - Stable facts about the discovered project source set.
- Materialized
Source Package - Materialized source package.
- Source
Package Materialization Request - Request to materialize a package-owned Lean source payload.
- Source
Package Provenance - Provenance sidecar for a materialized source package.
- Supported
Toolchain - One ABI-equivalence class in the supported toolchain window.
- Toolchain
Fingerprint - Typed identity of the Lean toolchain this crate was compiled against.
- Toolchain
Info - Outcome of a successful discovery.
Enums§
- Built
Capability Artifact - Which artifact a
LeanBuiltCapabilityresolution was looking for. - Discovery
Source - Which probe produced the resolved toolchain.
- Lean
Built Capability Error - Errors returned when resolving a
LeanBuiltCapabilitydescriptor. - Lean
Export AbiRepr - C ABI representation for one exported argument or result slot.
- Lean
Export Ownership - Ownership convention for one ABI slot.
- Lean
Export Result Convention - How an exported result is decoded.
- Lean
Export Symbol Kind - Whether an exported symbol is callable code or a Lean persistent global.
- Lean
Loader Diagnostic Code - Stable preflight diagnostic codes for manifest-backed capability loading.
- Lean
Loader Severity - Severity of one loader preflight finding.
- Lean
Module Discovery Diagnostic - Typed diagnostics for Lake module discovery.
- Link
Diagnostics - Reasons the Lean toolchain or its linkage could not be resolved.
- Source
Package Error - Source package materialization errors.
- Source
Package Manifest Policy - Validation policy for the materialized
lake-manifest.json.
Constants§
- CAPABILITY_
MANIFEST_ SCHEMA_ VERSION - Current JSON schema version for
CargoLeanCapabilityartifact manifests. - HOST_
TRIPLE - Cargo
TARGETtriplelean-toolchainwas built for. - LAKE_
FIXTURE_ DIGEST - SHA-256 over the workspace Lake fixture’s manifest plus compiled native artifacts.
- LEAN_
DIAGNOSTIC_ BYTE_ LIMIT_ DEFAULT - Default byte budget for the diagnostic collection returned per call (64 KiB ≈ 16 default-bounded messages).
- LEAN_
DIAGNOSTIC_ BYTE_ LIMIT_ MAX - Upper bound on the diagnostic byte budget (1 MiB).
- LEAN_
HEADER_ DIGEST - SHA-256 of the resolved
lean.h, lowercase hex. - LEAN_
HEADER_ PATH - Filesystem path to the
lean.hthis build resolved against, or a sentinel on a metadata-only build with no toolchain present. - LEAN_
HEARTBEAT_ LIMIT_ DEFAULT - Default heartbeat ceiling—matches Lean’s own
maxHeartbeatsdefault at 4.29.1 (Lean.Core.maxHeartbeats). - LEAN_
HEARTBEAT_ LIMIT_ MAX - Upper bound on the heartbeat ceiling. 1000× the default; values above saturate at this ceiling so a runaway elaborator finishes in bounded real time on every supported host.
- LEAN_
RESOLVED_ VERSION - Version string from the matched supported-toolchain entry (equal to
LEAN_VERSIONexcept when several releases share onelean.h). - LEAN_
VERSION LEAN_VERSION_STRINGread from the active toolchain’sversion.h, or the latest supported version on a metadata-only build with no toolchain present.- LOADER_
DIAGNOSTIC_ TEXT_ LIMIT - Maximum bytes preserved in user-facing loader diagnostic strings.
- SUPPORTED_
TOOLCHAINS - The supported Lean toolchain window.
- VERSION
- Version of the
lean-toolchaincrate, matchingCargo.toml.
Functions§
- bound_
loader_ text - Truncate
textto at mostLOADER_DIAGNOSTIC_TEXT_LIMITbytes on a UTF-8 char boundary. - build_
lake_ target - Build a Lake
lean_libshared-library target and return the produced dylib path. - build_
lake_ target_ quiet - Build a Lake
lean_libshared-library target without emitting Cargo build-script directives. - capability_
env_ var - Default Cargo environment variable for a Lean capability target.
- capability_
manifest_ env_ var - Default Cargo environment variable for a Lean capability artifact manifest.
- discover_
lake_ modules - Discover Lean modules in a Lake project.
- discover_
toolchain - Resolve a Lean toolchain following the documented probe precedence.
- emit_
lean_ link_ directives - Emit Lean link-search, link-lib, and runtime rpath directives plus
matching rerun triggers from a downstream
build.rs. - emit_
lean_ link_ directives_ checked - Emit Lean link-search, link-lib, and runtime rpath directives, returning typed diagnostics if the active Lean toolchain cannot be resolved.
- materialize_
source_ package - Materialize a package-owned Lean source payload into a digest-keyed cache.
- required_
symbols - Curated allowlist of
LEAN_EXPORTsymbols the workspace relies on. - supported_
by_ digest - Return the
SupportedToolchainentry whoseheader_digestmatches the given lowercase-hex SHA-256 string, if any. - supported_
for - Return the
SupportedToolchainentry that includesversion, if any.