diagnostics.kernel: read and set which kernel answers, and see the routing table

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SdcgExNEwfR9CX2RAzp2Pt
This commit is contained in:
Brett Lawson
2026-10-28 22:53:26 +01:00
parent ff909b58d5
commit 12ace49736
2 changed files with 21 additions and 0 deletions
+19
View File
@@ -38,6 +38,12 @@ 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.kernel", "Geometry Kernel", kernel).icon("bug_report").noundo().params(
"choice?: routed | smlib | solidcore (sets which kernel answers: routed = each operation on the kernel the routing \
table gives it, smlib = the C++ SMLib kernel for all, solidcore = its Rust port for all; bodies already computed \
keep their results). SOLIDCRAFT_KERNEL, when set, wins over it. Returns {choice, environment, routes: [{op, \
route, backend}]}: route is the table's kernel for the operation, backend the one it runs on now",
),
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 \
@@ -45,6 +51,19 @@ pub static COMMANDS: &[CommandSpec] = &[
),
];
fn kernel(_: &mut Session, p: &Value) -> Result<Value> {
use solidcraft_kernel::kernel_route as route;
if let Some(id) = str_(p, "choice") {
let c = route::Choice::from_id(id).ok_or_else(|| bad("diagnostics.kernel", "`choice` is routed, smlib or solidcore"))?;
route::set_choice(c);
}
let routes: Vec<Value> = route::Op::ALL
.iter()
.map(|op| json!({ "op": format!("{op:?}").to_lowercase(), "route": op.route().id(), "backend": op.backend().id() }))
.collect();
Ok(json!({ "choice": route::choice().id(), "environment": route::overridden(), "routes": routes }))
}
fn dir(cmd: &str) -> Result<std::path::PathBuf> {
crash::default_dir().ok_or_else(|| bad(cmd, "no crash folder on this system"))
}
+2
View File
@@ -207,6 +207,8 @@ pub use polyhedron::{HalfSpace, convex_polyhedron, draft, offset_faces, shell};
pub use prism::{PLANAR_FIT_TOL, extrude_planar_regions, planar_regions_boolean};
pub use prism_measure::certified_prism_equivalent;
pub use sew::{EdgeSpec, FaceSpec, SurfSpec, sew, sew_touching};
/// Which kernel answers each operation, SMLib or solidcore (crates/smlib/src/route.rs).
pub use solidcraft_smlib::route as kernel_route;
pub use splitface::{SplitTool, split_body, split_faces, split_faces_with_map};
pub use step::step_export;
pub use step_in::{