Wave 68/509: kernel-cases: fillets cases from #1008, #1191, #3276 and #3753 (and 2 more)

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

- 9c9ec27c3 Brennen Herbruck: kernel-cases: fillets cases from #1008, #1191, #3276 and #3753
- 22fdb5249 Brennen Herbruck: kernel-cases: tessellation case from #466, skipped sources for sheet-metal, sweeps and tessellation
- bf0761f6b jyviko: kernel-cases: base recipes, missing capabilities, and the commands' own time

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ
This commit is contained in:
Brennen Herbruck
2026-10-21 06:46:15 -04:00
committed by jyviko
parent ed5bed8f00
commit 68033b4357
14 changed files with 668 additions and 4 deletions
+78 -2
View File
@@ -14,17 +14,39 @@ fn kernel() -> String {
std::env::var("SOLIDCRAFT_BOOLEANS").ok().filter(|k| !k.is_empty()).unwrap_or_else(|| "default".into())
}
/// How many cases a chain of `base` recipes may go through (a ladder case builds on the one
/// before it, which builds on the one before that).
const MAX_BASE_DEPTH: usize = 32;
/// The case's commands: a script as is, or an oracle recipe translated. In a string, `$CASE` is
/// the case directory (input files such as `input.step`) and `$OUT` a scratch directory for files
/// the case writes (an export), outside the repository.
/// the case writes (an export), outside the repository. A script with `"base": "<case
/// directory>"` (relative to this case's directory) runs that case's commands first: a ladder
/// case starts from the previous tier's finished part without copying its commands.
fn script(dir: &str, out: &str, recipe: &Value) -> Result<Value, String> {
script_at(dir, out, recipe, 0)
}
fn script_at(dir: &str, out: &str, recipe: &Value, depth: usize) -> Result<Value, String> {
let s = if recipe.get("commands").is_some() || recipe.is_array() { recipe.clone() } else { recipe::to_script(recipe)? };
let text = serde_json::to_string(&s).map_err(|e| e.to_string())?;
let inner = |p: &str| -> Result<String, String> {
let j = serde_json::to_string(p).map_err(|e| e.to_string())?;
Ok(j.get(1..j.len().saturating_sub(1)).unwrap_or("").to_string())
};
serde_json::from_str(&text.replace("$CASE", &inner(dir)?).replace("$OUT", &inner(out)?)).map_err(|e| e.to_string())
let own: Value = serde_json::from_str(&text.replace("$CASE", &inner(dir)?).replace("$OUT", &inner(out)?)).map_err(|e| e.to_string())?;
let Some(base) = recipe.get("base").and_then(Value::as_str) else { return Ok(own) };
if depth >= MAX_BASE_DEPTH {
return Err(format!("`base` chain deeper than {MAX_BASE_DEPTH} cases"));
}
let base_dir = std::path::Path::new(dir).join(base).to_string_lossy().to_string();
let base_script = read_json(&format!("{base_dir}/recipe.json"))
.and_then(|r| script_at(&base_dir, out, &r, depth + 1))
.map_err(|e| format!("base {base}: {e}"))?;
let list = |v: &Value| v.get("commands").or(Some(v)).and_then(Value::as_array).cloned().unwrap_or_default();
let mut commands = list(&base_script);
commands.extend(list(&own));
Ok(json!({"commands": commands}))
}
/// A scratch directory for one case's output files.
@@ -62,6 +84,13 @@ fn check_case(dir: &str) -> Value {
}
};
out["sources"] = want["sources"].clone();
// A capability SolidCraft doesn't have yet (no command or parameter for it): recorded as a
// case so the gap is visible, never run against a stand-in.
if let Some(missing) = want["missing"].as_str() {
out["status"] = json!("unsupported");
out["error"] = json!(format!("not supported yet: {missing}"));
return out;
}
let commands = match scratch(&area, &name).and_then(|o| read_json(&format!("{dir}/recipe.json")).and_then(|r| script(dir, &o, &r))) {
Ok(s) => s,
Err(e) => {
@@ -88,7 +117,10 @@ fn check_case(dir: &str) -> Value {
let refused = outcome == "refused";
let may_refuse = refused || outcome == "solid_or_refused";
let mut s = solidcraft_engine::Session::default();
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.
out["seconds"] = json!(clock.elapsed().as_secs_f64());
match (ran, may_refuse) {
(Err(e), _) if crashed(&e.to_string()) => {
out["status"] = json!("crash");
@@ -159,6 +191,11 @@ fn check_case(dir: &str) -> Value {
let got = totals(&json!({"bodies": bodies}));
let (edges, vertices): (u64, u64) =
bodies.iter().fold((0, 0), |(e, v), b| (e + b["edges"].as_u64().unwrap_or(0), v + b["vertices"].as_u64().unwrap_or(0)));
// What the kernel made, graded or not: the ladder's golden records it per kernel.
out["measured"] = json!({
"body_count": got.body_count, "faces": got.faces, "edges": edges, "vertices": vertices,
"volume_mm3": got.volume, "area_mm2": got.area,
});
let has = |k: &str| want.get(k).is_some_and(|v| !v.is_null());
let rel = want["tolerance"]["rel"].as_f64().unwrap_or(REL_TOL);
let diag = |b: ([f64; 3], [f64; 3])| ((b.1[0] - b.0[0]).powi(2) + (b.1[1] - b.0[1]).powi(2) + (b.1[2] - b.0[2]).powi(2)).sqrt();
@@ -227,3 +264,42 @@ pub fn run(args: &[String]) -> Result<(), String> {
let bad = results.iter().filter(|r| matches!(r["status"].as_str(), Some("fail" | "crash"))).count();
if bad > 0 { Err(format!("{bad} kernel case(s) failed")) } else { Ok(()) }
}
#[cfg(test)]
mod tests {
use super::*;
fn case_dir(root: &std::path::Path, name: &str, recipe: &Value) -> String {
let d = root.join(name);
std::fs::create_dir_all(&d).unwrap();
std::fs::write(d.join("recipe.json"), recipe.to_string()).unwrap();
d.to_string_lossy().to_string()
}
#[test]
fn base_commands_run_first_through_the_chain() {
let root = std::env::temp_dir().join(format!("kernel-cases-base-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&root);
case_dir(&root, "a", &json!({"commands": [{"command": "a", "params": {"file": "$OUT/a.step"}}]}));
case_dir(&root, "b", &json!({"base": "../a", "commands": [{"command": "b"}]}));
let c = case_dir(&root, "c", &json!({"base": "../b", "commands": [{"command": "c", "params": {"file": "$CASE/x"}}]}));
let r = read_json(&format!("{c}/recipe.json")).unwrap();
let s = script(&c, "/scratch", &r).unwrap();
let ids: Vec<&str> = s["commands"].as_array().unwrap().iter().map(|c| c["command"].as_str().unwrap()).collect();
assert_eq!(ids, ["a", "b", "c"]);
assert_eq!(s["commands"][2]["params"]["file"], json!(format!("{c}/x")));
// `$OUT` is the running case's scratch directory, in its bases too.
assert_eq!(s["commands"][0]["params"]["file"], json!("/scratch/a.step"));
let _ = std::fs::remove_dir_all(&root);
}
#[test]
fn a_base_cycle_is_an_error_not_a_hang() {
let root = std::env::temp_dir().join(format!("kernel-cases-cycle-{}", std::process::id()));
let _ = std::fs::remove_dir_all(&root);
let a = case_dir(&root, "a", &json!({"base": "../a", "commands": []}));
let r = read_json(&format!("{a}/recipe.json")).unwrap();
assert!(script(&a, "/scratch", &r).unwrap_err().contains("deeper than"));
let _ = std::fs::remove_dir_all(&root);
}
}
@@ -0,0 +1,23 @@
{
"sources": [
"tangency-labs/solidcraft#1008"
],
"what": "an R10 round on the four inside floor edges and three of the four inside vertical corners of an open tray, so one corner keeps a sharp vertical edge where two floor rounds meet (rebuilt from the report's edge picks: the original design is not in the report)",
"source": "analytic",
"method": "Tray 100x100x50, cavity 90x90 from z=5 up through the open top (walls and floor 5 mm): V0 = 500000 - 90*90*45 = 135500. Rounding concave edges adds material. Let P be the cavity's plan outline after the vertical rounds: the 90x90 square with three corners rounded R10 (one corner sharp), area 8100 - 3 (1-pi/4) 100 = 8035.6194. The floor round is a rolling ball of R10 along the outline, so over a point at plan distance d from the outline (d<10) the floor rises by g(d) = 10 - sqrt(100 - (10-d)^2); at the sharp corner the two rounds meet in a mitre, which is g of the distance to the nearest wall, the same rule; at a rounded corner the torus degenerates to the ball's sphere. Co-area: the integral of g(d) over P = integral over t in [0,10] of g(t) L(t) dt, with L(t) the perimeter of the outline pulled in by t, L(t) = L0 - 2 pi t for a convex outline (L0 = 360 - 3 (20 - 5 pi) = 347.1239). Integral of g = (1-pi/4) 100 = 21.4602; integral of t g = 1000 (5/6 - pi/4) = 47.9352 (first moment of the square minus quarter disc). Added by the floor rounds = 347.1239*21.4602 - 2 pi 47.9352 = 7148.1569. Cavity after = 45 * 8035.6194 - 7148.1569 = 354454.7183; V = 500000 - that = 145545.2817 mm3 (a grid sum over the plan agrees to 2e-4).",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 145545.2817,
"bbox": {
"min": [
0,
-100,
0
],
"max": [
100,
0,
50
]
}
}
@@ -0,0 +1,78 @@
{
"commands": [
{
"command": "solid.box",
"params": {
"corner": [
0,
-100,
0
],
"length": 100,
"width": 100,
"height": 50,
"body_name": "Tray"
}
},
{
"command": "solid.box",
"params": {
"corner": [
5,
-95,
5
],
"length": 90,
"width": 90,
"height": 46,
"operation": "cut",
"targets": [
"Tray"
]
}
},
{
"command": "solid.fillet",
"params": {
"edges": [
[
5,
-50,
5
],
[
50,
-95,
5
],
[
95,
-50,
5
],
[
50,
-5,
5
],
[
95,
-5,
27.5
],
[
5,
-5,
27.5
],
[
5,
-95,
27.5
]
],
"radius": 10
}
}
]
}
@@ -0,0 +1,24 @@
{
"sources": [
"tangency-labs/solidcraft#1191"
],
"what": "an R2 round on the outer and inner rim circles of a tube's top face (the report's ten picks on a ring-shaped top: the round failed after 0.10.1; rebuilt as a plain tube since the design is not in the report)",
"source": "analytic",
"method": "Tube R=18.5, r=11.5, h=33: V0 = pi (18.5^2 - 11.5^2) 33 = 21771.2371. Each rim round removes the square-minus-quarter-disc section (area A = (1-pi/4) 4 = 0.858407, first moment about the round's centre line rho^3/6 = 4/3) swept about the axis (Pappus). Outer rim (convex), section centre at radius 16.5: 2 pi (16.5 A + 4/3) = 97.3737; inner rim (convex, material outside r=11.5), centre at radius 13.5: 2 pi (13.5 A - 4/3) = 64.4333. V = 21771.2371 - 97.3737 - 64.4333 = 21609.4311 mm3. Faces: outer wall, two toroidal rounds, top ring, inner wall, bottom ring = 6.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 21609.4311,
"faces": 6,
"bbox": {
"min": [
-18.5,
-18.5,
0
],
"max": [
18.5,
18.5,
33
]
}
}
@@ -0,0 +1,67 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XY"
}
},
{
"command": "sketch.circle.center",
"params": {
"center": [
0,
0
],
"radius": 18.5
}
},
{
"command": "sketch.circle.center",
"params": {
"center": [
0,
0
],
"radius": 11.5
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 33,
"body_name": "Ring",
"profiles": [
{
"point": [
15,
0
]
}
]
}
},
{
"command": "solid.fillet",
"params": {
"edges": [
[
0,
18.5,
33
],
[
0,
11.5,
33
]
],
"radius": 2
}
}
]
}
@@ -0,0 +1,28 @@
{
"sources": [
"tangency-labs/solidcraft#3276"
],
"what": "three extrudes joined into an L-shaped body with a 1 mm protrusion, then a chamfer on the protrusion's outer edge (the report: the corners are no longer 90 degrees and the chamfer fails)",
"source": "analytic",
"method": "Base 40x20x10 (8000). A wall 40x5x20 extruded up from the base's top face at y 0..5 (4000): an L section. A 20x10 pad extruded 1 mm out of the wall's front face (y 5..6, z 10..20, x 10..30) (200). A 0.5 mm chamfer on its top outer edge (y=6, z=20, length 20) removes a right triangle 0.5x0.5/2 x 20 = 2.5. V = 12200 - 2.5 = 12197.5 mm3. Centre of mass from the pieces: base (20,10,5), wall (20,2.5,20), pad (20,5.5,15), minus the removed wedge at (20, 17/3, 59.5/3).",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 12197.5,
"center_of_mass": [
20.0,
7.4676,
10.08
],
"bbox": {
"min": [
0,
0,
0
],
"max": [
40,
20,
30
]
}
}
@@ -0,0 +1,119 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XY"
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
40,
20
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 10,
"body_name": "L"
}
},
{
"command": "sketch.create",
"params": {
"plane": {
"face": [
20,
10,
10
]
}
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
0,
0
],
"p1": [
40,
5
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 20,
"operation": "join"
}
},
{
"command": "sketch.create",
"params": {
"plane": {
"face": [
20,
5,
20
]
}
}
},
{
"command": "sketch.rectangle.two_point",
"params": {
"p0": [
-30,
10
],
"p1": [
-10,
20
]
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 1,
"operation": "join"
}
},
{
"command": "solid.chamfer",
"params": {
"edges": [
[
20,
6,
20
]
],
"distance": 0.5
}
}
]
}
@@ -0,0 +1,24 @@
{
"sources": [
"tangency-labs/solidcraft#3753"
],
"what": "a circular pattern (6 copies about Y) of a through hole and the 1 mm chamfer on its rim (the report: the pattern is refused because the copied chamfer 'would grow the part'); rebuilt as a hole in a disc, the original design is not in the report",
"source": "analytic",
"method": "Disc R=30, h=10 (axis Y): V0 = pi 900 10 = 28274.3339. Each hole: diameter 4 through (pi 4 10 = 125.6637) plus the 1 mm chamfer on the top rim, a frustum from r=2 (depth 1) to r=3 (top) minus the cylinder it overlaps: pi/3 (4 + 6 + 9) - 4 pi = 7 pi/3 = 7.3304. The holes sit on a circle of radius 20, 60 degrees apart (chord 20, holes 4 mm wide plus the chamfer's 6 mm: no overlap, and 20 - 3 > 0 leaves the rim inside the disc). V = V0 - 6 (125.6637 + 7.3304) = 27476.3693 mm3. Faces: side, top, bottom, plus a wall and a cone per hole = 15.",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 27476.3693,
"faces": 15,
"bbox": {
"min": [
-30,
0,
-30
],
"max": [
30,
10,
30
]
}
}
@@ -0,0 +1,67 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XZ"
}
},
{
"command": "sketch.circle.center",
"params": {
"center": [
0,
0
],
"radius": 30
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.extrude",
"params": {
"distance": 10,
"body_name": "Disc"
}
},
{
"command": "solid.hole",
"params": {
"position": [
20,
10,
0
],
"diameter": 4
}
},
{
"command": "solid.chamfer",
"params": {
"edges": [
[
22,
10,
0
]
],
"distance": 1
}
},
{
"command": "solid.pattern.circular",
"params": {
"features": [
"Hole1",
"Chamfer1"
],
"axis": "Y",
"count": 6,
"angle": "360 deg"
}
}
]
}
+9 -1
View File
@@ -346,5 +346,13 @@
{
"source": "tangency-labs/solidcraft#117",
"why": "profile picks by curves, not geometry"
},
{
"source": "tangency-labs/solidcraft#2461",
"why": "auto-report with command parameters only (an extrude cut on a face of a sheet metal bracket refused for touching a bend); the bracket is not in the report and the refusal is the documented behaviour, no number to grade"
},
{
"source": "tangency-labs/solidcraft#3680",
"why": "auto-report with command parameters only (a 5 mm drilled hole at one point of a sheet metal bracket, refused as unsupported 3D machining); no design, and holes in flat sheet are covered by 560 and 955"
}
]
]
+5 -1
View File
@@ -286,5 +286,9 @@
{
"source": "tangency-labs/solidcraft#85",
"why": "not geometry: batch rollback and deleting a sketch removes its pipe (document history)"
},
{
"source": "tangency-labs/solidcraft#1967",
"why": "no repro: 'the Loft operation isn't working', no sections, no parameters, no design"
}
]
]
@@ -0,0 +1,24 @@
{
"sources": [
"tangency-labs/solidcraft#466"
],
"what": "a six-line profile revolved a full turn about its first line, with a cone ending in a point: the tip came out with dents every 120 degrees instead of a smooth cone (rebuilt as a pencil-like profile with a collinear frustum and tip; the original design is not in the report)",
"source": "analytic",
"method": "Profile (x radius, y along the axis): (0,0)-(0,40) on the axis, (0,40)-(10,40), (10,40)-(10,25), (10,25)-(10,15), (10,15)-(4,6), (4,6)-(0,0), revolved 360 degrees about the Y axis. Cylinder R=10 from y=15 to 40: pi 100 25 = 2500 pi. Cone from r=10 at y=15 to r=4 at y=6 then on to the point at y=0 (the two cone lines are collinear, slope 2/3): frustum pi 9/3 (100 + 40 + 16) = 468 pi, tip pi 16 6/3 = 32 pi. V = 3000 pi = 9424.7780 mm3. Area: top disc 100 pi + cylinder 2 pi 10 25 + frustum pi (10+4) sqrt(81+36) + tip pi 4 sqrt(16+36) = 2451.3143 mm2. The dents are a meshing defect this rig can only see through the exact solid's volume and area (no mesh grading field).",
"outcome": "solid",
"body_count": 1,
"volume_mm3": 9424.778,
"area_mm2": 2451.3143,
"bbox": {
"min": [
-10,
0,
-10
],
"max": [
10,
40,
10
]
}
}
@@ -0,0 +1,118 @@
{
"commands": [
{
"command": "sketch.create",
"params": {
"plane": "XY"
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
0,
0
],
[
0,
40
]
],
"infer": false
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
0,
40
],
[
10,
40
]
],
"infer": false
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
10,
40
],
[
10,
25
]
],
"infer": false
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
10,
25
],
[
10,
15
]
],
"infer": false
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
10,
15
],
[
4,
6
]
],
"infer": false
}
},
{
"command": "sketch.line",
"params": {
"points": [
[
4,
6
],
[
0,
0
]
],
"infer": false
}
},
{
"command": "sketch.finish",
"params": {}
},
{
"command": "solid.revolve",
"params": {
"axis": "Y",
"angle": "360 deg",
"body_name": "Pencil"
}
}
]
}
@@ -1010,5 +1010,9 @@
{
"source": "tangency-labs/solidcraft#4154",
"why": "rendering pipeline (CPU/GPU renderer, lighting, materials); no B-rep or mesh geometry"
},
{
"source": "tangency-labs/solidcraft#2450",
"why": "display only: Section Analysis draws a white line along the edge of a circular-pattern of a revolve; the report has no revolve profile or section plane, and the solid itself is not claimed wrong"
}
]