Owner decision 2026-11-23: the vendored Strata tree engine/strata is removed for good. This first step moves what is still read at build, test or ship time into one small directory, byte for byte: - third_party/strata/LICENSE (MIT; `leleka engine license` embeds it, the packagers ship it) - third_party/strata/ggml/LICENSE, project-maya/LICENSE, project-maya/NOTICE.md (licence texts the release packager ships) - third_party/strata/serve/chat_template.jinja (one copy, embedded by control-plane server_api.rs and gateway-text prompt.rs) - third_party/strata/serve/chat_golden.json (gateway-text prompt tests) - third_party/strata/tests/data/native_experts/*.txt (control-plane native_pack tests) - control-plane/tests/mcp_hub/mcp_fake_server.py next to its test harness - third_party/strata/UPSTREAM.md replaces engine/upstream.md: pin 41cf05a0, URL, the 25 locally patched files, where the removed tree is in history include_str! paths, deploy/build.rs (the `leleka version` Strata pin now reads third_party/strata/UPSTREAM.md), Dockerfile.static-cli, .dockerignore, .gitattributes, the release packagers (package-5090.sh, package-release.py: the subtree facts of the removed tree are dropped from PROVENANCE) and the evidence capture scripts follow the move. The tree itself is deleted in a later commit.
96 lines
3.8 KiB
Rust
96 lines
3.8 KiB
Rust
//! Build identity for `leleka version`.
|
|
//!
|
|
//! Embeds the git commit of the tree the binary was built from, whether that tree had uncommitted changes, and the
|
|
//! Strata upstream pin recorded in `third_party/strata/UPSTREAM.md`. The release packager (`scripts/release/package-5090.sh`)
|
|
//! exports `LELEKA_GIT_COMMIT` and `LELEKA_GIT_DIRTY` so the values do not depend on `git` being callable from the
|
|
//! build script; an ordinary developer build asks git itself and falls back to `unknown` (an exported tree has
|
|
//! no `.git`).
|
|
//! Nothing here reads the network or changes the generated code of the engine.
|
|
|
|
use std::path::{Path, PathBuf};
|
|
use std::process::Command;
|
|
|
|
fn git(repo: &Path, args: &[&str]) -> Option<String> {
|
|
let output = Command::new("git")
|
|
.args(args)
|
|
.current_dir(repo)
|
|
.output()
|
|
.ok()?;
|
|
if !output.status.success() {
|
|
return None;
|
|
}
|
|
Some(String::from_utf8_lossy(&output.stdout).trim().to_owned())
|
|
}
|
|
|
|
/// The 40-hex commit on the `Upstream commit SHA` row of the pin table in `third_party/strata/UPSTREAM.md`.
|
|
fn upstream_pin(doc: &Path) -> Option<String> {
|
|
let text = std::fs::read_to_string(doc).ok()?;
|
|
let line = text
|
|
.lines()
|
|
.find(|line| line.contains("Upstream commit SHA"))?;
|
|
let start = line.find('`')? + 1;
|
|
let end = start + line[start..].find('`')?;
|
|
let sha = &line[start..end];
|
|
(sha.len() == 40 && sha.bytes().all(|b| b.is_ascii_hexdigit()))
|
|
.then(|| sha.to_ascii_lowercase())
|
|
}
|
|
|
|
fn main() {
|
|
let manifest = PathBuf::from(
|
|
std::env::var_os("CARGO_MANIFEST_DIR").expect("cargo sets CARGO_MANIFEST_DIR"),
|
|
);
|
|
let repo = manifest.join("..").join("..");
|
|
let doc = repo.join("third_party").join("strata").join("UPSTREAM.md");
|
|
emit_reruns(&repo, &doc);
|
|
let commit = std::env::var("LELEKA_GIT_COMMIT")
|
|
.ok()
|
|
.filter(|value| !value.trim().is_empty())
|
|
.or_else(|| git(&repo, &["rev-parse", "HEAD"]))
|
|
.unwrap_or_else(|| "unknown".to_owned());
|
|
let dirty = tree_state(&repo);
|
|
let pin = upstream_pin(&doc).unwrap_or_else(|| "unknown".to_owned());
|
|
|
|
println!("cargo:rustc-env=LELEKA_BUILD_COMMIT={commit}");
|
|
println!("cargo:rustc-env=LELEKA_BUILD_TREE={dirty}");
|
|
println!("cargo:rustc-env=LELEKA_BUILD_STRATA_PIN={pin}");
|
|
println!(
|
|
"cargo:rustc-env=LELEKA_BUILD_TARGET={}",
|
|
std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_owned())
|
|
);
|
|
println!(
|
|
"cargo:rustc-env=LELEKA_BUILD_PROFILE={}",
|
|
std::env::var("PROFILE").unwrap_or_else(|_| "unknown".to_owned())
|
|
);
|
|
}
|
|
|
|
/// When cargo has to run this script again: the packager variables, the pin document, a commit or a branch switch.
|
|
fn emit_reruns(repo: &Path, doc: &Path) {
|
|
println!("cargo:rerun-if-env-changed=LELEKA_GIT_COMMIT");
|
|
println!("cargo:rerun-if-env-changed=LELEKA_GIT_DIRTY");
|
|
println!("cargo:rerun-if-changed={}", doc.display());
|
|
// A commit moves the reflog of HEAD; a branch switch moves HEAD itself.
|
|
for name in ["HEAD", "logs/HEAD"] {
|
|
if let Some(path) = git(repo, &["rev-parse", "--git-path", name]) {
|
|
println!("cargo:rerun-if-changed={}", repo.join(path).display());
|
|
}
|
|
}
|
|
}
|
|
|
|
/// `clean`, `dirty` or `unknown`: from the packager variable, else from git.
|
|
fn tree_state(repo: &Path) -> &'static str {
|
|
match std::env::var("LELEKA_GIT_DIRTY")
|
|
.ok()
|
|
.filter(|value| !value.trim().is_empty())
|
|
{
|
|
Some(value) => match value.trim() {
|
|
"0" | "no" | "false" | "clean" => "clean",
|
|
_ => "dirty",
|
|
},
|
|
None => match git(repo, &["status", "--porcelain", "--untracked-files=no"]) {
|
|
Some(status) if status.is_empty() => "clean",
|
|
Some(_) => "dirty",
|
|
None => "unknown",
|
|
},
|
|
}
|
|
}
|