Skip to content

DFM polish bundle: stocksim wired or removed, geom helper dedup, rule-pack schema validation #192

@ecto

Description

@ecto

Three small cleanups grouped into one ticket. Each is independent; can be split into separate PRs if convenient.


1. vcad-kernel-stocksim is built but unused

crates/vcad-kernel-stocksim/src/{lib,collision,marching_cubes,octree,subtract}.rs exists and CLAUDE.md (line ~150) explicitly notes it as "WIP, no consumers yet." A repo-wide grep for vcad_kernel_stocksim outside its own files returns zero hits. It's pulling its weight in compile time and member-list noise.

Action: either wire it into the CAM crate (it was presumably built for stock simulation during CNC toolpath planning) or move it to a archive/ directory until there's a consumer. Don't ship dead crates indefinitely.


2. vcad-kernel-dfm::geom::face_midpoint_and_normal duplicates raytrace helpers

crates/vcad-kernel-dfm/src/geom/mod.rs::face_midpoint_and_normal reimplements logic that already exists in vcad-kernel-raytrace::trim::{face_normal, point_in_face}. The DFM version was written before the raytrace feature was wired in (the v1 code had a non-raytrace fallback as the only path).

Action: With the raytrace feature on (default), call vcad_kernel_raytrace::trim::face_normal directly. Keep a local fallback only behind cfg(not(feature = "raytrace")). Same applies anywhere else in geom/ that recomputed surface evaluation.


3. DFM rule-pack TOML has no schema validation

crates/vcad-kernel-dfm/src/rules/mod.rs::Rule uses #[serde(flatten)] params: HashMap<String, toml::Value> so unknown fields are silently absorbed. A user typing min_wall_mn = 1.0 (typo) instead of min_wall_mm = 1.0 gets the silent default of 0.8mm and no warning. Worse, the field name pull_dir only matters on mold.insufficient_draft — putting it on a different rule is a silent no-op.

Action: validate rule params per rule_id against an expected-keys list (a small Rule::expected_keys() -> &'static [&'static str] lookup), and emit a warning (or hard error in --strict mode) on unknown keys. Add a CLI subcommand vcad dfm validate <pack.toml> for shop authors to lint their forks before deployment.


Why now

These don't block anything, but they're the kind of things that quietly accumulate. The DFM polish is especially worth doing while the crate is fresh and small (~12 source files); it'll be much harder once external rule packs start getting forked.

References

  • crates/vcad-kernel-stocksim/ — orphan crate
  • CLAUDE.md ~line 150 — "WIP crates" note
  • crates/vcad-kernel-dfm/src/geom/mod.rs::face_midpoint_and_normal
  • crates/vcad-kernel-raytrace/src/trim.rs::face_normal
  • crates/vcad-kernel-dfm/src/rules/mod.rs::Rule (the serde(flatten) site)
  • lib/dfm/*.toml — the seven default packs that would benefit from validation

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions