fix(dfam-check): carry p05_mm through per_body

Review from @earthtojake on #265.

SKILL.md has two rules that only hold together if p05_mm is present per
body: judge on p05_mm because min_mm alone can be a sampling outlier, and
attribute a violation to the body it belongs to rather than the pooled
figure. per_body carried min_mm but not p05_mm, so following the first
rule on an assembly required the pooled figure the second rule forbids.

_wall_facts_single already computed p05_mm; per_body just wasn't reading
it out. One field added, nothing else touched.

Also drops `Closes #188` from the PR description - the issue 404s in this
repo, as noted in review.
This commit is contained in:
knewnothing-git
2026-08-20 22:37:08 +05:30
parent f666a97d63
commit 757591acfd
2 changed files with 15 additions and 0 deletions
+1
View File
@@ -131,6 +131,7 @@ def _wall_facts(mesh: trimesh.Trimesh, samples: int, seed: int = 42) -> dict:
per_body.append({
"body": i,
"min_mm": facts.get("min_mm"),
"p05_mm": facts.get("p05_mm"),
"median_mm": facts.get("median_mm"),
"samples_valid": facts.get("samples_valid", 0),
})
@@ -249,6 +249,20 @@ class MultiBodyWallTest(unittest.TestCase):
# 0.3 mm is the fit gap; the thinnest real wall is the 1.7 mm socket.
self.assertGreater(thinnest, 1.0)
def test_per_body_carries_p05_for_the_same_judgement_rule_as_pooled(self) -> None:
"""SKILL.md says judge on p05_mm (min_mm alone can be a sampling
outlier) and also says attribute a violation to its own body rather
than the pooled figure. Both rules only hold together if p05_mm is
present per body, not only in the pooled result.
"""
with tempfile.TemporaryDirectory() as td:
tmp = Path(td)
facts = dfam_tool._wall_facts(dfam_tool._load(self._assembly(tmp)), samples=2000)
for body in facts["per_body"]:
self.assertIn("p05_mm", body)
self.assertIsNotNone(body["p05_mm"])
def test_internal_arrays_never_reach_the_payload(self) -> None:
"""The pooled arrays are numpy and would not survive json.dumps."""
with tempfile.TemporaryDirectory() as td: