Merge main (embedded expert profile) into single-copy

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Pavlo Ratushnyi
2026-11-02 22:17:46 +01:00
co-authored by Claude Sonnet 5.5
16 changed files with 279 additions and 43 deletions
+3
View File
@@ -15,3 +15,6 @@ scripts/e2e/codex/delta/** text eol=lf
# The release packager and the files it copies into the tarball are POSIX shell and systemd text: LF everywhere.
scripts/release/** text eol=lf
deploy/rust-runtime/** text eol=lf
# The embedded expert profile is pinned by SHA-256 in the sources: the bytes in the working tree must be the bytes in the index on every platform.
crates/deploy/data/expert-profile.bin -text binary
+4
View File
@@ -41,3 +41,7 @@ logs/
# Release tarballs made by scripts/package-release.py and build output
dist/
# The one binary kept in Git: upstream Strata's ranked expert profile (196,632 B, MIT, sha256 8f59b4aa...388975baf), embedded in `leleka`
# (crates/deploy/src/expert_profile.rs; attribution in crates/deploy/data/expert-profile.NOTICE). Every other *.bin stays ignored.
!crates/deploy/data/expert-profile.bin
+31
View File
@@ -0,0 +1,31 @@
expert-profile.bin
The ranked expert-usage table (Strata "STRP" v1, 24,576 (layer, expert) pairs of Qwen3.8-Flash-Next, 196,632 bytes,
sha256 8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf) is the file data/expert-profile.bin of the Strata
project, https://github.com/Niko1221/Strata at commit 41cf05a06a25dd29103b7b27a2279a3f60c21876 (byte-identical at
d9ab8435f654c368c586340d490915f6addf56a3). It is copied unchanged and embedded in the `leleka` binary
(crates/deploy/src/expert_profile.rs); `leleka up` writes it to ASSETS/data/expert-profile.bin after checking the digest.
Strata is distributed under the MIT License:
MIT License
Copyright (c) 2026 Niko1221 and the Strata contributors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Binary file not shown.
+4 -3
View File
@@ -50,9 +50,10 @@ UP / PREFLIGHT OPTIONS
strict re-derivation (hours-scale); the engine still checks its SHA-256 and every
CRC against the pinned digest at each load
--mtp-pack PATH import the MTP pack (directory or .tar/.tar.gz of data/mtp-rt) into the assets
--expert-profile-file PATH offline: install this copy of the upstream data/expert-profile.bin (the ranked VRAM
expert tier; sha256 8f59b4aa...388975baf is checked). Without it `up` downloads the
file from its pinned upstream commit and fails closed on any other digest
--expert-profile-file PATH install this copy of the upstream data/expert-profile.bin (the ranked VRAM expert tier;
sha256 8f59b4aa...388975baf is checked) instead of the table embedded in this binary.
Without it `up` installs the embedded table (works offline), downloads it from its
pinned upstream commit only if that fails, and fails closed on any other digest
--no-expert-tier run without the ranked VRAM expert tier (much slower decode); status and verify say OFF
--cublas-dir DIR use this CUDA 12 cuBLAS directory instead of searching / downloading
--no-install-cublas fail instead of downloading cuBLAS 12.9.1.4
+151 -8
View File
@@ -1,7 +1,7 @@
//! The ranked expert-usage table (`data/expert-profile.bin`): provisioning, verification and the "expert tier ON/OFF" report.
//!
//! What the file is, and why it is fetched rather than generated
//! -------------------------------------------------------------
//! What the file is, and why it is shipped rather than generated
//! --------------------------------------------------------------
//! It is Strata's `STRP` v1 table: all 48 x 512 = 24,576 (layer, expert) pairs of the Qwen3.8-Flash-Next model, ranked by how
//! often a calibration workload routed to them, plus the inverse slot table (24 + 4 x 24,576 + 4 x 48 x 512 = 196,632 bytes).
//! `--expert-cache auto` fills the VRAM expert slots in that order (`engine/strata/tools/make_profile.py`, header comment).
@@ -17,8 +17,12 @@
//! byte-identical at the pin `41cf05a0` and at the older pin `d9ab8435` (`docs/upstream.md` lists it as left out of the import
//! because `*.bin` is git-ignored). Commit-pinned raw URLs are immutable content; the SHA-256 is what is trusted, not the URL.
//!
//! Policy: the expert tier is never silently lost. `leleka up` provisions the file (download or `--expert-profile-file`),
//! checks the pinned digest, installs it atomically and fails closed; `--no-expert-tier` is the explicit opt-out. `status`,
//! * The 192 KiB file is small, so the exact upstream bytes are committed (`crates/deploy/data/expert-profile.bin`, the one
//! `*.bin` exception in `.gitignore`; MIT notice in `crates/deploy/data/expert-profile.NOTICE`) and embedded in the
//! binary with `include_bytes!`. First start therefore works offline.
//!
//! Policy: the expert tier is never silently lost. `leleka up` provisions the file (`--expert-profile-file`, else the bytes
//! embedded in the binary, else a download), checks the pinned digest, installs it atomically and fails closed; `--no-expert-tier` is the explicit opt-out. `status`,
//! `verify`, the ready summary and the supervisor log all say ON with the digest, or OFF with the reason.
use crate::{config::RunConfig, profile::Profile};
use serde::Serialize;
@@ -33,6 +37,15 @@ use std::{
pub const PINNED_SHA256: &str = "8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf";
/// Its length: 24-byte header, 24,576 (layer, expert) u16 pairs, 48 x 512 i32 slot table.
pub const PINNED_BYTES: u64 = 196_632;
/// The upstream table, compiled into the binary (`crates/deploy/data/expert-profile.bin`; pinned by [`PINNED_SHA256`], which a
/// unit test checks, and checked again before every install).
pub static EMBEDDED: &[u8] = include_bytes!("../data/expert-profile.bin");
/// The embedded table when it is the one with digest `expected` (a profile that pins another digest gets `None`).
pub fn embedded_for(expected: &str) -> Option<&'static [u8]> {
(sha256_hex(EMBEDDED) == expected).then_some(EMBEDDED)
}
/// Nothing larger is hashed or accepted (the pinned file is 192 KiB).
pub const MAX_BYTES: u64 = 1 << 20;
/// The Strata commit the sources below are pinned to (`docs/upstream.md`).
@@ -121,7 +134,9 @@ pub struct Request<'a> {
pub expected: &'a str,
/// `--expert-profile-file`: install this file instead of downloading (the offline route).
pub local: Option<&'a Path>,
/// Download sources in order (empty: no download is attempted).
/// The table compiled into the binary ([`embedded_for`]): installed before any download, so first start works offline.
pub embedded: Option<&'a [u8]>,
/// Download sources in order, the fallback after the embedded bytes (empty: no download is attempted).
pub sources: &'a [&'a str],
}
@@ -156,8 +171,13 @@ fn commit(part: &Path, dest: &Path, expected: &str) -> Result<Option<PathBuf>, S
Ok(moved)
}
/// `Outcome::Installed::origin` of the bytes compiled into the binary.
pub const EMBEDDED_ORIGIN: &str = "the table embedded in this leleka binary";
/// Put a file with the expected digest at `request.dest`, or fail with a message that says what to do.
///
/// Order: `local` (explicit), the `embedded` bytes, then the download sources.
///
/// `fetch(url, part)` downloads one URL to `part` (the caller picks the tool; tests pass a fake). A source that fails or
/// returns another digest is skipped; when none works the error names every failure and the two ways out
/// (`--expert-profile-file PATH`, `--no-expert-tier`). Nothing unverified is ever left at `dest`.
@@ -192,14 +212,36 @@ pub fn provision(
moved_aside,
});
}
let mut failures = Vec::new();
if let Some(bytes) = request.embedded {
let result = std::fs::write(&part, bytes)
.map_err(|e| format!("cannot write {}: {e}", part.display()))
.and_then(|()| commit(&part, request.dest, request.expected));
match result {
Ok(moved_aside) => {
return Ok(Outcome::Installed {
origin: EMBEDDED_ORIGIN.to_owned(),
moved_aside,
});
}
Err(message) => {
let _ = std::fs::remove_file(&part);
failures.push(format!("{EMBEDDED_ORIGIN}: {message}"));
}
}
}
if request.sources.is_empty() {
return Err(format!(
"no download source is known for sha256 {}; copy the file to {} or pass --expert-profile-file PATH",
"no download source is known for sha256 {}{}; copy the file to {} or pass --expert-profile-file PATH",
request.expected,
if failures.is_empty() {
String::new()
} else {
format!(" ({})", failures.join("; "))
},
request.dest.display()
));
}
let mut failures = Vec::new();
for url in request.sources {
let result = fetch(url, &part).and_then(|()| commit(&part, request.dest, request.expected));
match result {
@@ -332,7 +374,7 @@ pub fn tier_report_with(
match state() {
FileState::Absent => off(
format!(
"{shown} is missing; run `leleka up` (it fetches the pinned table) or pass --expert-profile-file PATH"
"{shown} is missing; run `leleka up` (it installs the pinned table) or pass --expert-profile-file PATH"
),
false,
Some(shown),
@@ -436,6 +478,99 @@ mod tests {
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn the_embedded_table_is_the_pinned_upstream_file() {
assert_eq!(EMBEDDED.len() as u64, PINNED_BYTES);
assert_eq!(sha256_hex(EMBEDDED), PINNED_SHA256);
assert_eq!(&EMBEDDED[..4], b"STRP");
assert!(embedded_for(PINNED_SHA256).is_some());
assert!(embedded_for(&fixture_digest()).is_none());
}
#[test]
fn the_embedded_table_is_installed_offline_before_any_download() {
let dir = temp("embedded");
let dest = dir.join("data").join("expert-profile.bin");
let mut never = |_: &str, _: &Path| -> Result<(), String> {
panic!("offline: the embedded table must be used before any download")
};
let request = Request {
dest: &dest,
expected: PINNED_SHA256,
local: None,
embedded: embedded_for(PINNED_SHA256),
sources: &SOURCES,
};
assert_eq!(
provision(&request, &mut never).unwrap(),
Outcome::Installed {
origin: EMBEDDED_ORIGIN.into(),
moved_aside: None
}
);
assert_eq!(file_state(&dest, PINNED_SHA256), FileState::Valid);
assert!(!with_suffix(&dest, ".part").exists());
assert_eq!(
provision(&request, &mut never).unwrap(),
Outcome::AlreadyPresent
);
// an explicit file wins over the embedded table
let other = dir.join("other.bin");
std::fs::write(&other, EMBEDDED).unwrap();
let second = dir.join("second").join("p.bin");
let outcome = provision(
&Request {
dest: &second,
local: Some(&other),
..request
},
&mut never,
)
.unwrap();
assert!(
matches!(outcome, Outcome::Installed { origin, .. } if origin.ends_with("other.bin"))
);
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn an_embedded_table_that_fails_its_digest_falls_back_to_the_download() {
let dir = temp("embedded-bad");
let dest = dir.join("expert-profile.bin");
let digest = fixture_digest();
let mut fetch =
|_: &str, part: &Path| std::fs::write(part, FIXTURE).map_err(|e| e.to_string());
let request = Request {
dest: &dest,
expected: &digest,
local: None,
embedded: Some(b"corrupted copy"),
sources: &["https://one.test/p.bin"],
};
assert_eq!(
provision(&request, &mut fetch).unwrap(),
Outcome::Installed {
origin: "https://one.test/p.bin".into(),
moved_aside: None
}
);
// ... and without a source the failure names the embedded table
let _ = std::fs::remove_file(&dest);
let error = provision(
&Request {
sources: &[],
..request
},
&mut fetch,
)
.unwrap_err();
assert!(
error.contains("embedded") && error.contains("is not the expected"),
"{error}"
);
let _ = std::fs::remove_dir_all(dir);
}
#[test]
fn a_download_is_verified_then_installed_and_a_present_file_is_left_alone() {
let dir = temp("download");
@@ -450,6 +585,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: None,
embedded: None,
sources: &["https://one.test/p.bin", "https://two.test/p.bin"],
};
let outcome = provision(&request, &mut fetch).unwrap();
@@ -486,6 +622,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: None,
embedded: None,
sources: &["https://one.test/p.bin", "https://two.test/p.bin"],
};
let error = provision(&request, &mut fetch).unwrap_err();
@@ -519,6 +656,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: None,
embedded: None,
sources: &["https://down.test/p.bin", "https://up.test/p.bin"],
};
assert_eq!(
@@ -548,6 +686,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: Some(&bad),
embedded: None,
sources: &["https://x.test/p"],
},
&mut never,
@@ -563,6 +702,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: Some(&good),
embedded: None,
sources: &["https://x.test/p"],
},
&mut never,
@@ -581,6 +721,7 @@ mod tests {
dest: &dir.join("other.bin"),
expected: &digest,
local: Some(&dir.join("nope.bin")),
embedded: None,
sources: &[],
},
&mut never,
@@ -603,6 +744,7 @@ mod tests {
dest: &dest,
expected: &digest,
local: None,
embedded: None,
sources: &["https://one.test/p.bin"],
},
&mut fetch,
@@ -629,6 +771,7 @@ mod tests {
dest: &dir.join("p.bin"),
expected: &fixture_digest(),
local: None,
embedded: None,
sources: &[],
},
&mut fetch,
+37 -19
View File
@@ -787,6 +787,7 @@ fn expert_profile_step(ctx: &Context) -> Step {
let dest = opts.dirs.assets.join(relative);
let expected = expected_digest(profile);
let shown = short_digest(expected);
let embedded = crate::expert_profile::embedded_for(expected);
let flag_hint = "pass --expert-profile-file PATH (a copy of the upstream data/expert-profile.bin) or --no-expert-tier";
let state = match &ctx.needs.expert_profile {
Some(ExpertProfileState::OptedOut) => StepState::Skip("--no-expert-tier: the VRAM expert tier is OFF (explicit opt-out; decode is much slower)".into()),
@@ -801,9 +802,11 @@ fn expert_profile_step(ctx: &Context) -> Step {
))
} else if wrong {
StepState::Blocked(format!(
"{} does not have the expected sha256 {shown} and is not used. Move it aside and rerun (`up` then downloads the pinned table), or {flag_hint}. A table of your own needs a profile with its own expert_profile_sha256 and a quality gate",
"{} does not have the expected sha256 {shown} and is not used. Move it aside and rerun (`up` then installs the pinned table), or {flag_hint}. A table of your own needs a profile with its own expert_profile_sha256 and a quality gate",
dest.display()
))
} else if let Some(bytes) = embedded {
StepState::Todo(format!("install the {}-byte table embedded in this binary (sha256 {shown} checked; no network needed)", bytes.len()))
} else if !opts.fetch {
StepState::Blocked(format!("{} is missing and --no-fetch was given; {flag_hint}", dest.display()))
} else if expected != PINNED_SHA256 {
@@ -820,12 +823,20 @@ fn expert_profile_step(ctx: &Context) -> Step {
id,
title,
state,
vec![format!(
"curl -fsSL --proto =https -o {}.part {} (sha256 {})",
dest.display(),
SOURCES[0],
expected
)],
vec![if embedded.is_some() {
format!(
"write {0}.part from the embedded table, check sha256 {1}, rename to {0}",
dest.display(),
expected
)
} else {
format!(
"curl -fsSL --proto =https -o {}.part {} (sha256 {})",
dest.display(),
SOURCES[0],
expected
)
}],
)
}
@@ -1151,16 +1162,14 @@ mod tests {
assert!(
matches!(expert_step(&[], ExpertProfileState::Valid), StepState::Done(why) if why.contains("8f59b4aa...388975baf"))
);
// missing: downloaded (the test host has curl)
assert!(
matches!(expert_step(&[], ExpertProfileState::Absent), StepState::Todo(why) if why.contains("196632"))
);
// missing and offline: blocked with both ways out
let blocked = expert_step(&["--no-fetch"], ExpertProfileState::Absent);
assert!(
matches!(&blocked, StepState::Blocked(why) if why.contains("--expert-profile-file") && why.contains("--no-expert-tier")),
"{blocked:?}"
);
// missing: the table embedded in the binary is installed, with or without network
for extra in [&[][..], &["--no-fetch"]] {
let embedded = expert_step(extra, ExpertProfileState::Absent);
assert!(
matches!(&embedded, StepState::Todo(why) if why.contains("196632-byte table embedded") && why.contains("no network")),
"{embedded:?}"
);
}
// the offline route installs from the local file
let local = expert_step(
&[
@@ -1197,18 +1206,27 @@ mod tests {
}
#[test]
fn a_host_without_curl_or_wget_blocks_the_download_but_not_the_local_file() {
fn only_a_profile_with_another_digest_needs_a_download_or_a_file() {
let mut ctx = context(
options(&[]),
Mode::Foreground,
"NVIDIA GeForce RTX 5090",
120,
);
// no curl or wget: the embedded table does not need them
ctx.facts.tools.insert("curl".into(), false);
ctx.needs.expert_profile = Some(ExpertProfileState::Absent);
let steps = plan_steps(&ctx, &FsState::default());
assert!(
matches!(state_of(&steps, "expert-profile"), StepState::Blocked(why) if why.contains("neither curl nor wget"))
matches!(state_of(&steps, "expert-profile"), StepState::Todo(why) if why.contains("embedded in this binary"))
);
// a profile that pins another digest has no embedded table and no download source: blocked with both ways out
ctx.profile.as_mut().unwrap().expert_profile_sha256 = Some("ab".repeat(32));
let steps = plan_steps(&ctx, &FsState::default());
assert!(
matches!(state_of(&steps, "expert-profile"), StepState::Blocked(why) if why.contains("--expert-profile-file") && why.contains("--no-expert-tier")),
"{:?}",
state_of(&steps, "expert-profile")
);
ctx.opts.expert_profile_file = Some("/x/p.bin".into());
let steps = plan_steps(&ctx, &FsState::default());
+3 -3
View File
@@ -748,7 +748,7 @@ pub fn evaluate(facts: &Facts, profile: &Profile, needs: &Needs) -> Report {
if let Some(relative) = profile.expert_profile.as_deref() {
let pinned = crate::expert_profile::short_digest(crate::expert_profile::expected_digest(profile));
let path = needs.assets_dir.join(relative).display().to_string();
let way_out = "run `leleka up` (it downloads the pinned table and checks the digest), or pass --expert-profile-file PATH offline; --no-expert-tier accepts the slower decode";
let way_out = "run `leleka up` (it installs the pinned table that is embedded in the binary, or downloads it, and checks the digest), or pass --expert-profile-file PATH offline; --no-expert-tier accepts the slower decode";
match &needs.expert_profile {
Some(ExpertProfileState::Valid) => checks.push(pass(
"expert-profile",
@@ -759,7 +759,7 @@ pub fn evaluate(facts: &Facts, profile: &Profile, needs: &Needs) -> Report {
"expert-profile",
Level::Warn,
"VRAM expert tier",
format!("OFF until fetched: {path} is not in the assets directory; without the ranked table the engine runs without the VRAM expert tier (much slower)"),
format!("OFF until installed: {path} is not in the assets directory; without the ranked table the engine runs without the VRAM expert tier (much slower)"),
Some(way_out.into()),
)),
Some(ExpertProfileState::WrongDigest) => checks.push(check(
@@ -877,7 +877,7 @@ mod tests {
assert_eq!(level_of(&report, "expert-profile"), Level::Pass);
assert!(report.render().contains("ON:") && report.render().contains("8f59b4aa...388975baf"));
for (state, needle) in [
(ExpertProfileState::Absent, "OFF until fetched"),
(ExpertProfileState::Absent, "OFF until installed"),
(ExpertProfileState::WrongDigest, "does not have the pinned sha256"),
(ExpertProfileState::OptedOut, "--no-expert-tier was given"),
] {
+5 -2
View File
@@ -524,8 +524,8 @@ fn download_small(tool: &str, url: &str, part: &Path, log: &Path) -> Result<(),
}
}
/// The `expert-profile` step: install the pinned upstream table from `--expert-profile-file` or by download, verified
/// against the profile's digest, atomically; fails closed (`expert_profile::provision`).
/// The `expert-profile` step: install the pinned upstream table from `--expert-profile-file`, else from the bytes embedded in
/// this binary, else by download, verified against the profile's digest, atomically; fails closed (`expert_profile::provision`).
pub fn provision_expert_profile(ctx: &Context) -> Result<(), String> {
use crate::expert_profile::{Outcome, Request, SOURCES, expected_digest, provision};
let profile = ctx.profile.as_ref().map_err(String::clone)?;
@@ -550,6 +550,7 @@ pub fn provision_expert_profile(ctx: &Context) -> Result<(), String> {
dest: &dest,
expected,
local: ctx.opts.expert_profile_file.as_deref(),
embedded: crate::expert_profile::embedded_for(expected),
sources,
};
let mut fetch = |url: &str, part: &Path| {
@@ -1304,6 +1305,7 @@ mod tests {
dest: &dest,
expected: PINNED_SHA256,
local: None,
embedded: None,
sources: &SOURCES,
};
let outcome = provision(&request, &mut |url, part| {
@@ -1320,6 +1322,7 @@ mod tests {
dest: &other,
expected: PINNED_SHA256,
local: None,
embedded: None,
sources: &[
"https://raw.githubusercontent.com/Niko1221/Strata/41cf05a06a25dd29103b7b27a2279a3f60c21876/LICENSE",
],
+1 -1
View File
@@ -657,7 +657,7 @@ async fn doctor(args: &[String]) -> i32 {
if volume_missing.is_empty() {
println!(
" complete{}",
if crate::doctor::expert_profile_present(&paths) { "" } else { " (data\\expert-profile.bin is absent or not the pinned table: `leleka up` downloads it, or pass --expert-profile-file; without it the VRAM expert tier is OFF)" }
if crate::doctor::expert_profile_present(&paths) { "" } else { " (data\\expert-profile.bin is absent or not the pinned table: `leleka up` installs it, or pass --expert-profile-file; without it the VRAM expert tier is OFF)" }
);
}
let inputs = crate::doctor::Inputs {
+32
View File
@@ -1198,6 +1198,38 @@ async fn up_installs_the_expert_profile_offline_and_reports_it() {
assert!(!report.on && report.opted_out && report.line().contains("explicit opt-out"), "{}", report.line());
}
#[tokio::test]
async fn first_start_installs_the_embedded_expert_profile_without_a_network() {
use leleka_deploy::expert_profile::{
FileState, PINNED_BYTES, PINNED_SHA256, file_state, tier_report,
};
let fixture = Fixture::new("embedded");
let bin_src = fixture.root.join("release/bin");
fixture.install_fake_binaries(&bin_src);
let (cublas, mtp) = (fixture.root.join("cublas"), fixture.root.join("mtp-src"));
fake_libraries(&cublas);
mtp_source(&mtp);
// The real 3080 profile pins the upstream table; no --no-expert-tier, no --expert-profile-file, no network tool on PATH.
let opts = up_options_with(&fixture, &bin_src, &cublas, &mtp, "rtx3080-16g", &["--no-fetch"]);
let mut ctx = healthy_context(&opts);
ctx.facts.tools.insert("curl".into(), false);
ctx.facts.tools.insert("wget".into(), false);
let steps = plan_steps(&ctx, &gather_fs(&ctx).await);
let step = steps.iter().find(|s| s.id == "expert-profile").unwrap();
assert_eq!(step.state.tag(), "todo", "{step:?}");
assert!(step.state.why().contains("embedded in this binary"), "{step:?}");
leleka_deploy::steps::provision_expert_profile(&ctx).unwrap();
let table = fixture.dirs.assets.join("data/expert-profile.bin");
assert_eq!(file_state(&table, PINNED_SHA256), FileState::Valid);
assert_eq!(fs::metadata(&table).unwrap().len(), PINNED_BYTES);
let config = ctx.config.as_ref().unwrap();
let report = tier_report(config, &fixture.dirs.assets);
assert!(report.on && report.line().contains("8f59b4aa...388975baf"), "{}", report.line());
// Re-planned: nothing left to do.
let steps = plan_steps(&healthy_context(&opts), &FsState::default());
assert_eq!(steps.iter().find(|s| s.id == "expert-profile").unwrap().state.tag(), "done");
}
#[tokio::test]
async fn a_wrong_size_archive_is_refused_before_the_engine_could_reject_it() {
let fixture = Fixture::new("wrongkar");
+2 -2
View File
@@ -43,7 +43,7 @@ Container: [section 7](#7-container-image). Build your own release: [section 8](
| 1 | preflight | driver >= 595, GPU architecture, VRAM free vs budget, RAM total/available, disk on each volume, WSL2 mounts, `libcublas.so.12`, `memfd_create`, ports, systemd, the six binaries | read-only; any FAIL stops before anything is changed |
| 2 | layout | state (0700), logs, run, stamps, assets | `mkdir -p` |
| 3 | binaries | copy `bin/*` to `PREFIX/bin`, SHA-256 checked against `MANIFEST.json` | skipped when identical; replaced by rename (safe for a running binary) |
| 3b | expert profile | the ranked VRAM expert tier's table `ASSETS/data/expert-profile.bin` (192 KiB, upstream Strata at the pinned commit): downloaded over https from the pinned commit, or installed from `--expert-profile-file PATH` (offline); SHA-256 `8f59b4aa...388975baf` is checked, the file is installed by rename, any other digest fails closed (a wrong file already there is moved aside, never deleted); `--no-expert-tier` is the explicit opt-out. Planned before the large downloads. `status`, `verify`, the ready summary and the supervisor log say `expert tier ON (sha256 ...)` or `WARNING expert tier OFF: reason` | skipped when the file has the pinned digest |
| 3b | expert profile | the ranked VRAM expert tier's table `ASSETS/data/expert-profile.bin` (192 KiB, upstream Strata at the pinned commit): the upstream bytes are embedded in the `leleka` binary (`crates/deploy/data/expert-profile.bin`, MIT notice beside it) and written there on first start, so no network is needed; `--expert-profile-file PATH` installs your copy instead, and an https download from the pinned commit is only the fallback; SHA-256 `8f59b4aa...388975baf` is checked, the file is installed by rename, any other digest fails closed (a wrong file already there is moved aside, never deleted); `--no-expert-tier` is the explicit opt-out. Planned before the large downloads. `status`, `verify`, the ready summary and the supervisor log say `expert tier ON (sha256 ...)` or `WARNING expert tier OFF: reason` | skipped when the file has the pinned digest |
| 4 | cuBLAS 12 | uses what the host has; otherwise downloads the pinned NVIDIA 12.9.1.4 redistributable (SHA-256 pinned, resumable) into `PREFIX/lib/cublas` | skipped when `libcublas.so.12` and `libcublasLt.so.12` are found |
| 5 | secrets | two service tokens into `STATE/runtime.env` (0600), API key through `strata-next api-key init` | never rotated; only missing/invalid ones are created |
| 6 | model | `strata-next model fetch qwen-iq3-s` then `model verify` (resumable `.part` files, SHA-256) | stamped with size+mtime: skipped on re-runs unless `--reverify` |
@@ -226,7 +226,7 @@ profile as `up` resolved it (`base_profile` in `leleka.json`, written since this
| `--reverify` | ignore the stamps and hash everything again |
| `--trust-archive` | accept an existing pinned-length archive + provenance without the strict re-derivation (section 2) |
| `--mtp-pack PATH` | import the MTP pack (directory or `.tar/.tar.gz/.tgz/.tar.xz`, sub-directories searched) |
| `--expert-profile-file PATH` / `--no-expert-tier` | install the ranked expert table from this copy of the upstream `data/expert-profile.bin` instead of downloading it (the pinned digest is still required) / run without the VRAM expert tier (much slower; reported as OFF) |
| `--expert-profile-file PATH` / `--no-expert-tier` | install the ranked expert table from this copy of the upstream `data/expert-profile.bin` instead of the embedded one (the pinned digest is still required) / run without the VRAM expert tier (much slower; reported as OFF) |
| `--cublas-dir DIR` / `--no-install-cublas` | use this CUDA 12 cuBLAS / fail instead of downloading it |
| `--kar-fd N` | an already sealed archive descriptor inherited from the parent (foreground or `--mode none` only) |
| `--timeout-s N` | wait this long for `/ready` (default 3600) |
@@ -48,7 +48,7 @@ are the ones in L4. (4) `engine/strata` is not part of any binary and not in the
| material | where | licence | shipped? | action |
| --- | --- | --- | --- | --- |
| Leleka crates (34 workspace members) | `crates/`, `control-plane/`, `desktop-core/` | `Apache-2.0` declared in the workspace (L1, L2) | binaries + PTX | owner decision L1; add the field to the two manifests |
| Strata (the Original, reference) | `engine/strata/` at upstream `41cf05a0`, `https://github.com/Niko1221/Strata.git` | MIT, (c) 2026 Niko1221 and the Strata contributors (`engine/strata/LICENSE`) | no (reference only); text shipped as `licenses/strata-MIT.txt` because sealed kernels and constants derive from it (file headers: "Copyright (c) 2026 Niko1221 and the Strata contributors") | none |
| Strata (the Original, reference) | `engine/strata/` at upstream `41cf05a0`, `https://github.com/Niko1221/Strata.git` | MIT, (c) 2026 Niko1221 and the Strata contributors (`engine/strata/LICENSE`) | reference only, except one data file: `crates/deploy/data/expert-profile.bin` (Strata `data/expert-profile.bin`, 196,632 B, sha256 `8f59b4aa8873209dff11c11e37bcda9529a1335b724a1afeea37bf6388975baf`, copied unchanged) is embedded in the `leleka` binary and written to the model volume by `leleka up`; its MIT notice is `crates/deploy/data/expert-profile.NOTICE`, and the package must ship that file with `licenses/strata-MIT.txt`. Text shipped as `licenses/strata-MIT.txt` because sealed kernels and constants derive from it (file headers: "Copyright (c) 2026 Niko1221 and the Strata contributors") | none |
| ggml / llama.cpp | `engine/strata/third_party/ggml` (revision `3cf03257f`), `control-plane/third_party/ggml`, `crates/cuda-driver/src/third_party/llamacpp`, `crates/native-cpu-expert/LICENSE.ggml`, `crates/quant-core/LICENSE-GGML` | MIT, (c) 2023-2026 The ggml authors | derived kernels and CPU code are inside the binaries; text shipped as `licenses/ggml-MIT.txt` | L5: add the licence file beside `UPSTREAM-REVISION` |
| Project Maya | `engine/strata/third_party/project-maya` | MIT, (c) 2026 Peasant Smith and the Project Maya contributors, with Strata's notice | no (DeepSeek engine, not used by Leleka); texts shipped as a courtesy (`licenses/project-maya-*`) | none |
| colibri | `crates/cpu-sys/NOTICE.colibri` | Apache-2.0, (c) 2026 Vincenzo Fornaro | CPU kernels, inside the binaries; notice shipped as `licenses/colibri-NOTICE.txt` | needs the Apache-2.0 text beside it: covered by L1 |
+1 -1
View File
@@ -108,7 +108,7 @@ The root `.gitignore` already drops `*.bin`, `*.gguf`, `*.log` and `models/`; th
| Binary media and assets added by upstream | 61 | `apps/desktop/src-tauri/icons/**` and `nsis/*.bmp` (app icons), `apps/host/public/**` (favicons, three GT Walsheim Pro `*.woff2` commercial fonts, an example gif/mp4/pdf), `docs/terminal-previews/*.png` (7), `docs/media/*.png` (2), `docs/media/models/*` | upstream |
| `docs/work/evidence/**` | 24 | test-run transcripts and JSON self-test output (logs) | upstream |
| Model-adjacent binaries that the root `.gitignore` also matches | `data/dsv41/profile-2.00.bin`, `profile-2.25.bin` (hot-expert profiles for the DeepSeek packs), `data/draft_vocab_fr.bin`, `data/expert-profile-sycl.bin`, `tests/fixtures/dsv41/engram-final-header.gguf` | binary data files; needed only to run the DeepSeek engine or its SYCL path | upstream |
| Already left out by the first import and still left out | `data/draft_vocab.bin`, `data/draft_vocab_cyrillic.bin`, `data/draft_vocab_en.bin`, `data/expert-profile.bin` (fetched by `leleka up` from the pinned commit, SHA-256 checked; `crates/deploy/src/expert_profile.rs`), `data/expert-profile-coder.bin`, `data/experimental-speed-projection/*.gguf`, `bench/results/2026-09-30-community-rtx-5090/engine.log` | same rule | upstream |
| Already left out by the first import and still left out | `data/draft_vocab.bin`, `data/draft_vocab_cyrillic.bin`, `data/draft_vocab_en.bin`, `data/expert-profile.bin` (since the embedded-profile commit it is in Git at `crates/deploy/data/expert-profile.bin`, the one `.gitignore` exception, compiled into `leleka` and written by `leleka up` after a SHA-256 check; download from the pinned commit is the fallback; `crates/deploy/src/expert_profile.rs`), `data/expert-profile-coder.bin`, `data/experimental-speed-projection/*.gguf`, `bench/results/2026-09-30-community-rtx-5090/engine.log` | same rule | upstream |
Kept on purpose although they look large: `apps/host` and `apps/desktop` source (TypeScript / Rust text; 8 MB), `tools/qwen35/pictures/*.png`
(three small test inputs), `docs/work/*.md`, `bench/prompts/**` (frozen benchmark prompts, hashed byte for byte), `sycl/`, `metal/`,
+1 -1
View File
@@ -97,7 +97,7 @@ ASSETS\model\Qwen3.8-Flash-Next-GSQ-RCO-IQ3_S-00002-of-00002.gguf 28,800,138
ASSETS\qwen-iq3-s-l2-v4.kar 55,295,529,472 bytes (at the root, not in model\)
ASSETS\qwen-iq3-s-l2-v4.kar.provenance.json
ASSETS\data\mtp-rt\{dense.bin,dense.txt,draft_vocab.bin,experts.bin}
ASSETS\data\expert-profile.bin (sha256 8f59b4aa...8975baf; the VRAM expert tier; `leleka up` downloads it, or `--expert-profile-file PATH`)
ASSETS\data\expert-profile.bin (sha256 8f59b4aa...8975baf; the VRAM expert tier; `leleka up` installs the copy embedded in `leleka.exe`, or `--expert-profile-file PATH`)
ASSETS\tokenizer-assets\ (made by `up`)
```
+3 -2
View File
@@ -24,7 +24,7 @@
# --rehearse package even though gates FAIL (to test the assembly): the archive is named -rehearsal, MANIFEST.json says
# "rehearsal": true and the tag procedure refuses it. Never a release
# --epoch N SOURCE_DATE_EPOCH of the archive (default: commit time of HEAD)
# --expert-profile F ship the ranked-expert table (data/expert-profile.bin of upstream Strata, 196,632 bytes; not in Git) as
# --expert-profile F ship the ranked-expert table (data/expert-profile.bin of upstream Strata, 196,632 bytes; the same bytes are embedded in `leleka`, so this is optional) as
# share/leleka/data/expert-profile.bin after checking its SHA-256 against the pin of the deploy crate
# --unattended P extra file or directory to ship under share/leleka/unattended/ (repeatable; the defaults below are added when they
# exist: the systemd units and scripts of the unattended-operation work, which the OWNER installs)
@@ -359,10 +359,11 @@ run_package() {
[ "$(sha256sum "$expert_profile" | awk '{print $1}')" = "$EXPERT_PROFILE_SHA256" ] || die "$expert_profile does not have the pinned SHA-256 $EXPERT_PROFILE_SHA256"
mkdir -p "$stage/share/leleka/data"; cp "$expert_profile" "$stage/share/leleka/data/expert-profile.bin"
else
note "no --expert-profile: the package does not carry data/expert-profile.bin; the 5090 profile runs without the ranked VRAM expert tier (slower) unless the asset volume has it (leleka up warns)"
note "no --expert-profile: no loose copy of data/expert-profile.bin is shipped; the leleka binary embeds the same bytes and `leleka up` installs them (sha256 checked)"
fi
[ ! -f LICENSE ] || cp LICENSE "$stage/LICENSE"
cp engine/strata/LICENSE "$stage/share/leleka/licenses/strata-MIT.txt"
cp crates/deploy/data/expert-profile.NOTICE "$stage/share/leleka/licenses/strata-expert-profile-NOTICE.txt"
cp engine/strata/third_party/ggml/LICENSE "$stage/share/leleka/licenses/ggml-MIT.txt"
cp engine/strata/third_party/project-maya/LICENSE "$stage/share/leleka/licenses/project-maya-MIT.txt"
cp engine/strata/third_party/project-maya/NOTICE.md "$stage/share/leleka/licenses/project-maya-NOTICE.md"