Wave 445/509: Engine: diagnostics.validation reads and sets the mode (and 3 more)

4 commits, squashed; the originals stay reachable from tag archive/merge-main-develop.

- 5d80fc571 jyviko: Engine: diagnostics.validation reads and sets the mode
- 1a93a3977 jyviko: CLI: run and kernel-cases take the validation mode
- 50501fe14 jyviko: Preferences: Body check, once per feature by default
- 6a133042c jyviko: Preferences: the body check is the kernel's, not named after SMLib

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
jyvikoandClaude Opus 5.5 committed 2026-10-30 10:48:24 -04:00
1 parent 143a6cb987
commit 99cd20ea20
19 files changed
+408 -33

No files matched your search

+10 -2
View File
@@ -633,7 +633,7 @@ fn flat_pattern_checks(c: &mut Checks, want: &Value, results: &[Value], rel: f64
}
}
fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
fn check_case(dir: &str, dumps: Option<&std::path::Path>, validation: solidcraft_engine::kernel::Validation) -> Value {
let (area, name) = case_name(dir);
let mut out = json!({"case": name, "area": area, "kernel": kernel()});
let want = match read_json(&format!("{dir}/expected.json")) {
@@ -692,6 +692,7 @@ fn check_case(dir: &str, dumps: Option<&std::path::Path>) -> Value {
}
}
let mut s = solidcraft_engine::Session::default();
s.set_validation(validation);
let clock = std::time::Instant::now();
let ran = s.run_script(&commands);
// The commands' own time, without process start or grading: the ladder's timing golden.
@@ -945,7 +946,14 @@ pub fn run(args: &[String]) -> Result<(), String> {
if dumps.as_ref().is_some_and(|d| d.as_os_str().is_empty()) {
return Err("kernel-cases: --dumps= needs a folder".into());
}
let results: Vec<Value> = dirs.iter().map(|d| check_case(d, dumps.as_deref())).collect();
// `--validation=MODE`: the cases' features are checked under MODE (each_step, each_feature,
// off; default each_feature, the app's default).
let validation = match args.iter().find_map(|a| a.strip_prefix("--validation=")) {
Some(m) => solidcraft_engine::kernel::Validation::parse(m)
.ok_or_else(|| format!("kernel-cases: --validation= must be each_step, each_feature or off, not `{m}`"))?,
None => solidcraft_engine::kernel::Validation::default(),
};
let results: Vec<Value> = dirs.iter().map(|d| check_case(d, dumps.as_deref(), validation)).collect();
if dumps.is_some() {
solidcraft_engine::kernel::smlib_dump_dir(None).map_err(|e| format!("kernel-cases: --dumps: {e}"))?;
}
+36 -9
View File
@@ -1,7 +1,7 @@
//! SolidCraft headless command line.
//!
//! ```text
//! solidcraft-cli run <script.json|design.solidcraft|part.step|mesh.3mf> [--in design|part.step|mesh.3mf] [--out FILE]... [--save FILE] [--quiet] [--results] [--timings] [--profile] [--json-out FILE] [--allow-errors]
//! solidcraft-cli run <script.json|design.solidcraft|part.step|mesh.3mf> [--in design|part.step|mesh.3mf] [--out FILE]... [--save FILE] [--quiet] [--results] [--timings] [--profile] [--json-out FILE] [--allow-errors] [--validation MODE]
//! solidcraft-cli eval <script.json|design.solidcraft|part.step> [--in design.solidcraft|part.step] [--json-out FILE] (alias: inspect) measurements as JSON
//! solidcraft-cli script <design.solidcraft> [--out script.json] the design's history as a command script
//! solidcraft-cli bench-open <design.solidcraft | part.step> [--parse-only] [--save OUT.solidcraft] [--display LEVEL [--edit NAME EXPR]] [--ops script.json] loading timings as JSON lines
@@ -15,7 +15,7 @@
//! solidcraft-cli commands the command registry as JSON
//! solidcraft-cli recipe <recipe.json> translate an oracle recipe to a script
//! solidcraft-cli oracle <case-dir>... replay recipes and compare with expected.json
//! solidcraft-cli kernel-cases [--json] [--dumps=DIR] <case-dir>... the kernel regression rig (tests/kernel-cases)
//! solidcraft-cli kernel-cases [--json] [--dumps=DIR] [--validation=MODE] <case-dir>... the kernel regression rig (tests/kernel-cases)
//! solidcraft-cli mcp [--headless] [--in design|script] [--connect HOST:PORT [--token T]] [--allow-path DIR]... [--allow-any-path]
//! [--param-check off|warn|strict]
//! MCP server on stdio (docs/mcp.md)
@@ -59,7 +59,7 @@ struct Command {
}
/// `run`'s lines in the usage.
const USAGE_RUN: &str = " solidcraft-cli run <script.json|design.solidcraft|part.step> [--in design.solidcraft|part.step] [--out FILE]... [--save FILE] [--quiet] [--results] [--timings] [--profile] [--profile-out trace.json] [--json-out FILE] [--allow-errors]\n solidcraft-cli run --in <design.solidcraft|part.step> [--out FILE]...\n (a timeline feature that fails fails the run and nothing is written; --allow-errors writes anyway)\n (--timings prints {timings: [{index, command, ms}], total_ms} for a script, with --results its results too;\n --profile adds each command's profile: {boolean_ms, tessellate_ms, other_ms}, the kernel's share)\n (--profile also records where the time goes, SMLib's calls, kernel operations, features, commands and import stages,\n and prints the table to stderr: count, total, self time and longest per span; --profile-out FILE writes the spans\n as a Chrome trace for chrome://tracing or ui.perfetto.dev; SOLIDCRAFT_PROFILE=1 does the same for any command)\n";
const USAGE_RUN: &str = " solidcraft-cli run <script.json|design.solidcraft|part.step> [--in design.solidcraft|part.step] [--out FILE]... [--save FILE] [--quiet] [--results] [--timings] [--profile] [--profile-out trace.json] [--json-out FILE] [--allow-errors] [--validation each_step|each_feature|off]\n solidcraft-cli run --in <design.solidcraft|part.step> [--out FILE]...\n (a timeline feature that fails fails the run and nothing is written; --allow-errors writes anyway)\n (--validation: when SMLib's full check runs on the features computed (diagnostics.validation), default each_feature)\n (--timings prints {timings: [{index, command, ms}], total_ms} for a script, with --results its results too;\n --profile adds each command's profile: {boolean_ms, tessellate_ms, other_ms}, the kernel's share)\n (--profile also records where the time goes, SMLib's calls, kernel operations, features, commands and import stages,\n and prints the table to stderr: count, total, self time and longest per span; --profile-out FILE writes the spans\n as a Chrome trace for chrome://tracing or ui.perfetto.dev; SOLIDCRAFT_PROFILE=1 does the same for any command)\n";
/// `eval`'s lines in the usage.
const USAGE_EVAL: &str = " solidcraft-cli eval <script.json|design.solidcraft|part.step> [--in design.solidcraft|part.step] [--json-out FILE] [--profile] [--profile-out trace.json] (alias: inspect)\n solidcraft-cli eval --in <script.json|design.solidcraft|part.step> [--json-out FILE]\n (with both inputs, runs the positional script on --in before measuring; does not automatically save the modified design)\n (--json-out FILE writes the JSON that run (with --results, else the measurement) and eval print to FILE instead of stdout,\n as plain UTF-8: a shell's > can re-encode it, e.g. Windows PowerShell adds a byte-order mark)\n (--profile and --profile-out as for run)\n";
/// `script`'s lines in the usage.
@@ -83,7 +83,7 @@ const USAGE_RECIPE: &str = " solidcraft-cli recipe <recipe.json>\n";
/// `oracle`'s lines in the usage.
const USAGE_ORACLE: &str = " solidcraft-cli oracle <case-dir>... [--json]\n";
/// `kernel-cases`'s lines in the usage.
const USAGE_KERNEL_CASES: &str = " solidcraft-cli kernel-cases <case-dir>... [--json] [--dumps=DIR]\n (the kernel regression rig, tests/kernel-cases, on SMLib; --dumps: each case's\n failing SMLib calls leave their inputs for replay in DIR/<area>-<case>)\n";
const USAGE_KERNEL_CASES: &str = " solidcraft-cli kernel-cases <case-dir>... [--json] [--dumps=DIR] [--validation=each_step|each_feature|off]\n (the kernel regression rig, tests/kernel-cases, on SMLib; --dumps: each case's\n failing SMLib calls leave their inputs for replay in DIR/<area>-<case>; --validation: when SMLib's\n full check runs (diagnostics.validation), default each_feature)\n";
/// `fuzz`'s lines in the usage.
const USAGE_FUZZ: &str =
" solidcraft-cli fuzz [--from N] [--count N] [--jobs J] [--timeout S] [--steps N] [--minimise] [--out DIR] [--report FILE]\n";
@@ -278,8 +278,15 @@ pub fn load(path: &str) -> Result<Session, String> {
/// `load`, with scripts and recipes run at the parameter-check level `check`, which the
/// session keeps.
fn load_checked(path: &str, check: solidcraft_engine::schema::ParamCheck) -> Result<Session, String> {
load_with(path, check, solidcraft_engine::kernel::Validation::default())
}
/// `load_checked`, the features computed under `validation` (`diagnostics.validation`), which
/// the session keeps.
fn load_with(path: &str, check: solidcraft_engine::schema::ParamCheck, validation: solidcraft_engine::kernel::Validation) -> Result<Session, String> {
let mut s = Session::default();
s.param_check = check;
s.set_validation(validation);
if solidcraft_engine::io::is_step_path(path) || solidcraft_engine::io::is_mesh_path(path) {
s.execute("doc.open", &json!({"path": path})).map_err(|e| e.to_string())?;
return Ok(s);
@@ -287,7 +294,7 @@ fn load_checked(path: &str, check: solidcraft_engine::schema::ParamCheck) -> Res
let bytes = solidcraft_engine::io::vfs::read(path, solidcraft_engine::io::MAX_DESIGN_BYTES).map_err(|e| format!("{path}: {e}"))?;
if solidcraft_engine::io::is_design_container(&bytes) {
let doc = solidcraft_engine::io::read_design(&bytes).map_err(|e| format!("{path}: {e}"))?;
let mut session = Session::opened_at(doc, None, Some(path));
let mut session = Session::opened_at_validating(doc, None, Some(path), validation);
session.param_check = check;
return Ok(session);
}
@@ -377,10 +384,11 @@ fn cmd_run(args: &[String]) -> Result<(), String> {
known_args(
"run",
args,
&["--in", "--out", "--save", "--json-out", "--profile-out"],
&["--in", "--out", "--save", "--json-out", "--profile-out", "--validation"],
&["--quiet", "--results", "--timings", "--profile", "--allow-errors"],
true,
)?;
let validation = validation_flag("run", args)?;
let base = flag(args, "--in");
let path = positional(args);
if path.is_none() && base.is_none() {
@@ -395,8 +403,12 @@ fn cmd_run(args: &[String]) -> Result<(), String> {
let (mut s, results) = if want_results || timings {
// Collect every command's result or time (scripts only), then process requested files too.
let mut s = match base {
Some(b) => load(b)?,
None => Session::default(),
Some(b) => load_with(b, solidcraft_engine::schema::ParamCheck::Off, validation)?,
None => {
let mut s = Session::default();
s.set_validation(validation);
s
}
};
let needs = if want_results { "--results needs a script" } else { "--timings needs a script" };
let v = read_json(path.ok_or(needs)?)?;
@@ -411,7 +423,7 @@ fn cmd_run(args: &[String]) -> Result<(), String> {
};
(s, Some(out))
} else {
(open(base, path)?, None)
(open_validating(base, path, validation)?, None)
};
// A feature that fails leaves the bodies as they were before it (a parameter change can
// break a feature without failing the command that made it): writing them would hand out
@@ -438,6 +450,12 @@ fn cmd_run(args: &[String]) -> Result<(), String> {
/// The session `run`, `eval` and `snapshot` start from: `--in` (a design or STEP file) with the
/// positional script run on top of it, or either one alone.
fn open(base: Option<&str>, path: Option<&String>) -> Result<Session, String> {
open_validating(base, path, solidcraft_engine::kernel::Validation::default())
}
/// [`open`], the features computed under `validation`.
fn open_validating(base: Option<&str>, path: Option<&String>, validation: solidcraft_engine::kernel::Validation) -> Result<Session, String> {
let load = |p: &str| load_with(p, solidcraft_engine::schema::ParamCheck::Off, validation);
match (base, path) {
(Some(b), Some(p)) => {
let mut s = load(b)?;
@@ -450,6 +468,15 @@ fn open(base: Option<&str>, path: Option<&String>) -> Result<Session, String> {
}
}
/// `--validation MODE` (`diagnostics.validation`): the default, each_feature, when not given.
fn validation_flag(cmd: &str, args: &[String]) -> Result<solidcraft_engine::kernel::Validation, String> {
match flag(args, "--validation") {
Some(m) => solidcraft_engine::kernel::Validation::parse(m)
.ok_or_else(|| format!("{cmd}: --validation must be each_step, each_feature or off, not `{m}`")),
None => Ok(solidcraft_engine::kernel::Validation::default()),
}
}
/// Refuses an option `cmd` doesn't take, and one missing its value: a typo, or another
/// command's option, would otherwise be ignored without a word. `positionals` says whether the
/// command takes a word of its own (a file, a seed): `fuzz` takes none, and would start a run.
@@ -0,0 +1,65 @@
{
"ar": {
"cmd.diagnostics_validation": "التحقق",
"prefs.validation": "التحقق من الأجسام",
"prefs.validation.each_feature": "مرة لكل ميزة",
"prefs.validation.each_step": "بعد كل خطوة",
"prefs.validation.label": "فحص النواة الكامل",
"prefs.validation.off": "متوقف (تجريبي)",
"prefs.validation_note": "مرة لكل ميزة: تُفحص الأجسام التي تنتجها الميزة مرة واحدة قبل الاحتفاظ بها، وتفشل الميزة إذا رُفض أحدها. بعد كل خطوة: يُفحص ناتج كل عملية سحب ودمج وتقويس، كما في السابق. متوقف: لا فحص، فقد يُحتفظ بجسم معيب."
},
"de": {
"cmd.diagnostics_validation": "Prüfung",
"prefs.validation": "Körperprüfung",
"prefs.validation.each_feature": "Einmal je Feature",
"prefs.validation.each_step": "Nach jedem Schritt",
"prefs.validation.label": "Vollständige Kernel-Prüfung",
"prefs.validation.off": "Aus (experimentell)",
"prefs.validation_note": "Einmal je Feature: Die Körper, die ein Feature erzeugt, werden einmal geprüft, bevor sie übernommen werden; wird einer abgelehnt, schlägt das Feature fehl. Nach jedem Schritt: Das Ergebnis jedes Sweeps, jeder Boolesche Operation und jeder Rundung wird geprüft, wie bisher. Aus: keine Prüfung, ein fehlerhafter Körper kann bleiben."
},
"en": {
"cmd.diagnostics_validation": "Validation",
"prefs.validation": "Body check",
"prefs.validation.each_feature": "Once per feature",
"prefs.validation.each_step": "After every step",
"prefs.validation.label": "Full kernel check",
"prefs.validation.off": "Off (experimental)",
"prefs.validation_note": "Once per feature: the bodies a feature makes are checked once before they are kept, and the feature fails if one is refused. After every step: the result of every sweep, boolean and blend is checked, as before. Off: no check, so a faulty body can be kept."
},
"he": {
"cmd.diagnostics_validation": "אימות",
"prefs.validation": "בדיקת גופים",
"prefs.validation.each_feature": "פעם אחת לכל תכונה",
"prefs.validation.each_step": "אחרי כל שלב",
"prefs.validation.label": "הבדיקה המלאה של הקרנל",
"prefs.validation.off": "כבוי (ניסיוני)",
"prefs.validation_note": "פעם אחת לכל תכונה: הגופים שתכונה יוצרת נבדקים פעם אחת לפני שהם נשמרים, והתכונה נכשלת אם אחד מהם נדחה. אחרי כל שלב: התוצאה של כל סחיפה, פעולה בוליאנית ועיגול נבדקת, כמו קודם. כבוי: אין בדיקה, ולכן גוף פגום עלול להישמר."
},
"ja": {
"cmd.diagnostics_validation": "検証",
"prefs.validation": "ボディのチェック",
"prefs.validation.each_feature": "フィーチャーごとに 1 回",
"prefs.validation.each_step": "各ステップの後",
"prefs.validation.label": "カーネルの完全チェック",
"prefs.validation.off": "オフ (試験的)",
"prefs.validation_note": "フィーチャーごとに 1 回: フィーチャーが作るボディを保持する前に 1 回チェックし、拒否されたものがあればフィーチャーは失敗します。各ステップの後: これまでどおり、スイープ、ブーリアン、ブレンドのたびに結果をチェックします。オフ: チェックしないため、不正なボディが残ることがあります。"
},
"ko": {
"cmd.diagnostics_validation": "검증",
"prefs.validation": "바디 검사",
"prefs.validation.each_feature": "피처마다 한 번",
"prefs.validation.each_step": "모든 단계 후",
"prefs.validation.label": "커널 전체 검사",
"prefs.validation.off": "끄기 (실험적)",
"prefs.validation_note": "피처마다 한 번: 피처가 만든 바디를 유지하기 전에 한 번 검사하며, 하나라도 거부되면 피처가 실패합니다. 모든 단계 후: 이전처럼 스윕, 불리언, 블렌드마다 결과를 검사합니다. 끄기: 검사하지 않으므로 결함 있는 바디가 남을 수 있습니다."
},
"zh": {
"cmd.diagnostics_validation": "验证",
"prefs.validation": "实体检查",
"prefs.validation.each_feature": "每个特征一次",
"prefs.validation.each_step": "每一步之后",
"prefs.validation.label": "内核完整检查",
"prefs.validation.off": "关闭(实验性)",
"prefs.validation_note": "每个特征一次:特征生成的实体在保留前检查一次,若有实体被拒绝,该特征失败。每一步之后:与以前一样,每次扫掠、布尔运算和倒圆后都检查结果。关闭:不检查,因此可能保留有缺陷的实体。"
}
}
+1 -1
View File
@@ -376,7 +376,7 @@ fn part_design(s: &Session, sc: &Scope, stem: &str, cmd: &str) -> Result<(Sessio
if !source.configs.is_empty() {
notices.push(format!("the configurations stay in this design; {stem} has none"));
}
let part = Session::new(part);
let part = Session::opened_validating(part, None, s.validation());
let failing: Vec<String> = part.model.results.iter().filter_map(|r| r.error.as_ref().map(|e| format!("{} ({e})", r.name))).take(5).collect();
if !failing.is_empty() {
return Err(bad(cmd, format!("{name} does not build on its own: {}", failing.join("; "))));
+6 -6
View File
@@ -88,8 +88,8 @@ pub fn resolve_design_links(doc: &mut Document, from: Option<&str>) {
/// the design gives their faces (`Feature::link_faces`), with the source's design properties.
type Linked = (String, solidcraft_io::StepFeature, Vec<Vec<String>>, solidcraft_doc::Metadata);
/// The solid bodies of the design at `file`, evaluated, as an Import feature.
fn linked_bodies(file: &Path, own: Option<&str>) -> Result<Linked> {
/// The solid bodies of the design at `file`, evaluated under `validation`, as an Import feature.
fn linked_bodies(file: &Path, own: Option<&str>, validation: solidcraft_kernel::Validation) -> Result<Linked> {
let shown = file.display().to_string();
if own.is_some_and(|o| absolute(Path::new(o)) == absolute(file)) {
return Err(EngineError::Other(format!("{shown}: a design can't be linked into itself")));
@@ -101,7 +101,7 @@ fn linked_bodies(file: &Path, own: Option<&str>) -> Result<Linked> {
EngineError::Other(if e.starts_with(&shown) { e } else { format!("{shown}: {e}") })
})?;
let doc = solidcraft_io::read_design(&bytes).map_err(|e| EngineError::Other(format!("{shown}: {e}")))?;
session_bodies(&Session::opened_at(doc, None, Some(&shown)), &shown)
session_bodies(&Session::opened_at_validating(doc, None, Some(&shown), validation), &shown)
}
/// The solid bodies of `part`, the design saved as `shown`, as an Import feature.
@@ -156,7 +156,7 @@ fn insert_design(s: &mut Session, p: &Value) -> Result<Value> {
return super::component::copy_occurrence(s, &json!({"component": component, "parent": parent, "translate": translate}));
}
}
let (design_name, sf, faces, metadata) = linked_bodies(&file, s.path.as_deref())?;
let (design_name, sf, faces, metadata) = linked_bodies(&file, s.path.as_deref(), s.validation())?;
let name = str_(p, "name").filter(|n| !n.trim().is_empty()).map(str::to_string).unwrap_or(design_name);
let mut create = json!({"name": name, "activate": false});
// Clipboard insertion uses reuse even for the first paste, which must stay movable.
@@ -224,7 +224,7 @@ fn update_links(s: &mut Session, p: &Value) -> Result<Value> {
let old = old.clone();
link_refused(s.path.as_deref(), &link.path).map_err(|e| bad(cmd, format!("{cname}: {e}")))?;
let file = resolve(s.path.as_deref(), &link.path);
let (_, sf, faces, _) = linked_bodies(&file, s.path.as_deref()).map_err(|e| bad(cmd, format!("{cname}: {e}")))?;
let (_, sf, faces, _) = linked_bodies(&file, s.path.as_deref(), s.validation()).map_err(|e| bad(cmd, format!("{cname}: {e}")))?;
warnings.extend(sf.warnings.iter().cloned());
let same = matches!(&sf.kind, FeatureKind::Import { step, .. } if *step == old);
let kept = s.doc.feature(link.feature).map(|f| &f.link_faces);
@@ -305,7 +305,7 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> {
}
// Read/evaluate the candidate before changing anything. Session::execute owns the single
// undo step and restores both the document and evaluated state on any later failure.
let (_, sf, faces, _) = linked_bodies(&file, s.path.as_deref()).map_err(|e| bad(cmd, e.to_string()))?;
let (_, sf, faces, _) = linked_bodies(&file, s.path.as_deref(), s.validation()).map_err(|e| bad(cmd, e.to_string()))?;
let geometry_changed = match (s.doc.feature(link.feature).map(|f| &f.kind), &sf.kind) {
(Some(FeatureKind::Import { step: old, .. }), FeatureKind::Import { step, .. }) => old != step,
_ => true,
+32
View File
@@ -38,6 +38,18 @@ pub static COMMANDS: &[CommandSpec] = &[
inside it; total counts its outermost run only. Recording also starts with SOLIDCRAFT_PROFILE=1, the CLI's \
--profile and the app's preference; off, it costs nothing measurable. Read-only",
),
CommandSpec::new("diagnostics.validation", "Validation", crate::checked!("diagnostics.validation", validation))
.icon("bug_report")
.noundo()
.contract(&VALIDATION_CONTRACT)
.output(crate::schema::output_schema_for::<crate::schema::diagnostics::ValidationReply>)
.params(
"mode?: each_step | each_feature | off (default: leave it). When the kernel's full check runs on the features computed \
from now on: after every sweep, boolean and blend (each_step), once on the bodies each feature makes or changes \
(each_feature, the default; a body it refuses still fails its feature, with the check's reason), or never (off, \
experimental). Results already there stand until their features are computed again (timeline.compute_all). \
The app's preference of the same name sets it. Returns {mode, previous}",
),
CommandSpec::new("diagnostics.crash_test", "Crash Test", crash_test).icon("bug_report").noundo().enabled(crash_test_enabled).params(
"mode: panic | kernel | abort. Checks that crash reports work: panic = an internal error in this command (caught; \
the design is unchanged), kernel = one inside the geometry kernel (caught), abort = the app ends at once (reported \
@@ -92,6 +104,26 @@ fn crash_test(_: &mut Session, p: &Value) -> Result<Value> {
const PROFILE_CONTRACT: crate::schema::TypedContract<crate::schema::diagnostics::ProfileParams> = crate::schema::TypedContract::new();
const VALIDATION_CONTRACT: crate::schema::TypedContract<crate::schema::diagnostics::ValidationParams> = crate::schema::TypedContract::new();
fn validation(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "diagnostics.validation";
let mode = match p.get("mode") {
None | Some(Value::Null) => None,
Some(v) => Some(
v.as_str()
.and_then(solidcraft_kernel::Validation::parse)
.ok_or_else(|| bad(cmd, format!("`mode` {}", crate::schema::diagnostics::VALIDATION_MODES)))?,
),
};
let previous = s.validation();
if let Some(mode) = mode {
s.set_validation(mode);
}
let out = crate::schema::diagnostics::ValidationReply { mode: s.validation().into(), previous: previous.into() };
serde_json::to_value(out).map_err(|e| EngineError::Other(format!("{cmd}: {e}")))
}
/// Rows `diagnostics.profile` returns at most.
const MAX_PROFILE_ROWS: u64 = 10_000;
+2
View File
@@ -134,7 +134,9 @@ fn restore_checkpoint(s: &mut Session, p: &Value) -> Result<Value> {
}
fn compute_all(s: &mut Session, _p: &Value) -> Result<Value> {
let validation = s.validation();
s.model = solidcraft_doc::Model::new();
s.set_validation(validation);
s.refresh();
let errors = s.model.results.iter().filter(|r| r.error.is_some()).count();
Ok(json!({"features": s.model.results.len(), "errors": errors}))
+16 -4
View File
@@ -294,6 +294,7 @@ fn open(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(command) = super::drawing_import_command(path) {
let stem = std::path::Path::new(path).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| "Untitled".into());
let mut fresh = Session::new(Document::new(&stem));
fresh.set_validation(s.validation());
let mut out = fresh.execute(command, &json!({"path": path}))?;
fresh.undo.clear();
s.replace_design(fresh);
@@ -307,6 +308,7 @@ fn open(s: &mut Session, p: &Value) -> Result<Value> {
// A new, unsaved design holding the file's bodies.
let stem = std::path::Path::new(path).file_stem().map(|x| x.to_string_lossy().to_string()).unwrap_or_else(|| "Untitled".into());
let mut fresh = Session::new(Document::new(&stem));
fresh.set_validation(s.validation());
let r = if solidcraft_io::is_step_path(path) {
add_step(&mut fresh, path, None, &step_options(p, "doc.open")?)?
} else {
@@ -335,7 +337,7 @@ fn open(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(stem) = default_name_for(&doc.name, path) {
doc.name = stem;
}
s.replace_design(Session::opened_at(doc, saved.as_ref(), Some(path)));
s.replace_design(Session::opened_at_validating(doc, saved.as_ref(), Some(path), s.validation()));
s.disk = disk;
s.read_only = read_only;
let errors = s.model.results.iter().filter(|r| r.error.is_some()).count();
@@ -460,9 +462,19 @@ fn write_bytes(
impl Session {
/// Open a design with its file location, resolving component links before history keeps
/// them. Absolute in-memory targets survive Save As, undo, redo and recovery unchanged.
pub fn opened_at(mut doc: Document, saved: Option<&solidcraft_doc::SavedModel>, path: Option<&str>) -> Self {
pub fn opened_at(doc: Document, saved: Option<&solidcraft_doc::SavedModel>, path: Option<&str>) -> Self {
Self::opened_at_validating(doc, saved, path, solidcraft_kernel::Validation::default())
}
/// [`Self::opened_at`], its features evaluated under `validation` ([`Session::set_validation`]).
pub fn opened_at_validating(
mut doc: Document,
saved: Option<&solidcraft_doc::SavedModel>,
path: Option<&str>,
validation: solidcraft_kernel::Validation,
) -> Self {
super::component_link::resolve_design_links(&mut doc, path);
let mut session = Self::opened(doc, saved);
let mut session = Self::opened_validating(doc, saved, validation);
session.path = path.map(str::to_owned);
session
}
@@ -815,7 +827,7 @@ fn recover(s: &mut Session, p: &Value) -> Result<Value> {
if let Some(stem) = entry.path.as_deref().and_then(|path| default_name_for(&doc.name, path)) {
doc.name = stem;
}
s.replace_design(Session::opened_at(doc, None, entry.path.as_deref()));
s.replace_design(Session::opened_at_validating(doc, None, entry.path.as_deref(), s.validation()));
s.mark_unsaved();
if bool_(p, "discard").unwrap_or(false) {
crate::recovery::remove(&dir, id)?;
+36 -6
View File
@@ -606,7 +606,12 @@ impl Session {
/// `doc`'s evaluation ([`Model::adopt`]); otherwise the timeline is evaluated.
/// Use [`Self::opened_at`] when the document's file location is known.
/// `SOLIDCRAFT_NO_MODEL_CACHE` set always evaluates.
pub fn opened(mut doc: Document, saved: Option<&solidcraft_doc::SavedModel>) -> Self {
pub fn opened(doc: Document, saved: Option<&solidcraft_doc::SavedModel>) -> Self {
Self::opened_validating(doc, saved, solidcraft_kernel::Validation::default())
}
/// [`Self::opened`], its features evaluated under `validation` ([`Session::set_validation`]).
pub fn opened_validating(mut doc: Document, saved: Option<&solidcraft_doc::SavedModel>, validation: solidcraft_kernel::Validation) -> Self {
// A design's font files are checked like its other paths before it is evaluated.
solidcraft_io::vfs::install_checks();
// The session keeps what is hidden (an undo step of its own); the design file carries it.
@@ -615,11 +620,18 @@ impl Session {
let adopted = saved
.filter(|_| solidcraft_geom::env::var_os("NO_MODEL_CACHE").is_none())
.and_then(|saved| Model::adopt(&doc, saved).map_err(|e| log::info!("the saved model is not used: {e}")).ok());
let model = adopted.unwrap_or_else(|| {
let mut model = Model::new();
model.evaluate(&doc);
model
});
let model = match adopted {
Some(mut model) => {
model.set_validation(validation);
model
}
None => {
let mut model = Model::new();
model.set_validation(validation);
model.evaluate(&doc);
model
}
};
Session {
saved: doc.clone(),
doc,
@@ -690,6 +702,7 @@ impl Session {
/// checkpoint keeps, not the replaced session's file path (docs/mcp.md).
pub fn replace_design(&mut self, fresh: Session) {
let auto_project = self.auto_project;
let validation = self.validation();
let metric_tap_drill_major_less_pitch = self.metric_tap_drill_major_less_pitch;
let surface_extrude_symmetric_per_side = self.surface_extrude_symmetric_per_side;
let param_check = self.param_check;
@@ -707,6 +720,9 @@ impl Session {
self.crash_journal = crash_journal;
self.command_check = command_check;
self.auto_project = auto_project;
// The user's, like `auto_project`: the commands that open a design evaluate it under it
// already (`Session::opened_validating`).
self.set_validation(validation);
self.metric_tap_drill_major_less_pitch = metric_tap_drill_major_less_pitch;
self.surface_extrude_symmetric_per_side = surface_extrude_symmetric_per_side;
self.param_check = param_check;
@@ -942,6 +958,20 @@ impl Session {
}
}
/// When SMLib's check runs on the features evaluated: after every sweep, boolean and blend,
/// once on the bodies each feature keeps (the default), or not at all. A user's setting,
/// kept when another design is opened (`diagnostics.validation`, the app's preference).
pub fn validation(&self) -> solidcraft_kernel::Validation {
self.model.validation()
}
/// Evaluate the features computed from now on under `validation` ([`Session::validation`]);
/// the results already there stand until their features are computed again
/// (`timeline.compute_all` computes every one).
pub fn set_validation(&mut self, validation: solidcraft_kernel::Validation) {
self.model.set_validation(validation);
}
pub fn refresh(&mut self) {
self.model.evaluate(&self.doc);
#[cfg(test)]
+61
View File
@@ -142,6 +142,67 @@ impl ProfileReport {
}
}
/// A validation mode by name, with the handler's message for anything else.
fn validation_mode<'de, D: serde::Deserializer<'de>>(d: D) -> Result<Option<ValidationMode>, D::Error> {
match Value::deserialize(d)? {
Value::Null => Ok(None),
Value::String(s) => ValidationMode::parse(&s).map(Some).ok_or_else(|| serde::de::Error::custom(VALIDATION_MODES)),
_ => Err(serde::de::Error::custom(VALIDATION_MODES)),
}
}
/// What a `mode` that names no validation mode is told.
pub(crate) const VALIDATION_MODES: &str = "must be each_step, each_feature or off";
/// When SMLib's full check runs while features are computed.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ValidationMode {
/// After every sweep, boolean and blend inside a feature: a step whose result fails the
/// check fails the feature there.
EachStep,
/// Once per feature (the default): each body the feature makes or changes is checked before
/// it is kept, and a body the check refuses fails the feature with the check's reason.
EachFeature,
/// Never (experimental): a body the check would refuse is kept.
Off,
}
impl ValidationMode {
fn parse(id: &str) -> Option<ValidationMode> {
solidcraft_kernel::Validation::parse(id).map(ValidationMode::from)
}
}
impl From<solidcraft_kernel::Validation> for ValidationMode {
fn from(v: solidcraft_kernel::Validation) -> Self {
match v {
solidcraft_kernel::Validation::EachStep => ValidationMode::EachStep,
solidcraft_kernel::Validation::EachFeature => ValidationMode::EachFeature,
solidcraft_kernel::Validation::Off => ValidationMode::Off,
}
}
}
/// Read, or set, when SMLib's full check runs on the features computed from now on.
#[derive(Debug, Default, Deserialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct ValidationParams {
/// The mode to compute features under from now on. Default: leave it as it is. The results
/// already there stand until their features are computed again (`timeline.compute_all`).
#[serde(default, deserialize_with = "validation_mode")]
pub mode: Option<ValidationMode>,
}
/// The reply of `diagnostics.validation`.
#[derive(Debug, Serialize, JsonSchema)]
pub struct ValidationReply {
/// The mode features are computed under now.
pub mode: ValidationMode,
/// The mode before this call.
pub previous: ValidationMode,
}
/// Tests that switch the process-wide profiler on, off or reset it run one at a time.
#[cfg(test)]
pub(crate) static PROFILE_TESTS: std::sync::Mutex<()> = std::sync::Mutex::new(());
+60 -1
View File
@@ -1,6 +1,6 @@
use serde_json::json;
use super::ProfileParams;
use super::{ProfileParams, ValidationParams};
use crate::Session;
use crate::schema::input_schema_for;
use crate::schema::tests::{assert_keys, assert_strict_keeps_todays_errors};
@@ -8,6 +8,7 @@ use crate::schema::tests::{assert_keys, assert_strict_keeps_todays_errors};
#[test]
fn schemas_and_the_key_check_agree() {
assert_keys(input_schema_for::<ProfileParams>(), &["enabled", "reset", "top", "trace"]);
assert_keys(input_schema_for::<ValidationParams>(), &["mode"]);
}
#[test]
@@ -18,6 +19,8 @@ fn strict_keeps_todays_errors() {
("diagnostics.profile", json!({"top": -1})),
("diagnostics.profile", json!({"top": 2.5})),
("diagnostics.profile", json!({"trace": 5})),
("diagnostics.validation", json!({"mode": "each step"})),
("diagnostics.validation", json!({"mode": true})),
]);
}
@@ -60,3 +63,59 @@ fn diagnostics_profile_reports_commands_features_and_the_kernel() {
assert_eq!(after["enabled"], json!(false), "{after}");
let _ = std::fs::remove_dir_all(&dir);
}
/// Features are checked once each by default; the command reads and sets the mode, and the mode
/// is the user's: it stays when another design is started and when everything is computed again.
#[test]
fn validation_defaults_to_each_feature_and_round_trips_through_the_command() {
use solidcraft_kernel::Validation;
let mut s = Session::default();
assert_eq!(s.validation(), Validation::EachFeature);
assert_eq!(s.execute("diagnostics.validation", &json!({})).unwrap(), json!({"mode": "each_feature", "previous": "each_feature"}));
let r = s.execute("diagnostics.validation", &json!({"mode": "each_step"})).unwrap();
assert_eq!(r, json!({"mode": "each_step", "previous": "each_feature"}));
assert_eq!(s.validation(), Validation::EachStep);
s.execute("file.new", &json!({})).unwrap();
s.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10})).unwrap();
s.execute("timeline.compute_all", &json!({})).unwrap();
assert_eq!(s.execute("diagnostics.validation", &json!({"mode": "off"})).unwrap()["previous"], json!("each_step"));
assert_eq!(s.validation(), Validation::Off);
// A refused mode changes nothing.
assert!(s.execute("diagnostics.validation", &json!({"mode": "never"})).is_err());
assert_eq!(s.validation(), Validation::Off);
}
/// A feature whose body SMLib's check refuses fails under each_feature as under each_step (once
/// at its end instead of at the step), with the check's reason; off keeps the body. The bar's
/// top edge rounded into the boss's round (kernel case
/// fillets/1207-fillet-bar-top-edge-after-boss-arc-round-r0-5, refused by the check on this
/// SMLib); the same features without the last round build under every mode, to the same volume.
#[test]
fn a_body_the_check_refuses_still_fails_its_feature_once_per_feature() {
use solidcraft_kernel::Validation;
let build = |mode: Validation, last: bool| {
let mut s = Session::default();
s.set_validation(mode);
s.execute("solid.box", &json!({"length": 100, "width": 30, "height": 10, "corner": [0, -15, 0], "body_name": "Arm"})).unwrap();
s.execute("solid.cylinder", &json!({"diameter": 40, "height": 20, "base": [0, 0, 0], "operation": "join", "targets": ["Arm"]})).unwrap();
s.execute("solid.fillet", &json!({"edges": [[16, 12, 10]], "radius": 2})).unwrap();
let r = if last { s.execute("solid.fillet", &json!({"edges": [[60, -15, 10]], "radius": 0.5})).map(|_| ()) } else { Ok(()) };
let volume = s.execute("inspect.measure", &json!({})).ok().and_then(|m| m["total"]["volume_mm3"].as_f64());
(r.map_err(|e| e.to_string()), volume)
};
let each_step = build(Validation::EachStep, false);
for mode in [Validation::EachFeature, Validation::Off] {
let (r, volume) = build(mode, false);
assert!(r.is_ok() && each_step.0.is_ok(), "{mode:?}: {r:?}");
assert!(volume.zip(each_step.1).is_some_and(|(v, w)| (v - w).abs() <= 1e-9 * w), "{mode:?}: {volume:?} vs {:?}", each_step.1);
}
let (step, _) = build(Validation::EachStep, true);
let (feature, _) = build(Validation::EachFeature, true);
assert_eq!(step.is_err(), feature.is_err(), "each_step {step:?}, each_feature {feature:?}");
if let Err(e) = &feature {
assert!(e.contains("SMLib's check refuses the result"), "{e}");
assert!(step.as_ref().err().is_some_and(|e| e.contains("SMLib's check refuses the result")), "{step:?}");
let (off, _) = build(Validation::Off, true);
assert!(off.is_ok(), "off keeps the body the check refuses: {off:?}");
}
}
+1
View File
@@ -160,6 +160,7 @@ fn swap_in(app: &mut SolveApp, mut slot: DocSlot) -> DocSlot {
app.session.auto_project = out.session.auto_project;
app.session.metric_tap_drill_major_less_pitch = out.session.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = out.session.surface_extrude_symmetric_per_side;
app.session.set_validation(out.session.validation());
// So does the host's pre-command check: every tab is held to it.
app.session.set_command_check(out.session.command_check());
// Views cache by revision: the incoming design must not look unchanged.
+4 -1
View File
@@ -408,8 +408,10 @@ fn start(app: &mut SolveApp) {
let before = if insert { crate::open_meshing::session_world(&app.session).bodies.iter().map(|b| b.name.clone()).collect() } else { Vec::new() };
let update = request.kind == Kind::UpdateLinks;
let mut scratch = if insert || update || request.kind == Kind::ExportDxf { app.session.scratch() } else { Session::default() };
// A design opened or recovered here is run through the host's pre-command check too.
// A design opened or recovered here is run through the host's pre-command check too, and
// evaluated under the user's validation mode.
scratch.set_command_check(app.session.command_check());
scratch.set_validation(app.preferences.validation);
if insert {
scratch.selection = app.session.selection.clone();
}
@@ -537,6 +539,7 @@ fn start_staged(app: &mut SolveApp) {
let before = if insert { crate::open_meshing::session_world(&app.session).bodies.iter().map(|b| b.name.clone()).collect() } else { Vec::new() };
let mut session = if insert { app.session.scratch() } else { Session::default() };
session.set_command_check(app.session.command_check());
session.set_validation(app.preferences.validation);
if insert {
session.selection = app.session.selection.clone();
}
+3
View File
@@ -982,6 +982,7 @@ impl SolveApp {
// next frame applies them.
self.session.metric_tap_drill_major_less_pitch = self.preferences.metric_tap_drill_major_less_pitch;
self.session.surface_extrude_symmetric_per_side = self.preferences.surface_extrude_symmetric_per_side;
self.session.set_validation(self.preferences.validation);
let t0 = now_ms();
let r = self.session.execute(id, &params).map_err(|e| e.to_string());
self.big_operation |= now_ms() - t0 >= recovery_ui::BIG_OPERATION_MS;
@@ -1010,6 +1011,8 @@ impl SolveApp {
self.ui.visual_style = index;
}
}
// The command and the preference are one setting.
"diagnostics.validation" => self.preferences.validation = self.session.validation(),
"view.grid" => self.ui.show_grid = v.get("on").and_then(Value::as_bool).unwrap_or(!self.ui.show_grid),
"view.ground_shadow" => self.ui.ground_shadow = v.get("on").and_then(Value::as_bool).unwrap_or(!self.ui.ground_shadow),
"view.navigation_bar" => {
+35
View File
@@ -641,6 +641,10 @@ preference_settings! {
/// extrudes; off by default: the distance is the total, split evenly around the start plane.
/// Saved designs keep the reading they stored either way.
surface_extrude_symmetric_per_side: bool = false, PAGE_DESIGN => check_id("prefs.surface_extrude_symmetric_per_side");
/// When SMLib's full check runs while features are computed (`diagnostics.validation`):
/// `each_feature` (the default) checks the bodies each feature keeps once; `each_step`, as
/// before, checks after every sweep, boolean and blend; `off` (experimental) never does.
validation: solidcraft_engine::kernel::Validation = solidcraft_engine::kernel::Validation::EachFeature, PAGE_DESIGN;
/// Reopen the saved designs that were open when the app was last closed (#5542).
reopen_designs: bool = true, PAGE_GENERAL;
/// Those designs' files, in tab order, as the last quit left them.
@@ -1130,6 +1134,8 @@ pub fn apply(app: &mut SolveApp, ctx: &egui::Context) {
// symmetric reading.
app.session.metric_tap_drill_major_less_pitch = app.preferences.metric_tap_drill_major_less_pitch;
app.session.surface_extrude_symmetric_per_side = app.preferences.surface_extrude_symmetric_per_side;
// The features computed from now on are checked as the preference says.
app.session.set_validation(app.preferences.validation);
// The profiler records while the preference is on (switched when it changes; at start-up only
// when on, so SOLIDCRAFT_PROFILE=1 is not undone by the default).
let profile = app.preferences.profile_operations;
@@ -2341,6 +2347,11 @@ pub fn set(app: &mut SolveApp, p: &serde_json::Value) -> Result<serde_json::Valu
{
return Err("`viewport_theme` must be theme, light or dark".into());
}
if let Some(v) = p.get("validation")
&& v.as_str().and_then(solidcraft_engine::kernel::Validation::parse).is_none()
{
return Err("`validation` must be each_step, each_feature or off".into());
}
let new: Prefs = migrate(serde_json::from_value(cur).map_err(|e| e.to_string())?);
if !UNITS.contains(&new.default_units.as_str()) {
return Err(format!("units must be one of {}", UNITS.join(", ")));
@@ -3843,6 +3854,30 @@ mod tests {
assert_eq!(app.preferences.display_quality, "normal");
}
/// The validation mode is once per feature by default; set by name or by the command, the
/// two stay one setting, the session computes under it, and Restore Defaults on Design brings
/// each_feature back. A saved unknown mode reads as the default.
#[test]
fn validation_defaults_to_each_feature_and_follows_the_command() {
use serde_json::json;
use solidcraft_engine::kernel::Validation;
let mut app = crate::SolveApp::new(solidcraft_engine::Session::default(), crate::Services::default());
assert_eq!(app.preferences.validation, Validation::EachFeature);
assert_eq!(super::lenient(&json!({"validation": "sometimes"})).validation, Validation::EachFeature);
assert!(super::set(&mut app, &json!({"validation": "never"})).unwrap_err().contains("each_step, each_feature or off"));
let out = super::set(&mut app, &json!({"validation": "each_step"})).unwrap();
assert_eq!(out["validation"], "each_step");
assert_eq!(super::lenient(&out).validation, Validation::EachStep);
// A command runs under the preference.
app.run("diagnostics.validation", json!({})).unwrap();
assert_eq!(app.session.validation(), Validation::EachStep);
// The command sets the preference too.
app.run("diagnostics.validation", json!({"mode": "off"})).unwrap();
assert_eq!((app.preferences.validation, app.session.validation()), (Validation::Off, Validation::Off));
super::defaults(&mut app, super::PAGE_DESIGN);
assert_eq!(app.preferences.validation, Validation::EachFeature);
}
#[test]
fn sketch_halo_is_off_by_default_saved_and_restored() {
use serde_json::json;
+19
View File
@@ -44,6 +44,25 @@ pub(super) fn show(app: &mut SolveApp, ui: &mut egui::Ui) {
let check = setting::surface_extrude_symmetric_per_side(app, ui);
crate::scenario::publish_handle("prefs:surface_extrude_symmetric_per_side", check.rect.center());
});
// When SMLib's full check runs while features are computed (`diagnostics.validation`).
ui_kit::settings_section(ui, "validation", app.tr("prefs.validation"), |ui| {
use solidcraft_engine::kernel::Validation;
let label = |v: &Validation| match v {
Validation::EachStep => "prefs.validation.each_step",
Validation::EachFeature => "prefs.validation.each_feature",
Validation::Off => "prefs.validation.off",
};
let labels: Vec<String> = Validation::ALL.iter().map(|v| app.tr(label(v)).to_string()).collect();
let options: Vec<&str> = labels.iter().map(String::as_str).collect();
let mut selected = Validation::ALL.iter().position(|v| *v == app.preferences.validation).unwrap_or(1);
ui_kit::row(ui, app.tr("prefs.validation.label"), |ui| {
ui_kit::segmented(ui, &mut selected, &options, ui_kit::Segments { intrinsic: true, ..Default::default() });
});
if let Some(v) = Validation::ALL.get(selected) {
app.preferences.validation = *v;
}
ui_kit::text(ui, app.tr("prefs.validation_note"), ui_kit::Text::Hint("validation"));
});
ui_kit::settings_section(ui, "orientation", app.tr("prefs.orientation"), |ui| {
ui.horizontal_wrapped(|ui| {
for (id, label, y_up) in [("z", "Z up", false), ("y", "Y up", true)] {
+4
View File
@@ -14,6 +14,10 @@ The CLI links SMLib by default (`scripts/fetch-smlib.sh` fetches the prebuilt li
built with `--no-default-features`, every operation answers that SMLib is not built. The run's output folder (`--out`, default `target/kernel-cases`)
gets `results.json`, every case's full result, and `dumps/<area>-<case>/`: the inputs of each
SMLib call a case failed in, for replay (the CLI's `--dumps=DIR`, which the rig always passes).
`--validation MODE` runs the cases' features under that mode of SMLib's check
(`diagnostics.validation`): `each_feature` (the default: the bodies each feature keeps are checked
once), `each_step` (after every sweep, boolean and blend, as before) or `off`; the
`KNOWN_FAILING` lists are each_feature's.
## Rules
+13 -2
View File
@@ -32,6 +32,9 @@ pub(crate) struct Options {
out: PathBuf,
/// `--known-failing FILE`: run as a regression gate against that baseline (see [`gate`]).
known_failing: Option<PathBuf>,
/// `--validation MODE`: when SMLib's full check runs on the cases' features (each_step,
/// each_feature, off; the CLI's default, each_feature, when not given).
validation: Option<String>,
}
/// The run's options; `out` is its output folder unless `--out` gives one.
@@ -44,7 +47,11 @@ pub(crate) fn options(rest: &[&str], out: &str) -> Result<Options, String> {
let p = PathBuf::from(p);
if p.is_absolute() { p } else { root().join(p) }
});
Ok(Options { cli: arg("--cli"), area: arg("--area"), timeout: Duration::from_secs(secs), jobs, out, known_failing })
let validation = arg("--validation");
if let Some(v) = validation.as_deref().filter(|v| !["each_step", "each_feature", "off"].contains(v)) {
return Err(format!("--validation must be each_step, each_feature or off, not `{v}`"));
}
Ok(Options { cli: arg("--cli"), area: arg("--area"), timeout: Duration::from_secs(secs), jobs, out, known_failing, validation })
}
/// Every case's full result as JSON, into the run's output folder.
@@ -99,7 +106,11 @@ fn run_case(o: &Options, case: &Path) -> Value {
};
let mut dumps = std::ffi::OsString::from("--dumps=");
dumps.push(o.out.join("dumps"));
cmd.current_dir(root()).args(["kernel-cases", "--json"]).arg(dumps).arg(&rel).stdout(Stdio::piped()).stderr(Stdio::piped());
cmd.current_dir(root()).args(["kernel-cases", "--json"]).arg(dumps);
if let Some(v) = &o.validation {
cmd.arg(format!("--validation={v}"));
}
cmd.arg(&rel).stdout(Stdio::piped()).stderr(Stdio::piped());
let base = |status: &str, error: String| {
let area = case.parent().and_then(|p| p.file_name()).map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
let id = case.file_name().map(|n| n.to_string_lossy().to_string()).unwrap_or_default();
+4 -1
View File
@@ -47,7 +47,7 @@ commands:
replay the reference tests (tests/oracle/*/recipe.json), compare with each
case's expected.json and write docs/oracle.md (--cli: a solidcraft-cli
already built, instead of cargo run --release)
kernel-cases [--area AREA] [--cli BIN] [--timeout S] [--jobs N] [--out DIR] [--known-failing FILE] [--coverage]
kernel-cases [--area AREA] [--cli BIN] [--timeout S] [--jobs N] [--out DIR] [--known-failing FILE] [--validation MODE] [--coverage]
the kernel regression rig: run every case in tests/kernel-cases/<area>/<id>/ on
SMLib (one process each, killed after --timeout, default 180 s), grade it against
the case's own answer and write docs/kernel-cases.md; DIR (default
@@ -56,6 +56,9 @@ commands:
--known-failing FILE: a regression gate instead of the report: fails on a case
that fails and FILE does not list, and on a listed case that passes
(tests/kernel-cases/<area>/KNOWN_FAILING, CI's Kernel rig workflow)
--validation MODE: when SMLib's full check runs on the cases' features:
each_step, each_feature (the default) or off (solidcraft-cli kernel-cases
--validation=MODE); with --ladder too
--ladder [--record REASON | --gate]: the complexity ladder instead
(tests/kernel-cases/ladder/ladder.json, tiers in order), graded and compared
with its timing golden (one case at a time unless --jobs), into