New kernel cases go to solidcore's corpus; the rig's case list only shrinks (#11646)

* New kernel cases go to solidcore's corpus; tests/kernel-cases/ only shrinks

tests/kernel-cases/CASES lists every rig and ladder case there is today. `cargo xtask lists`
fails on a case directory it does not list, saying where a kernel case goes instead
(solidcore's crates/solidcore/tests/kernel_cases/, exported with `cargo xtask kernel-cases
--export` or written by hand), and on a listed case that is gone. AGENTS.md, CONTRIBUTING.md,
the tests skill, the rig README and EXEMPT say the same; a new command gets an EXEMPT line
naming where it is tested.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ

* CONTRIBUTING: the kernel-cases paragraph ends before the naming corpus one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DtL5M41G8Nua7HvuFPZkmJ

---------

Co-authored-by: jyviko <2501648+jyviko@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
jyviko
2026-11-03 15:42:09 +00:00
committed by GitHub
parent 138e3478e6
commit 81e55b5443
8 changed files with 1349 additions and 19 deletions
+1
View File
@@ -11,6 +11,7 @@ Work: ROADMAP.md, "Where help is wanted most" in CONTRIBUTING.md, issues labelle
- Every asset is original or openly licensed with a row in ATTRIBUTION.md; read `assets/AGENTS.md` before icon work: `cargo xtask assets`, `cargo xtask icons`.
- Never crash: no unwrap/expect/panic/unsafe in non-test code (unsafe allowlist in crash-safety), errors are `Result`, input is hostile: clippy `-D warnings`, `hostile_params_never_panic`.
- Model decisions (what an operation does, which bodies it touches, which face or edge a point or name means, depths, nearness) use exact geometry; a mesh is for display, export, previews and mesh bodies (`xtask/mesh-decisions.txt` only shrinks): `cargo xtask mesh-decisions`.
- New kernel cases go to solidcore: `cargo xtask lists`.
- Everything is a command and programmatic calls never open dialogs: `skills/solidcraft-commands/SKILL.md`.
- Layering (geom, sketch/kernel/render, doc, io, engine, ui-egui, apps); only `crates/kernel` uses truck: `cargo xtask layers`.
- One outer UI container, one camera path (`navigation::handle`), colours from theme tokens: `cargo xtask ui-containers`.
+12
View File
@@ -163,6 +163,18 @@ the most complete description of the house style.
The reference for what the kernel builds is the kernel-cases ladder (`tests/kernel-cases/ladder/`,
`cargo xtask kernel-cases --ladder`, [docs/kernel-ladder.md](docs/kernel-ladder.md)).
**Kernel cases go to solidcore.** A case that checks a kernel operation (a boolean, a blend, a
shell, a sweep, an import's geometry) is a new entry in solidcore's corpus,
`crates/solidcore/tests/kernel_cases/<area>/` in
[tangency-labs/solidcore](https://github.com/tangency-labs/solidcore), with an answer in closed
form or exact. Draft it as a rig case here, export it with
`cargo xtask kernel-cases --area <area> --export DIR`, add `DIR/<area>/<case>.json` and its
`.bodies.json.gz` there, and delete the draft; or write the entry by hand as that folder's README
describes. `tests/kernel-cases/` takes no new cases: its `CASES` list only shrinks
(`cargo xtask lists`). App-level cases (what a command does, the UI, product rules) stay in
SolidCraft, as tests in their area's existing test file or UI scenarios.
The naming corpus checks persistent names: every name a corpus design stores still finds a face or
an edge, and two builds name its faces and edges alike
(`cargo test --profile ci -p solidcraft-cli --test naming_corpus`).
+2 -2
View File
@@ -16,7 +16,7 @@ The long form is `docs/book/src/dev/testing.md`.
## Unit test or rig case
- Unit tests assert the code's logic: which edges a chain picks, name resolution, history labels, refusal wording, hostile input, parsing and saving (`a_corner_round_wider_than_its_faces_overflows_and_takes_the_corners_other_edges`: per-edge radii, which no command takes).
- The rig (`tests/kernel-cases/`) asserts geometry: exact volumes, shapes, seam continuity, geometric refusals, through commands with a hand-derived answer, so it survives a kernel swap (`fillets/190-fillet-disc-rim-past-its-2mm-wall`). A test doing both keeps only its logic.
- The rig asserts geometry (exact volumes, shapes, seams, refusals) with a hand-derived answer. A test doing both keeps only its logic. `tests/kernel-cases/` only shrinks: kernel cases go to solidcore (CONTRIBUTING.md "Tests"); command, UI and product-rule cases stay here.
## A failing test needs its fix
A failing test cannot merge without its fix (it turns `main` red): include it, or list the test and cause in `tests/KNOWN_FAILING_TESTS` (`cargo xtask known-failing`); the fix drops the line.
@@ -28,7 +28,7 @@ A failing test cannot merge without its fix (it turns `main` red): include it, o
## Goldens, matrices and skipped tests
- The kernel's reference is the ladder (`tests/kernel-cases/ladder/`, `cargo xtask kernel-cases --ladder`, `docs/kernel-ladder.md`).
- Kernel PRs run `kernel-rig.yml` (areas by `PATHS` against `KNOWN_FAILING`, the ladder against its golden). In the same PR a fix drops its line, a new failing case adds one, a changed ladder result is re-recorded (`--record "why"`), a new command gets a case or an `EXEMPT` line (`tests/kernel-cases/README.md`).
- Kernel PRs run `kernel-rig.yml` (areas by `PATHS` against `KNOWN_FAILING`, the ladder against its golden). In the same PR a fix drops its line, a pin bump's new failure adds one, a changed ladder result is re-recorded (`--record "why"`), a new command gets an `EXEMPT` line (`tests/kernel-cases/README.md`).
- Maintainers' PRs run native, GPU and reference tests on affected packages; others wait for `approved-for-ci`. `release-gate.yml` runs all before develop replaces main.
- The action matrix is a ratchet: bless a newly passing action (`cargo xtask action-matrix --bless`, `docs/action-matrix.md`).
- PRs skip a few heavy tests, run in the merge queue, nightly and on `main`. Check them after merging (`.config/nextest.toml`).
File diff suppressed because it is too large Load Diff
+7 -4
View File
@@ -5,7 +5,9 @@
#
# Commands with no geometry to grade: the view, rendering, appearance, materials, selection, the
# browser, files and saving, documents, diagnostics, and component, parameter and timeline
# bookkeeping. Each is covered by the engine's and the UI's own tests.
# bookkeeping. Each is covered by the engine's and the UI's own tests. A command added since this
# folder stopped taking cases (tests/kernel-cases/CASES) is listed here too, its reason naming
# where it is tested: its kernel case in solidcore's corpus, or its test in its area's test file.
appearance.assign appearance only: colours and textures
appearance.chain appearance only: colours and textures
@@ -349,9 +351,10 @@ view.tool the view: camera, layout, display
view.top the view: camera, layout, display
view.visual_style the view: camera, layout, display
# Commands that make or change geometry and have no case yet. This section only shrinks:
# the pull request that adds a case for one removes its line (the check fails on a listed command
# that a case uses), and a new geometry command gets a case, not a line here.
# Commands that make or change geometry and have no case yet. This section only shrinks: the
# pull request that gives one a case in solidcore's corpus or a test moves its line to the section
# above with where it is tested (the check fails on a listed command that a case here uses), and a
# new geometry command gets its line in the section above.
[to cover]
body.repair repair: the solid a refused or open part becomes
component.move_sketches assemblies: sketches moved between components
+28 -11
View File
@@ -5,6 +5,12 @@ crash report, is a use case here with its own right answer. The kernel, solidcor
of them. `cargo xtask kernel-cases` runs them and writes
[`docs/kernel-cases.md`](../../docs/kernel-cases.md).
**This folder takes no new cases.** New kernel cases go to solidcore's corpus,
`crates/solidcore/tests/kernel_cases/<area>/` in
[tangency-labs/solidcore](https://github.com/tangency-labs/solidcore) (see
[Exporting to solidcore](#exporting-to-solidcore)). `CASES` lists every case here and only
shrinks: `cargo xtask lists` fails on a case it does not list, and on a listed case that is gone.
```sh
cargo xtask kernel-cases # every case
cargo xtask kernel-cases --cli target/release/solidcraft-cli --out /tmp/run # with a CLI already built
@@ -148,8 +154,9 @@ request, so the list only shrinks and never goes stale:
- a fix (yours, or a solidcore pin bump): remove the line of each case the shard reports as
`FIXED`;
- a new case that fails today: add its line, sorted, with the cause from its result
(`results.json` in the shard's `kernel-rig-results-<area>` artifact, or a local run);
- a case here that starts failing for a reason the kernel owns (a solidcore pin bump): add its
line, sorted, with the cause from its result (`results.json` in the shard's
`kernel-rig-results-<area>` artifact, or a local run);
- a regression: fix it in the same pull request.
To check a list locally before pushing: `cargo xtask kernel-cases --area <area> --cli
@@ -174,10 +181,9 @@ The workflow's trigger paths are whole folders that hold every `PATHS` glob (a s
starts no job at all. To see what a change would run:
`git diff --name-only -z origin/develop... | python3 scripts/ci/kernel_rig_plan.py --paths -`.
**A new area** joins with its folder: its cases, a `KNOWN_FAILING` (empty but for its header
when every case passes), and a `PATHS` listing the files its commands go through. The plan finds
the areas from the folders, so the workflow needs no edit (unless a `PATHS` glob lies outside
the trigger paths, which the self-test reports). Add a row to the table under Layout.
The plan finds the areas from the folders, so the workflow needs no edit when an area's `PATHS`
changes (unless a glob lies outside the trigger paths, which the self-test reports). No new area
joins: new kernel cases go to solidcore's corpus.
### Every command has a case
@@ -188,8 +194,9 @@ has no case>`, each section sorted. Lines before `[to cover]` have no geometry t
view, rendering, appearance, files, component and parameter bookkeeping, ...). Lines after it
make geometry and wait for a case: that section only shrinks. The check also fails on a listed
command that a case now uses (remove its line in the same pull request) or that the registry no
longer has. A new geometry command gets a case, not an `EXEMPT` line. The build job runs for this
check on any change to `crates/engine/src/cmd/`, a recipe or `EXEMPT`, even when no area does.
longer has. A new command gets an `EXEMPT` line before `[to cover]` whose reason names where it
is tested: its kernel case in solidcore's corpus, or its test in its area's test file. The build
job runs for this check on any change to `crates/engine/src/cmd/`, a recipe or `EXEMPT`, even when no area does.
## The complexity ladder
@@ -233,6 +240,16 @@ the timeout).
## Exporting to solidcore
solidcore#349 proposes a graded case format for the Rust port. The cases here are SolidCraft's
copy and the source; each one maps onto it field by field (`sources`, the derivation, the
graded quantities and invariants), so an exporter can write them out for solidcore unchanged.
solidcore holds the kernel cases as a corpus of kernel operations,
`crates/solidcore/tests/kernel_cases/<area>/<case>.json`, described in that folder's README.
`cargo xtask kernel-cases [--ladder] [--area AREA] --export DIR` writes each case here as such
an entry: the kernel operations that made its result, their operand records
(`<case>.bodies.json.gz`), the fix set and the expected values, with `DIR/manifest.json` listing
every case that is not expressible as kernel input and why.
A new kernel case: draft it here as `<area>/<id>/recipe.json` and `expected.json` (the format
above, answers in closed form or exact), export it with `--area <area> --export DIR`, add
`DIR/<area>/<id>.json` and its `.bodies.json.gz` to solidcore's corpus in a pull request there,
and delete the draft (it is not in `CASES`, so it cannot be committed here). An entry can also be
written by hand as solidcore's README describes. A case about a command, the UI or a product
rule stays in SolidCraft as a test in its area's existing test file.
+86 -1
View File
@@ -625,7 +625,7 @@ fn coverage(registry: &[(String, bool)], used: &[String], exempt_text: &str) ->
if used.iter().any(|u| u == id) {
covered += 1;
} else if !listed.iter().any(|e| e.id == id) {
problems.push(format!("NO CASE: {id} (add a case under tests/kernel-cases/, or a line to EXEMPT)"));
problems.push(format!("NO CASE: {id} (tests/kernel-cases/ takes no new cases: add a line to EXEMPT naming where it is tested)"));
}
}
if !problems.is_empty() {
@@ -641,6 +641,75 @@ fn run_coverage(o: &Options, dir: &Path) -> Result<String, String> {
coverage(&registry(o)?, &used_commands(dir)?, &text).map_err(|e| format!("{}: {e}", file.display()))
}
/// The committed list of the rig's cases. New kernel cases go to solidcore's corpus, so this
/// list only shrinks: `cargo xtask lists` fails on a case it does not name, and on a line whose
/// case is gone (the pull request that deletes a case removes its line).
pub const CASES_LIST: &str = "tests/kernel-cases/CASES";
/// Where a new kernel case goes instead, for the check's failure message.
const NEW_CASES_GO: &str = "tests/kernel-cases/ takes no new cases. A kernel case goes to solidcore's corpus, \
crates/solidcore/tests/kernel_cases/<area>/ in tangency-labs/solidcore: draft it here as a recipe, export it with \
`cargo xtask kernel-cases --area <area> --export DIR` and add DIR/<area>/<case>.json (and its .bodies.json.gz) there, \
or write the entry by hand as that folder's README describes; then delete the draft. A case about a command, the UI \
or a product rule is a test in its area's existing test file here (CONTRIBUTING.md, \"Tests\").";
/// `cargo xtask lists`: every case directory under `tests/kernel-cases/` is in [`CASES_LIST`],
/// and every line there is a case.
pub fn check_cases_list(root: &Path) -> Result<(), String> {
let dir = root.join("tests/kernel-cases");
let mut found = Vec::new();
case_dirs(&dir, &dir, &mut found)?;
let file = root.join(CASES_LIST);
let text = std::fs::read_to_string(&file).map_err(|e| format!("{CASES_LIST}: {e}"))?;
cases_listed(&text, &found).map_err(|e| format!("{CASES_LIST}: {e}"))
}
/// Every directory under `dir` that holds a `recipe.json` (a rig case or a ladder case), as its
/// path relative to `base` with `/` separators.
fn case_dirs(dir: &Path, base: &Path, out: &mut Vec<String>) -> Result<(), String> {
for entry in std::fs::read_dir(dir).map_err(|e| format!("{}: {e}", dir.display()))?.flatten() {
let path = entry.path();
if !path.is_dir() {
continue;
}
if path.join("recipe.json").is_file() {
out.push(path.strip_prefix(base).unwrap_or(&path).to_string_lossy().replace('\\', "/"));
}
case_dirs(&path, base, out)?;
}
Ok(())
}
/// The list `text` (one case a line, sorted, none twice; `#` starts a comment) against the cases
/// `found`: fails on a case it does not list, and on a listed case that is not there.
fn cases_listed(text: &str, found: &[String]) -> Result<(), String> {
let mut listed: Vec<&str> = Vec::new();
for (n, line) in text.lines().enumerate() {
let line = line.trim();
if line.is_empty() || line.starts_with('#') {
continue;
}
if let Some(prev) = listed.last()
&& *prev >= line
{
let what = if *prev == line { "a repeat" } else { "out of order" };
return Err(format!("line {}: {line} is {what} after {prev}: keep the list sorted, one case a line", n + 1));
}
listed.push(line);
}
let mut new: Vec<&str> = found.iter().map(String::as_str).filter(|c| listed.binary_search(c).is_err()).collect();
new.sort_unstable();
let gone: Vec<&str> = listed.iter().copied().filter(|l| !found.iter().any(|c| c == l)).collect();
let mut problems = Vec::new();
if !new.is_empty() {
problems.push(format!("NEW CASE: {}\n{NEW_CASES_GO}", new.join(", ")));
}
if !gone.is_empty() {
problems.push(format!("listed but not a case (remove its line): {}", gone.join(", ")));
}
if problems.is_empty() { Ok(()) } else { Err(problems.join("\n")) }
}
#[cfg(test)]
mod tests {
use super::*;
@@ -738,4 +807,20 @@ mod tests {
let gone = coverage(&registry, &used, "view.fit camera only\nview.gone removed\n[to cover]\nsolid.cone x\n").unwrap_err();
assert!(gone.contains("view.gone, which is not a registry command"), "{gone}");
}
/// The case list only shrinks: a new case directory fails with where kernel cases go now, a
/// deleted case still listed fails, and the list stays sorted with no case twice.
#[test]
fn the_case_list_fails_on_a_new_case_and_on_a_gone_one() {
let found = |cases: &[&str]| cases.iter().map(|c| c.to_string()).collect::<Vec<_>>();
let list = "# header\nbooleans/1-a\nladder/01-tier/001-box\n";
assert!(cases_listed(list, &found(&["ladder/01-tier/001-box", "booleans/1-a"])).is_ok());
let new = cases_listed(list, &found(&["booleans/1-a", "booleans/2-b", "ladder/01-tier/001-box"])).unwrap_err();
assert!(new.contains("NEW CASE: booleans/2-b"), "{new}");
assert!(new.contains("crates/solidcore/tests/kernel_cases/"), "{new}");
let gone = cases_listed(list, &found(&["booleans/1-a"])).unwrap_err();
assert!(gone.contains("remove its line): ladder/01-tier/001-box"), "{gone}");
assert!(cases_listed("b\na\n", &found(&["a", "b"])).unwrap_err().contains("out of order"));
assert!(cases_listed("a\na\n", &found(&["a"])).unwrap_err().contains("a repeat"));
}
}
+6 -1
View File
@@ -7,6 +7,8 @@
//! duplicate ids, as `serde_json` pretty-prints them.
//! - `tests/KNOWN_FAILING_TESTS`: one test a line with its cause, sorted, each test once
//! (checked only; `cargo xtask known-failing` reads it).
//! - `tests/kernel-cases/CASES`: every kernel rig case, sorted; it only shrinks, since new kernel
//! cases go to solidcore's corpus (checked only).
//! - Growing Rust lists: no written array lengths on more than ten lines of entries.
use std::path::Path;
@@ -44,7 +46,10 @@ pub fn run(root: &Path, fix: bool) -> Result<(), String> {
crate::pending::check_locales(root)?;
crate::pending::check_attribution(root)?;
crate::known_failing::check_list(root)?;
println!("lists: growing arrays checked; message catalogs and the known-failing tests sorted; pending locale and attribution files fold cleanly");
crate::kernel_cases::check_cases_list(root)?;
println!(
"lists: growing arrays checked; message catalogs, the known-failing tests and the kernel rig cases sorted (no new rig case); pending locale and attribution files fold cleanly"
);
Ok(())
}