From 049b2bc4059abee154ea3917a2cf9bc881f2df1d Mon Sep 17 00:00:00 2001 From: jyviko <2501648+jyviko@users.noreply.github.com> Date: Thu, 29 Oct 2026 21:51:09 -0400 Subject: [PATCH] Lumps: a face-source table of another length is refused, never sliced Body::parts (and so Body::lumps) mapped each piece's faces through the body's face-source table with a silent `get`, so a table shorter or longer than the body's faces gave its pieces sources of other faces, or none. The table is by face position: one whose length is not the body's face count belongs to another body. The pieces are now refused with "lumps: face source table does not match the body", as before the SMLib port (the check went with the old lumps_with_clearance in 66e31bede). Fixes kernel body::lump_tests::grouping_lumps_does_not_infer_absent_or_misaligned_sources. Co-Authored-By: Claude Opus 5.5 --- crates/kernel/src/body.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/crates/kernel/src/body.rs b/crates/kernel/src/body.rs index fbe6f8d50..763ff9ab8 100644 --- a/crates/kernel/src/body.rs +++ b/crates/kernel/src/body.rs @@ -1351,6 +1351,10 @@ impl Body { pub fn parts(&self, groups: &[Vec]) -> Result> { let regions = self.record.material_regions(); let counts = [(self.face_count(), self.edge_count())]; + // Sources are by face position: a table of another length belongs to another body. + if self.face_sources.as_ref().is_some_and(|all| all.len() != self.face_count()) { + return Err(KernelError::Invalid("lumps: face source table does not match the body".into())); + } groups .iter() .map(|group| {