Expand description
Lean 4 toolchain discovery, fingerprinting, allowlist re-export, and build-script helpers.
Sits one layer above the workspace crate lean_rs_sys, which owns the raw extern "C"
declarations, the hand-written refcount inline helpers, the signature-checked symbol
allowlist, the header SHA-256 digest, and the link directives. 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, and LEAN_HEADER_DIGEST are re-exported from
lean_rs_sys so embedders that depend on this crate need only one import for build
metadata. The allowlist comes through required_symbols (no copy).
§Layering
lean-rs-sys → lean-toolchain → lean-rs. Raw lean_* symbols never appear in this
crate’s public surface — they remain in lean-rs-sys and reach the safe layers through
lean-rs’s pub(crate) modules.
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.
- Lean
Built Capability - Runtime descriptor for a Lean capability built by a downstream
build.rs. - 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.
- 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
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.
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. Computed bybuild.rsand equal to theheader_digestof the matchedSupportedToolchainentry. - LEAN_
HEADER_ PATH - Filesystem path to the
lean.hthat the build was resolved against. - 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_
VERSION LEAN_VERSION_STRINGas read from the active toolchain’sversion.h(e.g."4.29.1").- LOADER_
DIAGNOSTIC_ TEXT_ LIMIT - Maximum bytes preserved in user-facing loader diagnostic strings.
- 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.
- required_
symbols - Curated allowlist of
LEAN_EXPORTsymbols the workspace relies on.